@mmerterden/multi-agent-pipeline 23.6.0 → 24.0.0

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 (167) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/README.md +61 -27
  3. package/README.tr.md +46 -12
  4. package/SECURITY.md +3 -3
  5. package/docs/architecture.md +47 -8
  6. package/docs/ecosystem.md +20 -18
  7. package/docs/engineering.md +1 -1
  8. package/docs/facts.json +8 -6
  9. package/docs/features.md +59 -15
  10. package/install/_codex-agents.mjs +13 -8
  11. package/install/_common.mjs +24 -0
  12. package/install/_dev-only-files.mjs +4 -0
  13. package/install/_mcp-register.mjs +6 -2
  14. package/install/_rewrite-tree.mjs +197 -0
  15. package/install/codex.mjs +96 -180
  16. package/install/copilot.mjs +24 -54
  17. package/install/index.mjs +29 -11
  18. package/install/templates/codex-instructions.md +21 -5
  19. package/install/templates/copilot-instructions.md +21 -14
  20. package/manifest.json +2082 -0
  21. package/package.json +6 -2
  22. package/pipeline/commands/multi-agent/SKILL.md +7 -5
  23. package/pipeline/commands/multi-agent/analysis/SKILL.md +4 -0
  24. package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
  25. package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
  26. package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
  27. package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
  28. package/pipeline/commands/multi-agent/resume/SKILL.md +2 -0
  29. package/pipeline/commands/multi-agent/review-rounds/SKILL.md +94 -0
  30. package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
  31. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  32. package/pipeline/contract/manifest.json +1 -1
  33. package/pipeline/contract/types/index.d.ts +1 -0
  34. package/pipeline/lib/_jira-auth.sh +50 -78
  35. package/pipeline/lib/_service-account.sh +191 -0
  36. package/pipeline/lib/credential-inventory.sh +49 -37
  37. package/pipeline/lib/credential-store.sh +48 -3
  38. package/pipeline/lib/fetch-confluence.sh +76 -92
  39. package/pipeline/lib/fetch-crashlytics.sh +30 -59
  40. package/pipeline/lib/fetch-figma-annotations.sh +9 -9
  41. package/pipeline/lib/fetch-fortify.sh +77 -81
  42. package/pipeline/lib/fetch-graylog.sh +38 -77
  43. package/pipeline/lib/figma-mcp-refresh.sh +23 -4
  44. package/pipeline/lib/figma-screenshot.sh +7 -8
  45. package/pipeline/lib/figma-token.sh +39 -46
  46. package/pipeline/lib/host.mjs +138 -0
  47. package/pipeline/lib/host.sh +48 -0
  48. package/pipeline/lib/issue-fetcher.sh +25 -41
  49. package/pipeline/lib/jira-publish.sh +23 -21
  50. package/pipeline/lib/local-model.mjs +93 -0
  51. package/pipeline/lib/md2confluence-v3.py +37 -30
  52. package/pipeline/lib/model-dispatch.sh +41 -4
  53. package/pipeline/lib/model-resolve.mjs +58 -0
  54. package/pipeline/lib/post-pr-review.sh +38 -53
  55. package/pipeline/lib/reviewer-families.mjs +70 -0
  56. package/pipeline/lib/service-account.mjs +2131 -0
  57. package/pipeline/lib/service-account.sh +35 -0
  58. package/pipeline/lib/usage-names.generated.mjs +3 -0
  59. package/pipeline/lib/usage-token.mjs +64 -24
  60. package/pipeline/lib/usage-vocab.mjs +1 -1
  61. package/pipeline/lib/user-facing.mjs +11 -3
  62. package/pipeline/lib/vercel-deploy.sh +17 -26
  63. package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
  64. package/pipeline/multi-agent-refs/_input-parser.md +1 -1
  65. package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
  66. package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
  67. package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
  68. package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
  69. package/pipeline/multi-agent-refs/channels/generator.md +10 -2
  70. package/pipeline/multi-agent-refs/channels/menu.md +3 -1
  71. package/pipeline/multi-agent-refs/channels/preview.md +3 -1
  72. package/pipeline/multi-agent-refs/channels/reference.md +16 -2
  73. package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
  74. package/pipeline/multi-agent-refs/component-dispatch.md +2 -2
  75. package/pipeline/multi-agent-refs/cross-cli-contract.md +38 -30
  76. package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +4 -4
  77. package/pipeline/multi-agent-refs/features/doctor.md +37 -11
  78. package/pipeline/multi-agent-refs/features/free-models.md +3 -3
  79. package/pipeline/multi-agent-refs/features/local-model.md +87 -0
  80. package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
  81. package/pipeline/multi-agent-refs/features/product-context.md +6 -5
  82. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  83. package/pipeline/multi-agent-refs/features/review-rounds.md +40 -0
  84. package/pipeline/multi-agent-refs/features/rework-escalation.md +5 -4
  85. package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
  86. package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
  87. package/pipeline/multi-agent-refs/help/en.md +31 -2
  88. package/pipeline/multi-agent-refs/help/tr.md +31 -2
  89. package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +3 -2
  90. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
  91. package/pipeline/multi-agent-refs/phases/modes.md +20 -1
  92. package/pipeline/multi-agent-refs/phases/operations.md +1 -1
  93. package/pipeline/multi-agent-refs/phases/phase-0-init.md +1 -1
  94. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
  95. package/pipeline/multi-agent-refs/phases/phase-3-review.md +7 -3
  96. package/pipeline/multi-agent-refs/phases/phase-5-report.md +12 -10
  97. package/pipeline/multi-agent-refs/phases.md +4 -3
  98. package/pipeline/multi-agent-refs/resume/details.md +2 -0
  99. package/pipeline/multi-agent-refs/review/panel.md +30 -18
  100. package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
  101. package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
  102. package/pipeline/multi-agent-refs/sync/overview.md +11 -5
  103. package/pipeline/multi-agent-refs/tracker-contract.md +28 -10
  104. package/pipeline/office/index.html +4 -4
  105. package/pipeline/schemas/agent-state.schema.json +19 -1
  106. package/pipeline/schemas/autopilot-config.schema.json +29 -4
  107. package/pipeline/schemas/hosts.json +512 -0
  108. package/pipeline/schemas/hosts.schema.json +310 -0
  109. package/pipeline/schemas/launch.json +22 -2
  110. package/pipeline/schemas/launch.schema.json +2 -1
  111. package/pipeline/schemas/phases.json +21 -3
  112. package/pipeline/schemas/phases.schema.json +8 -0
  113. package/pipeline/schemas/prefs.schema.json +346 -7
  114. package/pipeline/schemas/token-budget.json +2 -2
  115. package/pipeline/scripts/.doctor-mut.47076.mjs +2253 -0
  116. package/pipeline/scripts/_autopilot-config.mjs +67 -4
  117. package/pipeline/scripts/_autopilot-item.mjs +67 -0
  118. package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
  119. package/pipeline/scripts/_cost.mjs +75 -3
  120. package/pipeline/scripts/analysis-sources.mjs +22 -5
  121. package/pipeline/scripts/analysis-unattended.mjs +360 -0
  122. package/pipeline/scripts/anonymize-findings.mjs +3 -7
  123. package/pipeline/scripts/autopilot-arming.mjs +19 -10
  124. package/pipeline/scripts/autopilot-intake.mjs +124 -27
  125. package/pipeline/scripts/autopilot-menubar.swift +7 -0
  126. package/pipeline/scripts/autopilot-runner.mjs +77 -48
  127. package/pipeline/scripts/autopilot-status.sh +32 -9
  128. package/pipeline/scripts/bulk-read.sh +37 -5
  129. package/pipeline/scripts/confluence-readback.mjs +15 -7
  130. package/pipeline/scripts/cost-table.json +65 -25
  131. package/pipeline/scripts/doctor.mjs +119 -32
  132. package/pipeline/scripts/entry-mode.mjs +101 -0
  133. package/pipeline/scripts/estimate.mjs +30 -16
  134. package/pipeline/scripts/feedback-send.mjs +11 -8
  135. package/pipeline/scripts/gen-facts.mjs +16 -13
  136. package/pipeline/scripts/jira-attach.sh +23 -28
  137. package/pipeline/scripts/jira-search.sh +5 -21
  138. package/pipeline/scripts/launch-request.mjs +15 -9
  139. package/pipeline/scripts/migrate-prefs.mjs +56 -0
  140. package/pipeline/scripts/phase-tracker.sh +146 -38
  141. package/pipeline/scripts/priority-review.mjs +14 -7
  142. package/pipeline/scripts/product-context.mjs +26 -7
  143. package/pipeline/scripts/prune-logs.sh +4 -2
  144. package/pipeline/scripts/report-file.mjs +285 -0
  145. package/pipeline/scripts/review-rounds.mjs +592 -0
  146. package/pipeline/scripts/rework-escalation.mjs +26 -7
  147. package/pipeline/scripts/service-read.mjs +19 -17
  148. package/pipeline/scripts/skill-siblings.mjs +17 -1
  149. package/pipeline/scripts/status-overview.mjs +20 -10
  150. package/pipeline/scripts/uninstall.mjs +145 -57
  151. package/pipeline/scripts/usage-register.mjs +34 -11
  152. package/pipeline/scripts/usage-report.mjs +31 -26
  153. package/pipeline/scripts/validate-state.mjs +19 -11
  154. package/pipeline/scripts/validate-triage.mjs +11 -1
  155. package/pipeline/scripts/work-items.mjs +25 -28
  156. package/pipeline/scripts/write-store-config.mjs +37 -11
  157. package/pipeline/skills/.skill-manifest.json +11 -7
  158. package/pipeline/skills/.skills-index.json +13 -2
  159. package/pipeline/skills/shared/README.md +4 -3
  160. package/pipeline/skills/shared/core/multi-agent/SKILL.md +14 -6
  161. package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
  162. package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
  163. package/pipeline/skills/shared/core/multi-agent-resume/SKILL.md +1 -1
  164. package/pipeline/skills/shared/core/multi-agent-review-rounds/SKILL.md +92 -0
  165. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  166. package/pipeline/skills/skills-index.md +2 -1
  167. package/pipeline/lib/credential-resolve.mjs +0 -75
