Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## [Unreleased]

### Breaking Changes

- `dispatch_step` launches with `launch: true` and an optional root `role` instead of `launch: { role? }`; convene and `resolve.add` ticket entries declare no dependencies with `independent: true` instead of `dependsOn: []`, and `resolve` clears a ticket's dependencies with `clearDependsOn: true` instead of `dependsOn: []`
- `replaceBody` clears an issue body with `clearBody: true` instead of an empty `body`; `body` must now be a non-empty string, and every entry or action sets exactly one of the pair

### Changed

- All five tools are registered through the shared `omompTool` entry: blank strings, empty arrays, empty objects and `null` in tool arguments now behave as if the field was omitted, array elements must not be empty, and arguments are re-validated before the tool runs

### Fixed

- With Meerkat integration on, an issue whose repository belongs to a different owner than the configured Project now has its Project Status read and confirmed, instead of every Status write ending `failed` and blocking `finish`
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ A delivery starts a coordinator on the event that makes the trigger condition tr

Without the flag the extension registers no active coordinator tools, no timers, and no dispatch state (and `dispatch://` does not inject a global `promptDoc` entry).

Main starts a new agenda with `dispatch_ticket` (`convene`), supplying optional structured `parent` (`{"owner", "repo", "number"}`, omitted when there is none) and `tickets`. Every ticket entry has an `id`, a structured `issue` (`{"owner", "repo", "number"}`), a structured `target` (`{"owner", "repo", "branch"}`), and a `dependsOn` array of ticket IDs; an entry may also carry an optional structured `adoptPr` (`{"owner", "repo", "number"}`). All current parent sub-issues must be represented. Dependencies refer to ticket IDs; independent tickets have no edge. Main can change the topology and record exceptional rulings with `dispatch_step` (`resolve`), whose optional `githubActions` array encodes each GitHub write as a dedicated named action property (for example `publishPr`, `merge`, `replaceBody`, `createIssue`, `attachChild`, `rerunChecks`). A saved active agenda is taken over with `dispatch_ticket` (`resume: { agenda }`).
Main starts a new agenda with `dispatch_ticket` (`convene`), supplying optional structured `parent` (`{"owner", "repo", "number"}`, omitted when there is none) and `tickets`. Every ticket entry has an `id`, a structured `issue` (`{"owner", "repo", "number"}`), a structured `target` (`{"owner", "repo", "branch"}`), and exactly one of a `dependsOn` array of ticket IDs or `independent: true` for a ticket with no dependencies; an entry may also carry an optional structured `adoptPr` (`{"owner", "repo", "number"}`). All current parent sub-issues must be represented. Dependencies refer to ticket IDs; independent tickets have no edge. Main can change the topology and record exceptional rulings with `dispatch_step` (`resolve`), whose optional `githubActions` array encodes each GitHub write as a dedicated named action property (for example `publishPr`, `merge`, `replaceBody`, `createIssue`, `attachChild`, `rerunChecks`). A saved active agenda is taken over with `dispatch_ticket` (`resume: { agenda }`).

An agenda belongs to the issue that is its `parent` or the `issue` of any of its tickets. A coordinator sees only the active agendas that belong to its launch issue: they alone appear in the startup message, can be resumed, and refuse a new `convene` while one is saved. Resuming any other agenda is refused with `ownershipBlocked` and changes neither its file nor the coordinator. Active agendas of other issues in the same data directory, such as one an earlier coordinator of another issue left behind, stay as they are and do not keep this issue from being convened.

Expand Down Expand Up @@ -171,7 +171,7 @@ Notifications, command help, and the launcher CLI and HTML use English or Chines

## Ticket handoff

