@mmerterden/multi-agent-pipeline 20.41.0 → 20.42.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 (103) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +1 -1
  3. package/README.tr.md +1 -1
  4. package/docs/ecosystem.md +45 -8
  5. package/docs/facts.json +7 -7
  6. package/docs/features.md +9 -4
  7. package/install/claude.mjs +34 -1
  8. package/install/templates/claude-hooks.json +12 -1
  9. package/manifest.json +106 -86
  10. package/package.json +3 -2
  11. package/pipeline/commands/multi-agent/autopilot/SKILL.md +11 -0
  12. package/pipeline/commands/multi-agent/setup/SKILL.md +1 -1
  13. package/pipeline/lib/args.mjs +131 -4
  14. package/pipeline/lib/bg-launch.mjs +5 -2
  15. package/pipeline/lib/credential-store.sh +11 -1
  16. package/pipeline/lib/hook-once.mjs +134 -0
  17. package/pipeline/lib/isotonic.mjs +73 -0
  18. package/pipeline/lib/low-disk.mjs +153 -0
  19. package/pipeline/lib/mcp-schema-load.mjs +90 -0
  20. package/pipeline/lib/md2confluence-v3.py +8 -7
  21. package/pipeline/lib/model-dispatch.sh +26 -2
  22. package/pipeline/lib/normalize-text.mjs +135 -0
  23. package/pipeline/lib/outbound-gate.mjs +21 -3
  24. package/pipeline/lib/plan-todos.sh +17 -4
  25. package/pipeline/lib/redact.mjs +12 -3
  26. package/pipeline/lib/risky-settings.mjs +198 -0
  27. package/pipeline/lib/route-state.sh +1 -0
  28. package/pipeline/lib/secret-patterns.generated.mjs +6 -2
  29. package/pipeline/lib/session-usage.mjs +232 -0
  30. package/pipeline/lib/source-digest.mjs +211 -0
  31. package/pipeline/lib/tdd-evidence.mjs +250 -17
  32. package/pipeline/lib/untrusted-fence.mjs +132 -1
  33. package/pipeline/multi-agent-refs/analysis/locked.md +1 -1
  34. package/pipeline/multi-agent-refs/features/cost-analysis.md +37 -2
  35. package/pipeline/multi-agent-refs/features/doctor.md +51 -4
  36. package/pipeline/multi-agent-refs/features/model-fallback.md +25 -0
  37. package/pipeline/multi-agent-refs/features/plan-todos.md +4 -0
  38. package/pipeline/multi-agent-refs/features/unattended-gates.md +5 -3
  39. package/pipeline/multi-agent-refs/features/usage-reporting.md +4 -2
  40. package/pipeline/multi-agent-refs/help/en.md +1 -1
  41. package/pipeline/multi-agent-refs/help/tr.md +1 -1
  42. package/pipeline/multi-agent-refs/outside-the-pipeline.md +6 -0
  43. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +1 -1
  44. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
  45. package/pipeline/multi-agent-refs/phases/phase-3-review.md +2 -2
  46. package/pipeline/multi-agent-refs/phases/phase-5-report.md +2 -0
  47. package/pipeline/multi-agent-refs/progress-contract.md +3 -1
  48. package/pipeline/office/toolkit.json +1 -1
  49. package/pipeline/rules/outside-the-pipeline.md +1 -1
  50. package/pipeline/schemas/doctor-report.schema.json +47 -0
  51. package/pipeline/schemas/plan-todos.schema.json +29 -1
  52. package/pipeline/schemas/prefs.schema.json +63 -0
  53. package/pipeline/schemas/route-config.schema.json +51 -0
  54. package/pipeline/schemas/secret-patterns.json +17 -1
  55. package/pipeline/schemas/toolkit-path-params.json +15 -1
  56. package/pipeline/scripts/_cost-advise.mjs +357 -0
  57. package/pipeline/scripts/_cost-budget.mjs +78 -0
  58. package/pipeline/scripts/_cost.mjs +29 -0
  59. package/pipeline/scripts/_decode_text.py +107 -0
  60. package/pipeline/scripts/_guard-probe.mjs +406 -0
  61. package/pipeline/scripts/_guard_rules.py +206 -0
  62. package/pipeline/scripts/_memory-policy.mjs +1 -25
  63. package/pipeline/scripts/_retrieval.mjs +148 -2
  64. package/pipeline/scripts/_secret-scan.mjs +6 -1
  65. package/pipeline/scripts/_stack-routing.mjs +1 -0
  66. package/pipeline/scripts/_test-gaming.mjs +346 -0
  67. package/pipeline/scripts/agent-guard.py +8 -1
  68. package/pipeline/scripts/argv-secret-scan.mjs +2 -1
  69. package/pipeline/scripts/autopilot-loop.mjs +407 -0
  70. package/pipeline/scripts/autopilot-runner.mjs +38 -25
  71. package/pipeline/scripts/capture-resume.sh +9 -1
  72. package/pipeline/scripts/cost-analyze.mjs +66 -4
  73. package/pipeline/scripts/cost-budget-check.mjs +5 -13
  74. package/pipeline/scripts/disk-cleaner.mjs +1418 -0
  75. package/pipeline/scripts/doctor.mjs +169 -44
  76. package/pipeline/scripts/evidence-gate.mjs +90 -0
  77. package/pipeline/scripts/gate-ledger.mjs +76 -21
  78. package/pipeline/scripts/gc-tmp.sh +5 -0
  79. package/pipeline/scripts/guard-probe-known-holes.json +3 -0
  80. package/pipeline/scripts/learnings-ledger.mjs +16 -12
  81. package/pipeline/scripts/note-agent-event.mjs +2 -0
  82. package/pipeline/scripts/note-mcp-failure.mjs +9 -2
  83. package/pipeline/scripts/note-skill-use.mjs +4 -1
  84. package/pipeline/scripts/pre-commit-check.sh +2 -2
  85. package/pipeline/scripts/pre-push-check.sh +8 -1
  86. package/pipeline/scripts/publish-staged.mjs +324 -0
  87. package/pipeline/scripts/route-learn.mjs +628 -0
  88. package/pipeline/scripts/run-scope-guard.mjs +55 -1
  89. package/pipeline/scripts/scan-agent-config.sh +1 -1
  90. package/pipeline/scripts/statusline.mjs +309 -0
  91. package/pipeline/scripts/test-integrity-gate.mjs +97 -2
  92. package/pipeline/scripts/triage-memory.mjs +12 -4
  93. package/pipeline/scripts/uninstall.mjs +1 -0
  94. package/pipeline/skills/.skill-manifest.json +8 -4
  95. package/pipeline/skills/.skills-index.json +14 -3
  96. package/pipeline/skills/shared/README.md +5 -4
  97. package/pipeline/skills/shared/external/backlog/SKILL.md +1 -1
  98. package/pipeline/skills/shared/external/disk-cleaner/SKILL.md +105 -0
  99. package/pipeline/skills/shared/external/disk-cleaner/evals/evals.json +62 -0
  100. package/pipeline/skills/shared/external/disk-cleaner/scripts/disk-cleaner.mjs +1418 -0
  101. package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +1 -1
  102. package/pipeline/skills/skill-copies.json +4 -0
  103. package/pipeline/skills/skills-index.md +3 -2