@@ -22,7 +22,7 @@ things the tool used to do.
22
22
  ## What the exit code means
23
23
 
24
24
  | Code | Meaning |
25
- |---|---|
25
+ | ---- | ---------------------------------------------------------------------------------- |
26
26
  | 0 | healthy - nothing above INFO |
27
27
  | 1 | degraded - at least one WARN, no BLOCK |
28
28
  | 2 | blocked - at least one BLOCK |
@@ -44,7 +44,7 @@ Every other check tops out at WARN however bad it looks.
44
44
  ## Who calls it, and what they do with the code
45
45
 
46
46
  | Caller | When | On exit 2 |
47
- |---|---|---|
47
+ | --------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
48
48
  | `/multi-agent:setup` | before the first question, and again at the end | the closing run is the evidence for or against "setup complete" |
49
49
  | `/multi-agent:update` | after the install | report that the update left a state a run will fail from, rather than "updated" |
50
50
  | `/multi-agent:sync` | step 0 | **stop.** Syncing a blocked install copies one fault onto five surfaces, and the copies are what people then debug |
@@ -57,7 +57,7 @@ and a gate that blocked on every warning would be routed around within a week.
57
57
  ## The four severities
58
58
 
59
59
  | Severity | Meaning |
60
- |---|---|
60
+ | -------- | ---------------------------------------------------------------------------------------- |
61
61
  | BLOCK | a run will fail or leak |
