@mmerterden/multi-agent-pipeline 20.40.0 → 20.41.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 (76) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +4 -1
  3. package/README.tr.md +4 -1
  4. package/docs/adr/0019-product-tree.md +143 -0
  5. package/docs/adr/README.md +1 -0
  6. package/docs/ecosystem.md +9 -9
  7. package/docs/facts.json +4 -4
  8. package/docs/features.md +6 -0
  9. package/install/claude.mjs +12 -3
  10. package/install/templates/claude-hooks.json +12 -1
  11. package/manifest.json +79 -60
  12. package/package.json +2 -2
  13. package/pipeline/commands/multi-agent/review-analysis/SKILL.md +1 -1
  14. package/pipeline/contract/types/index.d.ts +53 -49
  15. package/pipeline/lib/context-budget.mjs +5 -42
  16. package/pipeline/lib/hook-registration.mjs +5 -0
  17. package/pipeline/lib/md2confluence-v3.py +12 -4
  18. package/pipeline/lib/tiered-budget.mjs +87 -0
  19. package/pipeline/multi-agent-refs/analysis/review.md +23 -1
  20. package/pipeline/multi-agent-refs/features/code-graph.md +11 -1
  21. package/pipeline/multi-agent-refs/features/doctor.md +32 -1
  22. package/pipeline/multi-agent-refs/features/product-tree.md +68 -0
  23. package/pipeline/multi-agent-refs/features/unattended-security.md +88 -1
  24. package/pipeline/multi-agent-refs/features/usage-reporting.md +31 -0
  25. package/pipeline/multi-agent-refs/help/en.md +1 -0
  26. package/pipeline/multi-agent-refs/help/tr.md +1 -0
  27. package/pipeline/multi-agent-refs/knowledge.md +58 -0
  28. package/pipeline/multi-agent-refs/phases/phase-0-init.md +4 -0
  29. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -0
  30. package/pipeline/multi-agent-refs/phases/phase-5-report.md +2 -0
  31. package/pipeline/office/index.html +13 -7
  32. package/pipeline/office/toolkit.json +1 -1
  33. package/pipeline/preferences-template.json +1 -0
  34. package/pipeline/schemas/learnings-ledger.schema.json +35 -2
  35. package/pipeline/schemas/office-archive.schema.json +225 -128
  36. package/pipeline/schemas/prefs.schema.json +83 -0
  37. package/pipeline/schemas/product-tree-overlay.schema.json +57 -0
  38. package/pipeline/schemas/product-tree.schema.json +136 -0
  39. package/pipeline/schemas/toolkit-path-params.json +1 -1
  40. package/pipeline/scripts/_eval-stats.mjs +182 -0
  41. package/pipeline/scripts/_guard_rules.py +130 -1
  42. package/pipeline/scripts/_learnings-promotion.mjs +229 -0
  43. package/pipeline/scripts/_locate.mjs +539 -0
  44. package/pipeline/scripts/_memory-policy.mjs +213 -14
  45. package/pipeline/scripts/_product-tree-extract.mjs +761 -0
  46. package/pipeline/scripts/_product-tree.mjs +923 -0
  47. package/pipeline/scripts/_retrieval.mjs +13 -2
  48. package/pipeline/scripts/_stack-routing.mjs +1 -0
  49. package/pipeline/scripts/_user_guard_rules.py +744 -0
  50. package/pipeline/scripts/agent-guard.py +61 -5
  51. package/pipeline/scripts/agent-guard.sh +8 -1
  52. package/pipeline/scripts/doctor.mjs +157 -1
  53. package/pipeline/scripts/graph-query.mjs +257 -17
  54. package/pipeline/scripts/learnings-ledger.mjs +664 -43
  55. package/pipeline/scripts/note-mcp-failure.mjs +356 -0
  56. package/pipeline/scripts/note-mcp-failure.sh +19 -0
  57. package/pipeline/scripts/note-skill-use.mjs +93 -23
  58. package/pipeline/scripts/office-archive.mjs +23 -10
  59. package/pipeline/scripts/office-memory.mjs +4 -1
  60. package/pipeline/scripts/persona-walk-anchors.mjs +443 -0
  61. package/pipeline/scripts/product-tree-eval.mjs +685 -0
  62. package/pipeline/scripts/product-tree.mjs +544 -0
  63. package/pipeline/skills/.skill-manifest.json +11 -7
  64. package/pipeline/skills/.skills-index.json +12 -1
  65. package/pipeline/skills/shared/README.md +4 -3
  66. package/pipeline/skills/shared/core/google-play-compliance/references/examples.md +1 -1
  67. package/pipeline/skills/shared/core/multi-agent-review-analysis/SKILL.md +1 -1
  68. package/pipeline/skills/shared/external/backlog/SKILL.md +1 -1
  69. package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +1 -1
  70. package/pipeline/skills/shared/external/spec-persona-walk/SKILL.md +118 -0
  71. package/pipeline/skills/shared/external/spec-persona-walk/evals/evals.json +50 -0
  72. package/pipeline/skills/shared/external/spec-persona-walk/scripts/persona-walk-anchors.mjs +443 -0
  73. package/pipeline/skills/shared/external/storekit/SKILL.md +1 -1
  74. package/pipeline/skills/shared/external/swiftdata/SKILL.md +1 -1
  75. package/pipeline/skills/skill-copies.json +5 -1
  76. package/pipeline/skills/skills-index.md +2 -1
package/CHANGELOG.md CHANGED
@@ -16,6 +16,56 @@ Internal file-layout changes that don't affect the slash-command surface are sti
16
16
 
17
17
  ## [Unreleased]
18
18
 
