opencode-swarm 7.140.3 → 7.140.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/.opencode/skills/brainstorm/SKILL.md +1 -1
  2. package/.opencode/skills/ci-failure-batching/SKILL.md +11 -1
  3. package/.opencode/skills/ci-fix-monitor/SKILL.md +6 -4
  4. package/.opencode/skills/discover/SKILL.md +1 -1
  5. package/.opencode/skills/durable-session-state/SKILL.md +82 -0
  6. package/.opencode/skills/engineering-conventions/SKILL.md +1 -1
  7. package/.opencode/skills/issue-ingest/SKILL.md +13 -7
  8. package/.opencode/skills/issue-tracer/SKILL.md +1 -1
  9. package/.opencode/skills/orchestrating-subagents/SKILL.md +113 -0
  10. package/.opencode/skills/parallel-work-check/SKILL.md +1 -1
  11. package/.opencode/skills/plan/SKILL.md +40 -12
  12. package/.opencode/skills/swarm-ci-monitor/SKILL.md +5 -3
  13. package/.opencode/skills/swarm-pr-feedback/SKILL.md +30 -4
  14. package/.opencode/skills/writing-tests/SKILL.md +1 -1
  15. package/dist/agents/architect.d.ts +2 -1
  16. package/dist/agents/reviewer-directive-compliance.d.ts +19 -5
  17. package/dist/background/pending-delegations.d.ts +5 -0
  18. package/dist/cli/{config-doctor-fnmfd35x.js → config-doctor-5vzpq4qa.js} +3 -3
  19. package/dist/cli/{core-p5cyej3r.js → core-xjzdc56e.js} +2 -2
  20. package/dist/cli/{curation-policy-d52h4g8t.js → curation-policy-avvb56x2.js} +6 -8
  21. package/dist/cli/{curator-3zpdqt9r.js → curator-5nytvg7p.js} +38 -38
  22. package/dist/cli/curator-llm-factory-rds75zhj.js +61 -0
  23. package/dist/cli/{evidence-summary-service-nfdc1ht9.js → evidence-summary-service-zq4gyx6g.js} +15 -12
  24. package/dist/cli/gate-evidence-smn2wqft.js +51 -0
  25. package/dist/cli/guardrail-explain-an7jvam1.js +62 -0
  26. package/dist/cli/{guardrail-log-82da8y5a.js → guardrail-log-0hnd2k9v.js} +4 -4
  27. package/dist/cli/{hive-promoter-af5yaxvt.js → hive-promoter-qe8pqg79.js} +38 -38
  28. package/dist/cli/{index-qksjaxpd.js → index-01ggt2mj.js} +49 -18
  29. package/dist/cli/{index-j1xmren9.js → index-0r2m0vbq.js} +12 -10
  30. package/dist/cli/{index-pg7n141e.js → index-0rx9t9w8.js} +1 -1
  31. package/dist/cli/{index-brh827g0.js → index-2bg901qt.js} +73 -32
  32. package/dist/cli/{index-8n4c3vec.js → index-386ts4tm.js} +4 -4
  33. package/dist/cli/{index-898f16j9.js → index-8rp1y4ab.js} +2 -2
  34. package/dist/cli/{index-hfvxhk4z.js → index-912qz4y0.js} +88 -88
  35. package/dist/cli/index-affh1gtg.js +2554 -0
  36. package/dist/cli/{index-1m1ksyqt.js → index-c432knmy.js} +1 -1
  37. package/dist/cli/{index-jvk119ck.js → index-e0mpz2j3.js} +54 -19
  38. package/dist/cli/{index-ry0hgg3m.js → index-epvhf50h.js} +37 -3
  39. package/dist/cli/{index-95bj4kaw.js → index-ex7r16gc.js} +2 -2
  40. package/dist/cli/{index-7d5jseea.js → index-jm4cpp4n.js} +5 -2
  41. package/dist/cli/{index-n408rw7n.js → index-jqsfsqbx.js} +27 -2
  42. package/dist/cli/{index-7kdd75se.js → index-kb5q9v34.js} +11 -9
  43. package/dist/cli/{index-jfjnn408.js → index-m9xrdjn0.js} +1 -1
  44. package/dist/cli/{index-pj9h75cc.js → index-mm2egvdt.js} +40 -40
  45. package/dist/cli/{index-8bnzzv3b.js → index-nwrwy8eb.js} +70 -34
  46. package/dist/cli/index-nyjtzmsj.js +43 -0
  47. package/dist/cli/{index-h2waehqq.js → index-p8kk34am.js} +3 -3
  48. package/dist/cli/{index-wf35ka4z.js → index-ptn13xjn.js} +3 -3
  49. package/dist/cli/{index-1kyex7z2.js → index-qwm6vdyv.js} +32 -1
  50. package/dist/cli/{index-p9dsb0tw.js → index-qy1nq52t.js} +2 -19
  51. package/dist/cli/{index-b9rd29ge.js → index-s1v0wza5.js} +6 -2
  52. package/dist/cli/{index-yyyk63kk.js → index-t5pytnca.js} +2 -2
  53. package/dist/cli/index-tjqzr3jc.js +623 -0
  54. package/dist/cli/{index-rs1f1bh0.js → index-vh05t3w5.js} +1 -1
  55. package/dist/cli/{index-adyxbmt5.js → index-wkt9fj06.js} +4 -4
  56. package/dist/cli/{index-kbfsp07d.js → index-wrb0gykj.js} +217 -15
  57. package/dist/cli/{index-xz8f1n1a.js → index-z7h37d63.js} +2 -2
  58. package/dist/cli/{index-q1q8b85k.js → index-z90nvqj3.js} +49315 -47331
  59. package/dist/cli/{index-b8zgtz81.js → index-zsrtt42s.js} +34 -1
  60. package/dist/cli/{index-gtbmabws.js → index-ztgn70jz.js} +2 -2
  61. package/dist/cli/index.js +37 -37
  62. package/dist/cli/{knowledge-escalator-7q59skqg.js → knowledge-escalator-4pfrc902.js} +20 -8
  63. package/dist/cli/{knowledge-events-3nwfdpq7.js → knowledge-events-3zkfnksk.js} +19 -6
  64. package/dist/cli/{knowledge-link-q46k9adx.js → knowledge-link-m9p80f4r.js} +5 -5
  65. package/dist/cli/{knowledge-store-0d83rhh3.js → knowledge-store-dpqgvvjt.js} +6 -6
  66. package/dist/cli/{knowledge-validator-6mfx91a2.js → knowledge-validator-2c7w87dk.js} +8 -9
  67. package/dist/cli/{pending-delegations-qzrx38y9.js → pending-delegations-cxx9tezp.js} +4 -4
  68. package/dist/cli/{pr-subscriptions-5s59h4dd.js → pr-subscriptions-2sfnb599.js} +4 -4
  69. package/dist/cli/{runner-y78d7ryb.js → runner-mky3vvht.js} +6 -6
  70. package/dist/cli/{scan-cursor-rc8q12ss.js → scan-cursor-1z60gwrw.js} +7 -7
  71. package/dist/cli/{schema-n9eaxp3a.js → schema-vpnkwvez.js} +2 -2
  72. package/dist/cli/{scope-persistence-dr1msqxw.js → scope-persistence-p9dmprry.js} +10 -5
  73. package/dist/cli/{skill-generator-q7c6vadg.js → skill-generator-yx7ka1cj.js} +19 -10
  74. package/dist/cli/{telemetry-sc57xtb0.js → telemetry-0x6kszvk.js} +1 -1
  75. package/dist/cli/{worktree-collision-ownership-7a8e6gr9.js → worktree-collision-ownership-wm5pse49.js} +8 -8
  76. package/dist/cli/worktree-isolation-bwc6ra8e.js +102 -0
  77. package/dist/cli/worktree-provisioning-owner-sjh7te1h.js +22 -0
  78. package/dist/commands/acknowledge-spec-drift.d.ts +4 -5
  79. package/dist/commands/ci-simulate.d.ts +7 -3
  80. package/dist/commands/close.d.ts +8 -0
  81. package/dist/commands/registry.d.ts +2 -2
  82. package/dist/commands/sdd.d.ts +15 -0
  83. package/dist/config/bundled-skills.d.ts +1 -1
  84. package/dist/config/evidence-schema.d.ts +3 -3
  85. package/dist/config/index.d.ts +2 -2
  86. package/dist/config/plan-schema.d.ts +8 -0
  87. package/dist/config/schema.d.ts +4 -2
  88. package/dist/council/council-evidence-writer.d.ts +1 -1
  89. package/dist/gate-evidence.d.ts +117 -4
  90. package/dist/git/branch.d.ts +1 -1
  91. package/dist/hooks/delegate-ack-collector.d.ts +5 -0
  92. package/dist/hooks/delegation-gate.d.ts +21 -0
  93. package/dist/hooks/hive-promoter.d.ts +4 -4
  94. package/dist/hooks/issue-trace-reducer.d.ts +7 -1
  95. package/dist/hooks/issue-trace-state.d.ts +18 -0
  96. package/dist/hooks/issue-trace.d.ts +3 -1
  97. package/dist/hooks/knowledge-application-gate.d.ts +8 -3
  98. package/dist/hooks/knowledge-application.d.ts +8 -5
  99. package/dist/hooks/knowledge-escalator.d.ts +9 -5
  100. package/dist/hooks/knowledge-events.d.ts +21 -8
  101. package/dist/hooks/knowledge-injector.d.ts +9 -0
  102. package/dist/hooks/knowledge-receipt-ledger-storage.d.ts +49 -0
  103. package/dist/hooks/knowledge-receipt-ledger.d.ts +305 -0
  104. package/dist/hooks/knowledge-receipt-observability.d.ts +28 -0
  105. package/dist/hooks/knowledge-receipt-validator.d.ts +13 -50
  106. package/dist/hooks/knowledge-store.d.ts +6 -1
  107. package/dist/hooks/knowledge-types.d.ts +12 -0
  108. package/dist/hooks/phase-complete-directive-gate.d.ts +3 -1
  109. package/dist/hooks/phase-directives.d.ts +4 -4
  110. package/dist/hooks/pr-workflow-gate.d.ts +34 -1
  111. package/dist/hooks/promotion-evidence-store.d.ts +14 -8
  112. package/dist/hooks/reviewer-verdict-parser.d.ts +34 -10
  113. package/dist/index.js +823 -779
  114. package/dist/knowledge/curation-policy.d.ts +0 -2
  115. package/dist/observability/catalog.d.ts +5 -3
  116. package/dist/observability/legacy.d.ts +4 -3
  117. package/dist/plan/ledger.d.ts +55 -0
  118. package/dist/plan/manager.d.ts +9 -0
  119. package/dist/plan/planning-profile.d.ts +27 -0
  120. package/dist/services/spec-drift-recovery.d.ts +84 -0
  121. package/dist/session/snapshot-writer.d.ts +3 -1
  122. package/dist/state.d.ts +19 -17
  123. package/dist/summaries/schema.d.ts +2 -2
  124. package/dist/telemetry.d.ts +1 -1
  125. package/dist/tools/convene-council.d.ts +6 -6
  126. package/dist/tools/index.d.ts +3 -0
  127. package/dist/tools/manifest.d.ts +3 -0
  128. package/dist/tools/phase-complete.d.ts +9 -0
  129. package/dist/tools/rebind-pr-feedback-head.d.ts +17 -0
  130. package/dist/tools/record-implementation-review.d.ts +19 -0
  131. package/dist/tools/record-recurrence-sweep.d.ts +17 -0
  132. package/dist/tools/run-pr-feedback-stage-a.d.ts +8 -0
  133. package/dist/tools/save-plan.d.ts +8 -0
  134. package/dist/tools/submit-phase-council-verdicts.d.ts +6 -6
  135. package/dist/tools/tool-metadata.d.ts +40 -28
  136. package/dist/tools/update-task-status.d.ts +13 -0
  137. package/dist/tools/write-final-council-evidence.d.ts +6 -6
  138. package/dist/types/events.d.ts +29 -1
  139. package/dist/workflow/coder-settlement.d.ts +62 -0
  140. package/dist/workflow/task-repair.d.ts +30 -0
  141. package/dist/workflow/task-terminal.d.ts +52 -0
  142. package/package.json +3 -1
  143. package/dist/cli/curator-llm-factory-2h0xb62t.js +0 -61
  144. package/dist/cli/gate-evidence-46qeyfc1.js +0 -32
  145. package/dist/cli/guardrail-explain-yktan15c.js +0 -62
  146. package/dist/cli/index-d181x9zr.js +0 -71
  147. package/dist/cli/index-n0pja0qs.js +0 -239
  148. package/dist/cli/index-n8jncheh.js +0 -666
