@mmerterden/multi-agent-pipeline 23.2.0 → 23.4.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 (230) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +25 -6
  3. package/README.tr.md +26 -7
  4. package/docs/adr/0008-installer-modularization-and-secret-leak-defense.md +1 -1
  5. package/docs/adr/0010-own-code-graph.md +299 -8
  6. package/docs/architecture.md +3 -3
  7. package/docs/ecosystem.md +10 -10
  8. package/docs/engineering.md +4 -4
  9. package/docs/facts.json +8 -8
  10. package/docs/features.md +6 -6
  11. package/docs/performance.md +17 -17
  12. package/install/_dev-only-files.mjs +9 -0
  13. package/install/claude.mjs +28 -2
  14. package/install/templates/claude-hooks.json +32 -1
  15. package/manifest.json +229 -161
  16. package/package.json +11 -3
  17. package/pipeline/commands/multi-agent/SKILL.md +1 -1
  18. package/pipeline/commands/multi-agent/design-check/SKILL.md +2 -2
  19. package/pipeline/commands/multi-agent/diff-explain/SKILL.md +3 -3
  20. package/pipeline/commands/multi-agent/fable-status/SKILL.md +1 -1
  21. package/pipeline/commands/multi-agent/graph/SKILL.md +57 -24
  22. package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
  23. package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
  24. package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
  25. package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
  26. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  27. package/pipeline/contract/CHANGELOG.md +49 -0
  28. package/pipeline/contract/build.mjs +13 -1
  29. package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
  30. package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
  31. package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
  32. package/pipeline/contract/fixtures/runs-empty.json +1 -1
  33. package/pipeline/contract/fixtures/runs-failed.json +4 -1
  34. package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
  35. package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
  36. package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
  37. package/pipeline/contract/fixtures/runs-running.json +4 -1
  38. package/pipeline/contract/manifest.json +28 -15
  39. package/pipeline/contract/types/index.d.ts +55 -3
  40. package/pipeline/lib/detach-self.mjs +95 -0
  41. package/pipeline/lib/model-rung.sh +1 -1
  42. package/pipeline/lib/public-mcp-servers.mjs +33 -0
  43. package/pipeline/lib/rotated-log.mjs +93 -0
  44. package/pipeline/lib/tls-trust.mjs +29 -0
  45. package/pipeline/lib/usage-lifecycle.mjs +9 -11
  46. package/pipeline/lib/usage-names.generated.mjs +614 -0
  47. package/pipeline/lib/usage-run-key.mjs +235 -0
  48. package/pipeline/lib/usage-vocab.mjs +210 -0
  49. package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
  50. package/pipeline/multi-agent-refs/analysis/render.md +1 -1
  51. package/pipeline/multi-agent-refs/channels/generator.md +4 -5
  52. package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
  53. package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
  54. package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
  55. package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
  56. package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
  57. package/pipeline/multi-agent-refs/features/model-fallback.md +9 -7
  58. package/pipeline/multi-agent-refs/features/remote-control.md +252 -0
  59. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  60. package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
  61. package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
  62. package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
  63. package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
  64. package/pipeline/multi-agent-refs/features/usage-reporting.md +252 -24
  65. package/pipeline/multi-agent-refs/help/en.md +3 -2
  66. package/pipeline/multi-agent-refs/help/tr.md +3 -2
  67. package/pipeline/multi-agent-refs/knowledge.md +1 -1
  68. package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +1 -1
  69. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +1 -1
  70. package/pipeline/multi-agent-refs/phases/operations.md +2 -2
  71. package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
  72. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
  73. package/pipeline/multi-agent-refs/phases/phase-3-review.md +5 -3
  74. package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
  75. package/pipeline/multi-agent-refs/platform-parity.md +2 -2
  76. package/pipeline/multi-agent-refs/review/panel.md +1 -1
  77. package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
  78. package/pipeline/office/index.html +1207 -233
  79. package/pipeline/office/toolkit.json +1 -1
  80. package/pipeline/rules/outside-the-pipeline.md +1 -1
  81. package/pipeline/schemas/activity.schema.json +23 -0
  82. package/pipeline/schemas/agent-state.schema.json +6 -1
  83. package/pipeline/schemas/code-graph-calls.schema.json +254 -0
  84. package/pipeline/schemas/code-graph-docs.schema.json +223 -0
  85. package/pipeline/schemas/code-graph-infra.schema.json +227 -0
  86. package/pipeline/schemas/code-graph.schema.json +2 -2
  87. package/pipeline/schemas/examples/design-check-config.json +27 -0
  88. package/pipeline/schemas/learning-curve.schema.json +67 -0
  89. package/pipeline/schemas/office-jobs.json +69 -2
  90. package/pipeline/schemas/office-jobs.schema.json +8 -1
  91. package/pipeline/schemas/phases.json +5 -0
  92. package/pipeline/schemas/phases.schema.json +8 -0
  93. package/pipeline/schemas/prefs.schema.json +46 -12
  94. package/pipeline/schemas/runs-index.schema.json +17 -0
  95. package/pipeline/schemas/toolkit-path-params.json +84 -8
  96. package/pipeline/scripts/README.md +1 -0
  97. package/pipeline/scripts/_code-graph.mjs +184 -103
  98. package/pipeline/scripts/_contract-core.mjs +1 -1
  99. package/pipeline/scripts/_contract-routes-office.mjs +21 -0
  100. package/pipeline/scripts/_diff-impact.mjs +21 -2
  101. package/pipeline/scripts/_graph-sidecars.mjs +372 -0
  102. package/pipeline/scripts/_http-post.mjs +103 -115
  103. package/pipeline/scripts/_safe-read.mjs +57 -0
  104. package/pipeline/scripts/_skill-practices.mjs +26 -0
  105. package/pipeline/scripts/_strip-code.mjs +380 -0
  106. package/pipeline/scripts/activity-snapshot.mjs +13 -1
  107. package/pipeline/scripts/aggregate-metrics.mjs +3 -5
  108. package/pipeline/scripts/call-graph/index.mjs +78 -0
  109. package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
  110. package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
  111. package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
  112. package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
  113. package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
  114. package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
  115. package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
  116. package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
  117. package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
  118. package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
  119. package/pipeline/scripts/call-graph/lex.mjs +396 -0
  120. package/pipeline/scripts/call-graph/platform.mjs +86 -0
  121. package/pipeline/scripts/call-graph/profiles.mjs +89 -0
  122. package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
  123. package/pipeline/scripts/call-graph/scan.mjs +267 -0
  124. package/pipeline/scripts/code-graph-rules/android.json +7 -2
  125. package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
  126. package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
  127. package/pipeline/scripts/code-graph-rules/go.json +2 -1
  128. package/pipeline/scripts/code-graph-rules/ios.json +3 -1
  129. package/pipeline/scripts/code-graph-rules/java.json +76 -0
  130. package/pipeline/scripts/code-graph-rules/node.json +7 -2
  131. package/pipeline/scripts/code-graph-rules/python.json +6 -2
  132. package/pipeline/scripts/code-graph-rules/rust.json +105 -0
  133. package/pipeline/scripts/contract-server.mjs +1 -0
  134. package/pipeline/scripts/cost-table.json +6 -5
  135. package/pipeline/scripts/feedback-send.mjs +26 -26
  136. package/pipeline/scripts/gate-ledger.mjs +2 -1
  137. package/pipeline/scripts/gen-usage-names.mjs +124 -0
  138. package/pipeline/scripts/graph-affected.mjs +109 -20
  139. package/pipeline/scripts/graph-build.mjs +95 -15
  140. package/pipeline/scripts/graph-export.mjs +272 -0
  141. package/pipeline/scripts/graph-hint.mjs +15 -2
  142. package/pipeline/scripts/graph-query.mjs +305 -26
  143. package/pipeline/scripts/graph-report.mjs +187 -1
  144. package/pipeline/scripts/health-report.mjs +3 -4
  145. package/pipeline/scripts/infra/docs.mjs +317 -0
  146. package/pipeline/scripts/infra/extract.mjs +998 -0
  147. package/pipeline/scripts/infra/graph.mjs +245 -0
  148. package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
  149. package/pipeline/scripts/job-launch.mjs +67 -2
  150. package/pipeline/scripts/learning-curve.mjs +288 -178
  151. package/pipeline/scripts/log-metric.sh +10 -1
  152. package/pipeline/scripts/note-agent-event.mjs +3 -4
  153. package/pipeline/scripts/note-command-use.mjs +333 -0
  154. package/pipeline/scripts/note-command-use.sh +126 -0
  155. package/pipeline/scripts/note-mcp-call.sh +89 -0
  156. package/pipeline/scripts/note-mcp-failure.mjs +272 -1
  157. package/pipeline/scripts/note-session.sh +62 -3
  158. package/pipeline/scripts/note-skill-use.mjs +58 -2
  159. package/pipeline/scripts/office-build.mjs +115 -1
  160. package/pipeline/scripts/office-memory.mjs +14 -5
  161. package/pipeline/scripts/pair.mjs +333 -0
  162. package/pipeline/scripts/pre-push-check.sh +1 -1
  163. package/pipeline/scripts/remote/cbor.mjs +128 -0
  164. package/pipeline/scripts/remote/contract.mjs +98 -0
  165. package/pipeline/scripts/remote/handler.mjs +317 -0
  166. package/pipeline/scripts/remote/handles.mjs +57 -0
  167. package/pipeline/scripts/remote/lifecycle.mjs +186 -0
  168. package/pipeline/scripts/remote/listener.mjs +204 -0
  169. package/pipeline/scripts/remote/lockout.mjs +103 -0
  170. package/pipeline/scripts/remote/nonces.mjs +61 -0
  171. package/pipeline/scripts/remote/pairing.mjs +519 -0
  172. package/pipeline/scripts/remote/qr-encode.mjs +459 -0
  173. package/pipeline/scripts/remote/store.mjs +188 -0
  174. package/pipeline/scripts/remote/transport.mjs +211 -0
  175. package/pipeline/scripts/remote/verbs.json +70 -0
  176. package/pipeline/scripts/remote/verbs.mjs +217 -0
  177. package/pipeline/scripts/remote/webauthn.mjs +169 -0
  178. package/pipeline/scripts/remote/wire.mjs +364 -0
  179. package/pipeline/scripts/remote-listener.mjs +83 -0
  180. package/pipeline/scripts/route-learn.mjs +4 -4
  181. package/pipeline/scripts/run-kill.mjs +1 -1
  182. package/pipeline/scripts/run-write.mjs +13 -2
  183. package/pipeline/scripts/runs-index.mjs +30 -3
  184. package/pipeline/scripts/search-logs.sh +9 -0
  185. package/pipeline/scripts/session-brief.mjs +458 -0
  186. package/pipeline/scripts/session-brief.sh +130 -0
  187. package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
  188. package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
  189. package/pipeline/scripts/test-gap-rules/java.json +20 -0
  190. package/pipeline/scripts/test-gap-rules/rust.json +14 -0
  191. package/pipeline/scripts/token-budget-report.mjs +3 -2
  192. package/pipeline/scripts/uninstall.mjs +29 -0
  193. package/pipeline/scripts/usage-access.mjs +16 -31
  194. package/pipeline/scripts/usage-health.mjs +31 -62
  195. package/pipeline/scripts/usage-register-beacon.mjs +11 -22
  196. package/pipeline/scripts/usage-register.mjs +39 -29
  197. package/pipeline/scripts/usage-report.mjs +579 -178
  198. package/pipeline/scripts/validate-code-graph.mjs +361 -111
  199. package/pipeline/scripts/write-state.mjs +39 -0
  200. package/pipeline/skills/.skill-manifest.json +22 -18
  201. package/pipeline/skills/.skills-index.json +13 -2
  202. package/pipeline/skills/shared/README.md +5 -4
  203. package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
  204. package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
  205. package/pipeline/skills/shared/core/multi-agent-fable-status/SKILL.md +1 -1
  206. package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
  207. package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
  208. package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
  209. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  210. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
  211. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
  212. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
  213. package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
  214. package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
  215. package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
  216. package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
  217. package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
  218. package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
  219. package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
  220. package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
  221. package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
  222. package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
  223. package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
  224. package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
  225. package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
  226. package/pipeline/skills/skills-index.md +3 -2
  227. package/docs/FIGMA_PIPELINE.md +0 -137
  228. package/pipeline/lib/identifier-scan.mjs +0 -156
  229. package/pipeline/scripts/publish-staged.mjs +0 -324
  230. package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