19
+ ## [20.41.0] - 2026-11-03
20
+
21
+ ### Added
22
+
23
+ - Global learnings. `learnings-ledger.mjs promote --candidates [--json]` lists learnings that recur in two or more repositories: entries of the same kind whose statements score at or above 0.5 on word-pair shingle similarity, high confidence only. Superseded entries, entries marked `dead_end` or `corrected`, and repositories in `memory.excludeProjects` are left out. Each candidate shows its repositories, entry ids and score. It runs on request only; nothing promotes automatically.
24
+ - `learnings-ledger.mjs promote --accept <P:id>` appends one candidate, with its source ids, to the global ledger `~/.claude/memory/multi-agent/_global/learnings-ledger.jsonl` after a y/N confirmation at a terminal; end of input at the question writes nothing and exits 2. `promote --retract <G:id> --reason "..."` takes a global learning back in every repository, and `feedback --id G:<id> --outcome dead_end|corrected` hides it in one repository. All three exit 3 in an unattended or autopilot run and when stdin is not a terminal, and agent-guard asks before an agent runs any of them and refuses them unattended.
25
+ - `brief` and `profile` include global entries marked `(global)` with a `G:` pointer (`show --id G:<id>`), at every tier. Global entries hold at most a third of the block and are ordered by date among the repository's own. They are left out in excluded repositories, in their source repositories, in repositories that already hold the same learning, and in a repository that hid them. A global row with an empty statement, or a retraction without an id, is skipped. A repo slug that folds onto a name starting with `_`, or resolves to the global ledger's folder, is refused, so no repository command can write the global ledger.
26
+ - Office: the memory archive (`GET /v1/archive`) has a `global` shelf for promoted learnings. Neither `/v1/archive` nor `/v1/memory` lists a folder whose name starts with `_` as a repository.
27
+ - `/multi-agent:review-analysis` gains an opt-in persona walk (`review.personaWalk.enabled`, default off). At most four personas derived from the document walk its flows and report missing states, unhandled errors, accessibility gaps and conflicting rules.
28
+ - `persona-walk-anchors.mjs` drops every persona-walk finding whose section or quote anchor is not in the document. A quote must sit in one paragraph and is matched across emphasis, code marks and link syntax; it may land above the first numbered heading or in an unnumbered document. Section ids may be bold or follow "Section" or "Bölüm", and a numbered heading nested under a numbered section whose number it does not extend belongs to that section. Fences close only on their own marker, and fenced code is never quotable. A conflicting-rule finding needs anchors in different sections or different paragraphs, and two quotes count only when they differ. A walk is refused past 200 findings, a finding past 8 anchors, and a document over 4 MB; the document and the walk must be regular files, opened without blocking.
29
+ - New `spec-persona-walk` skill in ai-common-toolkit, which ships the anchor checker.
30
+ - `eval-persona-walk.mjs` measures the walk on a seeded-defect corpus in invented domains: recall, precision, anchor-valid rate and recall per kind. Each planted gap is credited to one finding; kept findings are split into matched, duplicates and false positives, and duplicates lower precision. The scorer check runs in `npm test`; the model run is opt-in behind the live-eval cost gate. The bar for turning the walk on is in `pipeline/eval/README.md`.
31
+ - `graph-query.mjs --tier quick|panorama|deep` and `learnings-ledger.mjs brief|profile --tier` answer in a fixed character budget (1500, 6000, 12000), fitted by `fitToBudget` in `lib/tiered-budget.mjs`. `--tier=<t>` is accepted, an unknown tier exits 64, and the graph-query tier header shows at most 120 characters of the question. Output without `--tier` is unchanged.
32
+ - `note-mcp-failure.sh`, registered by install (PostToolUseFailure on `mcp__.*`), counts failed MCP calls per server and tool in `~/.claude/logs/multi-agent/mcp-failures.jsonl`. It records only server, tool, time and a closed error class, chosen from the JSON-RPC code first, then a message that opens with "invalid" or "validation", then an HTTP status (a bare three-digit number counts only after HTTP, status or a request line, or before a reason phrase), then wording. `denied` covers permission refusals only. Off with `mcpFailures.enabled: false` or `usageLog.optOut: true`, and while the preferences file exists but does not parse. `note-mcp-failure.mjs summary` prints "server-side failures of N failed calls" per server.
33
+ - Doctor check `mcp-failures`: INFO for a server with 5 or more server-side failures in 24 hours. Invalid input, denied and interrupted calls do not count.
34
+ - `eval-tool-order.mjs` (maintainer, opt-in) reports how often local sessions followed three documented tool orders, as rates only. A session counts as a pipeline run when it is named by `--run` or started a run-starting command from the command catalog; `help`, `status` and other helpers do not count.
35
+ - `prefs.global.guardRules`: user-defined agent-guard rules (tool, regex, `warn`/`ask`/`block`, reason). They only make the guard stricter, and unattended an `ask` is a `block`. A pattern with a back-reference, or one that does not compile, is invalid. The rest match under a 1-second budget in the guard's own process: `block` rules first, then `ask`, then `warn`, each with its own share of the time left. Messages name the rule id and reason, never the matched text.
36
+ - A guard rule that gives no answer (out of time, not reached before the budget ran out, or input past 65,536 characters with no match in its head and tail) refuses unattended and asks attended when it is an `ask` or `block` rule. A preferences file that does not parse, or a `guardRules` that is not a list, applies no rule: unattended it refuses every call a rule could govern when the file names `guardRules`, and attended each such call carries a note. With prompts off, an ask on Edit, Write or a toolkit tool prints the exact `confirm-command.mjs` key: the tool, the path and a sha256 of the input. A `warn` or `ask` message is added to a built-in ask's prompt.
37
+ - Doctor check `guard-rules`: reports invalid rules by id (an invalid `block` rule refuses its tool unattended; a duplicate id names both positions), names a rule with a slow shape as INFO, and reports rules whose tool has no agent-guard registration (a `Read` rule under the default hooks, or the `NotebookEdit` half of an `Edit` rule) and a preferences file or `guardRules` value it cannot read.
38
+ - `product-tree.mjs` builds a screen layer over the code graph without a model (screens, routes, flows, localized strings, endpoints, tests) for SwiftUI, Compose (Navigation 2 and 3) and Next.js / react-router. Programmatic navigation is counted and listed per stack when it cannot be resolved. Subcommands: `build`, `locate`, `show`, an evidence-checked `propose`, and person-only `agree` / `reject`.
39
+ - Product tree input handling: the build reads only regular files inside the repository (no symlinks, devices or FIFOs) up to 2 MB, decodes UTF-16 strings files, and runs git with the repository's fsmonitor, hooks, external diff and pager turned off. A root that is a git top level takes the main repository's name, so a linked worktree shares its repository's tree, project and exclusion. `locate` and `show` print one untrusted-data block or nothing, with the no-match note on stderr, and `locate` measures its budget on the fenced text, so it stays within `--max-chars`. Both `--json` outputs strip control characters from every string. `build`, `locate`, `show` and `propose` skip repositories in `memory.excludeProjects`.
40
+ - Product tree overlay: proposal evidence must resolve, symlinks followed, to a line of a regular file inside the repository, and `--parent` must name a node or a proposal. `--name` and `--note` lose control characters before a proposal is written. Proposing the same thing again keeps a person's earlier `agree` or `reject`. agent-guard asks before any `agree` or `reject` through `product-tree.mjs` (flags before the subcommand, a variable in its place, or a renamed copy run through node or directly) and before a shell write into the overlay, compared casefolded and after resolving a symlink, and refuses a file tool aimed at `product-tree-overlay.jsonl`, attended and unattended.
41
+ - `product-tree-eval.mjs` mines bug-fix commits, rebuilds graph and tree at each fix's parent, splits by time, tunes only on the older half, and reports Acc@k, recall@k, MRR, an exact McNemar test (summed in log space, so it holds past 1023 discordant pairs) and bootstrap intervals. It reads repository files under the same rules as the build and keeps non-ASCII paths.
42
+ - `prefs.global.productTree` (off by default). When on, Phase 0 builds the tree when it is missing or behind HEAD and locates the task, and Phase 1 injects the subtree, capped by `fitToBudget` at `productTree.maxChars` (default 6000) characters.
43
+
44
+ ### Changed
45
+
46
+ - `/multi-agent:review-analysis` verdicts always print a G (persona walk) row: its count, or `off` when `review.personaWalk.enabled` is false.
47
+ - The learnings near-duplicate check, like the new promotion measure, treats curly apostrophes, every n't form, "cannot" and Turkish -me/-ma verb negation as negations, past, reported past and imperative forms whose suffix vowel follows the stem included, and reads words of any script whole.
48
+ - The learnings-ledger schema accepts `source: promotion`, `promoted_from` and `retracts` on global ledger rows.
49
+ - Doctor's hook-registration check counts a non-empty `guardRules` as needing `agent-guard.sh`.
50
+ - Shorter descriptions for `backlog`, `localization-reuse-map`, `storekit` and `swiftdata`, so the skill description surface stays under 96000 bytes.
51
+
52
+ ### Fixed
53
+
54
+ - Confluence pages: an image inside a table cell renders at 240 px wide (`TABLE_IMAGE_WIDTH` in `md2confluence-v3.py`) instead of the 720 px page width, unless its own title names a width (`"width=400"`); images outside tables keep the page width.
55
+
56
+ ### Security
57
+
58
+ - The skill-usage log and the MCP failure log share one append and rotation path through safe-write, each log under its own lock. A FIFO, link or directory at the log path drops the row instead of redirecting it, throwing or holding the hook. A writer that finds the rotation lock held waits briefly for the rotation, and a log still full afterwards, or one whose `.1` is a directory, drops the row, so neither log grows past its 1 MiB cap. The MCP summary reads only regular files.
59
+ - Learnings: statements, rationales and scopes lose C0 and C1 control characters when added and when printed, so an escape sequence cannot hide what a person approves. A repository folder that is a symlink, or whose real name starts with `_`, is refused. Ledger and feedback files are opened without following a link or blocking, must be regular files, and are read up to 16 MiB from the newest end.
60
+
61
+ ### Docs
62
+
63
+ - ADR-0019 (Accepted, ships off, M0 verdict NO-GO): on 230 held-out bug fixes the product tree did not beat graph-only ranking (recall@10 46.5% against 47.1%, McNemar p = 1.0). It and the product tree page say the guard asks before an `agree`, a `reject` or a shell write into the overlay and refuses a file tool aimed at it.
64
+ - README: "Hooks per host" lists `note-mcp-failure.sh`, and "Your own guard rules" documents `guardRules`.
65
+ - Help lists Global Learnings under Key Features, with `--retract` and feedback on a `G:` id, in English and Turkish.
66
+ - `usage-reporting.md` section 10 and the hooks template say each local log rotates under its own lock, and give the MCP failure classifier's order with the `invalid` / `validation` opening read before an HTTP status.
67
+ - `docs/ecosystem.md` no longer carries hand-typed plugin skill counts and versions.
68
+
19
69
  ## [20.40.0] - 2026-11-03