@@ -60,7 +60,7 @@ If `council.general.enabled` is true in the resolved opencode-swarm config AND a
60
60
  → REQUIRED: The reviewer Task dispatch MUST contain a literal `ACCEPTANCE:` line. This is a pre-plan spec review (no fr_refs yet), so resolve per ACCEPTANCE FIELD RESOLUTION in your system prompt using a one-line task-derived DONE restatement, e.g. "DONE = reviewer flags HOW-encoded requirements, untestable requirements, missing edge cases, and silent assumptions in the draft spec." A missing line is BLOCKED by ACCEPTANCE_FIELD_REQUIRED.
61
61
  - Apply reviewer feedback. If reviewer rejects, iterate once and re-review. After two rounds, surface remaining disagreements to the user.
62
62
  - Before writing `.swarm/spec.md`, apply the FR-002 non-shadowing check: if a non-native spec already exists, do not shadow it (see MODE: SPECIFY step 1b).
63
- - Write the final spec to `.swarm/spec.md`.
63
+ - Resolve the effective spec first via `/swarm sdd status` (issue #2131 finding 9): write `.swarm/spec.md` ONLY when no non-native effective spec (openspec / speckit projection) is active — those sources are read-only inputs (see the status output's `allowed mutations` line); refine them in their own tool instead of shadowing them.
64
64
  - Exit when reviewer signs off (or user explicitly accepts remaining disagreements).
65
65
 
66
66
  **Phase 6: DEFER QA AND EXECUTION PROFILE SELECTION.**
@@ -21,7 +21,17 @@ check set is complete and includes all known failed checks in `failedChecks`.
21
21
  - For each: `gh run view <run-id> --log-failed`
22
22
  - Build a complete failure ledger
23
23
  4. **Fix ALL failures in one changeset:** Cluster by root cause, fix each cluster, verify locally
24
- 5. **Push the fixes in one cycle.** Amend the commit and push. NOTE: `git push --force` / `--force-with-lease` is deny-pattern-blocked by the guardrail in guarded sessions (no orchestrator exemption). If force-push is blocked, push a normal new fix commit instead — the batching goal is ONE push cycle (collect all → fix all → push once), not literally one commit. A single new commit containing all batched fixes satisfies the goal.
24
+ 5. **Publish through `commit-pr`.** This skill owns diagnosis and fix-planning
25
+ ONLY (issue #2131 criterion E): before any commit or push, compose the
26
+ `commit-pr` skill for the commit message, PR body/invariant-audit/test-plan
27
+ discipline, and the push protocol. The batching goal is ONE push cycle
28
+ (collect all → fix all → push once), not literally one commit — a single new
29
+ commit containing all batched fixes satisfies the goal. Guardrail facts (verified in the
30
+ tool-before push guardrail): bare `git push --force`
31
+ and `-f` are deny-pattern-blocked; `--force-with-lease` is EXEMPT because it
32
+ refuses to overwrite remote work gained since your last fetch — commit-pr
33
+ mandates it for fork/rebase flows. Even so, prefer a normal new fix commit
34
+ over amending an already-pushed commit.
25
35
  6. **Only re-push if NEW failures surface** that were not in the original batch.
26
36
 
27
37
  ## Why this matters
@@ -18,7 +18,7 @@ This skill was originally written for desktop Claude Code (Windows) with `gh`
18
18
  CLI. In the **remote execution / GitHub MCP** environment, use the equivalent
19
19
  MCP tools instead:
20
20
 
21
- | Desktop / `gh` CLI | Remote MCP equivalent |
21
+ | Capability needed | `gh` CLI | Example remote-MCP shape (resolve the real names via ToolSearch) |
22
22
  |---|---|
23
23
  | `gh pr checks <number>` | `mcp__github__pull_request_read` method `get_check_runs` |
24
24
  | `gh pr view <number> --json checks` | `mcp__github__pull_request_read` method `get_check_runs` |
@@ -26,9 +26,11 @@ MCP tools instead:
26
26
  | `gh pr edit --title` | `mcp__github__update_pull_request` with `title` |
27
27
  | `gh pr view --json mergeable` | `mcp__github__pull_request_read` method `get` |
28
28
 
29
- > MCP tool names are injected by the runtime harness and not guaranteed to be
30
- > stable across environments. Use `ToolSearch` to verify availability before
31
- > calling any `mcp__github__*` tool for the first time in a session.
29
+ > MCP tool names are injected by the runtime harness and are NOT stable across
30
+ > environments. Treat the right-hand column as an example SHAPE only: resolve
31
+ > the actual tools by CAPABILITY (PR read with check-run support, job-log read,
32
+ > PR update) via `ToolSearch` before first use in a session — never assume a
33
+ > specific `mcp__github__*` name exists (issue #2131 finding 9).
32
34
 
33
35
  ## Step 1 — Fetch current status
34
36
 
@@ -18,4 +18,4 @@ After explorer returns:
18
18
  - Run `symbols` tool on key files identified by explorer to understand public API surfaces
19
19
  - For multi-file module surveys: prefer `batch_symbols` over sequential single-file symbols calls
20
20
  - Run `complexity_hotspots` if not already run during project discovery (check context.md for existing analysis). Note modules with recommendation "security_review" or "full_gates" in context.md.
21
- - Check for project governance files using the `glob` tool with patterns `project-instructions.md`, `docs/project-instructions.md`, `CONTRIBUTING.md`, `INSTRUCTIONS.md`, `AGENTS.md`, and `CLAUDE.md` (process all matches found). For each file found: read it and extract all MUST (mandatory constraints) and SHOULD (recommended practices) rules. Write the extracted rules as a summary to `.swarm/context.md` under a `## Project Governance` section — append if the section already exists, create it if not. If no MUST or SHOULD rules are found in the file, skip writing. If no governance file is found: skip silently. Existing DISCOVER steps are unchanged.
21
+ - Check for project governance files using the `glob` tool with patterns `project-instructions.md`, `docs/project-instructions.md`, `CONTRIBUTING.md`, `INSTRUCTIONS.md`, `AGENTS.md`, and `CLAUDE.md` (process all matches found). For each file found: read it and extract all MUST (mandatory constraints) and SHOULD (recommended practices) rules. Write the extracted rules to `.swarm/context.md` under a `## Project Governance` section — append if the section exists, create it if not — PRESERVING PROVENANCE for every rule (issue #2131 finding 9): each entry records (a) its source file, (b) the subtree scope the file declares or implies (repo-wide when undeclared), (c) precedence — `AGENTS.md`/`project-instructions.md` outrank `CONTRIBUTING.md`/`INSTRUCTIONS.md`/`CLAUDE.md` when rules conflict, (d) strength (MUST vs SHOULD), and (e) a conflict flag naming the other file whose rule it contradicts, if any. Never flatten conflicting rules into one; surface the conflict. If no MUST or SHOULD rules are found in the file, skip writing. If no governance file is found: skip silently. Existing DISCOVER steps are unchanged.
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: durable-session-state
3
+ audience: swarm-plugin
4
+ description: >
5
+ Persist plans, scope decisions, evidence, and reviewer/critic verdicts to
6
+ durable files during long or multi-phase tasks so work survives context
7
+ compaction, session resumes, and handoffs. Use for swarm-mode tasks, before
8
+ context grows large, when recording approval gates, and when resuming after
9
+ compaction or a session restart.
10
+ ---
11
+
12
+ # Durable Session State
13
+
14
+ Long swarm-mode sessions outlive their context window. Compaction summarizes
15
+ history, and summaries lose exactly the things the swarm gates depend on:
16
+ which diff a reviewer approved, what evidence was recorded, which decisions
17
+ are settled. Without durable artifacts, a resumed session re-litigates settled
18
+ decisions or — worse — treats a stale approval as current. Persist state to
19
+ files as you go; treat the conversation as cache, not storage.
20
+
21
+ ## Where artifacts live
22
+
23
+ - Generic swarm tasks: `.claude/session/tasks/<task-slug>/` in the project.
24
+ - Issue-tracer work: `.claude/issue-traces/<issue>/` (that skill's own schema
25
+ — `08b-implementation-review.md`, `09-final-critic.md` — wins for its work).
26
+ - Never write task artifacts to the repo root, and never under `.swarm/` —
27
+ that directory is the OpenCode plugin's runtime state, not Claude Code's.
28
+ - These artifacts are working state, not deliverables: do not commit them
29
+ unless the user asks. Before committing, check `git status` and exclude
30
+ them explicitly.
31
+
32
+ ## What to persist
33
+
34
+ Keep it to four small files per task; update in place:
35
+
36
+ 1. `plan.md` — task scope, success criteria, files in scope, what must not
37
+ break. Update when scope changes; never fork a second plan file.
38
+ 2. `decisions.md` — one line per settled decision with a one-line rationale
39
+ ("chose X over Y because Z"). Settled means: do not reopen without new
40
+ evidence or a user request.
41
+ 3. `evidence.md` — validation commands run and their outcomes (pass/fail plus
42
+ the load-bearing output lines, not full logs).
43
+ 4. `gates.md` — the approval ledger. One entry per reviewer/critic verdict:
44
+
45
+ ```
46
+ ## <gate> — <APPROVE|NEEDS_REVISION|BLOCKED>
47
+ when: <ISO timestamp or turn marker>
48
+ head: <git rev-parse HEAD>
49
+ diff: <git diff --stat summary>
50
+ items: <blocking items, or none>
51
+ ```
52
+
53
+ ## When to write
54
+
55
+ - At phase boundaries (scope settled, plan built, implementation done, each
56
+ gate verdict received).
57
+ - Before ending a turn while background subagents are running.
58
+ - Whenever you notice the conversation is long — write ahead of compaction,
59
+ not after it.
60
+
61
+ ## Resume protocol
62
+
63
+ On resuming (after compaction, a restart, or a handoff), before doing new
64
+ work:
65
+
66
+ 1. Re-read the task's artifacts. They are authoritative over your memory of
67
+ the conversation.
68
+ 2. Do not re-litigate `decisions.md` entries or redo work `evidence.md`
69
+ already proves, absent new evidence or a user request.
70
+ 3. Check gate staleness: if `git rev-parse HEAD` or the working-tree diff no
71
+ longer matches the latest APPROVE entry in `gates.md`, that approval is
72
+ invalid — re-run the affected reviewer/critic gate on the current diff.
73
+ 4. If artifacts and the summarized conversation disagree, trust the artifacts
74
+ and say so.
75
+
76
+ ## Relationship to swarm gates
77
+
78
+ The swarm-mode contract invalidates any approval issued before the latest
79
+ edit. The `gates.md` ledger is what makes that rule *checkable* instead of
80
+ vibes: record the HEAD and diff summary at approval time, compare on resume
81
+ and before final synthesis. If you cannot demonstrate approval-after-last-edit
82
+ from the ledger, the gate is not satisfied.
@@ -201,7 +201,7 @@ When a sandbox executor (`src/sandbox/{linux,macos,win32}/*.ts`) interpolates en
201
201
 
202
202
  - **Keys must match POSIX env-var name syntax.** Every env key must be validated against the regex `/^[A-Za-z_][A-Za-z0-9_]*$/` (a leading letter or underscore, then letters/digits/underscores) before being interpolated. Define or reuse a single `isValidEnvKey(key: string): boolean` helper colocated with the `SandboxExecutor` interface in `src/sandbox/executor.ts` (around line 24+); do not duplicate the regex inline at every call site. Keys that fail validation must be silently dropped (not raised) so that one bad caller cannot wedge the sandbox path — but the drop must be observable in the advisory/observability layer (`pendingAdvisoryMessages` or structured log), never silent.
203
203
  - **Values must be shell-quoted or treated as opaque single tokens.** On POSIX, prepend a leading single quote, escape any embedded single quotes by replacing `'` with `'\''`, and append a trailing single quote. On Windows PowerShell, **prefer single-quoted literal contexts (e.g. `'$env:NAME'`) and run values through a `psStringEscape`-style helper that escapes backtick, `$`, `"`, and `` ` ``** (the special characters in double-quoted PowerShell strings). Single-quoted PowerShell strings are literal — only `'` needs escaping, doubling it to `''`. If a context requires double-quoted PS values, escape embedded `"` as `` ` ``, backtick as `` `` ``, and `$` as `` ` `` (backtick is the PS escape character in double-quoted strings; `$` must be escaped to prevent variable expansion). On bwrap, always pass values as separate argv tokens after the `--setenv` flag (`--setenv KEY VALUE`, two tokens), never as a single concatenated `KEY=VALUE` token that an intermediate shell would interpret.
204
- - **Use the array-form argv for every sandbox subprocess.** Never `shell:`-interpolate. The same invariant-3 rules (`array-form spawn`, `stdin: 'ignore'`, `cwd`, `timeout`, `proc.kill()` in `finally`) apply to sandbox spawns as to any other subprocess see the `subprocess-safety` cross-link.
204
+ - **Use the array-form argv for every sandbox subprocess.** Never `shell:`-interpolate. The same invariant-3 rules (`array-form spawn`, `stdin: 'ignore'`, `cwd`, `timeout`, `proc.kill()` in `finally`) apply to sandbox spawns as to any other subprocess; opencode-swarm repository contributors can also consult the repo's subprocess-safety developer skill.
205
205
 
206
206
  ## Sandbox fallback parity (Windows and Linux)
207
207
 
@@ -84,17 +84,23 @@ its receipt gates ARE the mechanical implementation for the parts it owns):
84
84
  - **Plan-critic gate before EXECUTE** — the reducer will not advance to EXECUTE until the
85
85
  plan-critic approval is observed.
86
86
  - **Authoritative plan state** — read through the ledger-aware loader, never the projection.
87
+ - **Independent implementation review before commit-pr handoff** — fresh-context reviewer
88
+ AND critic passes must both approve the diff; record them with
89
+ `record_implementation_review` (else the engine emits a one-shot review directive). The
90
+ receipt is an agent self-attestation of the fresh-context discipline; under
91
+ PR-review/feedback modes the mechanically authenticated reviewer gates remain the
92
+ PR-workflow machinery.
93
+ - **Recurrence sweep before commit-pr handoff** — the defect class must be characterized,
94
+ searched with explicit predicates, every hit dispositioned, and a guardrail installed
95
+ with proof it catches the original defect (or the "no defect class" fast path recorded);
96
+ record it with `record_recurrence_sweep` (else the engine emits a one-shot sweep directive).
87
97
  - **Honest completion** — `publication_handoff` is NOT "resolved"; terminal `published` needs
88
98
  an issue-bound publication receipt.
89
99
  - **Durable delivery** — a transition persists only after its directive is delivered.
90
100
 
91
- The following Contract obligations are NOT mechanically enforced by the trace engine and
92
- remain the responsibility of the agent / owning skills (tracked as residual criterion-B
93
- work on issue #2131, not yet composed into this path): the **independent implementation
94
- review** (separate reviewer/critic contexts on the diff — when run under PR-review/feedback
95
- modes those are enforced by the PR-workflow gates, not by this trace engine) and the
96
- **recurrence sweep** (checking for related prior fixes of the same root cause). Surface
97
- both honestly in the trace's evidence; do not claim the Contract is fully composed here.
101
+ With these receipts the Full-Resolution Contract is mechanically composed into this trace
102
+ path end to end; the receipts are issue-bound and survive until the next `/swarm issue` or
103
+ `/swarm reset`.
98
104
 
99
105
  RULES:
100
106
  - One question per message in INTAKE dialogue (max 6 questions)
@@ -74,7 +74,7 @@ Use these sources in this order.
74
74
  Before meaningful work, discover the repository's own contract in this order. Do not assume one project's conventions apply to another.
75
75
 
76
76
  1. Read the repo-root agent instruction files (`AGENTS.md` and any runtime-specific root instruction file your agent loads).
77
- 2. Read the repo's contributing/commit/test skills or docs if present (e.g. a `contributing` guide, a `writing-tests` skill, a `commit-pr` skill).
77
+ 2. Read the repo's contributing/commit/test skills or docs if present (e.g. a contributing guide, a `writing-tests` skill, a `commit-pr` skill).
78
78
  3. Inspect manifests (package/build metadata), test configs, and CI configs to learn the verification commands — from files, not memory.
79
79
  4. Only if an invariants/architecture-contract doc exists, perform the invariant audit against it and record touched-invariant evidence in the PR body. If none exists, state "no invariant doc found" in the PR body — never fabricate an audit.
80
80
 
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: orchestrating-subagents
3
+ audience: swarm-plugin
4
+ description: >
5
+ Tiering and economics for delegating to subagents: which agent type, model,
6
+ and effort to use per role (explorer, implementer, reviewer, critic), how many
7
+ agents to launch in parallel, how to write scoped subagent prompts with
8
+ bounded structured returns, and how to keep the main context clean. Use when
9
+ launching subagents, parallel explorers, independent reviewers, or critic
10
+ passes — especially for swarm-mode, qa-sweep, or issue-tracer work.
11
+ ---
12
+
13
+ # Orchestrating Subagents
14
+
15
+ Swarm-mode work in this repo delegates heavily (explorer → reviewer → critic).
16
+ This skill defines HOW to delegate so validation gates stay strong while
17
+ breadth stays fast and cheap. It complements — never replaces — the gates in
18
+ `.claude/session/swarm-mode.md`, qa-sweep, and swarm-implement.
19
+
20
+ ## Role → tier mapping
21
+
22
+ | Role | Agent type | Model / effort | Rationale |
23
+ |---|---|---|---|
24
+ | Explorer (mapping, candidate findings) | `Explore` when read-only suffices | Cheaper/faster tier acceptable; low–medium effort | Recall-bound, not reasoning-bound; the reviewer gate catches misses |
25
+ | Implementer (scoped edits) | general-purpose | Session model; medium–high effort | Edits need project conventions (CLAUDE.md context) |
26
+ | Reviewer (independent validation) | general-purpose, **fresh context** | Session (strongest) model; high effort | Precision-bound; false approvals are the expensive failure |
27
+ | Critic (final challenge) | general-purpose, **fresh context** | Session (strongest) model; high effort | Same — this is the last line of defense |
28
+
29
+ Hard rule: economize on explorers, never on reviewers or critics. If the
30
+ harness exposes model or effort overrides for subagents, tier explorers down;
31
+ do not tier the reviewer or critic below the session model or below high
32
+ effort. If no override is available, tier by agent type (`Explore` is
33
+ lightweight: read-only tools, skips CLAUDE.md) and by prompt scope.
34
+
35
+ ## Fan-out discipline
36
+
37
+ - Launch parallel agents only for **disjoint scopes**. Before launching, write
38
+ one line per agent stating its scope; if two overlap, merge them.
39
+ - 2–4 explorers per wave is a heuristic only when the active workflow does
40
+ not define its own fan-out contract. A workflow-specific contract overrides
41
+ this heuristic: PR review, for example, requires all six base dimensions and
42
+ all eleven risk families to be covered on every PR — its capability profiles
43
+ and depth tiers (see swarm-pr-review) govern how many lanes carry that
44
+ coverage, and under the plugin's mechanical controller the tier is computed
45
+ from the bound diff and the matching lane floors are enforced outright. No
46
+ time, cost, repository-size, or simplicity
47
+ rationale may reduce the coverage a workflow mandates.
48
+ Outside fixed-fan-out workflows, more agents than distinct scopes adds token
49
+ cost and synthesis burden without adding recall.
50
+ - Launch independent agents **in a single message** so they run concurrently.
51
+ - Do not re-run a search an agent is already doing; wait for its report.
52
+ - Scale waves, not width: if the first wave surfaces new territory, launch a
53
+ second targeted wave rather than one giant speculative first wave.
54
+
55
+ ## Subagent prompt contract
56
+
57
+ Every delegation prompt must state:
58
+
59
+ 1. **Scope** — exact directories, files, or question. Name what is out of scope.
60
+ 2. **Deliverable** — the structure of the report (per-item findings, then a
61
+ ranked summary). The agent's final message is the only thing you receive.
62
+ 3. **Evidence bar** — exact `file:line` references; no invented paths; verify a
63
+ path exists before citing it.
64
+ 4. **Status labels** — explorers return CANDIDATE findings only; reviewers
65
+ classify CONFIRMED / DISPROVED / UNVERIFIED / PRE_EXISTING; reviewer and
66
+ critic verdicts are APPROVE / NEEDS_REVISION / BLOCKED.
67
+ 5. **Output bound** — compact structured returns; no full-file dumps.
68
+
69
+ For reviewers and critics additionally:
70
+ - Give the **claims and locations**, not the author's justification — the
71
+ reviewer must re-derive, not confirm, the reasoning.
72
+ - State the adversarial default explicitly: "default to DISPROVED/UNVERIFIED
73
+ unless the code evidence supports the finding."
74
+ - A reviewer or critic must be a **fresh agent**, never a continued
75
+ conversation with the agent whose work it judges.
76
+
77
+ ## Independence and staleness
78
+
79
+ - Reviewer and critic review the **latest diff**, not a description of it. Give
80
+ them the branch state and the validation evidence, and require them to run
81
+ `git diff`/`git log` themselves.
82
+ - Any edit after an approval invalidates it. Record what was approved (e.g.
83
+ `git rev-parse HEAD`, `git diff --stat`) so staleness is checkable — see the
84
+ durable-session-state skill.
85
+
86
+ ## Nesting limitation
87
+
88
+ Whether a subagent can spawn further subagents depends on the harness and
89
+ agent type — check whether a subagent tool (`Agent` or `Task`) is actually
90
+ available in your context before assuming either way. If a skill mandating
91
+ fresh-subagent review (qa-sweep, swarm-implement) executes in a context
92
+ **without** a subagent tool:
93
+ - perform the same review checklist yourself as a clearly labeled
94
+ **fallback self-review**, and
95
+ - disclose in your report that independent review was unavailable in this
96
+ context, so the orchestrator can re-run the gate with a real fresh agent.
97
+ Never silently present self-review as independent review.
98
+
99
+ ## Main-context hygiene
100
+
101
+ - Push reading-heavy work into subagents; keep the main thread for scoping,
102
+ synthesis, and decisions.
103
+ - Do not paste subagent transcripts or large tool outputs back into the main
104
+ thread; carry forward only validated findings and verdicts.
105
+ - When a subagent report arrives, extract the load-bearing facts into your
106
+ durable task artifacts (see durable-session-state) before moving on.
107
+
108
+ ## When not to delegate
109
+
110
+ Answer directly, without a subagent, when the task is a single-fact lookup you
111
+ can resolve with one or two targeted Grep/Read calls, or when you already know
112
+ the file and symbol. Delegation overhead should buy breadth, isolation, or
113
+ independence — if it buys none of those, skip it.
@@ -122,7 +122,7 @@ The parallel-work-check skill is referenced by other skills that start work on a
122
122
  | Skill | Usage |
123
123
  |-------|-------|
124
124
  | `file:.swarm/bundled-skills/swarm-pr-feedback/SKILL.md` | Checks before starting PR feedback fixes — ensures no parallel work has already addressed the same findings |
125
- | Legacy `pr-review-fix` alias | Compatibility entry that delegates to the bundled `swarm-pr-feedback` protocol |
125
+ | Legacy pr-review-fix alias | Compatibility entry that delegates to the bundled `swarm-pr-feedback` protocol |
126
126
  | `file:.swarm/bundled-skills/swarm-implement/SKILL.md` | Checks before implementation Phase 1 — ensures the branch is up-to-date before planning |
127
127
  | Any skill that starts work on an existing branch | Run the parallel-work-check protocol before beginning fixes or implementation |
128
128
 
@@ -11,16 +11,41 @@ This protocol is loaded on demand by the architect runtime. The architect prompt
11
11
 
12
12
  ### MODE: PLAN
13
13
 
14
- SPEC GATE (soft check before planning):
14
+ PLANNING PROFILE (authoritative): obey the runtime-injected `[PLANNING PROFILE
15
+ — AUTHORITATIVE]` directive, which is produced by the same resolver used by
16
+ `save_plan`. Select exactly one path:
17
+
18
+ - `balanced`: use durable QA/execution defaults and do not pause for the full
19
+ questionnaire, spec ceremony, or complete clarification funnel. Ask only for
20
+ unresolved material ambiguity, destructive/high-risk authorization, or a
21
+ decision only the user can make. `save_plan` exact-binds the default QA
22
+ profile. Persist `planning_profile: "balanced"`.
23
+ - `strict` (including locked legacy profiles with no stored field): require an
24
+ effective spec, run the complete clarification funnel, present the unified
25
+ QA/execution questionnaire, and wait for the user's answers before saving.
26
+ Persist `planning_profile: "strict"` only when the field is already explicit
27
+ or this is a new/unlocked plan; do not materialize it into a locked legacy
28
+ profile.
29
+
30
+ A locked profile may ratchet `balanced` to `strict`; it never moves `strict` to
31
+ `balanced`.
32
+
33
+ SPEC POLICY (profile-dependent — check before planning):
15
34
 
16
35
  An effective spec exists iff `/swarm sdd status` reports a resolved spec (it reflects `readEffectiveSpecSync`, which returns null for no sources, multiple competing sources, multi-feature Spec-Kit without a selected feature, or any unresolvable state). Do NOT enumerate these cases — defer to `/swarm sdd status`.
17
36
 
18
37
  - If NO effective spec exists (confirmed via `/swarm sdd status`):
38
+ - `strict`: stop and enter MODE: SPECIFY (or materialize a selected SDD source
39
+ with explicit consent). Strict planning cannot save without an effective
40
+ spec.
41
+ - `balanced`: a spec is optional. Offer the choices below only when a spec
42
+ would materially resolve ambiguity; otherwise proceed directly.
43
+ - The remaining no-spec choices in this section apply only to `balanced`.
19
44
  - PLAN INGESTION DETECTION: Check if the user is providing an external plan (indicators: markdown content with Phase/Task structure, or phrases like "ingest this plan", "implement this plan", "prepare for implementation", "here is a plan", "here's the plan"):
20
45
  - If plan ingestion is detected AND no effective spec exists: offer this choice FIRST before any planning:
21
46
  1. "Generate spec from this plan first" → enter EXTERNAL PLAN IMPORT PATH in MODE: SPECIFY to reverse-engineer a spec.md from the provided plan, then return to planning
22
47
  2. "Skip spec and proceed with the provided plan" → proceed directly to plan ingestion and planning without creating a spec
23
- - This is a SOFT gate — option 2 always lets the user proceed without a spec
48
+ - In `balanced`, this is a SOFT gate — option 2 lets the user proceed without a spec.
24
49
  - If no plan ingestion detected: Warn: "No effective spec found. A spec helps ensure the plan covers all requirements and gives the critic something to verify against. Would you like to create one first?"
25
50
  - Offer two options:
26
51
  1. "Create a spec first" → transition to MODE: SPECIFY
@@ -28,20 +53,21 @@ An effective spec exists iff `/swarm sdd status` reports a resolved spec (it ref
28
53
  - If an effective spec EXISTS:
29
54
  - NOTE: Stale detection is intentionally heuristic (compare headings) — false positives are acceptable because this is a SOFT gate. When in doubt, ask the user.
30
55
  - Read the spec (using the effective spec path reported by `/swarm sdd status`) and compare its first heading (or feature description) against the current planning context (the user's request and any existing plan.md title/phase names)
31
- - STALE SPEC DETECTION: If the spec heading or feature description does NOT match the current work being planned (e.g., spec describes "user authentication" but user is asking to plan "payment integration"), treat the spec as potentially stale and offer three options:
56
+ - STALE SPEC DETECTION: If the spec heading or feature description does NOT match the current work being planned (e.g., spec describes "user authentication" but user is asking to plan "payment integration"), treat the spec as potentially stale. In `strict`, offer options 1 and 2 only. In `balanced`, offer all three options:
32
57
  1. **Archive and create new spec** → attempt to rename .swarm/spec.md to .swarm/spec-archive/spec-{YYYY-MM-DD}.md (create the directory if needed); if archival succeeds: enter MODE: SPECIFY and skip the "spec already exists" prompt; if archival fails: inform user of the failure and offer: retry archival, or proceed with option 2, or proceed with option 3
33
58
  2. **Keep existing spec** → use the effective spec as-is and proceed with planning below
34
- 3. **Skip spec entirely** → proceed to planning below ignoring the existing spec
59
+ 3. **Skip spec entirely** (`balanced` only) → proceed to planning below ignoring the existing spec
35
60
  - If the spec appears current (heading matches the work being planned) OR user chose option 2 above, proceed with spec:
36
61
  - Read it and use it as the primary input for planning
37
62
  - Cross-reference requirements (FR-###) when decomposing tasks
38
63
  - Ensure every FR-### maps to at least one task
39
64
  - If a task has no corresponding FR-###, flag it as a potential gold-plating risk
40
- - If user chose option 3 above, proceed without spec: skip all spec-based steps and proceed directly to planning
65
+ - If a `balanced` user chose option 3 above, proceed without spec: skip all spec-based steps and proceed directly to planning
41
66
 
42
- This is a SOFT gate. When the user chooses "Skip and plan directly", proceed to the steps below exactly as before — do NOT modify any planning behavior.
67
+ This is a soft gate only in `balanced`. In `strict`, a missing effective spec is
68
+ a hard prerequisite and `save_plan` will return `SPEC_REQUIRED`.
43
69
 
44
- **SAVE_PLAN SPEC_REQUIRED RECOVERY:**
70
+ **STRICT-ONLY SAVE_PLAN SPEC_REQUIRED RECOVERY:**
45
71
  When `save_plan` returns a SPEC_REQUIRED rejection (no effective spec found), the architect MUST:
46
72
  1. DIAGNOSE: run `/swarm sdd status` to determine why no effective spec resolved.
47
73
  - (a) If `/swarm sdd status` shows NO sources → transition to MODE: SPECIFY.
@@ -54,7 +80,7 @@ Run CODEBASE REALITY CHECK scoped to codebase elements referenced in the effecti
54
80
 
55
81
  ### GENERAL COUNCIL ADVISORY OPTION (pre-save_plan)
56
82
 
57
- Before drafting or saving the plan, the architect MUST offer General Council advisory input when `council.general.enabled` is true in the resolved opencode-swarm config and a search API key is configured.
83
+ In `strict`, before drafting or saving the plan, the architect MUST offer General Council advisory input when `council.general.enabled` is true in the resolved opencode-swarm config and a search API key is configured. In `balanced`, offer it only when current external facts could materially change the plan; do not introduce a pause merely because the feature is configured.
58
84
 
59
85
  - Ask the user: "Use General Council advisory input before I write the plan? The 3-agent council (generalist, skeptic, domain expert) will gather current external context and provide perspectives that I will fold into the plan before critic review. (default: no)"
60
86
  - If the user declines, proceed to the clarification funnel and planning normally.
@@ -70,7 +96,7 @@ General Council is advisory and distinct from `council_mode`, `phase_council`, a
70
96
 
71
97
  ### CLARIFICATION FUNNEL (pre-save_plan)
72
98
 
73
- Before calling `save_plan` — whether creating a new plan or finalizing an external plan ingestion — the architect MUST run this four-stage clarification funnel. The goal is to limit unnecessary user interruption, not planning completeness.
99
+ In `strict`, before calling `save_plan` — whether creating a new plan or finalizing an external plan ingestion — the architect MUST run this four-stage clarification funnel. In `balanced`, use the same classification concepts internally but surface only unresolved material ambiguity, destructive/high-risk authorization, or decisions only the user can make; do not run the full funnel as ceremony.
74
100
 
75
101
  #### Stage 1: Inventory All Material Uncertainties
76
102
 
@@ -113,6 +139,8 @@ For each item classified as `research_needed` or `user_decision` in Stage 2, sen
113
139
 
114
140
  **Hard constraint:** Items in the Always-Surface Categories list (below) MUST NOT receive `UNNECESSARY`/`DROP` from the critic — only `REPHRASE` or `APPROVED`/`ASK_USER` are allowed. If the critic attempts to `UNNECESSARY`/`DROP` an always-surface item, override to `APPROVED`/`ASK_USER`.
115
141
 
142
+ This always-surface protection remains mandatory in every planning profile.
143
+
116
144
  **Overconfidence guard:** If the critic attempts to self-resolve an item by supplying an answer (verdict `RESOLVE`) but the underlying default is not directly supported by user request, spec, or recorded context, the architect MUST classify the item as `user_decision` rather than `self_resolved`. Unsupported defaults must not be silently accepted.
117
145
 
118
146
  Update classifications based on critic response:
@@ -124,7 +152,7 @@ Update classifications based on critic response:
124
152
 
125
153
  The architect MUST update the plan's assumptions with all resolved items before proceeding to Stage 4.
126
154
 
127
- Exception: QA gate selection questions are already mandatory user decisions (enforced by the save_plan tool itself) and do NOT need to go through the funnel. QA gate selection is always a direct user dialogue.
155
+ Strict-only exception: QA gate selection questions are direct user decisions and do NOT need to go through the funnel. Balanced uses the durable default profile and does not present this dialogue.
128
156
 
129
157
  #### Stage 4: Surface User Decision Packet
130
158
 
@@ -182,7 +210,7 @@ Draft the complete implementation plan in memory first. Required parameters:
182
210
 
183
211
  1. Finish drafting the title, swarm identifier, phases, tasks, dependencies, and `files_touched` scopes. Freeze the exact raw plan identity as `swarm_id` plus `plan_title` (the same title passed to `save_plan`). Do not normalize, shorten, or rename either value between profile creation and plan save. An intentional identity replacement must use `confirm_identity_change: true`; never silently create a second profile because wording changed.
184
212
  2. Inspect dependency-ready tasks and their file scopes before recommending parallelism. File-disjoint task groups may run concurrently in isolated worktrees; overlapping or unknown scopes require serial execution.
185
- 3. Present the following unified four-choice dialogue in one message and wait for one complete answer. Silence is not consent.
213
+ 3. `strict`: present the following unified four-choice dialogue in one message and wait for one complete answer. Silence is not consent. `balanced`: skip this dialogue and continue with the durable defaults.
186
214
 
187
215
  <!-- BEGIN QA_GATE_BODY -->
188
216
 
@@ -208,7 +236,7 @@ Additionally, present these three sub-items as part of the same exchange:
208
236
  <!-- END QA_GATE_BODY -->
209
237
 
210
238
  4. MODE: LOOP exception: when `autonomy=auto`, do not pause. Use the loop skill's balanced-speed defaults: reviewer, test_engineer, sme_enabled, critic_pre_plan, sast_enabled, and drift_check ON; council_mode, hallucination_guard, mutation_test, phase_council, and final_council OFF. Choose the largest safe parallel count from the drafted scopes (1 when overlap or uncertainty exists), keep phase-level commits (`commit_after_each_completed_task: false`), and set `auto_proceed: true`.
211
- 5. Before the first `save_plan`, persist all eleven gate booleans with `set_qa_gates({ swarm_id: <exact swarm_id>, plan_title: <exact title>, ...gates })`. If it fails, stop and resolve the profile error; do not save a plan without the matching profile.
239
+ 5. `strict`: before the first `save_plan`, persist all eleven gate booleans with `set_qa_gates({ swarm_id: <exact swarm_id>, plan_title: <exact title>, ...gates })`. If it fails, stop and resolve the profile error. `balanced`: do not call `set_qa_gates` merely to reproduce defaults; `save_plan` creates and exact-binds them.
212
240
  Recovery for upgraded legacy plans: if `get_qa_gate_profile`, `save_plan`, or an execution gate reports that the QA profile is not exact-bound, run `set_qa_gates({ swarm_id: <exact swarm_id>, plan_title: <exact title>, adopt_legacy_binding_only: true })`. This exact-binds the existing profile without changing gates or its lock, then you retry the blocked read/save/enforcement step.
213
241
  6. Immediately call `save_plan` with the same exact identity, the full drafted phases, and the complete locked profile:
214
242
 
@@ -55,14 +55,16 @@ ci-fix-monitor; do not re-derive it here.
55
55
  The canonical uses the `gh` CLI. In remote/MCP environments, use the equivalent
56
56
  MCP tools and verify availability first:
57
57
 
58
- | `gh` CLI | Remote MCP equivalent |
58
+ | Capability needed | `gh` CLI | Example remote-MCP shape (resolve the real names via ToolSearch) |
59
59
  |---|---|
60
60
  | `gh pr checks <N>` | `mcp__github__pull_request_read` method `get_check_runs` |
61
61
  | `gh pr view <N> --json mergeable,mergeStateStatus,reviewDecision` | `mcp__github__pull_request_read` method `get` |
62
62
  | `gh run view <run> --log` | `mcp__github__get_job_logs` with `job_id`, `return_content: true` |
63
63
 
64
- > MCP tool names are injected by the harness and not stable across
65
- > environments. Use `ToolSearch` to verify before first use in a session.
64
+ > MCP tool names are injected by the harness and are NOT stable across
65
+ > environments. The right-hand column is an example SHAPE only: resolve tools
66
+ > by CAPABILITY (PR read, job-log read) via `ToolSearch` before first use —
67
+ > never assume a specific `mcp__github__*` name exists (issue #2131 finding 9).
66
68
 
67
69
  ## Step 1 — Pre-flight gates (run ONCE, before entering the loop)
68
70
 
@@ -619,10 +619,32 @@ settle on the Stage-A digest. After they settle, only one standalone `git commit
619
619
  command may create the reviewed commit; push and remote publication remain
620
620
  blocked until that exact commit is armed. The first completion requires a clean
621
621
  index/worktree and a non-merge direct child commit whose sole parent is the
622
- immutable intake head, so zero commits, multiple commits, merge commits,
622
+ immutable intake head, so multiple commits, merge commits,
623
623
  amend/non-descendant histories,
624
624
  `--allow-empty`, and partially committed reviewed content fail closed. There is no speed, efficiency, token, or time exception.
625
625
 
626
+ **Verified no-change terminal (issue #2131 C1).** When the ENTIRE immutable
627
+ inventory is verified as a no-change outcome — every `FB-###` item classified
628
+ `DISPROVED`, `PRE_EXISTING`, `NEEDS_MORE_EVIDENCE`, or `NEEDS_USER_DECISION`
629
+ in the settled verification lanes — a correct workflow needs NO content commit.
630
+ After every ordered gate settles, call `complete_pr_workflow` with the intake
631
+ `pr_head_sha` while HEAD still equals that intake head and the tree is clean:
632
+ it returns `verified-no-change` and clears the gate terminally (nothing to
633
+ publish; an empty or `--allow-empty` commit is still forbidden). Any item
634
+ classified `CONFIRMED`/`PARTIAL` requires the ordinary exactly-one-reviewed-
635
+ commit path above.
636
+
637
+ **Base-sync/rebind (issue #2131 C2).** When base drift or merge conflicts force
638
+ a merge/rebase, the repaired history is no longer a direct child of the intake
639
+ head and the ordinary publication path can never be satisfied. Do NOT abort
640
+ ad-hoc: finish the repair, fetch the new authoritative PR head, check it out,
641
+ then call `rebind_pr_feedback_head` with the new full PR head SHA. It moves the
642
+ immutable intake head to the new head, preserves the immutable inventory, and
643
+ invalidates every ancestry-bound receipt (Stage A, verification, ordered
644
+ gates) — re-run the entire mechanical ladder on the new ancestry. It refuses a
645
+ no-op rebind, refuses while publication is armed, and refuses while lanes are
646
+ in flight.
647
+
626
648
  **Without the controller (Profiles B/C).** The same gates run in the same
627
649
  order with the same one-row-per-feedback-ID verdict contracts; what changes is
628
650
  the executor. Stage A: run the repository's discovered build, typecheck, and
@@ -691,9 +713,13 @@ because a name such as `test` or `build` can hide a no-op. A
691
713
  reproduction must also return non-empty machine-observable runner output.
692
714
  The reproduction check also supplies one `feedback_targets` row per immutable
693
715
  feedback ID, in inventory order: exact `feedback_item_id`, one executed `target`,
694
- and concrete `expected_behavior`. Missing, duplicate, invented, or target-less
695
- mappings block Stage B; the controller persists that exact per-item mapping
696
- rather than stamping an unrelated test onto the whole inventory.
716
+ concrete `expected_behavior`, and a typed `proof_kind` (`defect`, `metadata`,
717
+ `source-proof`, `conflict`, `ci`, or `user-decision`). Missing, duplicate,
718
+ invented, target-less, or kind-less mappings block Stage B; the controller
719
+ persists that exact per-item mapping. This is a STRUCTURAL mapping with a typed
720
+ proof kind — it proves each item maps to a target the executed command actually
721
+ selects, not that the target is causally decisive for that item; the Stage B
722
+ reviewer lane owns that judgement (issue #2131 C4).
697
723
  No-op/help/list/dry-run,
698
724
  fix/update, package publication/deployment, Git mutation, remote client,
699
725
  shell/eval/wrapper, and credentialed publication surfaces fail closed. The
@@ -143,7 +143,7 @@ When test files pass individually but fail when run together, follow this protoc
143
143
  5. **Specific symptom — closure capture failure**: `vi.mock()` captures closures at **hoist time** (before `beforeEach` runs). Reassigning `mockFn.mockImplementation(newFn)` in the test body does **NOT** update the hoisted closure — the mock still calls the original function.
144
144
  - Symptom: `expect(mockFn).toHaveBeenCalledTimes(N)` fails with an unexpected count
145
145
  - Symptom: `expect(mockFn).not.toHaveBeenCalled()` fails because the real function was called
146
- 6. **Fix path**: Migrate the affected test file to `_internals` DI seam pattern per the `mock-to-internals-migration` skill. This eliminates both the `vi.mock()` call and the closure capture surface area. **Exception — reference-captured functions**: if the source code passes a function as a direct argument or captures it in a closure at module scope (e.g., `transactFile(path, readKnowledge, ...)`), the reference bypasses `_internals` entirely — mutating `_internals.readKnowledge` changes only the object property, not the module-scope binding the source already holds. Migrating to `_internals` does not help. In that case, test via observable outcomes (e.g., run concurrent callers and assert on final persisted state).
146
+ 6. **Fix path**: Migrate the affected test file to the `_internals` DI seam pattern documented above (opencode-swarm repository contributors also have a dedicated mock-to-internals-migration skill that walks the recipe in depth). This eliminates both the `vi.mock()` call and the closure capture surface area. **Exception — reference-captured functions**: if the source code passes a function as a direct argument or captures it in a closure at module scope (e.g., `transactFile(path, readKnowledge, ...)`), the reference bypasses `_internals` entirely — mutating `_internals.readKnowledge` changes only the object property, not the module-scope binding the source already holds. Migrating to `_internals` does not help. In that case, test via observable outcomes (e.g., run concurrent callers and assert on final persisted state).
147
147
 
148
148
  ## Two-Tier Mock Convention
149
149
 
@@ -1,5 +1,6 @@
1
1
  import type { AgentConfig } from '@opencode-ai/sdk';
2
2
  export type { AgentConfig };
3
+ import { type ResolvedPlanningProfile } from '../plan/planning-profile';
3
4
  export interface AgentDefinition {
4
5
  name: string;
5
6
  description?: string;
@@ -72,4 +73,4 @@ export declare function buildCouncilWorkflow(council?: CouncilWorkflowConfig): s
72
73
  * helper remains as a compatibility oracle for direct prompt-contract tests.
73
74
  */
74
75
  export declare function buildQaGateSelectionDialogue(modeLabel: 'BRAINSTORM' | 'SPECIFY' | 'PLAN'): string;
75
- export declare function createArchitectAgent(model: string, customPrompt?: string, customAppendPrompt?: string, adversarialTesting?: AdversarialTestingConfig, council?: CouncilWorkflowConfig, uiReview?: UIReviewConfig, memoryEnabled?: boolean, architecturalSupervision?: ArchitectureSupervisionWorkflowConfig, designDocsEnabled?: boolean, externalSkillsEnabled?: boolean, turboEnabled?: boolean, skillsEnabled?: boolean): AgentDefinition;
76
+ export declare function createArchitectAgent(model: string, customPrompt?: string, customAppendPrompt?: string, adversarialTesting?: AdversarialTestingConfig, council?: CouncilWorkflowConfig, uiReview?: UIReviewConfig, memoryEnabled?: boolean, architecturalSupervision?: ArchitectureSupervisionWorkflowConfig, designDocsEnabled?: boolean, externalSkillsEnabled?: boolean, turboEnabled?: boolean, skillsEnabled?: boolean, planningProfileResolution?: ResolvedPlanningProfile): AgentDefinition;
@@ -2,11 +2,12 @@
2
2
  * Reviewer DIRECTIVE_COMPLIANCE support (Swarm Learning System, Change 2 /
3
3
  * Task 2.1).
4
4
  *
5
- * The reviewer must emit a per-ID verdict for every knowledge directive shown
5
+ * The reviewer must emit a per-membership verdict for every knowledge directive shown
6
6
  * during the phase. This module owns:
7
7
  * - DIRECTIVE_COMPLIANCE_OUTPUT_SPEC: the static format documentation embedded
8
8
  * in the reviewer system prompt (always present).
9
- * - buildDirectiveComplianceBlock: the dynamic, per-phase list of directive IDs
9
+ * - buildDirectiveComplianceBlock: the dynamic, per-phase list of exact
10
+ * trace + entry memberships
10
11
  * to verify (with priorities + any verification_predicate), injected into the
11
12
  * reviewer's delegation prompt at runtime.
12
13
  *
@@ -18,7 +19,15 @@ import type { DirectivePriority } from '../hooks/knowledge-types.js';
18
19
  export declare const DIRECTIVES_TO_VERIFY_TAG = "<directives_to_verify>";
19
20
  /** A directive the reviewer must produce a verdict for. */
20
21
  export interface DirectiveToVerify {
21
- id: string;
22
+ /** Exact retrieval membership this verdict must close. */
23
+ trace_id: string;
24
+ entry_id: string;
25
+ /** Session recorded with the originating retrieval membership. */
26
+ session_id: string;
27
+ cohort_id?: string;
28
+ source_link_id?: string;
29
+ prior_terminal_outcome?: 'violated';
30
+ prior_terminal_event_id?: string;
22
31
  priority: DirectivePriority;
23
32
  lesson?: string;
24
33
  verification_predicate?: string;
@@ -27,10 +36,15 @@ export interface DirectiveToVerify {
27
36
  * Static spec embedded in the reviewer system prompt. Documents the mandatory
28
37
  * DIRECTIVE_COMPLIANCE output section and its verdict grammar.
29
38
  */
30
- export declare const DIRECTIVE_COMPLIANCE_OUTPUT_SPEC = "DIRECTIVE_COMPLIANCE: one line per knowledge directive shown during this phase (the IDs are listed in the DIRECTIVES TO VERIFY block of your prompt). Use exactly one of:\n VERIFIED:<id> evidence=<file:line | predicate_passed>\n VIOLATED:<id> evidence=<file:line | failing_predicate>\n N/A:<id> reason=<why it does not apply to this change>\nEvery listed directive ID MUST appear exactly once. If a directive carries a verification_predicate, you MUST run it and report predicate_passed / failing_predicate as the evidence. Omitting a listed directive ID is itself a VIOLATED verdict.";
39
+ export declare const DIRECTIVE_COMPLIANCE_OUTPUT_SPEC = "DIRECTIVE_COMPLIANCE: one line per retrieval membership shown during this phase. Copy the encoded trace_id and entry_id tokens exactly from the DIRECTIVES TO VERIFY block. Use exactly one of:\n VERIFIED:<trace_id>:<entry_id> evidence=<file:line | predicate_passed>\n VIOLATED:<trace_id>:<entry_id> evidence=<file:line | failing_predicate>\n N/A:<trace_id>:<entry_id> reason=<why it does not apply to this change>\nEvery listed trace_id + entry_id pair MUST appear exactly once. The same entry_id may appear under more than one trace_id and requires one verdict per pair. If a directive carries a verification_predicate, you MUST run it and report predicate_passed / failing_predicate as the evidence. Omitting a listed CRITICAL pair is itself a VIOLATED verdict.";
40
+ /** Encode arbitrary correlation identifiers into one delimiter-safe token. */
41
+ export declare function encodeDirectiveCorrelationId(value: string): string;
42
+ /** Decode one correlation token, rejecting malformed or unbounded values. */
43
+ export declare function decodeDirectiveCorrelationId(token: string): string | null;
31
44
  /**
32
45
  * Render the per-phase "DIRECTIVES TO VERIFY" block injected into the reviewer's
33
- * delegation prompt. Deterministic (sorted by priority then ID). Returns null
46
+ * delegation prompt. Deterministic (sorted by priority then entry + trace).
47
+ * Returns null
34
48
  * when there is nothing to verify (no block emitted).
35
49
  */
36
50
  export declare function buildDirectiveComplianceBlock(directives: DirectiveToVerify[]): string | null;