@@ -5,6 +5,8 @@
5
5
  - [Impact of a change, not of a name](#impact-of-a-change-not-of-a-name)
6
6
  - [Who implements this](#who-implements-this)
7
7
  - [How two symbols connect](#how-two-symbols-connect)
8
+ - [Who calls this](#who-calls-this)
9
+ - [Configuration, documentation and rationale](#configuration-documentation-and-rationale)
8
10
  - [Confirming with a language server](#confirming-with-a-language-server)
9
11
  - [Phase 5 Step 3 - refresh after the branch changed code](#phase-5-step-3---refresh-after-the-branch-changed-code)
10
12
  - [What the report answers that a file-level view cannot](#what-the-report-answers-that-a-file-level-view-cannot)
@@ -106,10 +108,143 @@ every file that imports it. On Android, a capitalised `fun` (in practice a
106
108
  Compose UI function) is a symbol of kind `composable`, so screens and
107
109
  components take part like types.
108
110
 
111
+ ### Who calls this
112
+
113
+ `calls` edges run from the function that contains a call to the function,
114
+ method or type it reaches, in Swift, Kotlin, TypeScript and JavaScript, Python,
115
+ Go, Rust, Java, C#, C and C++. They live in a sidecar, `<graph>.calls.json`,
116
+ built by default and joined in memory by `graph-query`, `graph-affected`,
117
+ `graph-report`, `graph-export` and `graph-hint`; the main graph file does not
118
+ change. When the sidecar is absent, stale, built against another graph or
119
+ truncated, the answer carries a note saying so (`notes` in `--json`, a line in
120
+ text output), and a caller list is then a lower bound, not a complete one.
121
+
122
+ Everything that is consumed without a person choosing it reads edges of medium
123
+ confidence and better by default: `--callers`, `--callees`, `--path`,
124
+ `graph-affected`, the report's most-called table and `graph-export`. Low edges
125
+ appear only with `--min-confidence low` (query, path, export) and are labelled
126
+ as leads.
127
+
128
+ Each edge carries `via` (typed-receiver, implicit-self, constructor,
129
+ interface-member, dispatch, import, same-file, same-directory, unique-name,
130
+ name-arity...) and a `confidence`:
131
+
132
+ - `high`: a binding was resolved: same file, an import into a repo file, a
133
+ member of the enclosing type, a member of the receiver's declared type, or
134
+ package-wide visibility in Go, Java, Kotlin, C# and Swift.
135
+ - `medium`: inference: a chain of return types, a dispatch to implementers, a
136
+ weak receiver match, a name unique in the repo in a language without per-name
137
+ imports.
138
+ - `low`: name and argument count only, or an import followed that did not reach
139
+ the definition. A bare same-directory match in JavaScript, TypeScript and
140
+ Python is at most `low`.
141
+
142
+ A name imported from outside the repo (`node:test`, a package) produces no
143
+ edge. A guess is never `certain`.
144
+
145
+ ```bash
146
+ node $HOME/.claude/scripts/graph-query.mjs --callers "Cache.store" --graph "$GRAPH_PATH" --depth 3
147
+ node $HOME/.claude/scripts/graph-query.mjs --callees "Service.notify" --graph "$GRAPH_PATH" --min-confidence medium
148
+ node $HOME/.claude/scripts/graph-affected.mjs "Cache.store" --graph "$GRAPH_PATH"
149
+ ```
150
+
151
+ `affected` follows `calls` only into a function or method that is itself a seed,
152
+ then through each caller, and reports files. It follows edges of high and medium
153
+ confidence and never a `low` one; every row carries its confidence and `via`,
154
+ and a dependent reached only through medium edges is marked so it can be
155
+ confirmed before it is reported. For a type it follows imports,
156
+ references and inheritance as before. Methods a type declares are nodes with
157
+ `symbolKind: "method"` and an `owner`. Call edges never feed degree, so hubs
158
+ and the free-text ranking stay as they were.
159
+
160
+ What a bare name may denote (ADR 0010 has the reasoning): a type nested in
161
+ another type only from inside that type or an extension of it, or written
162
+ qualified; a platform name (`URL`, `Date`, `Timeline`, `print`, `Map`, ...) only
163
+ when the repository declaration is in lexical scope; in Swift, a declaration in
164
+ another build target only when the caller's target can see it (its own target, a
165
+ module it imports, or, in a test target, the app target it is named after;
166
+ otherwise `low`). JavaScript and TypeScript arity ranks candidates and never
167
+ rejects one; a function declared inside another is visible to the closures in
168
+ it; `import { x } from m; export { x }`, `export { x } from m` and
169
+ `export * from m` are followed to the definition.
170
+
171
+ Measuring it. Three dev-only scripts, run from a checkout, with pinned seeds
172
+ (7 this repository, 278 a Next.js site, 11 a Swift app):
173
+
174
+ - `eval-call-sample.mjs --graph G --root R --confidence high --n 40 --seed 7`
175
+ prints edges to read by hand: the caller's lines that name the callee and the
176
+ callee's declaration.
177
+ - `eval-call-recall.mjs bare|member --graph G --root R [--n 40] [--seed 7]`
178
+ counts the calls a reader can see that are edges. `bare` is JavaScript and
179
+ TypeScript over the whole population (this repository 99.7%, the site 99.9%);
180
+ `member` samples functions in any language and over-counts, because a call on
181
+ a library object that shares a repository name counts as a miss.
182
+ - `eval-call-scope.mjs --graph G --root R` counts the `high` edges the Swift
183
+ scope rules rule out (a nested type reached from outside its outer type, a
184
+ platform-named symbol reached from another file). Both counts must be zero.
185
+
186
+ Edges by confidence on those trees: this repository 13,249 high / 66 medium /
187
+ 453 low; the site 3,915 / 1 / 0; the Swift app 3,629 / 1,371 / 165. A sample of
188
+ 40 with no error bounds the error rate at about 7% with 95% confidence, 8 with no
189
+ error at about 38%. A `low` edge is an unresolved binding: often right in
190
+ script-style code that shares globals, a lead anywhere else. Trust `high`,
191
+ confirm `medium`, ask for `low` explicitly.
192
+
193
+ Swift member-call recall is a named limit (15 of 23 member calls to repository
194
+ names have an edge with seed 11 on the Swift app; the rest include library name
195
+ clashes). The resolver's own misses have three causes: a local bound by a cast
196
+ inside a longer expression (`guard let c = x as? Cell` is read), a local bound to
197
+ a shared instance whose static is initialised by a closure, a factory or a
198
+ computed property (a typed or constructor-initialised static is read), and a
199
+ static extension method on a platform type called through the type.
200
+
201
+ Python, Go, Rust, Java, C#, C++ and Kotlin precision is fixture-verified only:
202
+ `eval-call-edges.mjs` checks nine hand-written cases (147 expected edges, pooled
203
+ recall 98.0%, precision at medium and above 100.0%); no real tree of those
204
+ languages was sampled.
205
+
206
+ "Functions nothing calls" in `graph-report` is a list of candidates, not dead
207
+ code: a function reached through a function value, a registry, reflection, a
208
+ framework entry point or a self-recursive call has no `calls` edge, and the
209
+ section says so.
210
+
211
+ ### Configuration, documentation and rationale
212
+
213
+ Two more sidecars are opt-in (`graph-build --infra`, `--docs`, or
214
+ `code-graph.config.json` beside the graph with `{"infra": true, "docs": true}`;
215
+ a flag beats the file):
216
+
217
+ - `<graph>.infra.json`: `infra` nodes (a Dockerfile stage, Compose service,
218
+ Kubernetes resource, Helm chart, Terraform block, CI workflow or job), `env`
219
+ (a variable name) and `config` (a Helm value, a BuildConfig field, an
220
+ application config key), joined by `sets`, `uses`, `builds`, `runs` and
221
+ `reads` edges. A source file that reads `process.env.X`, `os.getenv("X")` and
222
+ the like gets a `reads` edge to the `env:X` node that a Compose file,
223
+ manifest, workflow or `.env` file also points at, so `--path <file> env:X`
224
+ reaches the place the variable is set. `graph-report` lists variables read and
225
+ set nowhere in the repo, and the reverse. Dependency manifests (package.json,
226
+ Cargo.toml, go.mod, requirements, pyproject, Podfile, Package.swift,
227
+ pom.xml, build.gradle, csproj) become dependency module nodes. Only names are
228
+ stored, never values.
229
+ - `<graph>.docs.json`: documentation sections (`doc`) mention the files and
230
+ symbols they name in backticks, a decision record's first heading is
231
+ `symbolKind: "adr"`, and a code comment starting NOTE, WHY, HACK or citing an
232
+ ADR is a `rationale` node that `explains` the declaration around it.
233
+
234
+ Each sidecar has its own schema and version, caps on nodes and edges (calls
235
+ 250,000 / 1,000,000; docs 20,000 / 80,000; infra 30,000 / 120,000) with a
236
+ `truncated` marker, and a manifest of the files it read, so a documentation or
237
+ configuration file changed after the build makes the layer stale. Readers say
238
+ when a layer is off, absent or stale instead of answering as if it were empty.
239
+ Free-text `ask` leaves all of these out; `ask --include doc,infra` brings them
240
+ in. Files are read only when they are regular files inside the repo root;
241
+ symlinks are not followed.
242
+
109
243
  ### Confirming with a language server
110
244
 
111
245
  The graph joins by name, so a direct dependent can be a file that only uses
112
- the same word, and a dependent behind an ambiguous name is missing. Where the
246
+ the same word, and a dependent behind an ambiguous name is missing; a `low`
247
+ call edge is the same kind of lead. Where the
113
248
  toolkit's `code_references` (≥ v3.22.2) has an index (Swift through sourcekit-lsp, Kotlin
114
249
  through kotlin-lsp), check the answer before a decision rests on it: call
115
250
  `code_references` with `file` and `symbol` for each changed type (at most five).
@@ -164,7 +299,7 @@ import b. The graphs are not merged (ADR-0018).
164
299
 
165
300
  The rebuild costs no API tokens, so it runs every task rather than on a staleness
166
301
  heuristic. A non-zero validator exit keeps the previous graph and logs
167
- `knowledge.graph_invalid`; it never fails the run - a stale graph is a degraded
302
+ `knowledge.graph_invalid`; it never fails the run - a stale graph is a degraded
168
303
  Phase 1, not a broken deliverable.
169
304
 
170
305
  ### What the report answers that a file-level view cannot
@@ -227,15 +362,15 @@ MCP, so an agent without a shell (a read-only reviewer, a Copilot or Codex
227
362
  session) gets the graph too. `project` is the directory name under
228
363
  `~/.claude/knowledge/`; `mcp__multi-agent__graph_projects` lists them.
229
364
 
230
- | Need | Tool | Script equivalent |
231
- |---|---|---|
232
- | Starting file set for a question | `mcp__multi-agent__graph_query` (`project`, `query`, optional `budget` or `tier`) | `graph-query.mjs` (`--tier`) |
233
- | One node and its edges | `mcp__multi-agent__graph_node` (`project`, `id` or `name`) | none |
234
- | Dependents or dependencies | `mcp__multi-agent__graph_neighbors` (`project`, `id`, optional `direction`, `kinds`, `depth`, `limit`) | `graph-affected.mjs` |
235
- | How two nodes connect | `mcp__multi-agent__graph_path` (`project`, `from`, `to`, optional `kinds`, `maxDepth`, `directed`) | `graph-query.mjs --path` |
236
- | Is the graph sane and current | `mcp__multi-agent__graph_stats` (`project`): counts by kind, age in days, base commit, whether the stats header agrees with the arrays | `graph-report.mjs --status` |
237
- | Hubs a change will ripple through | `mcp__multi-agent__graph_hubs` (`project`, optional `kinds`, `nodeKind`, `limit`) | the report's hubs section |
238
- | Clusters and cross-cluster links | `mcp__multi-agent__graph_cluster` (`project`, optional `node`, `limit`, `surprising`) | the report's clusters and surprising connections |
365
+ | Need | Tool | Script equivalent |
366
+ | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
367
+ | Starting file set for a question | `mcp__multi-agent__graph_query` (`project`, `query`, optional `budget` or `tier`) | `graph-query.mjs` (`--tier`) |
368
+ | One node and its edges | `mcp__multi-agent__graph_node` (`project`, `id` or `name`) | none |
369
+ | Dependents or dependencies | `mcp__multi-agent__graph_neighbors` (`project`, `id`, optional `direction`, `kinds`, `depth`, `limit`) | `graph-affected.mjs` |
370
+ | How two nodes connect | `mcp__multi-agent__graph_path` (`project`, `from`, `to`, optional `kinds`, `maxDepth`, `directed`) | `graph-query.mjs --path` |
371
+ | Is the graph sane and current | `mcp__multi-agent__graph_stats` (`project`): counts by kind, age in days, base commit, whether the stats header agrees with the arrays | `graph-report.mjs --status` |
372
+ | Hubs a change will ripple through | `mcp__multi-agent__graph_hubs` (`project`, optional `kinds`, `nodeKind`, `limit`) | the report's hubs section |
373
+ | Clusters and cross-cluster links | `mcp__multi-agent__graph_cluster` (`project`, optional `node`, `limit`, `surprising`) | the report's clusters and surprising connections |
239
374
 
240
375
  Phase 1 Step 2.6 still runs the scripts, because it also builds and validates.
241
376
  The tools are for reading a graph that already passed `validate-code-graph.mjs`:
@@ -9,17 +9,17 @@ each platform already ships. Eight tools in the companion MCP server
9
9
 
10
10
  These two answer different questions and neither replaces the other.
11
11
 
12
- | Question | Use |
13
- |---|---|
12
+ | Question | Use |
13
+ | ---------------------------------------------------- | -------------------------------------------------------------------- |
14
14
  | Where does this concept live in a repo I do not know | `code-graph.md` - one cheap pass over the whole tree, token-budgeted |
15
- | What depends on this area, roughly | `graph-affected` |
16
- | Is THIS exact symbol referenced, and where | `mcp__multi-agent__code_references` |
17
- | What type is this, really | `mcp__multi-agent__code_hover` |
18
- | Does this file compile, without a full build | `mcp__multi-agent__code_diagnostics` |
15
+ | What depends on this area, roughly | `graph-affected` |
16
+ | Is THIS exact symbol referenced, and where | `mcp__multi-agent__code_references` |
17
+ | What type is this, really | `mcp__multi-agent__code_hover` |
18
+ | Does this file compile, without a full build | `mcp__multi-agent__code_diagnostics` |
19
19
 
20
20
  `docs/adr/0010-own-code-graph.md` states the trade the graph makes in as many
21
- words: *"Regex over comment-stripped source is not a parser. Definitions and
22
- imports survive that trade; call graphs and type resolution do not."* It names
21
+ words: _"Regex over comment-stripped source is not a parser. Definitions and
22
+ imports survive that trade; call graphs and type resolution do not."_ It names
23
23
  two consequences - a name declared in two files is dropped rather than fanned
24
24
  out, so `affected` under-reports on duplicated names, and only type-like symbols
25
25
  are reference targets. Those are exactly the two the language server answers
@@ -46,11 +46,11 @@ unfamiliar machine.
46
46
 
47
47
  `semantic` and `buildSettingsSource` come back on every result.
48
48
 
49
- | Root | definition | references | diagnostics |
50
- |---|---|---|---|
51
- | `Package.swift` | yes | yes, after the index settles | yes |
52
- | `buildServer.json` | yes | yes | yes |
53
- | `.xcodeproj`, no build server | same-file only | no, `semantic: false` | misleading, marked non-semantic |
49
+ | Root | definition | references | diagnostics |
50
+ | ----------------------------- | -------------- | ---------------------------- | ------------------------------- |
51
+ | `Package.swift` | yes | yes, after the index settles | yes |
52
+ | `buildServer.json` | yes | yes | yes |
53
+ | `.xcodeproj`, no build server | same-file only | no, `semantic: false` | misleading, marked non-semantic |
54
54
 
55
55
  A modular app is mostly packages, so this matters less than it reads: the iOS
56
56
  app measured here has 41 `Package.swift` roots and a single `.swift` file under
@@ -66,7 +66,9 @@ All three are opt-in and none is on by default.
66
66
  "nothing handles this" claim.
67
67
  2. **Phase 1, sharpening an impact estimate.** When `graph-affected` reports on
68
68
  a name that the graph itself flagged as ambiguous, `code_references` on the
69
- one symbol the task names resolves it exactly.
69
+ one symbol the task names resolves it exactly. A dependent that `graph-affected`
70
+ marks as reached only through medium-confidence call edges is confirmed the same way
71
+ before it is reported as a touched area.
70
72
  3. **Phase 3, fast feedback.** `code_diagnostics` on the file just edited,
71
73
  without waiting for `xcodebuild`.
72
74
 
@@ -1,8 +1,8 @@
1
- # Feature: Dev Critic (Phase 2 Step 3.5 Evaluator-Optimizer)
1
+ # Feature: Dev Critic (Phase 2.5 Evaluator-Optimizer)
2
2
 
3
3
  **Pattern**: Anthropic's evaluator-optimizer from "Building Effective Agents" (Dec 2024). Generator (Phase 2 Dev) and critic (`agents/dev-critic.md`) loop on deterministic criteria already written in `rules/*.md` before any Phase 3 reviewer call.
4
4
 
5
- **Gated by `prefs.global.devCritic.enabled`** (default: `false`). When enabled, after the generator's last edit and BEFORE Phase 4:
5
+ **Gated by `prefs.global.devCritic.enabled`** (default: `false`). When enabled, after the generator's last edit and BEFORE Phase 3:
6
6
 
7
7
  1. Dispatch `dev-critic` sub-agent (Sonnet by default, tools: `Read, Grep, Glob, Bash`).
8
8
  2. Critic runs 4 deterministic gates (build / lint / test / secrets) - failure of any → `pass: false` with `blocking` finding.
@@ -15,21 +15,21 @@
15
15
  |---|---|
16
16
  | 1 | Full critic pass - all gates + full checklist |
17
17
  | 2 | Re-check only round-1 failures. No new findings allowed (scope creep prevention) |
18
- | 3+ | NOT ALLOWED. Critic returns `escalate: true`; orchestrator pauses (interactive) or proceeds to Phase 4 with logged failure (autopilot) |
18
+ | 3+ | NOT ALLOWED. Critic returns `escalate: true`; orchestrator pauses (interactive) or proceeds to Phase 3 with logged failure (autopilot) |
19
19
 
20
20
  ## Action by severity
21
21
 
22
22
  - `blocking` → generator MUST fix; another Dev iteration before re-critic
23
- - `important` → generator SHOULD fix; if skipped, pass through to Phase 4 (legitimate reviewer ground)
23
+ - `important` → generator SHOULD fix; if skipped, pass through to Phase 3 (legitimate reviewer ground)
24
24
  - `suggestion` → generator's judgement; never blocks round 2
25
25
 
26
26
  ## Telemetry
27
27
 
28
- Each critic call emits `dev_critic.call` with `iteration`, `pass`, `gates_failed`, `blocking`, `important`, `duration_ms`, `tokens_in/out`. Phase 5 cost rollup lists these as `phase 3.5` line items so the net saving (Phase 3 reviewer/triage calls avoided) is measurable.
28
+ Each critic call emits `dev_critic.call` with `iteration`, `pass`, `gates_failed`, `blocking`, `important`, `duration_ms`, `tokens_in/out`. Phase 5 cost rollup lists these as `phase 2.5` line items so the net saving (Phase 3 reviewer/triage calls avoided) is measurable.
29
29
 
30
30
  ## Off by default reason
31
31
 
32
- Introduces ~1× Sonnet call per Dev iteration. On simple bug fixes the cost outweighs the benefit (Phase 4 would have caught the same thing for similar cost). Recommended on:
32
+ Introduces ~1× Sonnet call per Dev iteration. On simple bug fixes the cost outweighs the benefit (Phase 3 would have caught the same thing for similar cost). Recommended on:
33
33
 
34
34
  - Feature work (≥200 LOC diff)
35
35
  - Security-touching paths (auth, keychain, network)
@@ -37,7 +37,7 @@ Introduces ~1× Sonnet call per Dev iteration. On simple bug fixes the cost outw
37
37
 
38
38
  ## Why this fits orchestrator-workers + evaluator-optimizer hybrid
39
39
 
40
- Phase 4 is parallelization-with-voting - good for *adversarial* perspectives (security, architecture). Phase 3.5 is evaluator-optimizer - good for *deterministic* criteria (build, tests, checklists). Sending failing builds into Phase 4 wastes 2-3 reviewer calls + Fable triage; Phase 3.5 absorbs that cost at one Sonnet call.
40
+ Phase 3 is parallelization-with-voting - good for *adversarial* perspectives (security, architecture). Phase 2.5 is evaluator-optimizer - good for *deterministic* criteria (build, tests, checklists). Sending failing builds into Phase 3 wastes 2-3 reviewer calls + Fable triage; Phase 2.5 absorbs that cost at one Sonnet call.
41
41
 
42
42
  ## Reference
43
43
 
@@ -18,7 +18,7 @@ Personas route to the top available intelligence tier they declare in
18
18
  This contract defines when and how the orchestrator falls back, deterministically,
19
19
  without ever editing persona files at runtime.
20
20
 
21
- > **Fable is the top tier.** The `fable` rung resolves to `claude-fable-5-1`.
21
+ > **Fable is the top tier.** The `fable` rung resolves to `claude-fable-5-2`.
22
22
  > Architect (`ios/android/backend-architect`), Reviewer-1 (`code-reviewer`),
23
23
  > and triage personas declare `preferredModel: fable` - the deepest-reasoning
24
24
  > roles. **If Fable is unavailable, the first fallback is opus (`claude-opus-5-5`).**
@@ -46,7 +46,7 @@ model ID each rung resolves to lives in exactly two places: `scripts/cost-table.
46
46
  `phases/phase-3-review.md`. A generation move edits those; it never renames a rung and
47
47
  never touches a persona file.
48
48
 
49
- Current resolution: `fable` -> `claude-fable-5-1`, `opus` -> `claude-opus-5-5`,
49
+ Current resolution: `fable` -> `claude-fable-5-2`, `opus` -> `claude-opus-5-5`,
50
50
  `sonnet` -> `claude-sonnet-5-5`, `haiku` -> `claude-haiku-5-5`. These are the Claude Code
51
51
  wire IDs. Copilot CLI dispatches only the models `copilot help config` lists, with dotted
52
52
  names, so its column in the reviewer table names those (`claude-opus-4.7`,
@@ -70,9 +70,9 @@ different rather than broken, and none of them are bugs in this contract:
70
70
  Phase 5 report length and reviewer prose are where this shows.
71
71
  - **Self-verification without being asked.** Explicit "double-check your work"
72
72
  scaffolding now causes over-verification rather than preventing under-verification.
73
- Phase 4's deterministic gates already carry that load.
73
+ Phase 2's exit gates already carry that load.
74
74
  - **Readier subagent delegation.** The previous generation under-reached and needed
75
- encouragement; this one does not. Phase 1's parallel scan and Phase 4's reviewer
75
+ encouragement; this one does not. Phase 1's parallel scan and Phase 3's reviewer
76
76
  panel are already bounded by explicit counts, which is the right shape - keep them
77
77
  bounded rather than adding "delegate more" guidance.
78
78
 
@@ -124,11 +124,11 @@ Scope is Claude Code only, and the reason differs per host:
124
124
 
125
125
  | Host | Effect of `fableEnabled: false` | Why |
126
126
  |---|---|---|
127
- | Claude Code | Every `preferredModel: fable` persona (`ios/android/backend-architect`, `code-reviewer`, triage) starts on `opus` | This is the only host where the rung means Fable 5.1 |
127
+ | Claude Code | Every `preferredModel: fable` persona (`ios/android/backend-architect`, `code-reviewer`, triage) starts on `opus` | This is the only host where the rung means Fable 5.2 |
128
128
  | Copilot CLI | none | Fable is not offered there; its personas never sat on this rung |
129
129
  | Codex CLI | none, deliberately | The `fable` rung there means `gpt-5.6 @ xhigh`, a different model on a different account. Switching it off from a knob named after an Anthropic model would surprise a Codex user, so it does not |
130
130
 
131
- **Phase 4 loses a reviewer, and says so.** Reviewer 1 lands on `opus`, which
131
+ **Phase 3 loses a reviewer, and says so.** Reviewer 1 lands on `opus`, which
132
132
  Reviewer 2 already holds. Dispatching one model twice is not cross-model review,
133
133
  so the Claude Code panel collapses to two reviewers (`opus` + `sonnet`),
134
134
  `consensus.reviewerCount` records `2`, and the `unverified` verdict rule matters
@@ -174,7 +174,7 @@ Claude Code panel change.
174
174
  No log line is emitted per dispatch for this: it is a configured absence, not a
175
175
  degrade event, and one line per persona per run would be noise. Phase 0 Step 0
176
176
  prints it once instead:
177
- `INFO: fable rung disabled by prefs; architect/reviewer/triage personas dispatch on opus (Phase 4 panel = 2 reviewers).`
177
+ `INFO: fable rung disabled by prefs; architect/reviewer/triage personas dispatch on opus (Phase 3 panel = 2 reviewers).`
178
178
 
179
179
  ## Triggers (checked in this order)
180
180
 
@@ -308,6 +308,8 @@ each `~/.codex/agents/<persona>.toml`:
308
308
  | `sonnet` | `gpt-5.4` | `medium` |
309
309
  | `haiku` | `gpt-5.6-terra` | `low` |
310
310
 
311
+ This table is the persona default per tier. The Phase 3 review panel overrides it per slot (`phases/phase-3-review.md` Step 2): Reviewer 2 runs `gpt-5.4` @ `high` and Reviewer 3 runs `gpt-5.6` @ `medium`, so the panel buys its diversity from effort and one model change rather than from the tier ladder. `test/codex-model-tables.test.mjs` holds this table to `CODEX_TIER_MAP` and the panel tables to each other.
312
+
311
313
  Ladder on Codex: `gpt-5.6 @ xhigh -> gpt-5.6 @ high -> gpt-5.4 -> gpt-5.6-terra`.
312
314
  The first step down lowers effort rather than switching model, which is the
313
315
  cheapest useful degradation when the top tier is rate-limited rather than
@@ -0,0 +1,252 @@
1
+ # Remote control: answer and stop runs from your phone
2
+
3
+ <!-- toc -->
4
+ - [What it does](#what-it-does)
5
+ - [Commands](#commands)
6
+ - [How it runs](#how-it-runs)
7
+ - [What the computer checks for every request](#what-the-computer-checks-for-every-request)
8
+ - [What leaves the machine](#what-leaves-the-machine)
9
+ - [Threat model in plain terms](#threat-model-in-plain-terms)
10
+ - [Run handles and answers](#run-handles-and-answers)
11
+ - [Acknowledging requests](#acknowledging-requests)
12
+ - [Status and revocation](#status-and-revocation)
13
+ - [Where the code is shown](#where-the-code-is-shown)
14
+ - [The pairing secret and the transcript](#the-pairing-secret-and-the-transcript)
15
+ - [Transport](#transport)
16
+ - [What "unattended" means for a verb](#what-unattended-means-for-a-verb)
17
+ - [Requirements](#requirements)
18
+ <!-- /toc -->
19
+
20
+ Optional. Off until two things are true: the site has enabled the feature for
21
+ your account, and you have paired a phone with this computer. Until then
22
+ nothing runs, polls or listens.
23
+
24
+ ## What it does
25
+
26
+ From a paired phone, and only these:
27
+
28
+ | Verb | Effect on this computer |
29
+ |------|-------------------------|
30
+ | `list_runs` | Lists runs (id, title, state, phase, pending question) |
31
+ | `run_status` | One run's state, phase and pending question with its options |
32
+ | `answer_question` | Records a list of option ids the run's pending question offered (never free text) |
33
+ | `stop_run` | Stops the run's session (`claude stop`). The worktree and branch stay |
34
+
35
+ There is no shell verb, no file verb and no free-form command. `start_run`
36
+ exists in the shared contract for a later phase and is refused here. The
37
+ verbs are fixed in `scripts/remote/verbs.json`; the site cannot add one.
38
+
39
+ ## Commands
40
+
41
+ | Command | Purpose |
42
+ |---------|---------|
43
+ | `/multi-agent:pair` | Pair a phone (QR code or typed code, then a six-digit confirmation number) |
44
+ | `/multi-agent:pair --list` | Phones pinned on this computer |
45
+ | `/multi-agent:pair --revoke <device>` | Forget one phone here and remove it on the site when it is reachable |
46
+ | `/multi-agent:pair --off` | Stop the listener, forget every phone, remove them on the site when reachable. Works offline |
47
+ | `/multi-agent:pair --start` | Start the listener again for pinned phones |
48
+ | `/multi-agent:pair --status` | Listener and device count |
49
+
50
+ Pairing always needs the person and is refused in an unattended run
51
+ (`MULTI_AGENT_UNATTENDED=1`). A wrong confirmation number rejects the pairing,
52
+ warns that someone may be interfering, and blocks new pairings on this
53
+ computer for a cooldown that grows fourfold with each consecutive mismatch
54
+ (1 minute, 4, 16, 64, up to 24 hours), with at most 5 mismatches in the 24
55
+ hours counted from the first. A match ends the consecutive run, not the daily
56
+ count. The record is kept in a 0600 file and survives restarts; the site
57
+ cannot relax it.
58
+
59
+ ## How it runs
60
+
61
+ After a successful pairing a background process (`remote-listener.mjs`) is
62
+ started, detached like the office server, so it outlives the terminal. One
63
+ record in the state directory names its pid and start time; there is one
64
+ instance. It makes outbound HTTPS long-poll requests to the site only; no
65
+ port is opened. It ends by itself when no phone is pinned, when the site
66
+ answers that the feature or your permission is off, or when the usage token is
67
+ refused, and then polls no more until you run `pair --start`. `pair --off`
68
+ stops it.
69
+
70
+ Machine identity is the per-machine usage token that usage registration
71
+ stored. The site is the one in `usageLog.endpoint`, trusted under the same
72
+ rule as the usage clients (its own host or `usageLog.trustedHosts`), https
73
+ only, and a redirect is never followed. The pairing page the QR code opens
74
+ (`pairUrl`, the origin the passkey is bound to) must be https on a trusted
75
+ host, with the path `/remote/pair` and no query; this computer never sends a
76
+ request, or the token, to that host. Machine routes are always on the site's
77
+ main API origin. The device id is part of the pairing transcript, so a site that
78
+ names a different device than the phone confirmed produces a different number.
79
+
80
+ ## What the computer checks for every request
81
+
82
+ The site is not trusted. Each request is checked here before anything runs:
83
+ the device is one you confirmed locally; the sequence number is newer than the
84
+ last accepted (stored on disk, so a restart does not reset it); the passkey
85
+ assertion verifies against the key pinned at pairing (rpIdHash, user
86
+ presence and verification, type, origin, a challenge recomputed here from the
87
+ nonce, verb, run tag, sequence number and the exact ciphertext, ES256
88
+ signature, counter); the envelope decrypts with the header as authenticated
89
+ data; the plaintext verb equals the clear one and is a contract verb at an
90
+ enabled phase this computer implements; the arguments validate against the
91
+ schema; the request carries a nonce this computer issued less than 120 seconds ago and has not seen used (it is spent as soon as the request authenticates); the request's issue time is within 10 minutes of this computer's clock; for run verbs the run tag
92
+ matches the run named inside the payload. Answer and stop are refused when
93
+ this machine is unattended. Anything else is dropped and audited.
94
+
95
+ ## What leaves the machine
96
+
97
+ - To the site: the usage token (in a header), the pairing lookup token, public
98
+ keys, your answer to "did the numbers match" as accept or reject (never the
99
+ number), and sealed envelopes. The site sees the verb name, the run tag
100
+ (it cannot read the run id), sizes, timing and whether this computer is
101
+ online or unattended.
102
+ - To the phone, sealed so only it can read: a handle, a title, state, phase, the
103
+ pending question and its options. Text loses control, bidirectional and
104
+ zero-width characters, passes through the secret and path scrubber, and is
105
+ clipped: title and option labels to 60 characters, state and phase to 32, the
106
+ question to 1000 (200 in the run list). A run list that would not fit one
107
+ reply is cut from the end and carries `omitted`, the number of runs left out. No file contents, diffs, branch names, URLs, costs or keys.
108
+ - Locally, an audit log (`audit.jsonl`, 0600, rotated at 256 KiB): time,
109
+ device (8 characters), verb, outcome. Never content.
110
+
111
+ State lives under the autopilot root in `remote/` (0700): `devices.json` (the
112
+ pinned phones and their session keys), `audit.jsonl`, `lockout.json`,
113
+ `listener.json`, `ack.json`.
114
+
115
+ ## Threat model in plain terms
116
+
117
+ **Pairing trusts the JavaScript the site serves to your phone while you pair.**
118
+ That page reads the pairing secret from the URL fragment, creates the phone's
119
+ keys and passkey in the browser and shows the six-digit number. A site that is
120
+ malicious at pairing time can serve a page that makes its own software keys,
121
+ computes the correct number from the secret it read, shows it on your real
122
+ phone and so gets a key it controls pinned on this computer. This computer
123
+ checks no attestation of the passkey, so it cannot tell a hardware passkey
124
+ from a software one. From then on that site can send phase 1 verbs with no
125
+ biometric prompt. The six-digit number protects against a network attacker and
126
+ against a site that tampers after an honest pairing. It does not protect
127
+ against a site that served hostile pairing code.
128
+
129
+ What limits the damage is the fixed verb list: list runs, read a run's status
130
+ and pending question, answer a question with one of the options it offered,
131
+ and stop a run's session. There is no shell, no file access and no way to start
132
+ a run. The feature is off by default. Enable it only for a site you operate or
133
+ trust as much as your own machine. Checking the passkey's attestation would
134
+ close this gap and is not done yet.
135
+
136
+ After an honest pairing:
137
+
138
+ - The site can stop the service, drop or delay messages, and see metadata:
139
+ your account, device and machine, verb names, run tags, message sizes and
140
+ timing, and whether the computer is online. It cannot read a request or a
141
+ reply, forge, alter or replay one, or send a command without a key only the
142
+ paired phone holds and a passkey assertion this computer checks against the
143
+ key pinned at pairing.
144
+ - A device list from the site is used only to forget devices. A device id that
145
+ is already pinned is never replaced: a second pairing with the same id is
146
+ refused until you revoke the first.
147
+ - A man in the middle at pairing who substitutes a key or passkey passes the
148
+ six-digit number check with probability 1 in 1,000,000 per attempt; every
149
+ miss is visible, warns you, and locks pairing here.
150
+ - A site that serves malicious JavaScript to the phone after an honest pairing
151
+ can use the phone's keys while the page is open, read what the page decrypts
152
+ and show misleading text. It still cannot sign a verb without your biometric
153
+ prompt for that exact request.
154
+ - A stolen phone needs your biometric for every verb, including reads. Remove
155
+ it on the site and with `pair --revoke`.
156
+ - A site cannot hold a genuine signed request back and deliver it later: every
157
+ poll carries a fresh nonce this computer made, the phone signs the newest one
158
+ into the verb, and the request is accepted only with a nonce issued here in
159
+ the last 120 seconds that has not been used. The computer keeps its last 8
160
+ nonces in memory; a restart voids them. The issue time inside the request
161
+ (`iat`) is still checked within 10 minutes as a second bound.
162
+ - A compromised computer has everything this feature has and more.
163
+
164
+ ## Run handles and answers
165
+
166
+ The phone never sees a run id. `list_runs` returns a random handle per run, valid
167
+ for that phone until the computer restarts or the phone is removed; the other
168
+ verbs take the handle, and a raw run id or another phone's handle is answered
169
+ `unknown_run`. A question is `null` or `{id, text, kind, options}` with kind
170
+ `single` or `multi` and at most 8 options. An answer is a list of option ids
171
+ checked against the options the run actually offered (`unknown_question` or
172
+ `bad_answer` otherwise); the computer applies the ids, not any text.
173
+
174
+ ## Acknowledging requests
175
+
176
+ A poll hands requests out without removing them from the site's queue. The next
177
+ poll lists the ids of the answer just processed in `ack` (at most 10; the list is
178
+ kept in `remote/ack.json` until a poll that carried it was answered, so a restart
179
+ still sends it). A request the site hands out again is dropped by its sequence
180
+ number: it runs once and is answered once. The poll body stays under 1 KiB.
181
+
182
+ ## Status and revocation
183
+
184
+ Before showing a code, `pair` asks the site's `machine/status` and says which of
185
+ three things is true: the site has not enabled the feature, your account lacks
186
+ the permission, or the site did not accept this machine's usage token (the site
187
+ answers an invalid token with an empty 404, so only a valid token learns the
188
+ rest). The listener asks the same when `poll` answers 404, and stops for
189
+ "switched off", "no permission" or "token not accepted"; when the status cannot
190
+ explain the 404 it keeps trying. `pair --revoke` and `pair --off` also call
191
+ `machine/revoke` when the site is reachable and say plainly when they could
192
+ only act on this computer. The passkey counter starts at the `signCount` the
193
+ site reports for the registration.
194
+
195
+ ## Where the code is shown
196
+
197
+ `pair begin` writes the QR code and the fallback code straight to the controlling
198
+ terminal (`/dev/tty`) and returns to the session only that they were shown and
199
+ how many minutes remain, so the code does not pass through the model's context.
200
+ The command file therefore tells the person to run `pair begin` themselves, in
201
+ a terminal window of their own (the host's `! <command>` prefix runs it from
202
+ the prompt; whether it has a terminal there is the host's choice), and the
203
+ model continues from `pair wait`.
204
+
205
+ Inside the host's shell tool `/dev/tty` cannot be opened, so when the model runs
206
+ `pair begin` the QR code and the code always land in the session output and are
207
+ visible to the session, and are written to its transcript. That is the fallback,
208
+ and the command file says so before it uses it. It is bounded by the six-digit
209
+ confirmation, which only the phone shows and only the person types, and by the
210
+ computer's own lockout: a session that sees the code but not the number cannot
211
+ finish a pairing.
212
+
213
+ ## The pairing secret and the transcript
214
+
215
+ `pair begin` prints the QR code and the code to the terminal. When the command
216
+ runs inside an assistant session, that output passes through the assistant's
217
+ tool output and is therefore also written to the on-disk session transcript,
218
+ and the secret and the ephemeral key sit in `remote/pending.json` while the
219
+ pairing runs. That is acceptable because the code is single use, expires after
220
+ five minutes and is useless without the confirmation number typed on this
221
+ computer. `pending.json` is deleted as soon as the pairing ends, whichever way
222
+ it ends.
223
+
224
+ ## Transport
225
+
226
+ Requests go through Node's https only, with certificate verification forced on
227
+ for every request and a dedicated agent, so `NODE_TLS_REJECT_UNAUTHORIZED` and
228
+ proxy variables change nothing. The trust store is the one the usage transport uses
229
+ (`lib/tls-trust.mjs`): Node's bundled roots plus the file `NODE_EXTRA_CA_CERTS`
230
+ names, passed as the agent's `ca`; `SSL_CERT_FILE`, `SSL_CERT_DIR`,
231
+ `--use-openssl-ca` and `NODE_USE_SYSTEM_CA` add nothing. A certificate or TLS error fails that poll and
232
+ backs off; a 4xx answer with a body that is not JSON (a hosting layer's own
233
+ 404) is still returned as its status, so the switch-off check runs; there is no retry through another client. The listener starts with a
234
+ short list of inherited variables (path, home, state locations, the unattended
235
+ flag, `NODE_EXTRA_CA_CERTS` for a network with its own certificate authority);
236
+ `NODE_OPTIONS`, `NODE_TLS_*`, proxy variables and the usage token are not
237
+ passed on, and the listener reads the token from the credential store itself.
238
+
239
+ ## What "unattended" means for a verb
240
+
241
+ Answer and stop are refused when the listener itself was started in an
242
+ unattended environment (`MULTI_AGENT_UNATTENDED=1`, fixed when it started), and
243
+ also when the run they target is unattended: its own state says autopilot, or
244
+ it was launched in the background under the unattended log root. The stricter
245
+ of the two applies.
246
+
247
+ ## Requirements
248
+
249
+ - A usage token on this machine (`/multi-agent:setup`) and a site account the
250
+ token maps to.
251
+ - The site must have switched the feature on globally and for you.
252
+ - Node 20.11 or newer. `openssl` is not needed.
@@ -1,4 +1,4 @@
1
- # Feature: Cross-round review delta (Phase 4 Steps 2.1, 2.2, 3.8)
1
+ # Feature: Cross-round review delta (Phase 3 Steps 2.1, 2.2, 3.8)
2
2
 
3
3
  **Pattern**: reviewers re-read the whole diff every round with no memory of the round before, so they rediscover last round's findings in new words and nothing can tell "still broken" from "new". A finding therefore needs an identity that survives the fix: `finding-fingerprint.mjs` computes `F:xxxxxxxx` from the file and either the cited `ruleId` or the normalised issue text (lowercase, quotes stripped, paths reduced to basenames, digit runs collapsed). The line, the severity, the fix text and the reviewer take no part, because all of them change between rounds without the finding changing. `review-delta.mjs` then compares round N with round N-1 and reports `stillPresent`, `resolved`, `downgraded` (re-reported but no longer accepted by triage) and `new`, plus `recurrence`: how many consecutive rework cycles each survivor has lasted. That count is the autopilot circuit-breaker's trigger 2.
4
4
 
@@ -9,12 +9,12 @@
9
9
  - [What this is not](#what-this-is-not)
10
10
  <!-- /toc -->
11
11
 
12
- > The denominator for Phase 4's other axis. Loaded on demand by
13
- > `/multi-agent:review` and by pipeline Phase 4.
12
+ > The denominator for Phase 3's other axis. Loaded on demand by
13
+ > `/multi-agent:review` and by pipeline Phase 3.
14
14
 
15
15
  ## Why this exists
16
16
 
17
- Phase 4 had a size cap and no exclusion list. When the diff exceeds the phase
17
+ Phase 3 applies a size cap to the diff. When the diff exceeds the phase
18
18
  token allowance the cap truncates the LARGEST files first, so a regenerated
19
19
  lockfile or a snapshot dump is not merely wasted budget: it is the thing that
20
20
  survives while real code is cut.
@@ -47,7 +47,7 @@ For cross-repo findings, set `crossRepo: true` and list all impacted repos in `a
47
47
 
48
48
  **Triage cross-check**: Cross-repo findings are NEVER auto-rejected - the cross-cutting nature is exactly what reviewers are best at catching. Triage may still defer (out-of-scope) but rejection requires explicit reasoning.
49
49
 
50
- **Token-budget guard** (per `token-budget.json` Phase 4 allowance): if `COMBINED_DIFF` exceeds 80% of the budget, truncate the largest repo's diff with a footer header:
50
+ **Token-budget guard** (per `token-budget.json` Phase 3 allowance): if `COMBINED_DIFF` exceeds 80% of the budget, truncate the largest repo's diff with a footer header:
51
51
  ```
52
52
  [truncated - full diff in file://$WORKTREE/.review-diff.txt]
53
53
  ```