20
70
 
21
71
  ### Added
package/README.md CHANGED
@@ -515,7 +515,7 @@ The **secret scan** runs as a `PreToolUse` hook on Claude Code (hard-blocks a co
515
515
  | Hook | Claude Code | Codex CLI | Copilot CLI |
516
516
  | --- | --- | --- | --- |
517
517
  | `pre-commit-check.sh` (secret scan, owned paths, attended build/test evidence, unattended ledger) | PreToolUse `Bash` | none: pre-push check | none: pre-push check |
518
- | `agent-guard.sh` (attribution, force-push, skipped git hooks, argv secrets, closure confirmations, read-only repos, unattended policy) | PreToolUse `Bash`, file edits, fetch and toolkit tools | none | none |
518
+ | `agent-guard.sh` (attribution, force-push, skipped git hooks, argv secrets, closure confirmations, read-only repos, your own `guardRules`, unattended policy) | PreToolUse `Bash`, file edits, fetch and toolkit tools | none | none |
519
519
  | `run-scope-guard.sh` (Figma phase rule, worktree boundary warning) | PreToolUse Figma tools, file edits | none: the phase records its own MCP calls | none |
520
520
  | `run-stop-guard.sh` (no silent stop mid-run) | Stop | none: halts stay the phase's own write | none |
521
521
  | `task-mirror.sh` (native task list into the run tracker, so the office shows it) | PostToolUse `TaskCreate`/`TaskUpdate` | none: the phase calls `phase-tracker.sh task` itself | none: the phase calls `phase-tracker.sh task` itself |
@@ -524,11 +524,14 @@ The **secret scan** runs as a `PreToolUse` hook on Claude Code (hard-blocks a co
524
524
  | `note-agent-event.sh` (a subagent's outcome or a failed tool call, into the session notes) | SubagentStop, PostToolUseFailure | none | none |
525
525
  | `answer-check.sh` (an AskUserQuestion submitted without a choice is asked again, not defaulted) | PostToolUse `AskUserQuestion` | none | none |
526
526
  | `note-skill-use.sh` (skill name, outcome, time, host and repo folder name into a local log, so unused skills can be pruned on evidence; never arguments, prompts or output) | PostToolUse / PostToolUseFailure `Skill` | none: Codex reads skill files, no tool call to hook | none: no Copilot hooks are installed |
527
+ | `note-mcp-failure.sh` (server, tool, time and a closed error class of a failed MCP call into a local log, read by doctor's `mcp-failures` check; never arguments, output or error text) | PostToolUseFailure `mcp__.*` | none | none: no Copilot hooks are installed |
527
528
  | `edit-syntax-gate.sh` | PostToolUse file edits | PostToolUse `apply_patch` | none: Copilot discards postToolUse output |
528
529
  | `check-read-size.sh`, capture hooks | registered | none | none |
529
530
 
530
531
  Where a host has no equivalent hook the rule is still in the phase documents; it is a request there, not enforcement.
531
532
 
533
+ **Your own guard rules.** `prefs.global.guardRules` adds rules to `agent-guard.sh`: each names a tool (`Bash`, `Edit`, `Write`, `Read` or a toolkit tool glob), a regex and an action (`warn`, `ask` or `block`). A rule can only make the guard stricter, never allow what it refuses, and unattended an `ask` is a `block`. Messages name the rule id and reason, never the matched text, and `/multi-agent:doctor` (`guard-rules`) reports an invalid rule and one whose tool the guard is not registered on, such as `Read` under the default hooks, warns when the preferences file does not parse (unattended, that refuses every call a rule could govern when the file names `guardRules`), and names a rule whose pattern has a slow shape, which still runs under a 1-second matching budget. [Unattended security](./pipeline/multi-agent-refs/features/unattended-security.md#user-guard-rules)
534
+
532
535
  ## Outside a pipeline run
533
536
 
534
537
  Installing the pipeline is not only useful when you run it. Open an ordinary session and the same three things are available, announced by `rules/outside-the-pipeline.md` which loads with every conversation:
package/README.tr.md CHANGED
@@ -515,7 +515,7 @@ triage notu bunu belirtir.
515
515
  | Hook | Claude Code | Codex CLI | Copilot CLI |
516
516
  | --- | --- | --- | --- |
517
517
  | `pre-commit-check.sh` (secret taraması, sahipli yollar, attended build/test kanıtı, unattended defteri) | PreToolUse `Bash` | yok: pre-push kontrolü | yok: pre-push kontrolü |
518
- | `agent-guard.sh` (atıf, force-push, atlanan git hook'ları, argv'de secret, kapanış onayları, salt okunur repolar, unattended politikası) | PreToolUse `Bash`, dosya düzenlemeleri, fetch ve toolkit araçları | yok | yok |
518
+ | `agent-guard.sh` (atıf, force-push, atlanan git hook'ları, argv'de secret, kapanış onayları, salt okunur repolar, kendi `guardRules` kuralların, unattended politikası) | PreToolUse `Bash`, dosya düzenlemeleri, fetch ve toolkit araçları | yok | yok |
519
519
  | `run-scope-guard.sh` (Figma faz kuralı, worktree sınırı uyarısı) | PreToolUse Figma araçları, dosya düzenlemeleri | yok: faz kendi MCP çağrılarını kaydeder | yok |
520
520
  | `run-stop-guard.sh` (koşu ortasında sessizce durmaz) | Stop | yok: duraklama fazın kendi yazımı olarak kalır | yok |
521
521
  | `task-mirror.sh` (terminaldeki görev listesini koşunun takipçisine yazar, ofis de onu gösterir) | PostToolUse `TaskCreate`/`TaskUpdate` | yok: faz `phase-tracker.sh task`'ı kendisi çağırır | yok: faz `phase-tracker.sh task`'ı kendisi çağırır |
@@ -523,11 +523,14 @@ triage notu bunu belirtir.
523
523
  | `graph-hint.sh` (tüm repoda bir tanımlayıcı aranırken güncel kod grafiğini önerir, oturumda bir kez) | PreToolUse `Grep`/`Glob` | yok | yok |
524
524
  | `note-agent-event.sh` (alt ajanın sonucunu ya da başarısız araç çağrısını oturum notlarına yazar) | SubagentStop, PostToolUseFailure | yok | yok |
525
525
  | `note-skill-use.sh` (skill adı, sonuç, zaman, host ve repo klasör adı yerel bir loga yazılır; kullanılmayan skill'ler kanıtla ayıklanır; argüman, prompt ve çıktı asla yazılmaz) | PostToolUse / PostToolUseFailure `Skill` | yok: Codex skill dosyalarını okur, yakalanacak araç çağrısı yok | yok: Copilot hook'u kurulmaz |
526
+ | `note-mcp-failure.sh` (başarısız bir MCP çağrısının sunucusu, aracı, zamanı ve hata sınıfı yerel bir loga yazılır, doctor'ın `mcp-failures` kontrolü bunu okur; argüman, çıktı ve hata metni asla yazılmaz) | PostToolUseFailure `mcp__.*` | yok | yok: Copilot hook'u kurulmaz |
526
527
  | `edit-syntax-gate.sh` | PostToolUse dosya düzenlemeleri | PostToolUse `apply_patch` | yok: Copilot postToolUse çıktısını atar |
527
528
  | `check-read-size.sh`, capture hook'ları | kayıtlı | yok | yok |
528
529
 
529
530
  Bir host'ta eşdeğer hook yoksa kural yine faz dokümanlarında durur; orada zorlama değil, bir istektir.
530
531
 
532
+ **Kendi guard kuralların.** `prefs.global.guardRules`, `agent-guard.sh`'a kural ekler: her kural bir araç (`Bash`, `Edit`, `Write`, `Read` ya da bir toolkit araç glob'u), bir regex ve bir eylem (`warn`, `ask` ya da `block`) belirtir. Bir kural guard'ı yalnızca sıkılaştırır, onun reddettiğine asla izin vermez. Gözetimsiz koşuda `ask` bir `block` olur. Mesajlar kuralın id'sini ve gerekçesini verir, eşleşen metni asla yazmaz. Geçersiz bir kuralı ya da aracında guard kayıtlı olmayan bir kuralı (varsayılan hook'larda `Read` gibi) `/multi-agent:doctor` (`guard-rules`) bildirir. Tercih dosyası ayrıştırılamazsa da uyarır; gözetimsiz koşuda bu durum, bir kuralın kapsayabileceği her çağrıyı reddeder. [Gözetimsiz güvenlik](./pipeline/multi-agent-refs/features/unattended-security.md#user-guard-rules)
533
+
531
534
  ## Pipeline koşusu dışında
532
535
 
533
536
  Pipeline'ı kurmak yalnız onu çalıştırdığında işe yaramıyor. Sıradan bir oturum açtığında aynı üç şey elinin altında; her sohbette yüklenen `rules/outside-the-pipeline.md` bunları duyuruyor:
@@ -0,0 +1,143 @@
1
+ # 19. A product tree over the code graph, measured before it is trusted
2
+
3
+ **Status:** Accepted (ships off; M0 verdict NO-GO) · 2026-11-02 · extends [ADR-0010](./0010-own-code-graph.md)
4
+
5
+ ## Context
6
+
7
+ A bug report is written in the words a person saw: a button label, a screen,
8
+ a step in a flow. The code graph (ADR-0010) knows files and symbols, and it
9
+ scored 63% on questions phrased in domain words against near-perfect scores
10
+ on questions that named a type. The gap is the vocabulary between the two.
11
+
12
+ The proposed answer is a screen layer joined over the graph: localized text,
13
+ string key, route, screen, the files a screen owns, the endpoints it calls,
14
+ the tests that name it. The literature on bug localization (BM25F over
15
+ structured fields, query expansion through UI strings, graph-seeded ranking)
16
+ reports gains from exactly these joins, but on other corpora and with other
17
+ baselines. Before the pipeline relies on such a layer, it has to beat the
18
+ graph it sits on, on bugs it has not been tuned on.
19
+
20
+ ## Decision
21
+
22
+ Build the layer deterministically, keep it local, and gate its use on a
23
+ measurement.
24
+
25
+ - `pipeline/scripts/product-tree.mjs build` derives
26
+ `~/.claude/knowledge/<project>/product-tree.json` (0600, never shipped)
27
+ without a model. SwiftUI: views named Screen, Scene or Page, every
28
+ navigation target (links by destination, closure and value,
29
+ `navigationDestination` over a route enum, sheets, covers, stack roots,
30
+ tabs, scenes) and coordinators that host a view, which become flow nodes.
31
+ Compose: `composable`, `dialog`, `bottomSheet` and Navigation 3 `entry`
32
+ registrations, `@Serializable` route types, start destinations, one hop
33
+ through a wrapper composable. Web: Next.js `app/` and `pages/` routes when a
34
+ `package.json` depends on Next, app router API handlers, react-router tables
35
+ and `<Route>` elements. Strings from `.strings`, `.xcstrings`,
36
+ `strings.xml` and i18n JSON; endpoints from Retrofit annotations, route
37
+ handlers and API-shaped literals; tests by the screen names they contain.
38
+ - Programmatic navigation is counted and each call is resolved only when its
39
+ argument is a literal route or a view constructor. The rest are listed with
40
+ file and line. Coverage is reported per stack, never assumed.
41
+ - `locate` ranks files under three arms that share one implementation with the
42
+ evaluation: BM25F over names, symbols and directories; the same plus query
43
+ expansion through matched UI strings, a UI-string ranking, personalized
44
+ PageRank over the import and reference edges, Turkish-aware folding and
45
+ stemming, and identifier splitting; and the screen layer on top.
46
+ - The model only proposes, with evidence that resolves to a line of a
47
+ regular file inside the repository, into an append-only overlay. Proposing
48
+ the same thing again leaves an earlier decision in place. `agree` and
49
+ `reject` are refused in an unattended run and without a terminal. The
50
+ terminal check stops a piped shell but not an agent that allocates a
51
+ pseudo-terminal, so agent-guard is the layer that asks before an agent's
52
+ `agree` or `reject` and refuses a file tool aimed at the overlay. No
53
+ ranking reads the overlay yet: agreed rows are planned to feed `locate` in
54
+ M2.
55
+ - The repository is untrusted input. The build reads only regular files
56
+ inside the root, up to the same 2 MB limit the evaluation uses, never
57
+ through a symlink; every git call turns off the repository's fsmonitor,
58
+ hooks, external diff, pager, signature checks and gpg programs, and reads
59
+ no global or system config. `locate` and `show` print their result inside
60
+ one untrusted-data block. A repository listed in
61
+ `prefs.global.memory.excludeProjects` gets no tree.
62
+ - `prefs.global.productTree.enabled` defaults to `false`. When on, Phase 0
63
+ locates the task and Phase 1 injects the result, cut by `fitToBudget` to
64
+ `productTree.maxChars` (6,000).
65
+
66
+ ## Measurement
67
+
68
+ This measurement is the M0 gate; M1 is the Phase 0/1 wiring; M2 is derived flows and agreed overlay rows read by locate.
69
+
70
+ `product-tree-eval.mjs` mines bug-fix commits from git history, rebuilds the
71
+ graph and the tree at each fix commit's parent from git objects, ranks files
72
+ for the commit subject (conventional prefix and PR number removed) and scores
73
+ them against the production files the fix modified. Every arm is cut to the
74
+ same 6,000-character budget before scoring. Bugs are split by time per
75
+ repository: ranking settings were grid-searched on the older half only, and
76
+ the verdict is read from the newer half. Bugs whose text already names a file,
77
+ symbol or stack frame are reported apart.
78
+
79
+ Corpus: nine repositories, of which eight yielded qualifying fixes, 60 per
80
+ repository (480 bugs): two Node tooling repositories, three web applications
81
+ (two Next.js, one React single-page app), one Compose app, one SwiftUI macOS
82
+ app and one iOS app that mixes SwiftUI with UIKit.
83
+
84
+ Held-out, domain-text bugs (n = 230), recall@10 with a 95% bootstrap interval:
85
+
86
+ | Arm | Acc@1 | Acc@5 | Acc@10 | R@1 | R@5 | R@10 | MRR | Mean chars |
87
+ | ----- | ----- | ----- | ------ | ----- | ----- | --------------------- | ----- | ---------- |
88
+ | bm25 | 29.1% | 50.4% | 57.4% | 19.5% | 38.6% | 45.7% [40.1, 51.1] | 0.393 | 2,552 |
89
+ | graph | 29.1% | 51.3% | 58.3% | 19.5% | 39.5% | 47.1% [41.3, 52.8] | 0.396 | 4,014 |
90
+ | tree | 27.8% | 50.4% | 57.8% | 19.2% | 39.1% | 46.5% [40.9, 52.3] | 0.382 | 4,038 |
91
+
92
+ Tree against graph: hit@10 discordant pairs 3 (graph only) and 2 (tree only),
93
+ exact McNemar p = 1.0; recall@10 difference -0.6 points, interval
94
+ [-1.5, +0.4]. Per repository the tree arm was lower than the graph arm on
95
+ four of eight (between -1.2 and -2.0 points), equal on three and higher on
96
+ one (+1.7, the SwiftUI macOS app). On the development half the tuned tree arm led
97
+ the graph arm by 0.8 points (46.3% against 45.5%, n = 220), which did not
98
+ survive to the held-out half. The ten held-out bugs that name code scored
99
+ 54.5% under bm25 and graph and 42.0% under the tree.
100
+
101
+ Screen-index coverage at each repository's head: Compose 5 of 6 screens
102
+ reachable, 3 of 4 programmatic calls resolved; SwiftUI macOS 16 of 28
103
+ reachable, 0 of 22 programmatic; the mixed iOS app 45 of 92 reachable, 8 of
104
+ 25 enum routes with a screen, 0 of 286 programmatic calls resolved (almost all
105
+ UIKit pushes and presents of view controllers); web apps reach every screen by
106
+ construction, since a web screen is a route target, and resolved 20% to 40% of
107
+ programmatic navigation calls.
108
+
109
+ **Verdict: NO-GO.** The rule was a recall@10 lift of at least 15 points,
110
+ McNemar p below 0.05 and no repository regressing. None of the three held.
111
+
112
+ ## Consequences
113
+
114
+ - The tree ships off. Nothing in a default run builds or reads it.
115
+ - The non-tree signals (UI-string expansion and boost, PageRank) gave 1.4
116
+ points over plain BM25F on held-out bugs, inside the noise. They are not
117
+ moved into graph-query on this evidence.
118
+ - iOS programmatic navigation is the measured weak point: an app that
119
+ navigates through UIKit coordinators has half its screens unreachable and
120
+ no resolved programmatic call. Flows (M2) cannot be derived for such apps
121
+ from regex alone.
122
+ - Commit subjects are short and written by the developer who fixed the bug;
123
+ they are a weaker proxy for a user's report than issue text. A rerun with
124
+ linked issue bodies, and the optional issue-text-only memorization arm
125
+ (`--issue-text-arm`), is the next measurement before any re-decision.
126
+ - 41.7% of held-out bugs had no changed file in the top 10 under the best
127
+ arm. That is a candidate-recall question; it was not measured past k = 10
128
+ here.
129
+ - The per-bug rows and repository names stay in the harness's report under
130
+ `~/.claude/knowledge/_eval/` (0600); this ADR carries only pooled numbers
131
+ and repository kinds.
132
+
133
+ ## Alternatives considered
134
+
135
+ - **A model-written tree.** Generated repository summaries have lowered agent
136
+ success in published measurements, and a node nobody can re-derive is an
137
+ assertion. The model may propose with evidence; it never writes fact.
138
+ - **Embeddings for the screen match.** Not tried: an embedding model arrives
139
+ as a runtime package or a hosted service, and ADR-0004 keeps runtime
140
+ packages out of the published package. This measurement did not test
141
+ whether they would close the candidate-recall gap; see Consequences.
142
+ - **Shipping on by default on the development-half result.** The 0.8-point
143
+ development lead is the kind of result the time split exists to catch.
@@ -28,6 +28,7 @@ Format: lightly adapted from [Michael Nygard's ADR template](https://cognitect.c
28
28
  | [0016](./0016-the-run-shape-is-asked-not-typed.md) | The shape of a run is asked, not typed into its name | Accepted |
29
29
  | [0017](./0017-change-impact-from-the-graph.md) | Change impact from the graph: spans, a transitive walk, freshness | Accepted |
30
30
  | [0018](./0018-cross-repo-links-not-a-global-graph.md) | Cross-repository links, not a global graph | Accepted |
31
+ | [0019](./0019-product-tree.md) | A product tree over the code graph, measured before it is trusted | Accepted (ships off; M0 verdict NO-GO) |
31
32
 
32
33
  ## Writing a New ADR
33
34
 
package/docs/ecosystem.md CHANGED
@@ -113,14 +113,14 @@ hand-authored *inside* `multi-agent-plugins` and are never touched by sync.
113
113
  <!-- facts: skillCount="skills - single authoring source" -->
114
114
  ```mermaid
115
115
  graph TD
116
- EXT["pipeline/skills/shared/external/<br/>166 skills - single authoring source<br/>(the pipeline's own phases read these too)"]
116
+ EXT["pipeline/skills/shared/external/<br/>167 skills - single authoring source<br/>(the pipeline's own phases read these too)"]
117
117
 
118
- EXT -->|"cross-stack skills"| COMMONP["ai-common-toolkit<br/>19 skills · v0.7.4"]
119
- EXT -->|"outside facts for analysis"| ANAP["ai-analyst-toolkit<br/>5 skills · v0.1.11"]
120
- EXT -->|"Apple/Xcode-only"| IOSP["ai-ios-toolkit<br/>142 skills · v0.25.3"]
121
- EXT -->|"Android/Kotlin-only"| ANDP["ai-android-toolkit<br/>36 skills · v0.6.3"]
122
- EXT -->|"backend-only"| BEP["ai-backend-toolkit<br/>33 skills · v0.4.3"]
123
- EXT -->|"web/frontend-only"| FEP["ai-frontend-toolkit<br/>27 skills · v0.4.2"]
118
+ EXT -->|"cross-stack skills"| COMMONP["ai-common-toolkit"]
119
+ EXT -->|"outside facts for analysis"| ANAP["ai-analyst-toolkit"]
120
+ EXT -->|"Apple/Xcode-only"| IOSP["ai-ios-toolkit"]
121
+ EXT -->|"Android/Kotlin-only"| ANDP["ai-android-toolkit"]
122
+ EXT -->|"backend-only"| BEP["ai-backend-toolkit"]
123
+ EXT -->|"web/frontend-only"| FEP["ai-frontend-toolkit"]
124
124
 
125
125
  COMMONP --> BUMP{"skill set<br/>changed?"}
126
126
  ANAP --> BUMP
@@ -136,7 +136,7 @@ graph TD
136
136
  style EXT fill:#ffd,stroke:#333
137
137
  ```
138
138
 
139
- The plugins' skill counts sum to more than the <!-- fact:skillCount -->166<!-- /fact -->-skill source because each
139
+ Together the plugins carry more skills than the <!-- fact:skillCount -->167<!-- /fact -->-skill source because each
140
140
  plugin also carries its own authored `reference/`, `workflow/` and `tools/`
141
141
  skills and an `index` router. A vendored knowledge skill ships in exactly one
142
142
  plugin: cross-stack skills go to `ai-common-toolkit` rather than into every
@@ -240,7 +240,7 @@ Detail: [`unattended-security.md`](../pipeline/multi-agent-refs/features/unatten
240
240
  ### multi-agent-toolkit-mcp's tools, by category
241
241
 
242
242
  <!-- fact:toolCount -->228<!-- /fact --> tools in <!-- fact:toolFamilyCount -->23<!-- /fact --> families, counted from the server's own `tools/list` response
243
- at toolkit <!-- fact:toolkitVersion -->3.30.1<!-- /fact --> rather than from a README. Three families are defined in
243
+ at toolkit <!-- fact:toolkitVersion -->3.31.0<!-- /fact --> rather than from a README. Three families are defined in
244
244
  modules the main file only spreads in, so a count taken from the source reads
245
245
  low; the response is the only place the whole surface appears at once. A
246
246
  family is the prefix every tool name carries.
package/docs/facts.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$comment": "Generated by pipeline/scripts/gen-facts.mjs. Do not hand-edit: the site reads this, and a number edited here instead of at its source is the drift this file removes.",
3
3
  "generatedAt": "2026-11-03",
4
- "version": "20.40.0",
4
+ "version": "20.41.0",
5
5
  "phaseSchema": 2,
6
6
  "phases": [
7
7
  {
@@ -36,8 +36,8 @@
36
36
  "analysis": [0, 1, 2, 3, 4, 5]
37
37
  },
38
38
  "commandCount": 71,
39
- "skillCount": 166,
40
- "skillCountAll": 240,
39
+ "skillCount": 167,
40
+ "skillCountAll": 241,
41
41
  "agentCount": 11,
42
42
  "hosts": ["Claude Code", "Codex CLI", "Copilot CLI"],
43
43
  "toolCount": 228,
@@ -67,5 +67,5 @@
67
67
  "test": 1
68
68
  },
69
69
  "pluginSkillCount": 262,
70
- "toolkitVersion": "3.30.1"
70
+ "toolkitVersion": "3.31.0"
71
71
  }
package/docs/features.md CHANGED
@@ -68,6 +68,12 @@ Phase 1 queries it to hand Explore a ranked starting file set instead of a full
68
68
 
69
69
  Measured on a 4,300-file Swift app against a grep-and-read baseline at the same 30,000-token retrieval budget: 80.4% key-fact coverage at 18,465 tokens against 66.0% at 24,555. The gain is entirely in searches phrased in domain words (63.3% against 32.0%, at under half the cost). When the task already names an exact type, `grep -lw` is still slightly better and slightly cheaper, and the command says so rather than overselling. Reasoning, trade and limits: `docs/adr/0010-own-code-graph.md`.
70
70
 
71
+ ### Product Tree (`product-tree.mjs`, off by default)
72
+
73
+ A screen layer over the code graph: screens, routes, flows (coordinators), localized strings, endpoints and tests, derived without a model into `~/.claude/knowledge/<project>/product-tree.json`, so a bug written in the words a user saw can reach the files behind that screen. SwiftUI, Compose (including Navigation 3) and Next.js / react-router are read; programmatic navigation is counted and listed when its destination is computed, so coverage is a number rather than an assumption. The model may only propose additions with evidence; a person agrees at a terminal, agent-guard asks before an agent runs `agree` or `reject`, and an unattended run never decides.
74
+
75
+ Measured on 230 held-out bug fixes from eight repositories, the screen layer did not beat the graph-only ranking (recall@10 46.5% against 47.1%, McNemar p = 1.0), so `prefs.global.productTree.enabled` stays `false`. Method, numbers and coverage: `docs/adr/0019-product-tree.md`.
76
+
71
77
  ### Stack Auto-Detection
72
78
 
73
79
  | Platform | Detection | Guide Loaded |
@@ -755,11 +755,13 @@ export function quotePipelineHookCommands(hooks) {
755
755
  * The run-scoped hooks the installer registers beside the two gates above:
756
756
  * run-stop-guard.sh (Stop), task-mirror.sh (TaskCreate / TaskUpdate),
757
757
  * answer-check.sh (AskUserQuestion, in every session: it only adds context),
758
- * file-context.sh (after a Read, and before a Read, Grep or Glob), run-scope-guard.sh (Figma MCP tools, file edits, Figma over HTTP and direct run-state writes in Bash or WebFetch) and note-skill-use.sh (after a Skill call, ok or failed). The run hooks are silent outside a pipeline run (file-context also runs everywhere when prefs.global.fileContext.enabled is true) and fail open, so
758
+ * file-context.sh (after a Read, and before a Read, Grep or Glob), run-scope-guard.sh (Figma MCP tools, file edits, Figma over HTTP and direct run-state writes in Bash or WebFetch), note-skill-use.sh (after a Skill call, ok or failed) and note-mcp-failure.sh (after a failed MCP tool call). The run hooks are silent outside a pipeline run (file-context also runs everywhere when prefs.global.fileContext.enabled is true) and fail open, so
759
759
  * registering them by default changes nothing until a run is active. note-skill-use.sh runs in every
760
760
  * session, records only the skill name, outcome, time, host and repo folder name into the local
761
- * skill-usage log, and is off with prefs.global.skillUsage.enabled false. The same
762
- * entries are in install/templates/claude-hooks.json.
761
+ * skill-usage log, and is off with prefs.global.skillUsage.enabled false. note-mcp-failure.sh
762
+ * records only the server, tool, time and a closed error class into the local MCP failure log,
763
+ * probes nothing, and is off with prefs.global.mcpFailures.enabled false. Both are off with
764
+ * prefs.global.usageLog.optOut true. The same entries are in install/templates/claude-hooks.json.
763
765
  */
764
766
  export const RUN_HOOKS = [
765
767
  {
@@ -831,6 +833,13 @@ export const RUN_HOOKS = [
831
833
  timeout: 5,
832
834
  statusMessage: "Counting the skill call...",
833
835
  },
836
+ {
837
+ event: "PostToolUseFailure",
838
+ matcher: "mcp__.*",
839
+ script: "note-mcp-failure.sh",
840
+ timeout: 5,
841
+ statusMessage: "Counting the failed MCP call...",
842
+ },
834
843
  ];
835
844
 
836
845
  /**
@@ -1,5 +1,5 @@
1
1
  {
2
- "_readme": "Recommended Claude Code hooks for multi-agent-pipeline. `install` registers the pre-commit and agent-guard gates, the run-scoped run-stop-guard / run-scope-guard hooks, the task-mirror hook, the file-context hook and the skill-usage hook itself (install/claude.mjs configureSettings, RUN_HOOKS); /multi-agent:setup offers to merge the rest of this block. Merge the `hooks` object into your ~/.claude/settings.json to make these deterministic PreToolUse gates real (exit 2 blocks the tool call). A PreToolUse matcher is a regex over the TOOL NAME, so each gate registers on a tool name and reads the command from its stdin payload. Three PreToolUse gates ship here: (1) pre-commit-check.sh on Bash, which acts only on a `git commit` and blocks a secret in the staged diff; (2) agent-guard.sh on Bash, on Edit|Write|NotebookEdit, and on WebFetch plus every multi-agent-toolkit tool (WebFetch|mcp__multi-agent-toolkit__.*). Always, it blocks AI/assistant attribution in a commit message and a force-push, delete or mirror push to a protected branch (main/master/develop), including one inside a subshell or a `bash -c` / `eval` line. With MULTI_AGENT_UNATTENDED=1 in the hook's environment it also applies the unattended policy: no push, PR or tracker write, no Keychain read, no fetch outside the host allowlist (curl, WebFetch, the toolkit's web tools, agent_run_steps and open_url), no package install, and no write into a protected path (features/unattended-security.md); (3) check-read-size.sh on Read|Bash, which inspects Read plus the shell commands that read a file whole (cat/head/tail/sed), returns immediately for everything else, and routes an oversized read to a cheap worker instead of the caller's own rung; it is inert until `prefs.global.bulkRead.mode` is set to observe or enforce. Failure behaviour: pre-commit-check.sh and check-read-size.sh fail open on an internal error. agent-guard.sh fails open when attended, so a guard bug cannot break a legitimate tool call, and fails closed under MULTI_AGENT_UNATTENDED=1, where nobody is there to notice a gap. None of the three executes the inspected command, and none needs run-specific arguments. The other deterministic gates (evidence, consensus, intent, learnings) take run-specific arguments and are phase-enforced by the pipeline instead. Three capture hooks ship alongside them and block nothing: (4) SessionEnd runs capture-flush.sh --if-stale, which writes a run's triage findings and durable learnings into the per-repo stores when the run ended before Phase 5, where those writes otherwise happen; the same hook runs note-session.sh, which records the mechanical shape of a session outside the pipeline (tools used, commands that failed, calls the user refused). (4b) SubagentStop and PostToolUseFailure run note-agent-event.sh, which appends one row to the same session notes as the event happens: a subagent's type, id, the bound run's task id and its last message cut to 200 characters (secret-scanned; a hit stores the row without the message), or a failed tool's name and its command's first program word, never an argument or error text. (5) PreCompact runs capture-flush.sh without --if-stale: a compaction summarizes the conversation mid-phase, so it is the moment unflushed findings are at risk, and both writes are idempotent, so a finished run costs two no-op writes. The staleness test exists only so a session exit does not re-flush a run that already finished. (6) SessionStart runs capture-resume.sh, which prints at most two lines: an unfinished run and how to resume it, and a stale pipeline-observation queue. No capture hook calls a model or reads a payload - note-session.sh keeps a command's first word and an exit code, never an argument or any output - and all exit 0 on every path, because a hook that fails a session over bookkeeping costs more than the bookkeeping. A run-scoped PreToolUse gate ships too: (2b) run-scope-guard.sh on every Figma MCP tool (mcp__.*[Ff]igma.*) denies a Figma call above phases.json thresholds.mcpAllowedThroughPhase for the run bound to the session, unless the run is in analysis mode, and records each allowed call into telemetry.mcpCalls[]; on Edit|Write|NotebookEdit the same script warns, attended only, when the target is outside the bound run's worktree (additionalContext for the model, systemMessage for the user; the call proceeds). On Bash|WebFetch|AskUserQuestion it denies a question from a bound autopilot run, a Figma read over HTTP (figma.com or api.figma.com) under the same phase rule, and, in any session, a direct write to agent-state.json or tracker-state.json (Edit/Write, a shell redirect or tee), since write-state.mjs is their only writer; the shell wrapper starts node only when the payload mentions Figma or a state file. Outside a run it is silent, and it fails open. One PostToolUse hook ships as well and blocks nothing: (7) edit-syntax-gate.sh on Edit|Write|MultiEdit parses the file the edit just wrote (swiftc -parse, node --check, py_compile into a temp dir, JSON.parse, bash -n; Kotlin skipped) under a 2 s deadline and, when it no longer parses, hands the model the error as PostToolUse additionalContext; it exits 0 on every path, stays silent when a parser is missing or slow, and is inert until `prefs.global.editSyntaxGate.enabled` is true. A second PostToolUse hook blocks nothing either: (7b) task-mirror.sh on TaskCreate|TaskUpdate mirrors the native task list into the tracker of the run bound to the session (phase-tracker.sh task, tracker-contract.md, \"Mirroring the host's task list\"), skipping phase tiles, so the office panel shows the same list; silent outside a run, exit 0 on every path. A third blocks nothing: (7c) file-context.sh on Read (PostToolUse, and PreToolUse on Read|Grep|Glob) hands the model, once per file per session, what the repo's memory says about the file it reads or searches (ledger facts whose scope covers it, its latest review findings, its open known limits from debt-ledger.mjs) as additionalContext inside an <untrusted-data> block, after the secret scan and fitted to the host's 10,000-character hook output limit; a Grep with a path, or a Glob whose literal directory is inside the repo, is mapped to at most five files the stores know, and a whole-repo search gets nothing; inside a run bound to the session by default, everywhere with prefs.global.fileContext.enabled true, never with it false; exit 0 on every path. A fourth blocks nothing: (7d) answer-check.sh on AskUserQuestion names, as PostToolUse additionalContext, every question the user submitted without a choice, so an empty answer is asked again instead of resolved to the Recommended option; it runs in every session, since it only adds context, and exits 0 on every path. A fifth blocks nothing: (7e) graph-hint.sh on Grep|Glob (PreToolUse) adds, once per session, one line pointing at `/multi-agent:graph ask` and mcp__multi-agent-toolkit__graph_query when the call searches the whole repo for a bare identifier and a current code graph (graphFreshness: build commit is HEAD, no indexed file changed) exists for the repo; silent with prefs.global.codeGraph.enabled false; exit 0 on every path. A sixth blocks nothing: (7f) note-skill-use.sh on Skill (PostToolUse and PostToolUseFailure) appends one row to the local <log root>/skill-usage.jsonl: the skill name (kept only when it matches a strict charset and length and carries no credential pattern, else the call is dropped), ok or error, the time, the host and the repo folder name (null outside a git repository and for a repository in prefs.global.memory.excludeProjects), never the arguments, the prompt or any output; past 1 MiB the log moves to skill-usage.jsonl.1; off with prefs.global.skillUsage.enabled false or prefs.global.usageLog.optOut true; it reads stdin for at most 1.5 s and exits 0 on every path. skill-usage.mjs summary and prune-candidates read it. One Stop hook ships as well: (8) run-stop-guard.sh answers {\"decision\":\"block\"} when the session driving an active pipeline run (bound through agent-state.json sessionId or hostSessionId, never by a worktree match) tries to stop while the run is in_progress below its mode's last phase with no haltReason or waitingFor; the reason says to finish the current phase, record the wait, or record a halt. A turn that ends on a question to the user, a session with background tasks or crons, and prefs.global.stopGuard.enabled false are never held, and run-stop-guard.sh is not registered on SubagentStop: a subagent's stop is the dispatching session's business. After three consecutive blocks it records the halt itself (status paused, haltReason <phase>:stop-guard), which write-state clears when the run advances a phase. It never blocks outside a run and fails open, with a line in <log root>/hook-failures.log, on any error. These registrations are Claude Code's; README \"Hooks per host\" lists which have no equivalent elsewhere. On Codex only the syntax gate is offered, from codex-hooks.json through host-hooks.mjs; Copilot CLI gets none, since as of 1.0.45 it discards postToolUse output; the other gates are Claude Code only. multi-agent:setup offers to merge this block.",
2
+ "_readme": "Recommended Claude Code hooks for multi-agent-pipeline. `install` registers the pre-commit and agent-guard gates, the run-scoped run-stop-guard / run-scope-guard hooks, the task-mirror hook, the file-context hook, the skill-usage hook and the MCP failure hook itself (install/claude.mjs configureSettings, RUN_HOOKS); /multi-agent:setup offers to merge the rest of this block. Merge the `hooks` object into your ~/.claude/settings.json to make these deterministic PreToolUse gates real (exit 2 blocks the tool call). A PreToolUse matcher is a regex over the TOOL NAME, so each gate registers on a tool name and reads the command from its stdin payload. Three PreToolUse gates ship here: (1) pre-commit-check.sh on Bash, which acts only on a `git commit` and blocks a secret in the staged diff; (2) agent-guard.sh on Bash, on Edit|Write|NotebookEdit, and on WebFetch plus every multi-agent-toolkit tool (WebFetch|mcp__multi-agent-toolkit__.*). Always, it blocks AI/assistant attribution in a commit message and a force-push, delete or mirror push to a protected branch (main/master/develop), including one inside a subshell or a `bash -c` / `eval` line. With MULTI_AGENT_UNATTENDED=1 in the hook's environment it also applies the unattended policy: no push, PR or tracker write, no Keychain read, no fetch outside the host allowlist (curl, WebFetch, the toolkit's web tools, agent_run_steps and open_url), no package install, and no write into a protected path (features/unattended-security.md); (3) check-read-size.sh on Read|Bash, which inspects Read plus the shell commands that read a file whole (cat/head/tail/sed), returns immediately for everything else, and routes an oversized read to a cheap worker instead of the caller's own rung; it is inert until `prefs.global.bulkRead.mode` is set to observe or enforce. Failure behaviour: pre-commit-check.sh and check-read-size.sh fail open on an internal error. agent-guard.sh fails open when attended, so a guard bug cannot break a legitimate tool call, and fails closed under MULTI_AGENT_UNATTENDED=1, where nobody is there to notice a gap. None of the three executes the inspected command, and none needs run-specific arguments. The other deterministic gates (evidence, consensus, intent, learnings) take run-specific arguments and are phase-enforced by the pipeline instead. Three capture hooks ship alongside them and block nothing: (4) SessionEnd runs capture-flush.sh --if-stale, which writes a run's triage findings and durable learnings into the per-repo stores when the run ended before Phase 5, where those writes otherwise happen; the same hook runs note-session.sh, which records the mechanical shape of a session outside the pipeline (tools used, commands that failed, calls the user refused). (4b) SubagentStop and PostToolUseFailure run note-agent-event.sh, which appends one row to the same session notes as the event happens: a subagent's type, id, the bound run's task id and its last message cut to 200 characters (secret-scanned; a hit stores the row without the message), or a failed tool's name and its command's first program word, never an argument or error text. (5) PreCompact runs capture-flush.sh without --if-stale: a compaction summarizes the conversation mid-phase, so it is the moment unflushed findings are at risk, and both writes are idempotent, so a finished run costs two no-op writes. The staleness test exists only so a session exit does not re-flush a run that already finished. (6) SessionStart runs capture-resume.sh, which prints at most two lines: an unfinished run and how to resume it, and a stale pipeline-observation queue. No capture hook calls a model or reads a payload - note-session.sh keeps a command's first word and an exit code, never an argument or any output - and all exit 0 on every path, because a hook that fails a session over bookkeeping costs more than the bookkeeping. A run-scoped PreToolUse gate ships too: (2b) run-scope-guard.sh on every Figma MCP tool (mcp__.*[Ff]igma.*) denies a Figma call above phases.json thresholds.mcpAllowedThroughPhase for the run bound to the session, unless the run is in analysis mode, and records each allowed call into telemetry.mcpCalls[]; on Edit|Write|NotebookEdit the same script warns, attended only, when the target is outside the bound run's worktree (additionalContext for the model, systemMessage for the user; the call proceeds). On Bash|WebFetch|AskUserQuestion it denies a question from a bound autopilot run, a Figma read over HTTP (figma.com or api.figma.com) under the same phase rule, and, in any session, a direct write to agent-state.json or tracker-state.json (Edit/Write, a shell redirect or tee), since write-state.mjs is their only writer; the shell wrapper starts node only when the payload mentions Figma or a state file. Outside a run it is silent, and it fails open. One PostToolUse hook ships as well and blocks nothing: (7) edit-syntax-gate.sh on Edit|Write|MultiEdit parses the file the edit just wrote (swiftc -parse, node --check, py_compile into a temp dir, JSON.parse, bash -n; Kotlin skipped) under a 2 s deadline and, when it no longer parses, hands the model the error as PostToolUse additionalContext; it exits 0 on every path, stays silent when a parser is missing or slow, and is inert until `prefs.global.editSyntaxGate.enabled` is true. A second PostToolUse hook blocks nothing either: (7b) task-mirror.sh on TaskCreate|TaskUpdate mirrors the native task list into the tracker of the run bound to the session (phase-tracker.sh task, tracker-contract.md, \"Mirroring the host's task list\"), skipping phase tiles, so the office panel shows the same list; silent outside a run, exit 0 on every path. A third blocks nothing: (7c) file-context.sh on Read (PostToolUse, and PreToolUse on Read|Grep|Glob) hands the model, once per file per session, what the repo's memory says about the file it reads or searches (ledger facts whose scope covers it, its latest review findings, its open known limits from debt-ledger.mjs) as additionalContext inside an <untrusted-data> block, after the secret scan and fitted to the host's 10,000-character hook output limit; a Grep with a path, or a Glob whose literal directory is inside the repo, is mapped to at most five files the stores know, and a whole-repo search gets nothing; inside a run bound to the session by default, everywhere with prefs.global.fileContext.enabled true, never with it false; exit 0 on every path. A fourth blocks nothing: (7d) answer-check.sh on AskUserQuestion names, as PostToolUse additionalContext, every question the user submitted without a choice, so an empty answer is asked again instead of resolved to the Recommended option; it runs in every session, since it only adds context, and exits 0 on every path. A fifth blocks nothing: (7e) graph-hint.sh on Grep|Glob (PreToolUse) adds, once per session, one line pointing at `/multi-agent:graph ask` and mcp__multi-agent-toolkit__graph_query when the call searches the whole repo for a bare identifier and a current code graph (graphFreshness: build commit is HEAD, no indexed file changed) exists for the repo; silent with prefs.global.codeGraph.enabled false; exit 0 on every path. A sixth blocks nothing: (7f) note-skill-use.sh on Skill (PostToolUse and PostToolUseFailure) appends one row to the local <log root>/skill-usage.jsonl: the skill name (kept only when it matches a strict charset and length and carries no credential pattern, else the call is dropped), ok or error, the time, the host and the repo folder name (null outside a git repository and for a repository in prefs.global.memory.excludeProjects), never the arguments, the prompt or any output; past 1 MiB the log moves to skill-usage.jsonl.1; off with prefs.global.skillUsage.enabled false or prefs.global.usageLog.optOut true; it reads stdin for at most 1.5 s and exits 0 on every path. skill-usage.mjs summary and prune-candidates read it. A seventh blocks nothing: (7g) note-mcp-failure.sh on mcp__.* (PostToolUseFailure) appends one row to the local <log root>/mcp-failures.jsonl: the server and tool from the tool name (dropped unless both match a strict charset and length and carry no credential pattern), the time and a closed error class chosen from the error text (a JSON-RPC code first, then a message opening with invalid or validation, then an HTTP status, then fixed patterns), never the arguments, the output or the error text itself; it probes nothing, is written by the same code as the skill-usage log, so it has the same 1 MiB cap and .1 generation, rotates under its own mcp-failures.jsonl.lock, never follows a symlink at the log path, is off with prefs.global.mcpFailures.enabled false or prefs.global.usageLog.optOut true, and exits 0 on every path; doctor's mcp-failures check reads it. One Stop hook ships as well: (8) run-stop-guard.sh answers {\"decision\":\"block\"} when the session driving an active pipeline run (bound through agent-state.json sessionId or hostSessionId, never by a worktree match) tries to stop while the run is in_progress below its mode's last phase with no haltReason or waitingFor; the reason says to finish the current phase, record the wait, or record a halt. A turn that ends on a question to the user, a session with background tasks or crons, and prefs.global.stopGuard.enabled false are never held, and run-stop-guard.sh is not registered on SubagentStop: a subagent's stop is the dispatching session's business. After three consecutive blocks it records the halt itself (status paused, haltReason <phase>:stop-guard), which write-state clears when the run advances a phase. It never blocks outside a run and fails open, with a line in <log root>/hook-failures.log, on any error. These registrations are Claude Code's; README \"Hooks per host\" lists which have no equivalent elsewhere. On Codex only the syntax gate is offered, from codex-hooks.json through host-hooks.mjs; Copilot CLI gets none, since as of 1.0.45 it discards postToolUse output; the other gates are Claude Code only. multi-agent:setup offers to merge this block.",
3
3
  "hooks": {
4
4
  "PreToolUse": [
5
5
  {
@@ -181,6 +181,17 @@
181
181
  "statusMessage": "Counting the skill call..."
182
182
  }
183
183
  ]
184
+ },
185
+ {
186
+ "matcher": "mcp__.*",
187
+ "hooks": [
188
+ {
189
+ "type": "command",
190
+ "command": "bash \"$HOME/.claude/scripts/note-mcp-failure.sh\"",
191
+ "timeout": 5,
192
+ "statusMessage": "Counting the failed MCP call..."
193
+ }
194
+ ]
184
195
  }
185
196
  ],
186
197
  "PreCompact": [