@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
@@ -0,0 +1,233 @@
1
+ # Service accounts
2
+
3
+ <!-- toc -->
4
+ - [The problem it solves](#the-problem-it-solves)
5
+ - [The shape](#the-shape)
6
+ - [The two rules](#the-two-rules)
7
+ - [Reading one](#reading-one)
8
+ - [The header each service expects](#the-header-each-service-expects)
9
+ - [A credential from the environment](#a-credential-from-the-environment)
10
+ - [A credential named after its account](#a-credential-named-after-its-account)
11
+ - [Refusals](#refusals)
12
+ - [Migration](#migration)
13
+ - [The gate that keeps it the only reader](#the-gate-that-keeps-it-the-only-reader)
14
+ - [What is not here yet](#what-is-not-here-yet)
15
+ <!-- /toc -->
16
+
17
+ One credential, described in one place: which service it belongs to, where it
18
+ may be sent, and which credential-store items hold it.
19
+
20
+ ## The problem it solves
21
+
22
+ Split across `global.hosts`, `global.keychainMapping` and
23
+ `global.identities[].servicePatMap`, a credential is three unrelated lookups:
24
+ a host from one, a store item name from another, sometimes an identity-specific
25
+ item from a third. Nothing joins them, so nothing is in a position to notice
26
+ when one account's host is handed another account's token. A person with two
27
+ GitHub accounts, or a production and a test Jira, has no way to say which token
28
+ belongs to which, and
29
+ `keychainMapping` has room for exactly one of each.
30
+
31
+ ## The shape
32
+
33
+ ```json
34
+ {
35
+ "global": {
36
+ "serviceAccounts": [
37
+ {
38
+ "id": "jira-acme",
39
+ "service": "jira",
40
+ "label": "Acme Jira",
41
+ "default": true,
42
+ "identityId": "alice",
43
+ "scope": { "host": "jira.acme.example", "extraHosts": [] },
44
+ "secrets": { "token": "Acme_Jira_Access_Token" }
45
+ }
46
+ ],
47
+ "serviceOptOuts": []
48
+ }
49
+ }
50
+ ```
51
+
52
+ `secrets` holds item **names**, never values. `id` is how run state, flags and
53
+ the audit trail name an account, so it never changes once written. `label` is
54
+ what a person reads in a picker. `scope` says where the secret may go; what it
55
+ accepts depends on the service:
56
+
57
+ | Kind | Services | Scope | Where the secret may be sent |
58
+ |---|---|---|---|
59
+ | hosted | jira, confluence, bitbucket, fortify, graylog, jenkins | `host` required, `extraHosts`; graylog also `environment` | the account's own hosts |
60
+ | vendor | github, npm | `host` names another instance; github also `owners` | the vendor's hosts, or the named instance |
61
+ | vendor-fixed | figma, firebase, google_play, appstore_connect | firebase and google_play take `projectId` | a fixed list the account cannot widen |
62
+ | local | figma_mcp, vercel, claude_oauth, supabase | none | nowhere: handed to a local tool |
63
+ | endpoint | usage_ingest | none | the host in `global.usageLog.endpoint` |
64
+
65
+ ## The two rules
66
+
67
+ **A secret is never produced without a destination that was checked.** A request
68
+ that names no host gets a refusal, not the default account. A host no account
69
+ covers gets a refusal, not the nearest match. "I do not know which token this
70
+ host wants" and "here is the token I had" are different answers, and the second
71
+ one is how a token reaches a host it was never issued for.
72
+
73
+ **An unmigrated file resolves identically.** While `serviceAccounts` is absent
74
+ the same entries are derived in memory from the flat keys. A missing array is
75
+ not a refusal; it is the old shape, read the new way.
76
+
77
+ ## Reading one
78
+
79
+ Everything goes through `$HOME/.claude/lib/service-account.mjs`, or
80
+ `service-account.sh` for shell callers, which execs the same module.
81
+
82
+ ```bash
83
+ service-account.sh select --service jira --url https://jira.acme.example/rest
84
+ service-account.sh token --service jira --url https://jira.acme.example/rest
85
+ service-account.sh list --service github
86
+ service-account.sh check
87
+ ```
88
+
89
+ `token` writes the raw secret to stdout with no trailing newline. Everything
90
+ else writes one JSON line. On a refusal stdout is empty and one JSON line goes
91
+ to stderr, carrying `reason`, a sentence of `message`, and a `remedy` naming the
92
+ one thing to do next.
93
+
94
+ `items` lists every store item name the accounts refer to, with the account and
95
+ slot that refers to it. Names only, never values: it is the one listing that is
96
+ safe to print, and it stays that way by never reading the store at all.
97
+
98
+ `curl-config` is how a secret reaches an outbound request: the URL, a scheme
99
+ lock and the header live in one curl config, and redirects are refused, so
100
+ nothing can point curl elsewhere between the check and the request.
101
+
102
+ Shell callers get the same four things from `lib/_service-account.sh`, which is
103
+ sourced rather than run: `sa_cfg` writes a config only curl reads and removes it
104
+ when the shell exits, `sa_host` gives the host of the chosen account, `sa_token`
105
+ is there for the few callers that cannot use a config, and `sa_explain` turns a
106
+ refusal into a sentence. A fetcher that builds its own `-H "Authorization: ..."`
107
+ is a fetcher that can carry it through a redirect.
108
+
109
+ ## The header each service expects
110
+
111
+ The scheme is a fact about the service, not a choice at the call site:
112
+
113
+ | scheme | header |
114
+ |---|---|
115
+ | `bearer` (default) | `Authorization: Bearer <token>` |
116
+ | `basic` | `Authorization: Basic base64(<username slot>:<token>)` |
117
+ | `basic-token-user` | `Authorization: Basic base64(<token>:)` |
118
+ | `basic-or-bearer` | basic when the account carries a username, bearer when it does not |
119
+ | `figma-pat` | `X-Figma-Token: <token>` |
120
+ | `fortify-token` | `Authorization: FortifyToken base64(<token>)` |
121
+
122
+ `basic` reads the username through the store, because that slot holds an item
123
+ name like every other one. Reading it as the username itself would send the
124
+ store's item name as the login and fail like a wrong password.
125
+
126
+ ## A credential from the environment
127
+
128
+ A CI job, a container, and a person trying the pipeline before running setup all
129
+ supply a credential the same way: an environment variable. The resolver answers
130
+ from one when a variable holds something, as an account called `env:<service>`.
131
+
132
+ It is not a worse secret, but it is a differently bound one, because nobody said
133
+ which host it belongs to. So it reaches only what is already known: a host a
134
+ configured account covers, the vendor's own hosts, whatever its own `*_HOST`
135
+ variable names, and loopback. It never wins a destination a configured account
136
+ also covers, and it never becomes the default.
137
+
138
+ Loopback is also the one place `http` is allowed, for any credential. A local
139
+ model server, a mock and a dev instance all live at `127.0.0.1` with no
140
+ certificate, and refusing them outright is what pushes people to turn the check
141
+ off for everything; loopback is the one destination with no network to carry
142
+ the request, so there is nothing on the wire to protect. Everywhere else `http`
143
+ is `insecure-url`, refused before the store is touched. The destination rule is
144
+ unchanged underneath: a loopback address still has to be one the account names.
145
+
146
+ The URL in that config is one this module serialized, never the string it was
147
+ handed. The two differ more than they look: the URL parser silently removes
148
+ tab, CR and LF and rewrites a backslash as a slash, while a curl config is read
149
+ a line at a time. `https://good.example/x` followed by a newline and
150
+ `url = https://evil.example/` names `good.example` to a host check and is two
151
+ `url` directives to curl - and the `header` line applies to both. So a URL
152
+ carrying a control character or a backslash is refused outright, by
153
+ `normalizeHost`, before anything is selected; and `curl-config` parses the URL a
154
+ second time and checks its hostname against the host the secret was bound to.
155
+
156
+ ## A credential named after its account
157
+
158
+ A team that holds one credential per instance tells them apart by naming the
159
+ store item after the account: the short id, then the provider, then the rest
160
+ (`b_jira_access_token` for account `b`). `global.accounts[]` carries that
161
+ account's hosts under the same id.
162
+
163
+ Neither half names the other, so the pairing is made at the one moment both are
164
+ in hand: a request that asks by item name. The id read out of the name picks
165
+ the entry, and that entry supplies the single host the item may be sent to -
166
+ its own `jiraHost` / `bitbucketHost` / `confluenceHost`, or the host the file
167
+ names for the service when the entry declares none. An id the file does not
168
+ list is `unknown-account`, never the default account: resolving it to whichever
169
+ account came first is the pairing this module exists to refuse.
170
+
171
+ ```
172
+ --item B_Jira_Access_Token -> account jira-b, host jira.b.example.com
173
+ --item B_Jira_Access_Token --host jira.example.com
174
+ -> no-account-for-target
175
+ ```
176
+
177
+ The second line is the point: B's credential does not reach A's host because a
178
+ caller asked for it.
179
+
180
+ ## Refusals
181
+
182
+ | reason | exit | when |
183
+ |---|---|---|
184
+ | `invalid-request` | 3 | no such service, slot, or sub-command |
185
+ | `not-configured` | 1 | nothing configured for this service (carries `optedOut`) |
186
+ | `unknown-account` | 1 | an id no account carries |
187
+ | `slot-missing` | 1 | the account has nothing in that slot |
188
+ | `secret-missing` | 1 | the item it names is not in the store |
189
+ | `store-unavailable` | 2 | no credential backend on this machine |
190
+ | `store-error` | 4 | the backend failed |
191
+ | `secret-locked` | 5 | the store is locked |
192
+ | `prefs-unreadable` | 6 | the preferences file does not parse |
193
+ | `invalid-config` | 6 | the accounts do not hold together |
194
+ | `destination-required` | 7 | a secret was asked for with no destination |
195
+ | `insecure-url` | 7 | not https outside loopback, or userinfo in the URL |
196
+ | `host-mismatch` | 7 | a named account, and a destination outside it |
197
+ | `no-account-for-target` | 7 | no account covers the destination |
198
+ | `identity-mismatch` | 7 | every match belongs to another identity |
199
+ | `not-sendable` | 7 | an outbound request for a local-only credential |
200
+ | `ambiguous` | 8 | several fit and nothing tells them apart |
201
+ | `needs-pairing` | 8 | the account has a secret but no host yet |
202
+
203
+ ## Migration
204
+
205
+ `migrate-prefs.mjs` derives the array from the flat keys, and will not guess.
206
+ Where the file holds one token and one host for a service, that is the only
207
+ pairing the data allows and it is written. Where it holds more of either and
208
+ nothing says which goes with which, the entry is written with `unresolved`
209
+ instead of a host; the resolver refuses it and setup asks a person which host it
210
+ belongs to. Skipping the question asks again next run - only the explicit
211
+ permanent choice stops it.
212
+
213
+ The flat keys stay. `keychainMapping`, `hosts` and `credentialHosts` remain the
214
+ projection of each service's default account, so the toolkit server and people's
215
+ own scripts keep reading the same answers. `writeAccounts` is the only writer of
216
+ `serviceAccounts`, and it writes the array and the keys it projects into in one
217
+ replacement.
218
+
219
+ ## The gate that keeps it the only reader
220
+
221
+ `lint-credential-reads.mjs` counts the lines that still read `keychainMapping`,
222
+ `credentialHosts` or `global.hosts`, or call the credential store, outside the
223
+ resolver. It is a per-file ratchet against
224
+ `pipeline/scripts/fixtures/credential-reads-baseline.txt`: a file may carry
225
+ fewer than its baseline, never more, and a file absent from the baseline may
226
+ carry none. The resolver is the join only while it is the only reader - a caller
227
+ that looks a key up itself has reintroduced the gap for its own request.
228
+
229
+ ## What is not here yet
230
+
231
+ The entity, the resolver, the migration and the gate are in. Callers are moving
232
+ over a batch at a time, and the baseline is what says how far that has got. The
233
+ "add another account" flow in setup, and the picker that uses it, come after.
@@ -930,6 +930,12 @@ base, title and body, records `state.publish`, and the attempt is
930
930
  push it again, and not parked, because the step left is a person's and needs
931
931
  neither the worktree nor the repo's queue slot.
932
932
 
933
+ An analysis item never reaches any of this. Its queue label says the work is a
934
+ document, the publish step returns before it reads a request, and the attempt is
935
+ `doc-delivered`: terminal, because the document is the delivery. Nothing is
936
+ pushed and no pull request is opened for it, by this path or any other - the
937
+ guard blocks both for every unattended run.
938
+
933
939
  Every process the publish step starts runs with `MULTI_AGENT_UNATTENDED` and
934
940
  `MULTI_AGENT_SESSION_ID` removed and `GIT_TERMINAL_PROMPT=0`. The runner is not
935
941
  the agent: these are spawns, not tool calls, so no hook sees them, and the
@@ -947,7 +953,10 @@ step with `autopilot-publish.mjs --session <id> --state <agent-state.json>
947
953
  ## Phase 5 and channels
948
954
 
949
955
  Under the variable Phase 5 skips external delivery (`deferred-to-runner`) and
950
- `channels` posts nothing. After the PR opened, and only then, the runner posts
956
+ `channels` posts nothing. It still runs with `--file-only`: the local report
957
+ file is written under `LOGS_ROOT`, which is already an `allowWrite` entry. It is
958
+ not a post, nothing outside the machine sees it, and no runner step depends on
959
+ it (`channels/report-file.md`). After the PR opened, and only then, the runner posts
951
960
  what `~/.claude/autopilot/config.json` opts into
952
961
  (`schemas/autopilot-config.schema.json`), once, through the existing scripts:
953
962
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- facts: commandCount="commands" toolCount="tools, most for a RUNNING app" -->
4
4
  ```
5
- Multi-Agent Pipeline - 80 commands, grouped by what you want to do
5
+ Multi-Agent Pipeline - 81 commands, grouped by what you want to do
6
6
 
7
7
  Start here:
8
8
 
@@ -13,6 +13,10 @@ Start here:
13
13
  5. /multi-agent:help This page
14
14
 
15
15
  A task is a Jira key or URL, a GitHub issue URL, #N, repo#N or free text.
16
+ Typing /multi-agent on its own asks which kind it is, instead of this page, and
17
+ the same goes for a bare /multi-agent:analysis. A modifier with no task
18
+ (autopilot on its own) still prints what it needs, and an unattended run
19
+ started with no task stops instead of waiting for an answer.
16
20
  Each command's own page has the detail: ~/.claude/commands/multi-agent/<name>/SKILL.md
17
21
 
18
22
  ------------------------------
@@ -22,13 +26,14 @@ Develop
22
26
  /multi-agent "task" Full run: plan, TDD, review, commit, report
23
27
  /multi-agent "task" autopilot Same run, no questions; commit and PR automatic
24
28
  /multi-agent "task" autopilot --loop N Up to N autopilot runs in the background
29
+ /multi-agent "task" --review-rounds N This run: N review rework rounds, 1 to 3
25
30
  /multi-agent:status Runs in every project: id, phase, branch, state
26
31
  /multi-agent:log [#id] A run's log (the latest by default)
27
32
  /multi-agent:resume [#id] [autopilot] Continue a stopped run, or finish a branch
28
33
  /multi-agent:steer #id "..." Correct a running task at its next phase
29
34
  /multi-agent:kill #id Stop a run and delete its worktree; logs kept
30
35
  /multi-agent:manual-test [#id] Check out the branch, test it, answer ok or fix
31
- /multi-agent:channels [KEY|#N] Post the report: Jira, Confluence, Wiki, PR body
36
+ /multi-agent:channels [KEY|#N] Post the report: Jira, Confluence, Wiki, PR; and to a file
32
37
 
33
38
  A run asks where the branch lives (worktree or project root). Autopilot
34
39
  picks a worktree, and still stops at the Phase 5 channels menu.
@@ -45,6 +50,12 @@ Continuous mode
45
50
  agent-queue label. agent-queue:1 .. agent-queue:9 set the order
46
51
  (agent-queue:1 first). Change the label and assignee in autopilot-on.
47
52
 
53
+ Analysis has a queue of its own, on its own label: agent-analysis, per
54
+ repository as analysisGithubLabel and analysisJiraLabel. An item there is
55
+ analysed unattended and ends at the document, recorded as doc-delivered; it
56
+ never opens a pull request. The two labels have to differ, and a repository
57
+ that gives both the same value is refused.
58
+
48
59
  Jira and GitHub
49
60
 
50
61
  /multi-agent:jira Pick one of your open Jira items and start a run
@@ -60,6 +71,7 @@ Review and analysis
60
71
  /multi-agent:review [PR|branch] Parallel review of a PR or branch diff
61
72
  /multi-agent:address-review [PR] Answer review on our own PR; each write approved alone
62
73
  /multi-agent:diff-explain Map a review finding back to its diff lines
74
+ /multi-agent:review-rounds [1|2|3] How often review may send work back; default 2
63
75
  /multi-agent:analysis ["name"] Feature analysis from Figma, Swagger, Confluence, repos
64
76
  /multi-agent:analysis-resolve [doc] Answer an analysis doc's open questions one by one
65
77
  /multi-agent:review-analysis [doc] Review a written analysis against its rules
@@ -111,6 +123,21 @@ Setup
111
123
  /multi-agent:stack [ids...] Enable stack plugins for this repo
112
124
  /multi-agent:scaffold <stack> <name> New project from a stack's scaffold
113
125
 
126
+ Install targets, one per host: --claude, --copilot, --codex, --local, --all.
127
+ --local is the Codex engine pointed at a model served from this machine, in
128
+ a tree of its own (~/.codex-local). It needs a server that speaks the OpenAI
129
+ Responses API (POST /v1/responses); Ollama 0.13.4 or newer serves it, and
130
+ other servers are a question about that server. Record the model in
131
+ prefs.global.localModel (baseUrl, model, contextWindow); doctor's local-model
132
+ check reads it. There the model rungs collapse to that one model, review is
133
+ one reviewer, one child runs at a time, and autopilot is not offered.
134
+
135
+ Every token belongs to a service account (prefs.global.serviceAccounts) that
136
+ says which host it may be sent to. No secret is produced without a
137
+ destination, and the host has to match exactly: a subdomain of a configured
138
+ host is refused rather than allowed. A file with no accounts in it resolves
139
+ the same way, because the entries are derived from the older keys.
140
+
114
141
  Routines
115
142
 
116
143
  /multi-agent:save [name] Save a recurring job as /multi-agent:<name>
@@ -162,4 +189,6 @@ Plugins and tools (call them directly)
162
189
  Not registered means a silent no-op.
163
190
 
164
191
  Logs: $HOME/.claude/logs/multi-agent/{project}/{task-id}/
192
+ agent-log.md (what the run did) and task-report.md (the report, written
193
+ every run whether or not a channel took it)
165
194
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- facts: commandCount="komut" toolCount="araç, çoğu" -->
4
4
  ```
5
- Multi-Agent Pipeline - 80 komut, ne yapmak istediğine göre gruplu
5
+ Multi-Agent Pipeline - 81 komut, ne yapmak istediğine göre gruplu
6
6
 
7
7
  Buradan başla:
8
8
 
@@ -13,6 +13,10 @@ Buradan başla:
13
13
  5. /multi-agent:help Bu sayfa
14
14
 
15
15
  Görev bir Jira anahtarı ya da URL'i, GitHub issue URL'i, #N, repo#N veya düz metin olabilir.
16
+ Tek başına /multi-agent yazınca bu sayfa yerine hangisi olduğunu sorar. Aynı
17
+ soru tek başına yazılan analiz komutunda da çıkar: /multi-agent:analysis.
18
+ Görevsiz bir ek (tek başına autopilot) yine ne gerektiğini yazar; gözetimsiz
19
+ koşu görevsiz başlatılırsa cevap beklemeden durur.
16
20
  Ayrıntı her komutun kendi sayfasında: ~/.claude/commands/multi-agent/<ad>/SKILL.md
17
21
 
18
22
  ------------------------------
@@ -22,13 +26,14 @@ Geliştir
22
26
  /multi-agent "task" Tam koşu: plan, TDD, review, commit, rapor
23
27
  /multi-agent "task" autopilot Aynı koşu, soru yok; commit ve PR kendiliğinden
24
28
  /multi-agent "task" autopilot --loop N Arka planda en fazla N autopilot koşusu
29
+ /multi-agent "task" --review-rounds N Bu koşu: N review rework turu, 1 ile 3
25
30
  /multi-agent:status Tüm projelerdeki koşular: id, faz, branch, durum
26
31
  /multi-agent:log [#id] Koşunun log'u (varsayılan: en sonuncusu)
27
32
  /multi-agent:resume [#id] [autopilot] Duran koşuyu sürdür ya da bir branch'i bitir
28
33
  /multi-agent:steer #id "..." Koşan işi düzelt; sonraki fazda uygulanır
29
34
  /multi-agent:kill #id Koşuyu durdur, worktree'yi sil; log'lar kalır
30
35
  /multi-agent:manual-test [#id] Branch'e geç, test et, "ok" ya da "fix" de
31
- /multi-agent:channels [KEY|#N] Raporu gönder: Jira, Confluence, Wiki, PR metni
36
+ /multi-agent:channels [KEY|#N] Raporu gönder: Jira, Confluence, Wiki, PR; ayrıca dosyaya
32
37
 
33
38
  Koşu branch'in nerede duracağını sorar: worktree ya da proje kökü.
34
39
  Autopilot worktree seçer. Faz 5'teki kanal menüsünde yine de durur.
@@ -45,6 +50,12 @@ Sürekli mod
45
50
  Jira maddelerini alır. Sırayı agent-queue:1 .. agent-queue:9 belirler
46
51
  (önce agent-queue:1). Etiketi ve atananı autopilot-on'da değiştir.
47
52
 
53
+ Analizin kendi kuyruğu ve kendi etiketi var: agent-analysis; repo bazında
54
+ analysisGithubLabel ve analysisJiraLabel. Oradaki madde analiz komutunu
55
+ gözetimsiz koşturur ve dokümanda biter; kuyruk bunu doc-delivered diye yazar,
56
+ PR açılmaz. İki etiket farklı olmak zorunda; ikisine
57
+ aynı değeri veren repo reddedilir.
58
+
48
59
  Jira ve GitHub
49
60
 
50
61
  /multi-agent:jira Açık Jira maddelerinden birini seç, koşuyu başlat
@@ -60,6 +71,7 @@ Review ve analiz
60
71
  /multi-agent:review [PR|branch] PR ya da branch diff'ine paralel review
61
72
  /multi-agent:address-review [PR] Kendi PR'ımızdaki review'u yanıtla; her yazma ayrı onaylı
62
73
  /multi-agent:diff-explain Review bulgusunu diff satırlarına bağla
74
+ /multi-agent:review-rounds [1|2|3] Review işi kaç kez geri yollar; varsayılan 2
63
75
  /multi-agent:analysis ["ad"] Figma, Swagger, Confluence ve repolardan analiz
64
76
  /multi-agent:analysis-resolve [doc] Analizin açık sorularını tek tek yanıtla
65
77
  /multi-agent:review-analysis [doc] Yazılmış analizi kurallarına göre incele
@@ -111,6 +123,21 @@ Kurulum
111
123
  /multi-agent:stack [id...] Bu repo için stack plugin'lerini aç
112
124
  /multi-agent:scaffold <stack> <ad> Stack'in iskeletinden yeni proje
113
125
 
126
+ Her host için bir kurulum hedefi: --claude, --copilot, --codex, --local, --all.
127
+ --local, bu makinede sunulan bir modele bağlanan Codex motorudur; kendi
128
+ ağacına kurulur (~/.codex-local). Sunucunun OpenAI Responses API'sini
129
+ konuşması gerekir (POST /v1/responses); Ollama 0.13.4 ve sonrası bunu sunar,
130
+ başka sunucular için cevap o sunucuya bağlıdır. Modeli
131
+ prefs.global.localModel içine yaz (baseUrl, model, contextWindow); doctor'ın
132
+ local-model kontrolü bunu okur. Orada model basamakları tek modele iner,
133
+ review tek reviewer'dır, aynı anda tek çocuk koşar ve autopilot sunulmaz.
134
+
135
+ Her token, nereye gönderilebileceğini söyleyen bir servis hesabına bağlıdır
136
+ (prefs.global.serviceAccounts). Hedefi olmayan istek sır almaz ve host birebir
137
+ eşleşmek zorundadır: tanımlı bir host'un alt alan adı kabul değil, ret alır.
138
+ İçinde hesap bulunmayan dosya da aynı cevabı verir; girdiler eski
139
+ anahtarlardan türetilir.
140
+
114
141
  Rutinler
115
142
 
116
143
  /multi-agent:save [ad] Sık yaptığın işi /multi-agent:<ad> olarak kaydet
@@ -162,4 +189,6 @@ Plugin'ler ve araçlar (doğrudan çağır)
162
189
  Kayıtlı değilse sessizce hiçbir şey yapmaz.
163
190
 
164
191
  Log'lar: $HOME/.claude/logs/multi-agent/{project}/{task-id}/
192
+ agent-log.md (koşu ne yaptı) ve task-report.md (rapor; bir kanal
193
+ alsın almasın her koşuda yazılır)
165
194
  ```
@@ -45,7 +45,8 @@ All types enter the same Phase 0 flow.
45
45
  | `purge` | User-only: name `/multi-agent-purge` for the user to type; that skill deletes ALL worktrees, branches, logs, state and the counter |
46
46
  | `review` | Skip phases 0-3, review the current diff only |
47
47
  | `autopilot` flag | Add to any pipeline command: skip user confirmations except destructive ops |
48
- | No args / `help` | Usage guide |
48
+ | `help` | Usage guide |
49
+ | No args | Ask (`_entry-picker.md`), then route the answer. A modifier with no task prints usage; an unattended run refuses |
49
50
 
50
51
  Every task gets an auto-incremented short ID (`#1`, `#2`), stored in `agent-state.json`.
51
52
 
@@ -79,7 +80,7 @@ Each persona file carries its own `modelRationale`. Observability: emit a `phase
79
80
 
80
81
  **Phase 2: Dev (Sonnet).** Per todo in dependency order: mark `in_progress`, TDD (failing test, verify RED, minimal code, verify GREEN, refactor), build via a task agent, on failure fix and rebuild (max 3, `retryCount` in `agent-state.json`), mark `done`, log `Phase 2: {todo-id} - Test ok, Build ok`.
81
82
 
82
- **Phase 3: Review (parallel + triage).** Step 0 diff risk scoring is advisory: `node $HOME/.claude/scripts/diff-risk-score.mjs --base "$BASE_BRANCH" --top 5`, injected as `${PRIORITY_FILES}`; off when `prefs.global.diffRiskAdvisory = false`. Reviewers by host: Claude Code runs `claude-fable-5-2` (security + architecture), `claude-opus-5-5` (edge cases), `claude-sonnet-5-5` (quality); Copilot CLI runs `gpt-5.4`, `claude-opus-4.7`, `claude-sonnet-4.6` (no Fable). Triage is one top-tier pass (`claude-fable-5-2` on Claude Code, `claude-opus-4.7` on Copilot CLI). Blocking findings go back to Phase 2 (max 3 iterations), important ones are fixed and re-reviewed, suggestions applied when reasonable.
83
+ **Phase 3: Review (parallel + triage).** Step 0 diff risk scoring is advisory: `node $HOME/.claude/scripts/diff-risk-score.mjs --base "$BASE_BRANCH" --top 5`, injected as `${PRIORITY_FILES}`; off when `prefs.global.diffRiskAdvisory = false`. Reviewers by host: Claude Code runs `claude-fable-5-2` (security + architecture), `claude-opus-5-5` (edge cases), `claude-sonnet-5-5` (quality); Copilot CLI runs `gpt-5.4`, `claude-opus-4.7`, `claude-sonnet-4.6` (no Fable). Triage is one top-tier pass (`claude-fable-5-2` on Claude Code, `claude-opus-4.7` on Copilot CLI). Blocking findings go back to Phase 2 (at most `review-rounds.mjs get --state "$STATE_FILE" --value` rework rounds, 1 to 3, default 2), important ones are fixed and re-reviewed, suggestions applied when reasonable.
83
84
 
84
85
  **Phase 4: Commit & PR.** Per-project steps and the GitHub issue body update: `orchestrator/phase-4-5-projects.md`.
85
86
 
@@ -72,7 +72,8 @@ The full tables behind the dispatcher's compact routing table. Route first, then
72
72
  | `language [en\|tr]` | Show or set the assistant `outputLanguage` (explanations and chat replies). `promptLanguage` is locked to `en` and is not toggleable. No arg = show current `outputLanguage`. With `en` or `tr` = set and persist `outputLanguage`. Commits and branch names stay English; PR, Jira and wiki bodies follow it. |
73
73
  | `setup` | Keychain token + Git Identity onboarding |
74
74
  | `autopilot` | Skip user confirmations, auto commit/PR |
75
- | No args / `help` | Show usage guide |
75
+ | `help` | Show usage guide |
76
+ | No args | Ask (`_entry-picker.md`), then route the answer. A modifier with no task prints usage; an unattended run refuses |
76
77
 
77
78
  ### Loading
78
79
 
@@ -75,6 +75,8 @@ The generic "zero-interaction" contract covers Phases 0-4 only. Phase 5 channels
75
75
  - **30-minute timeout** - if user does not respond, session ends cleanly:
76
76
  - External delivery aborted (no silent apply - prevents accidental Jira comments / Confluence pages).
77
77
  - Internal capture (`agent-log.md`, telemetry, knowledge base) STILL runs.
78
+ - The report file is written from prefs content (`--file-only`) as part of that
79
+ capture: a timeout is the person not answering, not the work being worthless.
78
80
  - State persisted as `{phase: 5, waitingFor: "user-channels-choice", channelsTimeout: true}`.
79
81
  - Resume: `/multi-agent:resume <task-id>` re-opens menu with same inputs.
80
82
  - Post-hoc `/multi-agent:channels <task>` never times out - user invoked it explicitly.
@@ -98,7 +100,24 @@ Phase 0: Intake -> Phase 1: Evidence -> Phase 2: Synthesis -> Phase 3: Review ->
98
100
  | 4 Publish | Local file / Confluence / Jira. Locked 6 still forbids `git add` and `git commit` |
99
101
  | 5 Report | Channels, same as every mode |
100
102
 
101
- **No `autopilot` variant.** Worktree isolation buys nothing when no code is written, and the intake, the Pass B convention preview and the open-question resolution are interactive by nature; a zero-interaction analysis would be a document nobody agreed to.
103
+ ### The unattended form (`analysis-autopilot`)
104
+
105
+ `/multi-agent:analysis <tracker-ref> autopilot` is its own declared mode
106
+ (`phases.json` `modes.analysis-autopilot`: the same six slots, the same step
107
+ names, `autopilot: true`, `commits: false`). It is the shape an unattended queue
108
+ launches for a tracker item carrying the repo's analysis label, and it ends at
109
+ `doc-delivered` rather than at a pull request. Still no worktree: isolation buys
110
+ nothing when no code is written, and Locked 6 forbids `git add` and `git commit`
111
+ in every analysis mode.
112
+
113
+ Every intake question is **derived from evidence or parked**, never defaulted and
114
+ never asked: what each one answers and from which evidence is
115
+ [`analysis/unattended.md`]($HOME/.claude/multi-agent-refs/analysis/unattended.md),
116
+ and a question that evidence cannot settle parks the run with the reason rather
117
+ than guessing a document nobody agreed to. The Phase 3.3 bucket rule is
118
+ unchanged (searches still run; a gap the user alone could close is stamped and
119
+ recorded in Section 20), and Phase 3.5 resolves to the local file only - an
120
+ unattended run publishes nothing outside the machine.
102
121
 
103
122
  **Where the document lands.** Drafts go to `/tmp/analysis-<slug>-<ts>/` first, then the Phase 4 picker decides: Local writes `<repo>/analysis/<feature>-<platform>.md` uncommitted, Confluence posts the page, Jira updates the description. In the full pipeline the same engine writes into the worktree instead and `prefs.global.analysisPhase.commitDoc` decides whether it rides along with the commit.
104
123
 
@@ -193,7 +193,7 @@ This keeps orchestrator context lean and enables programmatic routing.
193
193
 
194
194
  **Proactive compaction + phase-boundary checkpoint**: the orchestrator follows ~2,500 lines of phase prose in one session; once context fills, it starts dropping steps - the single biggest cause of "it got stuck / skipped a step." Two defenses, both required on full-pipeline runs:
195
195
 
196
- - *Phase-boundary checkpoint.* At every phase transition, before loading the next phase doc, write the durable state (`agent-state.json` phase status + `files[]` + `retryCount`) and append a structured handoff block to `agent-log.md` (format below). The next phase reads state + log, not the back-conversation - so a transition is a clean re-entry point even if context is later compacted. Then flush what the run has learned so far:
196
+ - *Phase-boundary checkpoint.* At every phase transition, before loading the next phase doc, write the durable state (`agent-state.json` phase status + `files[]` + `retryCount` + `reworkCount`) and append a structured handoff block to `agent-log.md` (format below). The next phase reads state + log, not the back-conversation - so a transition is a clean re-entry point even if context is later compacted. Then flush what the run has learned so far:
197
197
 
198
198
  ```bash
199
199
  bash $HOME/.claude/scripts/capture-flush.sh --state "$STATE_FILE" --quiet
@@ -518,7 +518,7 @@ git -C $PROJECT_ROOT config user.email "{identity.email}"
518
518
  `worktreePath` = `$PROJECT_ROOT`, `localMode` = `true`. Step 5b already recorded
519
519
  `workspaceSource`; this step does not decide, it applies.
520
520
 
521
- **If worktree** (Step 5b answered worktree, or autopilot resolved it): 2. Worktree path: Jira → `.worktrees/{jiraId}/`, GitHub → `.worktrees/GH{issueNo}/`, free-text → `.worktrees/task-{shortId}/` 3. **Prepare the worktree** (heal, residue guard, add or re-enter, identity: "Worktree preparation" below) 4. Create log dir + `agent-log.md` + `agent-state.json` at `${LOGS_ROOT:-$HOME/.claude/logs/multi-agent}/{project}/{task-id}/`, never inside the worktree:
521
+ **If worktree** (Step 5b answered worktree, or autopilot resolved it): 2. Worktree path: Jira → `.worktrees/{jiraId}/`, GitHub → `.worktrees/GH{issueNo}/`, free-text → `.worktrees/task-{shortId}/` 3. **Prepare the worktree** (heal, residue guard, add or re-enter, identity: "Worktree preparation" below) 4. Create log dir + `agent-log.md` + `agent-state.json` (with `--review-rounds N`, then run `node "$HOME/.claude/scripts/review-rounds.mjs" record --state "$STATE_FILE" --rounds N`) at `${LOGS_ROOT:-$HOME/.claude/logs/multi-agent}/{project}/{task-id}/`, never inside the worktree:
522
522
 
523
523
  **Worktree location convention (cited by every other command):** always `{projectRoot}/.worktrees/{taskId}`, inside the repo, never under `$HOME`. `{taskId}` is the directory name from the rule above (`DC-<shortId>` for `/multi-agent:design-check`). `.worktrees` is fixed, not a preference: no `worktreeBasePath` key exists, and `gc-worktrees.sh`, `purge.sh`, the cost renderers and `usage-report.mjs` resolve `<repo>/.worktrees/` by name. Multi-repo tasks get one worktree per repo (below); a local answer creates none and `worktreePath` is `$PROJECT_ROOT`.
524
524
 
@@ -59,7 +59,7 @@ Phase 2 consumes the Phase 1 output object conforming to `$HOME/.claude/schemas/
59
59
 
60
60
  #### Component tasks - delegated dispatch (taskType === "component")
61
61
 
62
- When Phase 0 Step 7 classified the task as `component`, Phase 2 delegates the entire phase to the enabled `ai-<platform>-toolkit` marketplace plugin's component skill (`create-component`, fallback `create-ui-component`) via the Skill tool and does NOT run the TDD loop below. The dispatch layer passes the plugin skill the analysis Section 6 (Bileşen Envanteri) entry + Section 13.1 conventions for the named component as context. Because plugin skills do not write pipeline state, the **dispatch layer** (not the skill) owns `state.phases["2"].subphases[]`, recording a coarse component-build row. Resolution, failure/resume, multi-repo and cross-CLI detail: `$HOME/.claude/multi-agent-refs/component-dispatch.md`. Phase 2 still owns: progress line `-> dispatching create-component <name>`, `retryCount` cap at 3, and fallthrough to the TDD path when dispatch prerequisites are missing (`taskType` absent OR the plugin is not enabled in this repo -> log anomaly, halt or run TDD per component-dispatch.md).
62
+ When Phase 0 Step 7 classified the task as `component`, Phase 2 delegates the entire phase to the enabled `ai-<platform>-toolkit` marketplace plugin's component skill (`create-component`, fallback `create-ui-component`) via the Skill tool and does NOT run the TDD loop below. The dispatch layer passes the plugin skill the analysis Section 6 (Bileşen Envanteri) entry + Section 13.1 conventions for the named component as context. Because plugin skills do not write pipeline state, the **dispatch layer** (not the skill) owns `state.phases["2"].subphases[]`, recording a coarse component-build row. Resolution, failure/resume, multi-repo and cross-CLI detail: `$HOME/.claude/multi-agent-refs/component-dispatch.md`. Phase 2 still owns: progress line `-> dispatching create-component <name>`, the build-retry cap (`retryCount`, 3), and fallthrough to the TDD path when dispatch prerequisites are missing (`taskType` absent OR the plugin is not enabled in this repo -> log anomaly, halt or run TDD per component-dispatch.md).
63
63
 
64
64
  For non-component taskTypes (`bugfix`, `feature`, `refactor`, `chore`), continue with the standard TDD section below.
65
65
 
@@ -75,7 +75,7 @@ Missing design data (variant, padding, copy) → HALT and instruct the user to r
75
75
 
76
76
  #### Re-entry from Phase 3 triage
77
77
 
78
- Phase 2 runs twice in the pipeline lifetime: first for initial development, then optionally for rework after Phase 3 review. **Phase 2 never acts on raw reviewer output.** It only consumes `triage.accepted` findings - Fable triage in Phase 3 already filtered false-positives, deferred out-of-scope items, and rejected noise.
78
+ Phase 2 runs first for initial development, then once per rework round after Phase 3 review (at most the review limit, 1 to 3, default 2). **Phase 2 never acts on raw reviewer output.** It only consumes `triage.accepted` findings - Fable triage in Phase 3 already filtered false-positives, deferred out-of-scope items, and rejected noise.
79
79
 
80
80
  When re-entering from Phase 3:
81
81
 
@@ -87,7 +87,7 @@ When re-entering from Phase 3:
87
87
  3. `accepted.suggestion` items are applied opportunistically (no TDD loop required) unless the user asked for suggestions to be treated strictly.
88
88
  4. `deferred` items are NOT actioned in this re-entry - Phase 4 Step 0b lists them before the commit and the PR description carries them as follow-ups.
89
89
  5. `rejected` items are never touched. Log their IDs + triage reasons for audit only; Step 3.7 checks it.
90
- 6. After rework, increment `state.phases["2"].retryCount`; at `retryCount === 3` run `node $HOME/.claude/scripts/rework-rulings.mjs --triage "{worktreePath}/triage-output.json" --state "$STATE_FILE"`: blocking or security findings `escalate` (hard-kill, escalate to the user), the rest are `parked` as follow-ups and the run continues to Phase 4; exit 2 or 3 escalates. Do not loop indefinitely. When `prefs.global.autopilotCircuitBreaker.enabled` is true (default), record the hard-kill before escalating as `state.circuitBreaker = {tripped: true, trigger: 3, detail: "rework cycles exhausted", checkpoint: {phase: 3, step: "re-entry", iteration: <n>}, trippedAt, counters: {reworkCycles: <n>}}`: the rework-storm trigger; `autopilotCircuitBreaker.maxReworkCycles` (default 3) is bounded above by this cap.
90
+ 6. The review limit and the rework count are owned by Phase 3 Step 4 (`features/review-rounds.md`): it decides `rework` or `rule` with `review-rounds.mjs next`, and a `rework` has already recorded one more `state.phases["2"].reworkCount` before this re-entry starts. This step neither increments a counter nor compares one: `retryCount` counts build retries only. The re-entry is the rework Step 4 recorded: `phases["2"].reworkForIteration` equals the number of `reviewIterations`; a resumed run with that state comes straight here and never repeats the decision. Run the rework, then return to Phase 3, which reviews it again. Do not loop indefinitely: the limit is 1 to 3 reworks, 2 by default.
91
91
  7. When `state.reviewIterations[-1].delta` exists, `stillPresent[]` findings come first in the task list, quoted `STILL PRESENT after round N-1's fix`; repeating the previous attempt is the loop the circuit-breaker stops.
92
92
  8. Before each rework dispatch, `rework-escalation.mjs` picks the rung; findings and the prior report go as files (`features/rework-escalation.md`).
93
93
 
@@ -168,7 +168,7 @@ For each task (respecting dependency order), on start and on end: `bash $HOME/.c
168
168
  - **ios, fallback (raw)**: same lock pair around `xcodebuild build -scheme "{scheme}" -destination "generic/platform=iOS" -derivedDataPath "{worktreePath}/.DerivedData" 2>&1 | tail -5`.
169
169
  - **android**: lock pair around `./gradlew assembleDebug 2>&1 | tail -5` (the Gradle daemon and `build/` outputs contend across parallel worktrees exactly as DerivedData does - the lock applies).
170
170
  - **backend / web**: `python -m compileall .` / run the command `node $HOME/.claude/scripts/package-manager.mjs run --dir "{worktreePath}" --script build` prints, `2>&1 | tail -5` (exit 3: no build script); no lock.
171
- 5. If build fails → fix → rebuild (max 3 attempts, track `retryCount` in state). A failure that says `ENOSPC` or no space left is not a code defect, and retrying will not fix it: save the output and run `node $HOME/.claude/lib/low-disk.mjs --scan <log>`, print its line, and stop retrying. Attended, name `/multi-agent:clean-disk` for the user to type; unattended, record the line and halt. Never delete anything from here.
171
+ 5. If build fails → fix → rebuild (max 3 attempts, the build-retry cap; track `retryCount` in state. It is one counter on `phases["2"]` that nothing resets, so it is cumulative across every Phase 2 entry of the run, initial development and each rework included, and reaching 3 stops the run whatever the review limit is). A failure that says `ENOSPC` or no space left is not a code defect, and retrying will not fix it: save the output and run `node $HOME/.claude/lib/low-disk.mjs --scan <log>`, print its line, and stop retrying. Attended, name `/multi-agent:clean-disk` for the user to type; unattended, record the line and halt. Never delete anything from here.
172
172
  6. **Intermediate commit** (after each completed task in the plan):
173
173
  ```bash
174
174
  git -C "{worktreePath}" add -A
@@ -581,7 +581,7 @@ Merge the JSON into `state.reviewIterations[-1].delta` via `write-state.mjs`; em
581
581
  | **3** | Autopilot with `prefs.global.autopilotCircuitBreaker.enabled` (default true): write `state.circuitBreaker = {tripped: true, trigger: 2, detail, checkpoint: {phase: 4, step: "3.8", iteration: N}, trippedAt, counters}`, then the `operations.md` halt protocol with `haltReason="4:circuit-breaker:identical-finding"`. Interactive: show `delta.stillPresent`, ask `Continue rework` / `Escalate to me` / `Accept as deferred`. |
582
582
  | **1** | Log `review.delta_skipped reason=invalid`, continue; the delta never blocks on its own failure. |
583
583
 
584
- `plateau` is logged, not acted on; trigger 3 (the rework cap) is recorded by the Phase 2 re-entry.
584
+ `plateau` is logged, not acted on; trigger 3 (the rework cap) is recorded by Step 4, on a `rule` whose ruling escalates.
585
585
 
586
586
  #### Step 4 - Consensus + Action (triage-driven)
587
587
 
@@ -589,8 +589,12 @@ If `triage.consensus.verdict` is `split` or `unverified`, surface `consensus.dis
589
589
 
590
590
  Act **only on triage.accepted**:
591
591
 
592
- - **accepted.blocking** → back to Phase 2 (max 3 iterations, rung per `features/rework-escalation.md`, reflection prompt cites only accepted items). The reflection prompt names findings by `fingerprint` and quotes `delta.stillPresent` first, marked `STILL PRESENT after round N-1's fix`. When Step 3.7 ran and `state.reviewIterations[-1].verifyByTest.redTests[]` is non-empty, the reflection prompt cites each red test: "a failing repro test already exists at <testRef>; make it green; do not delete or weaken it."
593
- - **accepted.important** → fix and re-review
592
+ - **accepted.blocking** (and **accepted.important**) → ask the limit, then send the work back or rule. With limit N (1 to 3, default 2; `features/review-rounds.md`) review sends work back N times, every rework is reviewed again, and the run stops when a review still has accepted findings after N reworks.
593
+ ```bash
594
+ ACTION=$(node $HOME/.claude/scripts/review-rounds.mjs next --state "$STATE_FILE")
595
+ ```
596
+ - `rework`: `next` has recorded one more `state.phases["2"].reworkCount` and the review iteration it decided for (`reworkForIteration`); asked again for that iteration it answers `rework` without recording, and `next --peek` never records. Back to Phase 2 (rung per `features/rework-escalation.md`; reflection prompt cites only accepted items). The reflection prompt names findings by `fingerprint` and quotes `delta.stillPresent` first, marked `STILL PRESENT after round N-1's fix`. When Step 3.7 ran and `state.reviewIterations[-1].verifyByTest.redTests[]` is non-empty, the reflection prompt cites each red test: "a failing repro test already exists at <testRef>; make it green; do not delete or weaken it." After the rework, review again.
597
+ - `rule`: the reworks done have reached the limit (anything `next` does not print as `rework`, or a non-zero exit, is also `rule`). Run `node $HOME/.claude/scripts/rework-rulings.mjs --triage "{worktreePath}/triage-output.json" --state "$STATE_FILE"` on THIS review's triage: blocking or security findings `escalate` (hard-kill, escalate to the user), the rest are `parked` as follow-ups and the run continues to Phase 4; exit 2 or 3 escalates. When `prefs.global.autopilotCircuitBreaker.enabled` is true (default), record it before escalating as `state.circuitBreaker` with `trigger: 3`, `detail: "rework cycles exhausted"` and `counters.reworkCycles` (shape: `features/autopilot-circuit-breaker.md`).
594
598
  - **accepted.suggestion** → apply if reasonable
595
599
  - **deferred** → Phase 4 Step 0b lists it before the commit; the PR follow-ups carry it (do not block)
596
600
  - **rejected** → log reasons for audit; do not touch