@@ -236,6 +236,31 @@ same once `cost-budget-check.mjs` reports the run at the warn threshold of
236
236
  `budgetCeilingUsd`. `recordDecisions: false` is honoured; `true` (the default)
237
237
  logs each decision as `model_routing.decision`.
238
238
 
239
+ **Learned order (`modelRouting.learned.enabled`, ships false).** After the
240
+ strategy, `route-learn.mjs choose` may reorder the same candidates from a
241
+ promoted policy; the decision's reason then ends in `learned`. The loop:
242
+
243
+ 1. `route-learn.mjs ingest --state <agent-state.json>` at the end of a run
244
+ turns each `model_routing.decision` it logged into an outcome row for its
245
+ bucket (call site, task kind, complexity band from `--complexity`) and rung.
246
+ The reward is 0 when any gate's latest verdict failed, else
247
+ `1 / (1 + first-round blockers + still-present findings + rework rounds)`.
248
+ A model's own report never enters it, and a row with no gate or review
249
+ signal is refused.
250
+ 2. `route-learn.mjs promote` fits per-bucket Beta posteriors (older outcomes
251
+ weighted down by `halfLifeDays`), calibrates them with isotonic regression,
252
+ and replaces the policy only when it beats the current one by `margin` in
253
+ Brier score on the newest `holdout` fraction (at least `minRows` rows).
254
+ The old policy is kept as `policy.json.bak`.
255
+ 3. `choose` draws one Thompson sample per rung, seeded by task id so the same
256
+ task gets the same order, and tries the cheapest rung whose draw clears
257
+ `target` first. Until two candidates have `minSamples` outcomes the rule's
258
+ order stands; a rung whose last three outcomes scored 0 goes last on nine
259
+ draws in ten.
260
+
261
+ The two limits above still hold on a learned order: the fable switch is
262
+ checked after it, and a subagent stays on the Anthropic ladder.
263
+
239
264
  The script never fails and never returns an empty rung: a missing preferences
240
265
  file, a missing `jq`, unparseable JSON, an out-of-scope call site and a rung
241
266
  absent from `cost-table.json` all return the caller's default and exit 0. A
@@ -47,9 +47,13 @@ A later drift replaces the flag and its confirmation. `files[]` and `creates[]`
47
47
  | `tdd-red <task> <todo> <results> [--tests a,b]` | at least one test fails; with `--tests`, one of the failing tests is a named one | nothing failed, nothing ran, or every failure is in another test; under `enforce`, `--tests` on results that name no failing test (use JUnit XML); `warn` records that run with `red.testsUnverifiable` and a warning |
48
48
  | `tdd-red ... --already-passing <reason>` | the run has no failure: the behaviour already exists; the run stands for RED and GREEN, the reason is kept | any test fails |
49
49
  | `tdd-green <task> <todo> <results>` | RED is recorded (not needed under test policy `tests-after`), the run has no failure, and it is the RED suite: RED's named tests pass in it, or, without names on either side, it ran at least as many tests | a test still fails, nothing ran, no RED, a RED test is missing, fewer tests than RED |
50
+ | `tdd-green ... --test-edit-reason <why>` | as above, when a test file RED kept was changed because the test itself was wrong; the edit and the reason go to `green.testEdits[]` and Phase 3 reviews them | the reason is missing |
51
+ | `tdd-restore <task> <todo>` | writes the RED bytes of every kept test file that changed back into the worktree | a kept path leaves the worktree |
50
52
 
51
53
  Both refuse results written before the todo's `startedAt`.
52
54
 
