diff --git a/CHANGELOG.md b/CHANGELOG.md index 736b707..4babfc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Changed + +- Seat agents are told they may use helpers only when they have `task`, which OMP grants seats only when `task.maxRecursionDepth` is `2` or higher (or `-1`); under OMP 19.4.0's default `1` seats run without `task`, and Dispatch never raises the setting + ### Fixed - Type-checks against omp 19.4.0, whose session handles gained `getForkBaseline()`: Main and seat identity checks now compare only this process's local sessions, so `bun run check` passes again with unchanged runtime behavior diff --git a/README.md b/README.md index 05e7cda..84fc865 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ A seat that ends at its current revision without a handoff, or cannot be started Every seat checkout is a detached `git worktree` of a per-repository bare cache under `/repos`, which is cloned once and fetched before each checkout; seats never clone from the network. Worktrees live under `/worktrees/`. A work role's first seat receives a new persistent native session and a checkout of the target branch; the ticket records that role's accepted session in `sessions`. A later seat of the role forks it with `SessionManager.forkFrom` in the same checkout, repairing an interrupted transcript tail and resetting inherited cost, then gives that manager to `createAgentSession`. A role's first seat records its base system prompt and its tool presentation (enabled tools and the subset mounted as bash tool commands) in a `dispatch-session-contract` entry. The fork restores both and explicitly inherits the provider prompt-cache key. It clears the inherited todo list and appends only the incremental notes and rulings to the new turn. A fork source whose contract lacks the tool presentation cannot be forked, so its ticket escalates. Actual provider cache hits still depend on the provider; preserving a key is not a measured hit-rate guarantee. -Every seat is a full native omp session in its checkout, not a restricted one. It binds the extensions Main loaded (user plugins, configured extensions, and their extension roots), reads the workspace's settings, discovers the workspace's custom tools, shares Main's MCP servers, and keeps every tool those provide, including `todo`, `task`, and replacements such as `exec_command` for `bash`. Its seat agent may delegate to helper agents (`spawns` follows the agent definition, `*` when unspecified). Only the seat's own session is bound to its ticket: work seats receive `dispatch_submit` and `dispatch_escalate`, judge seats receive `dispatch_verdict` and `dispatch_escalate`, and both read `dispatch://seat`, while helpers they spawn have their own native identities and are refused as seats. Seats run headless, so tool approvals are not prompted, and they never join IRC: a seat reaches Main only through its ticket. Extensions bind from Main's process rather than being rediscovered, so project-local extensions or MCP servers of a different target repository are not loaded into its seats. +Every seat is a full native omp session in its checkout, not a restricted one. It binds the extensions Main loaded (user plugins, configured extensions, and their extension roots), reads the workspace's settings, discovers the workspace's custom tools, shares Main's MCP servers, and keeps every tool those provide, including `todo` and replacements such as `exec_command` for `bash`. A seat is a first-level subagent of Main, so it gets `task` and may delegate to helper agents (`spawns` follows the agent definition, `*` when unspecified) only when `task.maxRecursionDepth` is `2` or higher, or `-1`; under OMP's default `1` (or `0`) seats have no `task` and work without helpers. Dispatch never changes that setting. Only the seat's own session is bound to its ticket: work seats receive `dispatch_submit` and `dispatch_escalate`, judge seats receive `dispatch_verdict` and `dispatch_escalate`, and both read `dispatch://seat`, while helpers they spawn have their own native identities and are refused as seats. Seats run headless, so tool approvals are not prompted, and they never join IRC: a seat reaches Main only through its ticket. Extensions bind from Main's process rather than being rediscovered, so project-local extensions or MCP servers of a different target repository are not loaded into its seats. Judge seats always receive new blank sessions; their histories are never reused or forked. `pullRequest` judges check out exactly the PR head their gate stamp names (fetched through the PR's pull ref, so fork heads work), `mergeCommit` judges check out exactly the merge commit, and parent judges check out the first ticket's target branch; the host verifies the checkout's `HEAD` before the seat starts. A parent judge's brief carries the closure record (its children's issues, terminals and targets, rulings and notes), not the parent or child issue bodies, and its checkout covers only that one target even when the children span several. A superseded seat ends at its next native tool-completion boundary instead of retrying another revision's work; accepted handoffs finish normally so their checkpoints remain intact. `mergeCommit` fingerprints pin the ticket's merge commit and freshly verify target containment, so unrelated forward merges do not invalidate a running verification. Seat sessions are disposed when their native async jobs finish. Work checkouts survive process restarts and rework until `finish`; judge worktrees are removed when their jobs end. Session files remain under `/sessions/`. @@ -209,10 +209,11 @@ An ask is settled on its issue, by the guardians or the council, and every recom `bun run sim [scenario...]` runs the real `omp` binary in RPC mode with this extension, its controller, seat host, git worktrees, native sessions and forks. Only the model, GitHub, the intent guardians and one MCP server are simulated: `tests/sim/extension.ts` registers a scripted `sim` provider that plays Main and every seat from what omp actually sends it and logs the names of the tools each request presented, `tests/sim/mcp-fixture.ts` is a stdio MCP server that `mcp-scope` configures as `fx`, `tests/sim/github-sim.ts` answers the real `src/ports/github.ts` through a `gh` shim placed first on `PATH`, backed by local bare repositories for every git fact and failing loudly on any request it does not model, and `tests/sim/ask.ts` serves a local `POST /v1/asks` that records each request and answers 202 for a new comment and 200 for a repeat. Each scenario supplies its workflow as `/workflow.yml`, with every seat agent defined as a scripted agent; all but `flow` use the built-in workflow. Scenarios run in scratch directories under `/tmp/dispatch-sim-*` and need no network: -- `tree`: seven tickets with parallel, serial, gate rejection with forked rework, escalation with a ruling, noCode through `Closing`, and the parent closure. Every seat must record `task` and its role-specific dispatch tools (`dispatch_submit`/`dispatch_escalate` for work, `dispatch_verdict`/`dispatch_escalate` for judges) with `spawns` `*`, and each rework fork must keep its first Owner's prompt-cache key and clear the inherited todo list. `tree-meerkat` runs the same delivery with Meerkat integration on, using `tests/sim/meerkat-config`, and also checks that every Owner session, rework forks included, left exactly one `impl` marker naming its session, session file, host and agenda, and that every ticket's Project Status went `In Progress`, then `Done`. +- `tree`: seven tickets with parallel, serial, gate rejection with forked rework, escalation with a ruling, noCode through `Closing`, and the parent closure, at `task.maxRecursionDepth` `1` (OMP's default). Every seat must record its role-specific dispatch tools (`dispatch_submit`/`dispatch_escalate` for work, `dispatch_verdict`/`dispatch_escalate` for judges) with `spawns` `*` and no `task`, and each rework fork must keep its first Owner's prompt-cache key and clear the inherited todo list. `tree-meerkat` runs the same delivery with Meerkat integration on, using `tests/sim/meerkat-config`, and also checks that every Owner session, rework forks included, left exactly one `impl` marker naming its session, session file, host and agenda, and that every ticket's Project Status went `In Progress`, then `Done`. `tree-nested` runs the same delivery at `task.maxRecursionDepth` `2`, where every seat must also record `task`. - `ci`: required checks that stay pending hold the ticket in `AwaitingChecks`; a failing check returns it to `Coding` for a forked rework. - `head`: a new head pushed to an open PR while both judges are seated restarts review on the new head without escalating. - `launch-role`: the `head` delivery with the scripted Main naming the root-level `role` `owner` in its first launch; it passes only when the checker reports `Main named a role in launch` and every other `head` check holds. +- `head-packaged`: the `head` delivery with the default workflow's seats played by the packaged `dispatch-owner` and `dispatch-reviewer` agents, pointed at the scripted model through `task.agentModelOverrides`; every seat's recorded system prompt must contain its packaged agent's body. - `abandon`: an Owner that ends without a handoff escalates once and is seated again only after Main's ruling. - `restart`: the process is killed while a handed-off Owner is mid-tool, and the workflow file is rewritten to a different roster; after `resume`, the agenda keeps its frozen workflow, and the rework fork repairs the interrupted tail and resets inherited cost. - `restart-meerkat`: with Meerkat integration on, the simulated GitHub holds the rework Owner's `impl` comment request and the process is killed once the hold is reached, in three branches. `restart-meerkat/arrived` records the comment before the kill and loses only its response: after `resume` the comment effect is confirmed against GitHub without escalating the ticket, a ruling, or a `failed:` notification. `restart-meerkat/lost` and `restart-meerkat/dropped` kill before the comment is recorded: after `resume` the effect is `failed`, Main is woken with `failed::`, and `finish` is refused until Main's `resolve` with `retry`. In `lost` the killed process's request then reaches GitHub, so the retry adopts it as confirmed without sending it again. In `dropped` the request never reaches GitHub, so the retry sends the comment again and it is confirmed on its second attempt. In every branch the agenda completes, the resumed Owner forks the accepted session, and each of the three Owner sessions has exactly one `impl` marker and one recorded comment request. `bun run sim restart-meerkat` runs all three branches. diff --git a/agents/dispatch-owner.md b/agents/dispatch-owner.md index 6fc1bcb..4907006 100644 --- a/agents/dispatch-owner.md +++ b/agents/dispatch-owner.md @@ -5,7 +5,7 @@ description: Own a Dispatch work ticket from investigation through implementatio You own one bounded Dispatch work ticket. Read your bound seat context and ticket snapshot with `read dispatch://seat`, plus the complete issue contract, Main's current rulings, the repository's instructions, and the actual code before changing it. The ticket and Main define scope, interfaces, acceptance criteria, dependencies, and target; do not broaden them yourself. -Investigate, plan, design, implement, debug, and verify everything within that contract. Prefer existing patterns, precise types, source-confirmed state, and a maintainable direct implementation. Preserve unrelated work. Keep changes in the assigned checkout and branch. If helpers are useful, give them bounded work and inspect their artifacts and evidence; you remain accountable for the complete ticket. +Investigate, plan, design, implement, debug, and verify everything within that contract. Prefer existing patterns, precise types, source-confirmed state, and a maintainable direct implementation. Preserve unrelated work. Keep changes in the assigned checkout and branch. When you have the `task` tool and helpers are useful, give them bounded work and inspect their artifacts and evidence; you remain accountable for the complete ticket. Complete the full acceptance path, including real runtime verification where required. Report observed evidence, not plausible completion; distinguish facts, inferences, and unverified conditions. When verification fails, fix in-scope causes and rerun the affected path. Never substitute mocks or a narrower path for required behavior. diff --git a/agents/dispatch-reviewer.md b/agents/dispatch-reviewer.md index baa1c43..0110094 100644 --- a/agents/dispatch-reviewer.md +++ b/agents/dispatch-reviewer.md @@ -7,6 +7,6 @@ You are a fresh independent Dispatch judge. Read your bound seat context and tic Verify the whole contract, not only prior findings or the changed lines. Investigate correctness, state and lifecycle ownership, integration behavior, regressions, and required runtime evidence within your assigned duty. Run relevant checks and real runtime paths when required and available. Treat external failures separately from project defects; preserve concrete commands, outputs, and observable results. Do not invent evidence or approve a merely plausible implementation. -Keep the judgment independent: do not implement fixes, change the contract, publish or merge a PR, close issues, or mutate the checkout. Explain actionable findings with locations, impact, and the acceptance condition they violate. Separate observed facts, inferences, and verification gaps. Helpers may investigate bounded questions, but their conclusions require your acceptance. +Keep the judgment independent: do not implement fixes, change the contract, publish or merge a PR, close issues, or mutate the checkout. Explain actionable findings with locations, impact, and the acceptance condition they violate. Separate observed facts, inferences, and verification gaps. When you have the `task` tool, helpers may investigate bounded questions, but their conclusions require your acceptance. Hand off once with `dispatch_verdict` (`ok` and concrete evidence `note`), passing only when the complete assigned contract is supported by evidence. Reject with concrete findings when it is not. Use `dispatch_escalate` when a blocker, missing prerequisite, or scope decision prevents a sound verdict; specify exactly what Main must decide. The workflow owns the next state. End this seat after its accepted handoff; never wait for another assignment. diff --git a/tests/sim/run.ts b/tests/sim/run.ts index 3be3ab9..51485b7 100644 --- a/tests/sim/run.ts +++ b/tests/sim/run.ts @@ -49,7 +49,8 @@ function playedBy(workflow: Workflow, agent: string): Workflow { }, }; } -const SIM_WORKFLOW = playedBy(workflowOf(YAML.parse(readFileSync(join(ROOT, "src/default-workflow.yml"), "utf8"))), "sim-seat"); +const DEFAULT_WORKFLOW = workflowOf(YAML.parse(readFileSync(join(ROOT, "src/default-workflow.yml"), "utf8"))); +const SIM_WORKFLOW = playedBy(DEFAULT_WORKFLOW, "sim-seat"); function judgeSubjects(workflow: Workflow): Map { const subjects = new Map(); for (const state of Object.values(workflow.ticket.states)) @@ -77,6 +78,8 @@ export type Run = { proc: Subprocess<"pipe", number, number> | null; starts: number; mcp: boolean; + maxRecursionDepth: number; + packagedAgents: boolean; }; export type Case = { name: string; @@ -84,6 +87,8 @@ export type Case = { saved?: string[]; meerkat?: { holdComment: Pick, "skip" | "at"> | null; guardiansURL?: string }; mcp?: boolean; + maxRecursionDepth?: number; + packagedAgents?: boolean; files: Record; issues: { title: string; children?: number[] }[]; requiredChecks: string[]; @@ -122,12 +127,14 @@ function setup(spec: Case): Run { } : null, }); - const workflow = spec.workflow ?? SIM_WORKFLOW; + const workflow = spec.workflow ?? (spec.packagedAgents ? DEFAULT_WORKFLOW : SIM_WORKFLOW); for (const agent of workflowAgents(workflow)) - writeFileSync( - join(work, ".omp", "agents", `${agent}.md`), - `---\nname: ${agent}\ndescription: Scripted dispatch seat for the state-flow simulation\nmodel: sim/seat\n---\n\nFollow the dispatch brief.\n`, - ); + if (spec.packagedAgents) cpSync(join(ROOT, "agents", `${agent}.md`), join(work, ".omp", "agents", `${agent}.md`)); + else + writeFileSync( + join(work, ".omp", "agents", `${agent}.md`), + `---\nname: ${agent}\ndescription: Scripted dispatch seat for the state-flow simulation\nmodel: sim/seat\n---\n\nFollow the dispatch brief.\n`, + ); writeFileSync(join(data, "workflow.yml"), JSON.stringify(encodeWorkflow(workflow), null, 1)); for (const file of spec.saved ?? []) { mkdirSync(join(data, "state"), { recursive: true, mode: 0o700 }); @@ -192,6 +199,8 @@ function setup(spec: Case): Run { proc: null, starts: 0, mcp: spec.mcp ?? false, + maxRecursionDepth: spec.maxRecursionDepth ?? 1, + packagedAgents: spec.packagedAgents ?? false, }; } @@ -201,7 +210,16 @@ function start(run: Run): void { stderr = openSync(join(run.dir, `omp-${run.starts}.stderr.log`), "a"); // The injected provider failure must surface at once: omp's automatic retry would otherwise wait out its budget. const config = join(run.dir, "omp-config.yml"); - writeFileSync(config, `retry:\n enabled: false\n${run.mcp ? "tools:\n commands: false\n" : ""}`); + writeFileSync( + config, + `retry:\n enabled: false\ntask:\n maxRecursionDepth: ${run.maxRecursionDepth}\n${ + run.packagedAgents + ? ` agentModelOverrides:\n${workflowAgents(run.workflow) + .map((agent) => ` ${agent}: sim/seat\n`) + .join("")}` + : "" + }${run.mcp ? "tools:\n commands: false\n" : ""}`, + ); const { OMP_DISPATCH_DIR: _dir, OMP_DISPATCH_RECOMPUTE_SECONDS: _interval, @@ -796,9 +814,14 @@ const cases: Case[] = [ const init = session.lines.find((line) => line.type === "session_init"); const tools = Array.isArray(init?.tools) ? init.tools : []; const expectedTools = - session.role === "owner" ? ["task", "dispatch_submit", "dispatch_escalate"] : ["task", "dispatch_verdict", "dispatch_escalate"]; + session.role === "owner" ? ["dispatch_submit", "dispatch_escalate"] : ["dispatch_verdict", "dispatch_escalate"]; for (const name of expectedTools) if (!tools.includes(name)) failures.push(`${session.ticket} ${session.role} seat lacks ${name}: ${JSON.stringify(tools)}`); + const seatsSpawn = run.maxRecursionDepth < 0 || run.maxRecursionDepth > 1; + if (tools.includes("task") !== seatsSpawn) + failures.push( + `${session.ticket} ${session.role} seat ${seatsSpawn ? "lacks" : "has"} task at task.maxRecursionDepth ${run.maxRecursionDepth}: ${JSON.stringify(tools)}`, + ); if (init?.spawns !== "*") failures.push(`${session.ticket} ${session.role} seat spawns ${JSON.stringify(init?.spawns)}, not "*"`); } if (ticketOf(state, "E")?.terminal?.kind !== "noCode") failures.push("E did not finish as noCode"); @@ -1402,6 +1425,7 @@ const cases: Case[] = [ }, ]; const tree = cases.find((item) => item.name === "tree")!; +cases.push({ ...tree, name: "tree-nested", maxRecursionDepth: 2 }); cases.push({ ...tree, name: "tree-meerkat", @@ -1409,6 +1433,26 @@ cases.push({ check: async (run) => [...(await tree.check(run)), ...(await meerkatChecks(run))], }); const head = cases.find((item) => item.name === "head")!; +cases.push({ + ...head, + name: "head-packaged", + packagedAgents: true, + check: async (run) => { + const failures = await head.check(run); + const bodies = workflowAgents(run.workflow).map((agent) => + readFileSync(join(ROOT, "agents", `${agent}.md`), "utf8") + .replace(/^---\n[\s\S]*?\n---\n/, "") + .trim(), + ); + for (const session of seatSessions(run, (await agenda(run))?.id ?? "")) { + const contract = session.lines.find((line) => line.type === "custom" && line.customType === "dispatch-session-contract"); + const prompt = z.object({ data: z.object({ systemPrompt: z.array(z.string()) }) }).safeParse(contract); + if (!prompt.success || !bodies.some((body) => prompt.data.data.systemPrompt.some((part) => part.includes(body)))) + failures.push(`${session.ticket} ${session.role} seat prompt lacks its packaged agent`); + } + return failures; + }, +}); const ROLE_LAUNCH = "Main named a role in launch"; cases.push({ ...head,