62
62
  | WARN | a run will work and be worse: a degraded capability, a stale copy, a rejected credential |
63
63
  | INFO | a capability the user chose not to enable; nothing to fix |
@@ -98,7 +98,9 @@ golden file:
98
98
  "schemaVersion": 1,
99
99
  "exit": 1,
100
100
  "selection": null,
101
- "checks": [{ "id": "identity", "severity": "WARN", "problem": "...", "step": "set ...", "detail": null }]
101
+ "checks": [
102
+ { "id": "identity", "severity": "WARN", "problem": "...", "step": "set ...", "detail": null }
103
+ ]
102
104
  }
103
105
  ```
104
106
 
@@ -146,9 +148,14 @@ nothing tests.
146
148
 
147
149
  ### install-present
148
150
 
149
- The installed tree exists and carries the subtrees a run reads: `commands/`,
150
- `multi-agent-refs/`, `scripts/`, `lib/`, `schemas/`. BLOCK when any is missing -
151
- a run cannot start without them.
151
+ The installed tree this doctor is part of exists and carries the subtrees a run
152
+ reads on that host, as `schemas/hosts.json` lists them: `multi-agent-refs/`,
153
+ `scripts/`, `lib/` and `schemas/` on all three, plus `commands/` on Claude Code
154
+ and `skills/` on Copilot CLI and Codex CLI. The tree is the one the script was
155
+ installed into (`~/.claude`, `~/.copilot` or `~/.codex`), so a Copilot-only or
156
+ Codex-only machine is checked against its own install; run from a checkout, the
157
+ checks answer for the first host in the registry. BLOCK when any subtree is
158
+ missing - a run cannot start without them.
152
159
 
153
160
  ### install-version
154
161
 
@@ -402,7 +409,6 @@ readiness, not correctness: a machine that fails all four still runs the
402
409
  pipeline perfectly well with someone watching it. What they catch is the
403
410
  failure mode of an unwatched run - stopping without saying so.
404
411
 
405
-
406
412
  ### usage-report
407
413
 
408
414
  The outcome `usage-report.mjs` recorded for its last send attempt, read from
@@ -435,6 +441,7 @@ outcome, naming the status, its detail and either "the failure report
435
441
  was sent" (no login, a dry run, or a refusal the person chose). Registration
436
442
  runs quietly from setup, update and Phase 0, so this is where a machine that
437
443
  never registers shows why.
444
+
438
445
  ### access
439
446
 
440
447
  The last answer of the run-time access check (`usage-access.mjs`), read from
@@ -455,16 +462,33 @@ Claude while the user believes it does not. `--probe` also sends each
455
462
  configured provider one tiny request and WARNs when every usable one fails it
456
463
  (a revoked key, an exhausted quota). `--explain` lists each provider with its
457
464
  key source, never a value.
465
+
466
+ ### local-model
467
+
468
+ Only on the local-model host; SKIP elsewhere, naming the host, because no other
469
+ host runs a model served from this machine. BLOCK when `global.localModel` is
470
+ absent or unusable, with the reason naming the field and what it has to be: a
471
+ model id of a narrow character set, a base URL that is loopback unless
472
+ `allowRemote` is set, and a context window of at least 8192 tokens. `--probe`
473
+ also asks the server for its model list and BLOCKs when nothing answers, since a
474
+ run that reaches a phase and then cannot ask a model has already spent the
475
+ setup. The step is to set `global.localModel` in the preferences file, which the
476
+ message names by path.
477
+
458
478
  ### xcode-skills
459
479
 
460
480
  Is Apple's `xcode-integration` plugin, which Xcode 27.1 and later materialize
461
481
  (`xcrun agent plugin path`), linked into Claude Code at the installed Xcode
462
- build. SKIP when this Mac has no such plugin, because the pipeline's own iOS
463
- skills then apply; INFO when it is available but not linked; WARN when the link
464
- was copied from an older Xcode build than the one installed; OK otherwise. The
482
+ build. SKIP on Copilot CLI and Codex CLI, which receive Apple's skills as copied
483
+ directories rather than a linked plugin, so the linkage this check reads does
484
+ not describe them. SKIP when this Mac has no such plugin, because the pipeline's
485
+ own iOS skills then apply; INFO when it is available but not linked; WARN when
486
+ the link was copied from an older Xcode build than the one installed; OK
487
+ otherwise. The
465
488
  step is `/multi-agent:update`, which re-runs the installer's link. Apple's skills
466
489
  are the reference for iPhone Duo and window resizing, SwiftUI, App Intents and
467
490
  the accessibility audits, so a stale copy is a worse answer, never a failed run.
491
+
468
492
  ### routine-commands
469
493
 
470
494
  Does a saved routine still name a removed command: the plain autopilot command,
@@ -480,6 +504,7 @@ each routine with the removed commands it names, the replacement for each
480
504
  (`/multi-agent "<task>" autopilot`; `/multi-agent:fable-on`,
481
505
  `/multi-agent:fable-off` or `/multi-agent:fable-status`;
482
506
  `/multi-agent:routines-<action>`) and the file to edit.
507
+
483
508
  ### mcp-legacy-names
484
509
 
485
510
  Does the current project still name the MCP server by its pre-4.0 id. The
@@ -492,6 +517,7 @@ until the old registration is gone. OK when none of them names the old
492
517
  id, WARN listing each file and its entries, with the replacement to make:
493
518
  `mcp__multi-agent__` for permission rules and hook matchers, `multi-agent` as
494
519
  a server id or `.mcp.json` key.
520
+
495
521
  ### unattended-contract
496
522
 
497
523
  Is `multi-agent-refs/unattended-contract.md` installed. It is the only place
@@ -48,8 +48,8 @@ is not stated. Corporate source, tickets and logs belong under the default.
48
48
  ## The two call sites
49
49
 
50
50
  | Call site | Who calls | What goes free | Fallback |
51
- |---|---|---|---|
52
- | `bulk-read` | `bulk-read.sh`, when the read gate diverts a large file | the line-numbered summary of one file, validated against `schemas/bulk-read-output.schema.json` and the file's line count | `claude -p --model <bulkRead.model or haiku>` |
51
+ | ----------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
+ | `bulk-read` | `bulk-read.sh`, when the read gate diverts a large file | the line-numbered summary of one file, validated against `schemas/bulk-read-output.schema.json` and the file's line count | the host's one-shot call, taken from `schemas/hosts.json` (`headless.argv`), on the `bulkRead.model` rung or `haiku`: `claude -p --model <rung>` on Claude Code. A host the registry gives no such call for degrades and names the reason, and the caller reads the region itself |
53
53
  | `delegate` | a skill or phase, through the `llm_delegate` MCP tool | one of the simple tasks below | the session does the task itself |
54
54
 
55
55
  Both ask the router first, so the policy has one implementation:
@@ -67,7 +67,7 @@ for one.
67
67
  Only tasks whose answer can be checked against their own source:
68
68
 
69
69
  | Task | `llm_delegate` | Development | Analysis |
70
- |---|---|---|---|
70
+ | ------------------------------- | ------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
71
71
  | Summarize a long text | `task: summarize` | build and test logs, crash logs, a long file the plan only needs the shape of | Confluence pages, Swagger descriptions, Jira descriptions and comment threads, `generic-doc` links fetched through `web_scrape`, research documents |
72
72
  | Pull named fields out of a text | `task: extract` with a `schema` | ticket keys, endpoints, error codes, failing test names from a log | acceptance criteria, endpoints and field lists, dates and owners from a document |
73
73
  | Pick one label | `task: classify` with `labels` | commit type from a diff summary, a log line's severity | issue type, affected platform, a comment's intent |
@@ -0,0 +1,87 @@
1
+ # Local model host
2
+
3
+ A fourth install target: the Codex CLI engine pointed at a model served from
4
+ this machine, in a tree of its own. `npx @mmerterden/multi-agent-pipeline
5
+ install --local` writes `~/.codex-local/` and leaves `~/.codex/` untouched.
6
+
7
+ ## Why a separate tree rather than a profile
8
+
9
+ The engine keeps its model binding in agent files under its own home. Two
10
+ installs sharing one home means the second silently retunes the first, and a
11
+ run started on one answers on the other's model. A profile would also open a
12
+ second dimension every consumer has to ask about, which is the name-based
13
+ branching the host registry exists to remove. So the local target is a host
14
+ record like any other, in the host registry: id `local`, root `.codex-local`.
15
+
16
+ ## What the server has to be
17
+
18
+ Not "any OpenAI-compatible server". The engine speaks the OpenAI **Responses**
19
+ API and no other: `wire_api = "chat"` is refused when the config loads, and both
20
+ the custom-provider path and `--oss --local-provider` send `POST /v1/responses`.
21
+ A server that offers only `/v1/chat/completions` cannot answer.
22
+
23
+ Ollama serves `/v1/responses` from v0.13.3, with streaming and tool calling, and
24
+ the engine requires v0.13.4 or newer. Whether another local server qualifies is
25
+ a question about that server, and the answer is which endpoint it serves.
26
+
27
+ ## What the user chooses
28
+
29
+ The registry is packaged data: it names install roots and argv, so it is not
30
+ extensible. Two values are the user's and live in preferences:
31
+
32
+ ```json
33
+ {
34
+ "global": {
35
+ "localModel": {
36
+ "baseUrl": "http://127.0.0.1:11434/v1",
37
+ "model": "qwen3-coder",
38
+ "contextWindow": 131072
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ Both are validated before either reaches a config file or an agent file
45
+ (`lib/local-model.mjs`, and `doctor` check `local-model`):
46
+
47
+ - `baseUrl` is loopback unless `allowRemote` is set. The base URL is where every
48
+ prompt in a run goes, so an address off this machine is an explicit decision
49
+ rather than a typo that happened to resolve.
50
+ - `model` is a narrow character set, because the value is written into a TOML
51
+ file.
52
+ - `contextWindow` is required and not guessed. A one-turn request already
53
+ carries about 45 KB of instructions before the task, and a phase spec is
54
+ larger again; a window set too small truncates the diff and the run reports on
55
+ a file it never saw.
56
+
57
+ Until a model is recorded, agents are written with no model at all and children
58
+ inherit the session's. That is the one answer that cannot be wrong.
59
+
60
+ ## What the run looks like
61
+
62
+ | | Local model host |
63
+ |---|---|
64
+ | Rungs | all four collapse to the one model; no reasoning effort |
65
+ | Review panel | one reviewer, triage on the same model |
66
+ | Children at once | 1 |
67
+ | Price | zero per token; the ledger still counts tokens, so a run is comparable with one that cost money |
68
+ | Network | optional |
69
+ | Autopilot | not offered |
70
+
71
+ The engine still attempts a request to its vendor's telemetry host. Denying it
72
+ does not stop a run, but "offline" means the model is local, not that the
73
+ process makes no outbound request.
74
+
75
+ ## The honest limit
76
+
77
+ Quality drops, and this host says so. One reviewer instead of three means less
78
+ disagreement to triage, and a smaller model reads a diff less carefully. The
79
+ profile claims the pipeline runs, not that it runs as well.
80
+
81
+ ## Gates
82
+
83
+ `pipeline/scripts/smoke-local-host.sh` covers the registry shape, the
84
+ preference refusals (an address off this machine, a model name carrying shell
85
+ syntax, a window too small, a non-http scheme), a live install that keeps to its
86
+ own tree, and the agent binding with and without a configured model. No model is
87
+ started there, so nothing in it claims a local model produces usable work.
@@ -84,7 +84,7 @@ genuine outage - it falls through to the normal phase-error path (pause ->
84
84
  resume), since there is nothing left to step down to. The mechanism is the existing per-dispatch override:
85
85
  set `PHASE_MODEL_OVERRIDE=<fallback>` before dispatch (the orchestrator exports
86
86
  `CLAUDE_CODE_SUBAGENT_MODEL` on Claude Code, or passes `--model` on Copilot
87
- CLI). Persona frontmatter stays the source of truth for the *preferred* model;
87
+ CLI). Persona frontmatter stays the source of truth for the _preferred_ model;
88
88
  the override is per-dispatch and leaves files untouched.
89
89
 
90
90
  ## Prefs knob
@@ -105,7 +105,7 @@ predate this field still get the second downgrade step):
105
105
  ```
106
106
 
107
107
  | Field | Meaning |
108
- |---|---|
108
+ | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
109
  | `enabled` | Master switch. `false` = always dispatch the persona's `preferredModel`, fail loudly on error. |
110
110
  | `modelFallback.fableEnabled` | Whether the `fable` rung exists at all on Claude Code. **Ships `false`.** `false` starts every `preferredModel: fable` persona on `opus`; `/multi-agent:fable-on` opts the top rung back in and `/multi-agent:fable-off` takes it out. A cost control that defaults to on is not a control. See "Turning the fable rung off" below. |
111
111
  | `premiumTierUntil` | ISO date (`YYYY-MM-DD`) or `null`. When set and today is **after** this date, every `preferredModel` dispatch is downgraded to `fallbackModel` unless the user re-confirms (see Date gate). Use when the top tier is included in a plan only until a known date. |
@@ -123,7 +123,7 @@ recover from. That distinction is why it is checked before them.
123
123
  Scope is Claude Code only, and the reason differs per host:
124
124
 
125
125
  | Host | Effect of `fableEnabled: false` | Why |
126
- |---|---|---|
126
+ | ----------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
127
127
  | Claude Code | Every `preferredModel: fable` persona (`ios/android/backend-architect`, `code-reviewer`, triage) starts on `opus` | This is the only host where the rung means Fable 5.2 |
128
128
  | Copilot CLI | none | Fable is not offered there; its personas never sat on this rung |
129
129
  | Codex CLI | none, deliberately | The `fable` rung there means `gpt-5.6 @ xhigh`, a different model on a different account. Switching it off from a knob named after an Anthropic model would surprise a Codex user, so it does not |
@@ -213,6 +213,18 @@ per-phase `model` field already carries the override).
213
213
 
214
214
  ## Routing at dispatch
215
215
 
216
+ How a dispatch hands a child its model differs per host, and the registry
217
+ (`schemas/hosts.json`) holds the mapping. This table is generated from it:
218
+
219
+ <!-- hosts:dispatch -->
220
+ | Host | Model | Effort | Required | Children at once | Personas |
221
+ |---|---|---|---|---|---|
222
+ | Claude Code | export `CLAUDE_CODE_SUBAGENT_MODEL` | - | - | no stated ceiling | `.claude/agents/*.md` |
223
+ | Copilot CLI | pass `--model` | - | - | no stated ceiling | `.copilot/agents/*.md` |
224
+ | Codex CLI | `model` on the spawn call | `reasoning_effort` | `fork_turns: none` | 3 | `.codex/agents/*.toml` |
225
+ | Local model | `model` on the spawn call | - | `fork_turns: none` | 1 | `.codex-local/agents/*.toml` |
226
+ <!-- /hosts -->
227
+
216
228
  `$HOME/.claude/lib/model-dispatch.sh` turns `prefs.global.modelRouting` into a
217
229
  rung. Three call sites ask it: the subagent dispatch contract in
218
230
  `skills/shared/core/multi-agent/SKILL.md`, `bulk-read.sh`, and the `delegate`
@@ -228,16 +240,19 @@ Two limits are enforced by the script rather than written here and hoped for:
228
240
  - **A rule may not turn the fable rung on.** With `modelFallback.fableEnabled`
229
241
  false, a rule preferring `fable` falls past it to the next rung. Otherwise
230
242
  `/multi-agent:fable-off` would have a second door.
231
- - **A subagent stays inside the Anthropic ladder.** A subagent is dispatched by
232
- the host, so `free` and every other non-Anthropic rung is refused at the
233
- subagent site and the rule's next rung answers, with the reason on stderr.
243
+ - **A rung this host does not offer is refused.** The preferences file is
244
+ shared across every CLI on the machine, so a rule naming a rung only one of
245
+ them carries is a normal thing for the router to find. It answers from the
246
+ host it is installed under: a rung absent from that host's ladder, or one
247
+ whose model belongs to a provider the host does not dispatch, is skipped and
248
+ the rule's next rung answers, with the reason on stderr.
234
249
  - **`free` only where the pipeline makes the call, and only when switched on.**
235
250
  The `free` rung (provider `free-chain`) answers at `bulk-read` and `delegate`
236
251
  while `modelRouting.free.enabled` is true (`route-on --free`), ahead of the
237
252
  matched rule's rungs. Its callers keep their own default as the fallback,
238
253
  because the toolkit answers `ESCALATE_TO_CLAUDE` whenever no free answer
239
- survives verification. Any other external rung (the `gpt-*` rows) is refused
240
- everywhere: no call site speaks it.
254
+ survives verification. A rung priced for a provider this host does not
255
+ dispatch is refused everywhere: no call site here speaks it.
241
256
 
242
257
  Strategies change the order of the candidate rungs, never the set: `task-fit`
243
258
  tries the cheapest first by `cost-table.json` price, and `cost-ceiling` does the
@@ -268,7 +283,7 @@ promoted policy; the decision's reason then ends in `learned`. The loop:
268
283
  draws in ten.
269
284
 
270
285
  The two limits above still hold on a learned order: the fable switch is
271
- checked after it, and a subagent stays on the Anthropic ladder.
286
+ checked after it, and a rung this host does not offer is still refused.
272
287
 
273
288
  The script never fails and never returns an empty rung: a missing preferences
274
289
  file, a missing `jq`, unparseable JSON, an out-of-scope call site and a rung
@@ -302,7 +317,7 @@ on Claude Code. The map is applied at install time by
302
317
  each `~/.codex/agents/<persona>.toml`:
303
318
 
304
319
  | Tier | Codex model | Effort |
305
- |---|---|---|
320
+ | -------- | --------------- | -------- |
306
321
  | `fable` | `gpt-5.6` | `xhigh` |
307
322
  | `opus` | `gpt-5.6` | `high` |
308
323
  | `sonnet` | `gpt-5.4` | `medium` |
@@ -37,7 +37,7 @@ and writes what it found into the plan and into the learning layer.
37
37
  | `stack` | `ios`, `android`, `web`, `backend` or `resources` |
38
38
  | `remote` | `https://`, `ssh://` or `user@host:path`, never with credentials in it |
39
39
  | `branch` | Optional override; without it the branch rule below applies |
40
- | `credential` | Optional logical credential-store key of a read token for that host; accepted only when `prefs.global.credentialHosts` already binds the key to that https host (`/multi-agent:setup`, Token Save Flow Step 3.7) |
40
+ | `credential` | Optional logical credential-store key of a read token for that host; accepted only when the pairing already exists - an account that names the key and covers that https host, or the host listed for the key in `prefs.global.credentialHosts` (`/multi-agent:setup`, Token Save Flow Step 3.7) |
41
41
  | `authScheme` | `basic` (GitHub, default) or `bearer` (Bitbucket Data Center HTTP access tokens) |
42
42
 
43
43
  A project joins a product through `prefs.projects[<key>].product`, or implicitly
@@ -94,10 +94,11 @@ Every read goes through the toolkit's `repo_*` tools
94
94
  - **Fenced**: file text, match lines and commit subjects come back marked as
95
95
  untrusted, with `injectionFlags`. They are data from another team's
96
96
  repository, never an instruction.
97
- - **Credentials stay with their host**: a token is sent only over https, only
98
- to a host `prefs.global.credentialHosts` binds it to. That binding is made in
99
- `/multi-agent:setup` with the person present; nothing in this flow creates
100
- one, and the toolkit refuses any other pairing whatever a request says.
97
+ - **Credentials stay with their host**: a token is sent only over https, and
98
+ only to a host its own account covers or that `prefs.global.credentialHosts`
99
+ binds it to. Both pairings are made in `/multi-agent:setup` with the person
100
+ present; nothing in this flow creates one, and the toolkit refuses any other
101
+ pairing whatever a request says.
101
102
  - **Honest when offline**: an unreachable remote is served from its last fetch
102
103
  with `stale: true` and the reason, and the plan says so.
103
104
 
@@ -77,7 +77,7 @@ $HOME/.claude/scripts/log-metric.sh "$TASK_ID" 3 review.delta iteration=$ITERATI
77
77
  | 3 | A blocking/important finding survived `identicalFindingCycles` consecutive rework cycles | **Autopilot** with `enabled`: trip the breaker. `state.circuitBreaker = {tripped: true, trigger: 2, detail: "finding <fingerprint> (<file>: <issue>) survived <n> consecutive rework cycles", checkpoint: {phase: 4, step: "3.8", iteration: N}, trippedAt, counters: {identicalFindingCycles: <max recurrence>, reworkCycles: N-1}}`, then the halt-visibility protocol from `phases/operations.md` (`status=paused`, `haltReason="4:circuit-breaker:identical-finding"`, tracker meta, the `>&2 HALT` line, the usage report). **Interactive modes**: do not trip; show `delta.stillPresent` and ask (picker-contract) `Continue rework` / `Escalate to me` / `Accept as deferred`, the last moving those findings to `deferred[]` with reason `circuit-breaker: accepted by user after <n> cycles`. |
78
78
  | 1 | Unreadable round file | Log `review.delta_skipped reason=invalid` and continue; the delta is advisory and never blocks on its own failure. |
79
79
 
80
- `plateau` (the still-present set unchanged from the previous delta) is logged, not acted on: at the default threshold it coincides with trigger 2 and with the Phase 3 `retryCount` hard-kill. The rework-storm cap itself is trigger 3, recorded by the Phase 3 re-entry. The Phase 3 reflection prompt names each accepted finding by `fingerprint` and quotes `delta.stillPresent` first, marked `STILL PRESENT after round N-1's fix`.
80
+ `plateau` (the still-present set unchanged from the previous delta) is logged, not acted on: at the default threshold it coincides with trigger 2 and with the review rework limit at its default. The rework-storm cap itself is trigger 3, recorded by Phase 3 Step 4. The Phase 3 reflection prompt names each accepted finding by `fingerprint` and quotes `delta.stillPresent` first, marked `STILL PRESENT after round N-1's fix`.
81
81
 
82
82
  ## Why fingerprints are computed, not stored
83
83
 
@@ -0,0 +1,40 @@
1
+ # Feature: Review rework limit
2
+
3
+ **Pattern**: Phase 3 sends accepted blocking findings back to Phase 2 for rework. How many times it may do that before the run stops is one number, resolved in one place, so the phase docs, the escalation script and the circuit-breaker cannot disagree about it.
4
+
5
+ The range is 1 to 3 and the default is <!-- fact:reworkDefault -->2<!-- /fact -->. The ceiling, <!-- fact:reworkCap -->3<!-- /fact -->, is the schema cap on `phases["2"].reworkCount`.
6
+
7
+ ## Contract
8
+
9
+ With limit N, review sends work back to development N times, every rework is reviewed again, and the run stops when a review still has accepted findings after N reworks: N reworks, at most N + 1 reviews. `state.phases["2"].reworkCount` counts the reworks; `retryCount` counts build and component-dispatch retries and is a separate counter. `retryCount` is cumulative across the run (nothing resets it between Phase 2 entries) with its own cap of 3, so build retries can stop a run independently of the review limit. A state file without `reworkCount` counts from zero.
10
+
11
+ `next` is idempotent per review iteration: it records `phases["2"].reworkForIteration` (the length of `reviewIterations`) in the same write that increments `reworkCount`, and asked again for that iteration it answers `rework` without recording. A resumed run whose `reworkForIteration` equals the number of `reviewIterations` re-enters the rework instead of deciding again.
12
+
13
+ ## Resolution
14
+
15
+ `node $HOME/.claude/scripts/review-rounds.mjs get [--state "$STATE_FILE"] [--json | --value]`. First valid value wins:
16
+
17
+ | Source | Where it lives | Set by |
18
+ |---|---|---|
19
+ | `flag` | `state.reviewRounds` | `--review-rounds N` on `/multi-agent`, stored by Phase 0 (`review-rounds.mjs record`) |
20
+ | `repo` | `prefs.projects.<project>.maxReworkCycles` | `/multi-agent:review-rounds N --repo` |
21
+ | `global` | `prefs.global.review.maxReworkCycles` | `/multi-agent:review-rounds N` |
22
+ | `default` | the schema default | nothing set |
23
+
24
+ `<project>` is the main repository's folder name as is, the value of `state.project`; the command and the run use the same key. A stored value outside 1 to 3, or not an integer, is ignored and listed under `ignored[]`; it is never clamped. In an autopilot run (`state.autopilot`, or `MULTI_AGENT_UNATTENDED=1`) with the circuit-breaker enabled, `prefs.global.autopilotCircuitBreaker.maxReworkCycles` lowers the result and the source reads `breaker`; it never raises it. `--json` also reports `configured` (before that bound) and `breakerCap`.
25
+
26
+ ## Where a run reads it
27
+
28
+ | Step | Reads |
29
+ |---|---|
30
+ | Phase 0, right after `agent-state.json` is created, when the input carried `--review-rounds N` | writes `state.reviewRounds` |
31
+ | Phase 3 Step 4, accepted blocking or important findings | `review-rounds.mjs next --state "$STATE_FILE"`: `rework` (after recording `reworkCount + 1`) or `rule` (`reworkCount >= limit`; the comparison is `shouldRule` in the script) |
32
+ | `rule` | `rework-rulings.mjs` on the current triage; `escalate` stops the run and records autopilot trigger 3 |
33
+ | Phase 2 re-entry | reads neither the limit nor the count |
34
+ | Rework dispatch | `rework-escalation.mjs`, whose last round is the limit and whose round is `reworkCount` |
35
+
36
+ Attended and autopilot runs take the same path. At the limit every open finding is ruled on (`escalate` or `parked`): a blocking or security finding stops the run for the user, and the rest continue to Phase 4 as follow-ups.
37
+
38
+ ## Changing it
39
+
40
+ `/multi-agent:review-rounds` with no argument shows the value and its source and asks. `status` prints, `1`, `2` or `3` sets it globally, `--repo` scopes it to the current repository, `reset` removes the override. Setting needs an explicit argument in an unattended run, which never opens a picker.
@@ -18,12 +18,13 @@ On by default because it fires at most on the rounds where a failure costs the m
18
18
  ```bash
19
19
  node $HOME/.claude/scripts/cost-budget-check.mjs --task-id "$TASK_ID" --prefs "$PREFS_FILE" >/dev/null; BUDGET_RC=$?
20
20
  STILL=$(jq '.reviewIterations[-1].delta.counts.stillPresent // 0' "$STATE_FILE")
21
- ESC=$(node $HOME/.claude/scripts/rework-escalation.mjs --iteration "$ITERATION" --max-iterations 3 \
21
+ REWORK_ROUND=$(jq '.phases["2"].reworkCount // 1' "$STATE_FILE")
22
+ ESC=$(node $HOME/.claude/scripts/rework-escalation.mjs --iteration "$REWORK_ROUND" \
22
23
  --still-present "$STILL" --current-tier "$DEV_TIER" --budget-exit "$BUDGET_RC" \
23
24
  --prefs "$PREFS_FILE" --state "$STATE_FILE" ${FELL_BACK:+--fallen-back})
24
25
  ```
25
26
 
26
- `ITERATION` is the rework round about to run (1-based, `retryCount + 1`); `DEV_TIER` is the rung the Phase 2 dev dispatch resolves to without this override (persona and routing, `skills/shared/core/multi-agent/SKILL.md`), so escalations never compound; `FELL_BACK` is set when this run emitted a `model_fallback` metric. Pass `BUDGET_RC` on every call: without `--budget-exit` the budget counts as disabled only when `costBudget.enabled` is not `true`, otherwise the rung holds with `budget-unchecked`. Prefs come from `--prefs`, then `$MULTI_AGENT_PREFS`, then `~/.claude/multi-agent-preferences.json`. `--state` records the result as `reviewIterations[-1].reworkEscalation`, including a refusal and its reason, and in an autopilot run lists an escalation in `decisions[]` (`features/autopilot-decisions.md`). Exit 2 or 3: log `rework.escalation_skipped`, dispatch on `DEV_TIER`; it never blocks the rework.
27
+ The script resolves the review limit itself (1 to 3, default 2, the repo setting and the autopilot bound included), so the call passes no `--max-iterations`. `REWORK_ROUND` is the rework round about to run, 1-based: `state.phases["2"].reworkCount`, which Phase 3 Step 4 recorded before this dispatch (`retryCount` counts build retries and is not read here); `DEV_TIER` is the rung the Phase 2 dev dispatch resolves to without this override (persona and routing, `skills/shared/core/multi-agent/SKILL.md`), so escalations never compound; `FELL_BACK` is set when this run emitted a `model_fallback` metric. Pass `BUDGET_RC` on every call: without `--budget-exit` the budget counts as disabled only when `costBudget.enabled` is not `true`, otherwise the rung holds with `budget-unchecked`. Prefs come from `--prefs`, then `$MULTI_AGENT_PREFS`, then `~/.claude/multi-agent-preferences.json`. `--state` records the result as `reviewIterations[-1].reworkEscalation`, including a refusal and its reason, and in an autopilot run lists an escalation in `decisions[]` (`features/autopilot-decisions.md`). Exit 2 or 3: log `rework.escalation_skipped`, dispatch on `DEV_TIER`; it never blocks the rework.
27
28
 
28
29
  | `reason` | Meaning |
29
30
  |---|---|
@@ -42,8 +43,8 @@ Telemetry: `log-metric.sh "$TASK_ID" 2 rework.escalation escalate= from= to= rea
42
43
 
43
44
  `escalate: true` -> `PHASE_MODEL_OVERRIDE=<toTier>` for that one dev dispatch (the override outranks routing, so the fable and ceiling checks above are the only ones that apply). The agent is **fresh**: no forked history, no conversation. It gets files:
44
45
 
45
- - `$WORKTREE/.pipeline/triage-round-$ITERATION.json`: the persisted findings of the review that sent this round back (accepted, with fingerprints)
46
- - `$WORKTREE/.pipeline/rework-attempt-$((ITERATION-1)).diff`: the prior attempt's change, written by the orchestrator before the dispatch as `git diff <round start>..HEAD` (round 0 starts at the run's base), so the escalated agent sees what was tried without the conversation that tried it
46
+ - `$WORKTREE/.pipeline/triage-round-$REWORK_ROUND.json`: the persisted findings of the review that sent this round back (accepted, with fingerprints)
47
+ - `$WORKTREE/.pipeline/rework-attempt-$((REWORK_ROUND-1)).diff`: the prior attempt's change, written by the orchestrator before the dispatch as `git diff <round start>..HEAD` (round 0 starts at the run's base), so the escalated agent sees what was tried without the conversation that tried it
47
48
  - `delta.stillPresent[]` quoted first, as Phase 2 re-entry item 7 already requires
48
49
 
49
50
  An escalation is per dispatch: the next round asks again from `DEV_TIER`, so the rework never sits more than one rung above the dev dispatch.