55
+ `tdd-red` keeps the test files the run wrote (committed since the run base, `state.baseSha` or `MA_RUN_BASE_SHA`, plus new and changed ones in the worktree) as `red.testFiles[]` ({path, blob}; the bytes go into the repository's object store). `tdd-green` refuses (exit 2) when one of them was modified or deleted since: a suite made green by weakening its own new test proves nothing. Restore it with `tdd-restore`, or give `--test-edit-reason`. `test-integrity-gate.mjs --state` reports a recorded edit as important (blocking in an unattended run, where nobody read the reason) and an unrecorded one as blocking.
56
+
53
57
  `complete` then reads `prefs.global.tddEvidence.mode`:
54
58
 
55
59
  - `off`: no check.
@@ -174,8 +174,10 @@ In addition to the attended exit gate:
174
174
  ```bash
175
175
  S="$HOME/.claude/scripts"
176
176
  STACK=$(node "$S/_stack-adapter.mjs" resolve --dir "$WORKTREE" | cut -d' ' -f1)
177
- node "$S/evidence-gate.mjs" --claim build --status passed --evidence "$WORKTREE/.build.log" --stack "$STACK"
178
- node "$S/evidence-gate.mjs" --claim test --status passed --evidence "$WORKTREE/.test.log" --stack "$STACK"
177
+ # taken right before each command runs: BUILD_RAN_ON / TEST_RAN_ON
178
+ # =$(node "$HOME/.claude/lib/source-digest.mjs" --repo "$WORKTREE")
179
+ node "$S/evidence-gate.mjs" --claim build --status passed --evidence "$WORKTREE/.build.log" --stack "$STACK" --ran-on "$BUILD_RAN_ON"
180
+ node "$S/evidence-gate.mjs" --claim test --status passed --evidence "$WORKTREE/.test.log" --stack "$STACK" --ran-on "$TEST_RAN_ON" --command "<test-command>"
179
181
  node "$S/test-summary.mjs" --log "$WORKTREE/.test.log" --stack "$STACK"
180
182
  node "$S/test-strength.mjs" --repo "$WORKTREE" --base HEAD --head worktree --stack "$STACK"
181
183
  node "$S/symbol-existence-gate.mjs" --repo "$WORKTREE" --base HEAD --stack "$STACK"
@@ -183,7 +185,7 @@ node "$S/symbol-existence-gate.mjs" --repo "$WORKTREE" --base HEAD --stack "$STA
183
185
 
184
186
  | Gate | Verdict in the ledger |
185
187
  |---|---|
186
- | `evidence-gate --stack` | the adapter's markers and test counts; a status that is not `passed` is recorded as a failure. A test claim needs a positive executed-test count, from the log or from `--junit <dir>` / `--xcresult <bundle>`: markers alone fail. Gradle prints no counts on success and `xcodebuild -quiet` only its verdict, so pass the adapter's `resultFiles` directory of this run (`build/test-results`, `target/surefire-reports`) or the `-resultBundlePath` bundle; wipe the directory before the run so an old result cannot be counted. An adapter's `skipped` markers (Maven `Tests are skipped.`, a runner's "no test files") and a Gradle log whose every test task is `SKIPPED` or `NO-SOURCE` count as zero tests |
188
+ | `evidence-gate --stack` | the adapter's markers and test counts; a status that is not `passed` is recorded as a failure. A test claim needs a positive executed-test count, from the log or from `--junit <dir>` / `--xcresult <bundle>`: markers alone fail. Gradle prints no counts on success and `xcodebuild -quiet` only its verdict, so pass the adapter's `resultFiles` directory of this run (`build/test-results`, `target/surefire-reports`) or the `-resultBundlePath` bundle; wipe the directory before the run so an old result cannot be counted. An adapter's `skipped` markers (Maven `Tests are skipped.`, a runner's "no test files") and a Gradle log whose every test task is `SKIPPED` or `NO-SOURCE` count as zero tests. The run has to be on the source as it is now: a `--ran-on` digest (`lib/source-digest.mjs`) that differs from the tree's current one fails the claim, and the ledger entry carries that digest, so an edit after the build makes the entry `stale` at commit even though HEAD did not move. The test run has to be the whole suite: a narrowed `--command` (`-only-testing`, `--filter`, `--tests`, `-t`, `-k`, `--grep`, `-run`, one test file, `--passWithNoTests`) fails with `gaming.kind: narrowed-run`, and so does a log in which the runner names its filter |
187
189
  | `test-summary` | `passed` pass; `failed` and `no-tests` fail; `unparsed` not-applicable (the markers still decide) |
188
190
  | `test-strength --head worktree` | every changed test red: pass. Any still-green, or a test failing on head: fail. No test file or no production change: not-applicable. A test that goes red only by failing to compile or load without the change is `unjudged`, never red: red plus unjudged is a pass, unjudged alone not-applicable. The uncommitted tree is snapshotted through a private index, so the checkout is not touched |
189
191
  | `symbol-existence-gate` | every key, resource and endpoint the added lines reference exists in the adapter's truth sources (section 6); nothing to check against: not-applicable |
@@ -386,7 +386,7 @@ per failed MCP tool call to `~/.claude/logs/multi-agent/mcp-failures.jsonl`.
386
386
  | `server` | the server part of `mcp__<server>__<tool>`, kept only when it matches `[A-Za-z0-9][A-Za-z0-9._-]`, at most 96 characters, with no credential pattern; otherwise the call is dropped |
387
387
  | `tool` | the tool part, under the same rule |
388
388
  | `ts` | when the hook ran |
389
- | `errorClass` | one of `denied`, `timeout`, `rate-limit`, `auth`, `connection`, `invalid-input`, `not-found`, `server-error`, `interrupted`, `other`, chosen from the error text: a JSON-RPC error code first (`-32603` and the implementation range `-32000..-32099` are the server's, with the MCP SDK's `-32000` read as connection and `-32001` as timeout; `-32602`, `-32600` and `-32700` are the caller's input; `-32601` and `-32002` are not found), then a message that opens with `invalid` or `validation` (the caller's input), then an HTTP status written as a status rather than a number in a path, a bare three-digit number counting only after `HTTP`, `status` or a request line, or before a reason phrase (5xx server, 401 and 403 auth, 404 not found, 429 rate limit), then fixed wording patterns that try the server-side classes before `invalid-input`; `denied` is kept for a refusal by the user or the permission layer |
389
+ | `errorClass` | one of `denied`, `disk-full`, `timeout`, `rate-limit`, `auth`, `connection`, `invalid-input`, `not-found`, `server-error`, `interrupted`, `other`, chosen in this order: the host's interrupt flag (`interrupted`), then a refusal by the user or the permission layer (`denied`), then a JSON-RPC error code in the error text (`-32603` and the implementation range `-32000..-32099` are the server's, with the MCP SDK's `-32000` read as connection and `-32001` as timeout; `-32602`, `-32600` and `-32700` are the caller's input; `-32601` and `-32002` are not found), then a message that opens with `invalid` or `validation` (the caller's input), then an HTTP status written as a status rather than a number in a path, a bare three-digit number counting only after `HTTP`, `status` or a request line, or before a reason phrase (5xx server, 401 and 403 auth, 404 not found, 429 rate limit), then fixed wording patterns that try `disk-full` (`ENOSPC`, no space left on device) first and the other server-side classes before `invalid-input` |
390
390
  | `v` | the row format version, a constant (`1.0.0`) |
391
391
 
392
392
  The arguments, the output and the error text are never written; the text is
@@ -403,4 +403,6 @@ opt-out in it cannot be read.
403
403
  counts failed calls per server, per tool and per class in the window (default
404
404
  24 hours). `doctor`'s `mcp-failures` check lights INFO for a server with five or
405
405
  more failures there; `invalid-input`, `denied` and `interrupted` are the
406
- caller's or the user's and never count toward it.
406
+ caller's or the user's and never count toward it. Any `disk-full` row in the
407
+ window also lights INFO with the disk-cleaner skill as its step, whatever the
408
+ count, because a full disk fails every server at once.
@@ -144,7 +144,7 @@ Plugins & tools (called directly, no wrappers):
144
144
 
145
145
  Stack plugins ai-<stack>-toolkit:<skill>, e.g. ai-ios-toolkit:create-component
146
146
  Catalog: ai-<stack>-toolkit:help Enable per repo: /multi-agent:stack (common + analyst always on)
147
- Toolkit MCP multi-agent-toolkit - 228 tools, most for a RUNNING app, no pipeline run needed:
147
+ Toolkit MCP multi-agent-toolkit - 230 tools, most for a RUNNING app, no pipeline run needed:
148
148
  ios_* / android_* (launch, tap, screenshot, ui tree, logs, crashes,
149
149
  locale, dark mode), web_*, design_* (Design Check above), and the
150
150
  audits (ios_app_store_audit, ios_testflight_validate, android_apk_audit,
@@ -143,7 +143,7 @@ Plugin'ler ve tool'lar (doğrudan çağrılır, sarmalayıcı yok):
143
143
 
144
144
  Stack plugin ai-<stack>-toolkit:<skill>, örn. ai-ios-toolkit:create-component
145
145
  Katalog: ai-<stack>-toolkit:help Repo bazında aç: /multi-agent:stack (common + analyst hep açık)
146
- Toolkit MCP multi-agent-toolkit - 228 araç, çoğu ÇALIŞAN uygulama için, pipeline koşusu
146
+ Toolkit MCP multi-agent-toolkit - 230 araç, çoğu ÇALIŞAN uygulama için, pipeline koşusu
147
147
  gerektirmez: ios_* / android_* (başlat, tap, screenshot, ui ağacı, log,
148
148
  crash, locale, koyu mod), web_*, design_* (yukarıdaki Design Check), ve
149
149
  denetimler (ios_app_store_audit, ios_testflight_validate,
@@ -6,6 +6,7 @@
6
6
  - [Read here, write through a command](#read-here-write-through-a-command)
7
7
  - [Which stack skills apply](#which-stack-skills-apply)
8
8
  - [multi-agent-toolkit MCP](#multi-agent-toolkit-mcp)
9
+ - [Status line](#status-line)
9
10
  <!-- /toc -->
10
11
 
11
12
  > Loaded on demand by `rules/outside-the-pipeline.md`, which carries only the
@@ -112,6 +113,7 @@ another stack's toolkit in its place.
112
113
  | `learnings_search` / `learnings_timeline` / `learnings_get` | what past runs learned about a repo, across every repo not excluded from memory |
113
114
  | `graph_*` (`graph_stats`, `graph_hubs`, `graph_cluster`, `graph_query`, ...) | reading a built code graph without a shell |
114
115
  | `research_community` / `media_transcript` | what developers already reported about a problem, or the subtitles of a linked YouTube talk (`media-remote` cap, `yt-dlp`) |
116
+ | `media_video_plan` / `media_video_render` | a short video is wanted from screenshots, clips or a script: plan the scenes and timing first, then render the planned video |
115
117
  | `social_read` | the user asked for posts from X, Reddit, LinkedIn, Instagram or Facebook; reads through their own signed-in Chrome, off unless the `social` cap is set, confirmed per channel, never unattended |
116
118
  | `pass_*` (`pass_inspect`, `pass_validate`, `pass_certificates`, `pass_build`) | an Apple Wallet pass will not open, or a test pass is needed |
117
119
  | `store_*` (`store_status`, `store_asc_*`, `store_play_*`, `store_search` / `store_call`) | a question about App Store Connect or Google Play data: builds and build numbers, reviews, subscriptions, tracks, vitals. Keys come from the Keychain via the store reference file `/multi-agent:setup` writes; `store_status` says which store resolves. Writes return a preview until `confirm: true` and are refused unattended |
@@ -125,3 +127,7 @@ config, and a `@scope:registry=` line there outranks `--registry`. That is how t
125
127
  server came to report `CONNECTION_CLOSED` while working perfectly when run directly:
126
128
  npm fetched from the wrong registry and the process never started. The registration
127
129
  carries `--@<scope>:registry=<url>`; `smoke-npm-scope-pinning.sh` keeps it that way.
130
+
131
+ ## Status line
132
+
133
+ Asked for a status bar that shows the run, offer `node "$HOME/.claude/scripts/statusline.mjs" install`. It adds a Claude Code `statusLine` with the phase, the cost against an enabled `costBudget`, the gates and whether the run waits for an answer, from local files only. It never replaces a `statusLine` already set; `statusline.mjs uninstall` removes only its own.
@@ -213,7 +213,7 @@ Phase 1 and Phase 2 pre-flights BLOCK on `analysis/<feature-slug>-<platform>.md`
213
213
 
214
214
  A fresh document is also skipped when one already exists for this feature and platform AND its front-matter `evidence_digest` still matches (Locked 26 cache); record `docStatus = "reused"`.
215
215
 
216
- **How it runs.** Load `$HOME/.claude/multi-agent-refs/analysis/` on demand, in order: `locked.md` (the 31 binding decisions) then `evidence.md`, `synthesis.md`, `render.md`. Intake is NOT re-asked; platform, repos and account come from Phase 0 state. Autopilot auto-approves the Phase 2a convention preview and writes the local file, because it may not ask.
216
+ **How it runs.** Load `$HOME/.claude/multi-agent-refs/analysis/` on demand, in order: `locked.md` (the 37 binding decisions) then `evidence.md`, `synthesis.md`, `render.md`. Intake is NOT re-asked; platform, repos and account come from Phase 0 state. Autopilot auto-approves the Phase 2a convention preview and writes the local file, because it may not ask.
217
217
 
218
218
  **Where it lands.** `<worktree>/analysis/<feature-slug>-<platform>.md`, one file per platform in `state.analysisSpec.platforms[]`. Persist the paths to `state.analysis.docPath[]` and set `docStatus` to `produced` | `reused` | `not-applicable`. Also persist `state.run.lastAnalysisDigest` (this document's `evidence_digest`) and `state.run.analysisBaseCommit` (`git rev-parse HEAD`). Phase 2's freshness check reads both; unwritten, it has nothing to compare and passes silently. Whether the file is committed with the work is `prefs.global.analysisPhase.commitDoc` (default `true`), read at Phase 4.
219
219
 
@@ -166,7 +166,7 @@ For each task (respecting dependency order), on start and on end: `bash $HOME/.c
166
166
  - **ios, fallback (raw)**: same lock pair around `xcodebuild build -scheme "{scheme}" -destination "generic/platform=iOS" -derivedDataPath "{worktreePath}/.DerivedData" 2>&1 | tail -5`.
167
167
  - **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).