Main decides only when each ticket is launched. `read dispatch://status` returns the agenda, including its workflow, with the `launchable` tickets (never launched, neither `Escalated` nor delivered, every dependency delivered), the `asking` tickets (each with its worker's question, the id of its `ask` comment once GitHub shows it, and the council `agenda` once the ask was escalated there, see [Meerkat integration](#meerkat-integration)), and the seats currently `seated`. Main calls `dispatch_step` with `ticketId` and `launch: { role? }`, once per ticket; an omitted `role` means the ticket's currently executable seats, and a given `role` must be one of them. The call marks the ticket started, seats its current state at once, and returns their native async job IDs, so independent tickets can be launched back to back. From then on Dispatch follows the workflow by itself: it seats each work and judge state, performs each action, and evaluates each decision, including the parent machine once every ticket is delivered. A seat is one-shot per revision: a role seated at a revision is never seated at that revision again within the process, so a seat that ends without a handoff is followed by its escalation, not by a replacement. A work seat starts only after every seat of its ticket has exited. Native `task` is not used for these seats because its session allocator cannot accept a work-session fork manager.
Main decides only when each ticket is launched. `read dispatch://status` returns the agenda, including its workflow, with the `launchable` tickets (never launched, neither `Escalated` nor delivered, every dependency delivered), the `asking` tickets (each with its worker's question, the id of its `ask` comment once GitHub shows it, and the council `agenda` once the ask was escalated there, see [Meerkat integration](#meerkat-integration)), and the seats currently `seated`. Main calls `dispatch_step` with `ticketId` and `launch: true` (plus an optional `role`), once per ticket; an omitted `role` means the ticket's currently executable seats, and a given `role` must be one of them. The call marks the ticket started, seats its current state at once, and returns their native async job IDs, so independent tickets can be launched back to back. From then on Dispatch follows the workflow by itself: it seats each work and judge state, performs each action, and evaluates each decision, including the parent machine once every ticket is delivered. A seat is one-shot per revision: a role seated at a revision is never seated at that revision again within the process, so a seat that ends without a handoff is followed by its escalation, not by a replacement. A work seat starts only after every seat of its ticket has exited. Native `task` is not used for these seats because its session allocator cannot accept a work-session fork manager.

Main is woken by a `dispatch-attention` message only for a decision it has not yet been told about and that is still open when its current turn ends: a ticket that became launchable, an `Escalated` ticket or closure (keyed by revision), a failed Meerkat effect (`failed:<ticket>:<effect>`, see [Meerkat integration](#meerkat-integration)), or a finished agenda awaiting `dispatch_ticket` `finish`. A decision Main settles within the turn that produced it, such as launching what `convene` unlocked, never wakes it again. Launching, running seats, seat job completions, a ticket waiting in `Asking`, and effects in flight do not notify.

Expand Down
57 changes: 31 additions & 26 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { logger } from "@oh-my-pi/pi-utils";
import { applyActiveTools } from "./omomp-shared/active-tools.ts";
import { tr } from "./omomp-shared/i18n.ts";
import { registerInternalScheme } from "./omomp-shared/internal-url.ts";
import { omompTool } from "./omomp-shared/tool-entry.ts";
import type { ParseError, PortInput, Result } from "./src/domain/model.ts";
import { parseDispatchStepParameters, parseDispatchTicketParameters } from "./src/domain/parse.ts";
import { buildPublicGrammar } from "./src/domain/public-grammar.ts";
Expand Down Expand Up @@ -222,32 +223,36 @@ export default function dispatch(pi: ExtensionAPI): void {
description: tr("Start Main as coordinator for <owner>/<repo>#<number>", "将 Main 启动为 <owner>/<repo>#<number> 的协调者"),
type: "string",
});
pi.registerTool({
name: "dispatch_ticket",
label: tr("Dispatch Ticket", "调度工单"),
description:
"Manage Dispatch agenda lifecycle (convene a new ticket graph, resume a saved active agenda, or finish a completed agenda). Read live state via read dispatch://status, dispatch://tickets, or dispatch://<ticketId>.",
loadMode: "essential",
parameters: grammar.dispatchTicketParametersSchema,
defaultInactive: true,
async execute(_id, params, _signal, _update, ctx) {
const response = await runtime.execute(ctx, parseDispatchTicketParameters(params));
return { content: [{ type: "text", text: JSON.stringify(response) }], details: response, isError: !response.ok };
},
});
pi.registerTool({
name: "dispatch_step",
label: tr("Dispatch Step", "调度步骤"),
description:
"Launch a Dispatch ticket once (Dispatch relays its seats automatically) or resolve a ticket/closure with an exceptional ruling, topology edit, effect disposition, or GitHub write actions. Read state via read dispatch://status or dispatch://<ticketId>.",
loadMode: "essential",
parameters: grammar.dispatchStepParametersSchema,
defaultInactive: true,
async execute(_id, params, _signal, _update, ctx) {
const response = await runtime.execute(ctx, parseDispatchStepParameters(params));
return { content: [{ type: "text", text: JSON.stringify(response) }], details: response, isError: !response.ok };
},
});
pi.registerTool(
omompTool({
name: "dispatch_ticket",
label: tr("Dispatch Ticket", "调度工单"),
description:
"Manage Dispatch agenda lifecycle (convene a new ticket graph, resume a saved active agenda, or finish a completed agenda). Read live state via read dispatch://status, dispatch://tickets, or dispatch://<ticketId>.",
loadMode: "essential",
parameters: grammar.dispatchTicketParametersSchema,
defaultInactive: true,
async execute(_id, params, _signal, _update, ctx) {
const response = await runtime.execute(ctx, parseDispatchTicketParameters(params));
return { content: [{ type: "text", text: JSON.stringify(response) }], details: response, isError: !response.ok };
},
}),
);
pi.registerTool(
omompTool({
name: "dispatch_step",
label: tr("Dispatch Step", "调度步骤"),
description:
"Launch a Dispatch ticket once (Dispatch relays its seats automatically) or resolve a ticket/closure with an exceptional ruling, topology edit, effect disposition, or GitHub write actions. Read state via read dispatch://status or dispatch://<ticketId>.",
loadMode: "essential",
parameters: grammar.dispatchStepParametersSchema,
defaultInactive: true,
async execute(_id, params, _signal, _update, ctx) {
const response = await runtime.execute(ctx, parseDispatchStepParameters(params));
return { content: [{ type: "text", text: JSON.stringify(response) }], details: response, isError: !response.ok };
},
}),
);
pi.registerCommand("dispatch-launcher", {
description: tr(
"Install, uninstall, or inspect the local Dispatch launcher, or register its GitHub App (install|uninstall|status|github-app register --webhook-url <url>)",
Expand Down
2 changes: 1 addition & 1 deletion omomp-shared.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"directory": "omomp-shared",
"files": ["active-tools.ts", "biome.base.json", "i18n.ts", "internal-url.ts"]
"files": ["active-tools.ts", "biome.base.json", "i18n.ts", "internal-url.ts", "tool-entry.ts"]
}
Loading