168
168
  - **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.
169
- 5. If build fails → fix → rebuild (max 3 attempts, track `retryCount` in state).
169
+ 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, ask once whether to run the disk-cleaner skill; unattended, record the line and halt. Never delete anything from here.
170
170
  6. **Intermediate commit** (after each completed task in the plan):
171
171
  ```bash
172
172
  git -C "{worktreePath}" add -A
@@ -372,11 +372,11 @@ bash $HOME/.claude/scripts/pre-commit-check.sh
372
372
  **Default-FAIL evidence gate (required before recording any pass):** a green exit code is not enough - the captured log must actually show success. Before marking build/test passed, run the evidence gate against the tee'd log; it fails CLOSED when the log is missing, empty, or shows failure markers:
373
373
 
374
374
  ```bash
375
- node $HOME/.claude/scripts/evidence-gate.mjs --claim build --status passed --evidence "$WORKTREE/.build.log" || BUILD_PASS=false
376
- node $HOME/.claude/scripts/evidence-gate.mjs --claim test --status passed --evidence "$WORKTREE/.test.log" || TEST_PASS=false
375
+ node $HOME/.claude/scripts/evidence-gate.mjs --claim build --status passed --evidence "$WORKTREE/.build.log" --repo "$WORKTREE" || BUILD_PASS=false
376
+ node $HOME/.claude/scripts/evidence-gate.mjs --claim test --status passed --evidence "$WORKTREE/.test.log" --repo "$WORKTREE" --command "<test-command>" || TEST_PASS=false
377
377
  ```
378
378
 
379
- This prevents a false "it built" claim with no log behind it. On exit 1, treat the gate as failed (do NOT proceed to AI review) and surface the gate's `reason`.
379
+ This prevents a false "it built" claim with no log behind it. `--repo` fails a log older than the last edit, `--command` a narrowed run (`-only-testing`, `-k`, `-t`, one file). On exit 1, treat the gate as failed (do NOT proceed to AI review) and surface the gate's `reason`.
380
380
 
381
381
  **Why the pipe (opt-in via `prefs.global.contextOffload.enabled`).** `tee` decides where the log is written, not how much of it the model reads. The filter parks the full text at `.multi-agent/refs/<node_id>.md` and prints a stub plus the tail, where a failing build's error already is; read that file before re-running a failed build. The evidence gate still reads the whole `.build.log`, so what counts as a verified pass is unchanged. Pref off = pass-through.
382
382
 
@@ -123,11 +123,11 @@ $HOME/.claude/scripts/log-metric.sh "$TASK_ID" 3 review.diff_risk \
123
123
 
124
124
  #### Step 1.76 - Test-integrity gate (produces BLOCKING findings)
125
125
 
126
- Turns Step 1.75's `test_lines_removed` hint into blocking findings triage must adjudicate, and greps the diff for test gaming: an environment branch, a swallowed error, an inflated timeout, a disabled test, a lint suppression or a loosened lint config. A lint suppression that states its reason on the line is important, not blocking. `TI_COUNT=-1` (non-zero exit, missing file, or `gaming.scanned: false`) means the change was not checked for test gaming, never "no findings": `review-decision-gate.mjs` reads that file as unreadable (exit 3), which parks the run; where that gate does not run, add one blocking `test_integrity` finding with `signal: "gate_error"`. `--out` drops the previous iteration's file first, so a failed run leaves none.
126
+ Turns Step 1.75's `test_lines_removed` hint into blocking findings triage must adjudicate, and greps the diff for test gaming: an environment branch, a swallowed error, an inflated timeout, a disabled test, a lint suppression or a loosened lint config; `--state` adds RED tests changed later. A lint suppression that states its reason on the line is important, not blocking. `TI_COUNT=-1` (non-zero exit, missing file, or `gaming.scanned: false`) means the change was not checked for test gaming, never "no findings": `review-decision-gate.mjs` reads that file as unreadable (exit 3), which parks the run; where that gate does not run, add one blocking `test_integrity` finding with `signal: "gate_error"`. `--out` drops the previous iteration's file first, so a failed run leaves none.
127
127
 
128
128
  ```bash
129
129
  TI_FILE="$WORKTREE/.pipeline/test-integrity.json"
130
- printf '%s' "$RISK_FULL" | node $HOME/.claude/scripts/test-integrity-gate.mjs --diff-base "$BASE_BRANCH" --repo "$WORKTREE" --out "$TI_FILE" 2>/dev/null; TI_RC=$?
130
+ printf '%s' "$RISK_FULL" | node $HOME/.claude/scripts/test-integrity-gate.mjs --diff-base "$BASE_BRANCH" --repo "$WORKTREE" --state "$STATE_FILE" --out "$TI_FILE" 2>/dev/null; TI_RC=$?
131
131
  TI_COUNT=$(jq -r 'if .gaming.scanned == false then -1 else (.count // 0) end' "$TI_FILE" 2>/dev/null || echo -1)
132
132
  [ "$TI_RC" -ne 0 ] && TI_COUNT=-1
133
133
  [ "$TI_COUNT" -gt 0 ] && $HOME/.claude/scripts/log-metric.sh "$TASK_ID" 3 review.test_integrity findings="$TI_COUNT"
@@ -233,6 +233,8 @@ WS_ERR=$(printf '{"status":"complete","currentPhase":5,"finishedAt":"%s"}' "$TS"
233
233
 
234
234
  **Per-run outcome metrics (evidence corpus):** also emit `run-metrics.mjs --state <agent-state.json>` and append/persist its JSON. It records review iterations, first-pass-clean, reviewer signal-to-noise, consensus verdict and build outcome.
235
235
 
236
+ **Routing outcomes:** with `modelRouting.learned.enabled`, run `route-learn.mjs ingest --state "$STATE_FILE"` (outcome rows only, `features/model-fallback.md`).
237
+
236
238
  **Cost Breakdown emission (required):** as part of agent-log compose, append the per-task cost block produced by `render-agent-log-cost.sh`:
237
239
 
238
240
  ```bash
@@ -158,7 +158,9 @@ Act on the exit code:
158
158
  - `10` (WARN) - surface the printed `WARN: ...` line to the user (and into `agent-log.md`). Continue.
159
159
  - `11` (EXCEEDED) - surface the `EXCEEDED: ...` line. If `costBudget.onExceed = "halt"`, pause the run and require `multi-agent:resume` (autopilot included) so the user explicitly accepts the overage; if `"warn"`, continue.
160
160
 
161
- The check is a silent no-op (exit 0) when the budget is disabled or no tracker data exists yet, so unconditional invocation is safe. It prices accumulated tokens conservatively (default `opus` rate) so the ceiling trips early. Enforced by `smoke-cost-budget.sh`.
161
+ The check is a silent no-op (exit 0) when the budget is disabled or no tracker data exists yet, so unconditional invocation is safe. It prices accumulated tokens conservatively (default `fable` rate, the most expensive tier) so the ceiling trips early. Enforced by `smoke-cost-budget.sh`.
162
+
163
+ Between phases the same ladder is read at every subagent spawn: `run-scope-guard.sh` on `Agent|Task` prices the bound run's tracker with `_cost-budget.mjs` and, while the run is over `maxUsd`, asks the user before the subagent starts (`onExceed: "halt"` refuses it). From `warnPct` up to the ceiling the model gets a note and the spawn goes ahead. Off with the budget, outside a run, and for a finished run.
162
164
 
163
165
  ---
164
166
 
@@ -1,3 +1,3 @@
1
1
  {
2
- "toolkitVersion": "3.31.0"
2
+ "toolkitVersion": "3.32.0"
3
3
  }
@@ -26,7 +26,7 @@ the file first; never inline it). The repo's own `.claude/skills` come first.
26
26
  `ai-common-toolkit` and `ai-analyst-toolkit` are on everywhere. Nothing enabled
27
27
  is a normal state.
28
28
 
29
- **multi-agent-toolkit MCP.** <!-- fact:toolCount -->228<!-- /fact --> tools, most for a running app: `ios_get_ui_tree` /
29
+ **multi-agent-toolkit MCP.** <!-- fact:toolCount -->230<!-- /fact --> tools, most for a running app: `ios_get_ui_tree` /
30
30
  `android_get_ui_tree`, `ios_list_crashes` / `android_list_crashes`, `design_*`,
31
31
  `ios_app_store_audit`, `ios_testflight_validate`. Use them instead of guessing
32
32
  about on-screen state. Not registered is a silent no-op.
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/doctor-report.schema.json",
4
+ "title": "Doctor report",
5
+ "description": "What `doctor.mjs --json` prints. schemaVersion changes only when an existing field changes meaning or shape; a new check id or a new optional field does not change it. Every check id is listed by `doctor.mjs --list-checks` and documented in multi-agent-refs/features/doctor.md. `exit` is the process exit code: 0 healthy, 1 at least one WARN, 2 at least one BLOCK, 4 indeterminate (the layout did not resolve).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schemaVersion", "exit", "selection", "checks"],
9
+ "properties": {
10
+ "schemaVersion": { "const": 1, "x-sensitivity": "none" },
11
+ "exit": { "type": "integer", "enum": [0, 1, 2, 4], "x-sensitivity": "none" },
12
+ "selection": {
13
+ "description": "The check ids --only asked for, in the order given, or null for a full run.",
14
+ "anyOf": [
15
+ { "type": "null" },
16
+ { "type": "array", "items": { "type": "string", "pattern": "^[a-z0-9-]+$" } }
17
+ ],
18
+ "x-sensitivity": "none"
19
+ },
20
+ "checks": {
21
+ "description": "One entry per check that ran, in registry order.",
22
+ "type": "array",
23
+ "x-sensitivity": "local",
24
+ "items": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["id", "severity", "problem", "step", "detail"],
28
+ "properties": {
29
+ "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
30
+ "severity": { "type": "string", "enum": ["OK", "INFO", "WARN", "BLOCK", "SKIP"] },
31
+ "problem": {
32
+ "description": "What is wrong (WARN, BLOCK, INFO) or why it was not checked (SKIP); null for OK.",
33
+ "type": ["string", "null"]
34
+ },
35
+ "step": {
36
+ "description": "The single step that fixes it, starting with a verb from the closed list; null for OK and SKIP.",
37
+ "type": ["string", "null"]
38
+ },
39
+ "detail": {
40
+ "description": "What --explain prints: a string, a list, or null. Free-form per check.",
41
+ "type": ["string", "array", "object", "null"]
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
@@ -85,6 +85,20 @@
85
85
  "testsUnverifiable": {
86
86
  "type": "boolean",
87
87
  "description": "The todo named tests (--tests) but the results name no failing test, so the names went unchecked. Recorded in warn and off mode; enforce refuses the run instead."
88
+ },
89
+ "testFiles": {
90
+ "type": "array",
91
+ "maxItems": 200,
92
+ "description": "The worktree's new and changed test files at RED, each with the blob id its bytes were written to in the repository's object store. tdd-green refuses when one of them changed without --test-edit-reason; tdd-restore writes them back.",
93
+ "items": {
94
+ "type": "object",
95
+ "additionalProperties": false,
96
+ "required": ["path", "blob"],
97
+ "properties": {
98
+ "path": { "type": "string", "minLength": 1 },
99
+ "blob": { "type": "string", "pattern": "^[0-9a-f]{40,64}$" }
100
+ }
101
+ }
88
102
  }
89
103
  }
90
104
  },
@@ -96,7 +110,21 @@
96
110
  "properties": {
97
111
  "at": { "type": "string", "format": "date-time" },
98
112
  "failed": { "const": 0 },
99
- "total": { "type": "integer", "minimum": 1 }
113
+ "total": { "type": "integer", "minimum": 1 },
114
+ "testEdits": {
115
+ "type": "array",
116
+ "description": "Test files RED kept that GREEN found changed, accepted with the reason given to --test-edit-reason. test-integrity-gate --state reports them for review.",
117
+ "items": {
118
+ "type": "object",
119
+ "additionalProperties": false,
120
+ "required": ["path", "change", "reason"],
121
+ "properties": {
122
+ "path": { "type": "string", "minLength": 1 },
123
+ "change": { "type": "string", "enum": ["modified", "deleted"] },
124
+ "reason": { "type": "string", "minLength": 1 }
125
+ }
126
+ }
127
+ }
100
128
  }
101
129
  },
102
130
  "outcome": {
@@ -674,6 +674,26 @@
674
674
  "recordDecisions": {
675
675
  "type": "boolean",
676
676
  "default": true
677
+ },
678
+ "learned": {
679
+ "type": "object",
680
+ "additionalProperties": false,
681
+ "description": "Learned rung order (route-learn.mjs), ships disabled. Contract: route-config.schema.json.",
682
+ "properties": {
683
+ "enabled": { "type": "boolean", "default": false },
684
+ "minSamples": { "type": "integer", "minimum": 1, "default": 20 },
685
+ "target": { "type": "number", "minimum": 0, "maximum": 1, "default": 0.8 },
686
+ "halfLifeDays": { "type": "integer", "minimum": 1, "default": 60 },
687
+ "explore": { "type": "boolean", "default": false },
688
+ "holdout": {
689
+ "type": "number",
690
+ "exclusiveMinimum": 0,
691
+ "exclusiveMaximum": 1,
692
+ "default": 0.25
693
+ },
694
+ "minRows": { "type": "integer", "minimum": 1, "default": 10 },
695
+ "margin": { "type": "number", "minimum": 0, "default": 0.005 }
696
+ }
677
697
  }
678
698
  }
679
699
  },
@@ -1495,6 +1515,31 @@
1495
1515
  }
1496
1516
  }
1497
1517
  },
1518
+ "diskCleaner": {
1519
+ "type": "object",
1520
+ "additionalProperties": false,
1521
+ "description": "When the ecosystem suggests the disk-cleaner skill. lib/low-disk.mjs reads these with one statfs call from doctor's disk-space check, the SessionStart banner and the pre-push gate's failure path, and prints one line naming the skill. The suggestion never deletes anything.",
1522
+ "properties": {
1523
+ "lowDiskGb": {
1524
+ "type": "number",
1525
+ "minimum": 0,
1526
+ "default": 10,
1527
+ "description": "Suggest the cleaner when less than this many gigabytes are free on the volume holding $HOME."
1528
+ },
1529
+ "lowDiskPercent": {
1530
+ "type": "number",
1531
+ "minimum": 0,
1532
+ "maximum": 100,
1533
+ "default": 5,
1534
+ "description": "Suggest the cleaner when less than this share of the volume is free. Either floor is enough."
1535
+ },
1536
+ "suggest": {
1537
+ "type": "boolean",
1538
+ "default": true,
1539
+ "description": "false silences the suggestion everywhere, including after a disk-full failure."
1540
+ }
1541
+ }
1542
+ },
1498
1543
  "analysisPhase": {
1499
1544
  "type": "object",
1500
1545
  "additionalProperties": false,
@@ -1901,6 +1946,18 @@
1901
1946
  "maximum": 3650,
1902
1947
  "default": 30,
1903
1948
  "description": "Recency half-life. Recency only separates entries of comparable relevance; it never promotes an unrelated entry."
1949
+ },
1950
+ "mmrLambda": {
1951
+ "type": "number",
1952
+ "minimum": 0,
1953
+ "maximum": 1,
1954
+ "default": 0.7,
1955
+ "description": "Maximal Marginal Relevance weight for the head of a recall answer: lambda * relevance - (1 - lambda) * similarity to what is already picked (TF-IDF cosine). Keeps near-duplicate rows from filling every place. 1 turns the re-pick off."
1956
+ },
1957
+ "multiQuery": {
1958
+ "type": "boolean",
1959
+ "default": true,
1960
+ "description": "Rank each clause of a multi-part task as its own query and fuse the rankings, so the second thing a task asks about is not crowded out by the first. false ranks the whole text as one query."
1904
1961
  }
1905
1962
  },
1906
1963
  "default": {
@@ -2640,6 +2697,12 @@
2640
2697
  "minimum": 0,
2641
2698
  "default": 8,
2642
2699
  "description": "Report the registered-server count once it exceeds this. The number is JUDGEMENT, not a measurement - it exists so the threshold is visible and adjustable instead of hidden in the script. 0 reports the count always."
2700
+ },
2701
+ "schemaInfoAboveTokens": {
2702
+ "type": "integer",
2703
+ "minimum": 0,
2704
+ "default": 8000,
2705
+ "description": "doctor --probe reports the toolkit's tool-list load per family (an estimate, bytes / 4) once the total reaches this many tokens, with the MCP_TOOLKIT_CAPS families that would cut it. Judgement, like infoAbove. 0 reports it always."
2643
2706
  }
2644
2707
  }
2645
2708
  }
@@ -94,6 +94,57 @@
94
94
  "type": "boolean",
95
95
  "default": true,
96
96
  "description": "Write every routing decision to the cost ledger: which rule matched, which rung it chose, and why. On by default because a router whose choices are not recorded cannot be audited after the fact - and the question that always arrives later is 'why did this run cost that'."
97
+ },
98
+ "learned": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "description": "Learned rung order (route-learn.mjs). Ships disabled. While enabled, model-dispatch.sh hands the strategy's order to route-learn.mjs choose, which reorders the rule's own candidates from the PROMOTED policy: per call site, task kind and complexity band, a Beta posterior over a reward taken from gate verdicts and review findings, never from a model's report on itself, sampled by seeded Thompson sampling. A policy changes only through route-learn.mjs promote, after it beats the current one on a time-ordered holdout. Too few outcomes, no promoted policy or any failure leaves the order unchanged.",
102
+ "properties": {
103
+ "enabled": { "type": "boolean", "default": false, "description": "Ships false." },
104
+ "minSamples": {
105
+ "type": "integer",
106
+ "minimum": 1,
107
+ "default": 20,
108
+ "description": "Outcomes a rung needs in a bucket before its posterior is used; with fewer than two such rungs the rule's order stands."
109
+ },
110
+ "target": {
111
+ "type": "number",
112
+ "minimum": 0,
113
+ "maximum": 1,
114
+ "default": 0.8,
115
+ "description": "A rung whose sampled reward clears this is good enough; the cheapest such rung is tried first."
116
+ },
117
+ "halfLifeDays": {
118
+ "type": "integer",
119
+ "minimum": 1,
120
+ "default": 60,
121
+ "description": "An outcome's weight halves every this many days."
122
+ },
123
+ "explore": {
124
+ "type": "boolean",
125
+ "default": false,
126
+ "description": "Draw a rung with too few outcomes from its prior instead of leaving it after the known ones. Off by default: exploring means sometimes trying a rung with no record."
127
+ },
128
+ "holdout": {
129
+ "type": "number",
130
+ "exclusiveMinimum": 0,
131
+ "exclusiveMaximum": 1,
132
+ "default": 0.25,
133
+ "description": "Newest fraction of the outcomes promote scores a candidate on."
134
+ },
135
+ "minRows": {
136
+ "type": "integer",
137
+ "minimum": 1,
138
+ "default": 10,
139
+ "description": "Holdout rows promote requires."
140
+ },
141
+ "margin": {
142
+ "type": "number",
143
+ "minimum": 0,
144
+ "default": 0.005,
145
+ "description": "Brier-score improvement over the current policy promote requires."
146
+ }
147
+ }
97
148
  }
98
149
  }
99
150
  }
@@ -202,7 +202,7 @@
202
202
  "id": "url-with-credentials",
203
203
  "label": "URL with embedded credentials",
204
204
  "kind": "context",
205
- "ere": "[a-z][a-z0-9+.-]*://[^[:space:]/:@]+:[^[:space:]/@]+@",
205
+ "ere": "[a-z][a-z0-9+.-]{0,31}://[^[:space:]/:@]{1,255}:[^[:space:]/@]+@",
206
206
  "left": "word"
207
207
  },
208
208
  {
@@ -423,6 +423,22 @@
423
423
  "len": 12,
424
424
  "suffix": "@example.com/x.git"
425
425
  },
426
+ {
427
+ "id": "url-with-credentials-300",
428
+ "rule": "url-with-credentials",
429
+ "prefix": "https://user:",
430
+ "fill": "s",
431
+ "len": 300,
432
+ "suffix": "@example.com/x.git"
433
+ },
434
+ {
435
+ "id": "url-with-credentials-2000",
436
+ "rule": "url-with-credentials",
437
+ "prefix": "https://user:",
438
+ "fill": "s",
439
+ "len": 2000,
440
+ "suffix": "@example.com/x.git"
441
+ },
426
442
  {
427
443
  "id": "bearer-header",
428
444
  "rule": "bearer-header",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$comment": "Generated by pipeline/scripts/gen-toolkit-path-params.mjs from multi-agent-toolkit-mcp tool-manifest.json; do not edit. Per toolkit tool: the parameters it writes to and the filesystem paths it reads, both confined by scripts/unattended_policy.py.",
3
- "toolkitVersion": "3.31.0",
3
+ "toolkitVersion": "3.32.0",
4
4
  "tools": {
5
5
  "agent_query_output": {
6
6
  "writes": [],
@@ -577,6 +577,20 @@
577
577
  "writes": [],
578
578
  "reads": []
579
579
  },
580
+ "media_video_plan": {
581
+ "writes": [],
582
+ "reads": []
583
+ },
584
+ "media_video_render": {
585
+ "writes": [
586
+ "out_dir"
587
+ ],
588
+ "reads": [
589
+ "footage_dir",
590
+ "voice_dir",
591
+ "music"
592
+ ]
593
+ },
580
594
  "pass_build": {
581
595
  "writes": [
582
596
  "output"