clearotron 0.5.1 → 0.6.0-beta.1

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 (390) hide show
  1. package/.env.example +7 -7
  2. package/INSTALL.md +10 -10
  3. package/QUICKSTART.md +6 -6
  4. package/README.md +2 -2
  5. package/THIRD-PARTY-NOTICES.md +4 -4
  6. package/bin/README.md +2 -2
  7. package/bin/clearotron.mjs +1 -1
  8. package/bin/connect.mjs +1 -1
  9. package/bin/disconnect.mjs +1 -1
  10. package/bin/example.mjs +2 -2
  11. package/bin/grant.mjs +1 -1
  12. package/bin/onboard.mjs +78 -23
  13. package/bin/start.mjs +88 -33
  14. package/bin/update.mjs +13 -3
  15. package/build-info.json +2 -2
  16. package/docs/DELIVERY.md +1 -1
  17. package/docs/PORTAL.md +1 -1
  18. package/docs/RELEASES.md +1 -1
  19. package/docs/architecture/02-architecture.md +10 -2
  20. package/docs/architecture/03-run-lifecycle.md +6 -2
  21. package/docs/architecture/04-configuration-reference.md +3 -3
  22. package/docs/architecture/05-config-governance.md +5 -4
  23. package/docs/architecture/08-development-guide.md +4 -4
  24. package/docs/architecture/09-security-and-data.md +1 -1
  25. package/{driver/skills/clearance-search/SKILL.md → docs/architecture/retired-manuals/clearance-search-spine.md} +17 -30
  26. package/{driver/skills/clearance-search/templates/email/generic.md → docs/architecture/retired-manuals/email-generic.md} +1 -1
  27. package/{driver/skills/clearance-search → docs/architecture/retired-manuals}/template-formatting.md +3 -4
  28. package/docs/configuration.md +1 -1
  29. package/docs/decisions/0002-no-dark-functionality.md +5 -0
  30. package/driver/CHANGELOG.md +69 -0
  31. package/driver/README.md +11 -1
  32. package/driver/accepted-order.mjs +13 -5
  33. package/driver/attempt-rows.mjs +64 -0
  34. package/driver/attributed-span.mjs +1 -1
  35. package/driver/authority-trees.mjs +1 -1
  36. package/driver/band-shape.mjs +21 -3
  37. package/driver/best-draft.mjs +3 -3
  38. package/driver/blind-frame-record.mjs +2 -2
  39. package/driver/cancel.mjs +3 -2
  40. package/driver/carry-through.mjs +2 -2
  41. package/driver/citation-census.json +3 -3
  42. package/driver/clearance-variants-record.mjs +4 -10
  43. package/driver/common-law-coverage-status.mjs +3 -3
  44. package/driver/common-law-receipts.mjs +2 -2
  45. package/driver/commonlaw-carry-floor.json +3 -3
  46. package/driver/compare.mjs +1 -1
  47. package/driver/config-inventory.mjs +6 -79
  48. package/driver/consumption-ledger.mjs +2 -1
  49. package/driver/contract-arm2-baseline.json +2 -3
  50. package/driver/contract-dictation-registry.mjs +5 -0
  51. package/driver/contract-e3-backlog.mjs +45 -66
  52. package/driver/contract-e3-baseline.json +16 -16
  53. package/driver/contract-vocabulary.mjs +8 -6
  54. package/driver/corrections-feedforward.mjs +3 -1
  55. package/driver/coverage-form-io.mjs +7 -8
  56. package/driver/coverage-tool.mjs +1 -1
  57. package/driver/declination-tool.mjs +2 -2
  58. package/driver/degraded-parts.mjs +9 -9
  59. package/driver/demo-container.mjs +5 -4
  60. package/driver/demo-posture.mjs +17 -0
  61. package/driver/deploy-live-run-guard.mjs +19 -7
  62. package/driver/derived-state.mjs +2 -2
  63. package/driver/dev-portal.mjs +2 -1
  64. package/driver/dispatch-record.mjs +1 -1
  65. package/driver/disposition-tool.mjs +2 -1
  66. package/driver/doubt-closure-tool.mjs +2 -2
  67. package/driver/driver.config.mjs +35 -724
  68. package/driver/e2e-rounds.mjs +3 -4
  69. package/driver/engine/CONTRACT.md +3 -0
  70. package/driver/engine/README.md +2 -0
  71. package/driver/engine/anthropic-agent.mjs +13 -42
  72. package/driver/engine/auth.mjs +74 -0
  73. package/driver/engine/child-record.mjs +1 -1
  74. package/driver/engine/deny-authority-write.mjs +2 -2
  75. package/driver/engine/jx-turn.mjs +10 -2
  76. package/driver/engine/mcp/README.md +1 -1
  77. package/driver/engine/mcp/band-server.mjs +20 -13
  78. package/driver/engine/mcp/codex-config.mjs +1 -1
  79. package/driver/engine/mcp/declination-server.mjs +2 -3
  80. package/driver/engine/mcp/dispositions-server.mjs +3 -3
  81. package/driver/engine/mcp/gather-config.mjs +24 -19
  82. package/driver/engine/mcp/grid-provenance.mjs +1 -1
  83. package/driver/engine/mcp/held-answers.mjs +5 -5
  84. package/driver/engine/mcp/perplexity-server.mjs +16 -7
  85. package/driver/engine/mcp/recording-server.mjs +7 -6
  86. package/driver/engine/mcp/register-server.mjs +29 -0
  87. package/driver/engine/mcp/stdio-server.mjs +5 -5
  88. package/driver/engine/mcp/supplemental.mjs +9 -9
  89. package/driver/engine/openai-agent.mjs +5 -2
  90. package/driver/engine/registry.mjs +103 -0
  91. package/driver/engine/run-choices.mjs +162 -0
  92. package/driver/engine/stamps.mjs +35 -0
  93. package/driver/enqueue-schema.mjs +4 -4
  94. package/driver/envelope-settle.mjs +3 -2
  95. package/driver/feedback-issues.mjs +1 -1
  96. package/driver/feedback-mint.mjs +3 -2
  97. package/driver/feedback-store.mjs +3 -2
  98. package/driver/findings-model.mjs +1 -1
  99. package/driver/flag-snapshot.mjs +5 -4
  100. package/driver/floor-duty.mjs +3 -3
  101. package/driver/foreign-record-links.mjs +1 -1
  102. package/driver/frame-diff-record.mjs +2 -8
  103. package/driver/framework.mjs +1 -1
  104. package/driver/gate-metrics.mjs +10 -11
  105. package/driver/gateway.mjs +220 -839
  106. package/driver/goods-evidence.mjs +26 -14
  107. package/driver/jx-lanes.mjs +3 -3
  108. package/driver/jx-units.mjs +31 -37
  109. package/driver/jx.mjs +44 -59
  110. package/driver/knockout-assess-record.mjs +3 -3
  111. package/driver/knockout-caveats.mjs +21 -0
  112. package/driver/knockout-correction-record.mjs +58 -28
  113. package/driver/knockout-frame-record.mjs +2 -2
  114. package/driver/knockout-register-read.mjs +38 -21
  115. package/driver/knockout-register-record.mjs +5 -6
  116. package/driver/knockout-review-record.mjs +12 -11
  117. package/driver/ladder/model-gauge.mjs +88 -0
  118. package/driver/ladder/next-rung.mjs +296 -0
  119. package/driver/ladder/rescue.mjs +146 -0
  120. package/driver/ladder/stage-tools.mjs +57 -0
  121. package/driver/ladder/turn-failure.mjs +166 -0
  122. package/driver/log.mjs +2 -2
  123. package/driver/matter-frame-record.mjs +4 -4
  124. package/driver/methodology-witness.mjs +2 -2
  125. package/driver/named-band.mjs +60 -3
  126. package/driver/narrative-refutation-record.mjs +145 -42
  127. package/driver/one-build-per-run.mjs +62 -0
  128. package/driver/outbox-backoff.mjs +4 -4
  129. package/driver/owner-screen.mjs +0 -10
  130. package/driver/owner-use-check.mjs +2 -28
  131. package/driver/package.json +1 -1
  132. package/driver/partial-payload-baseline.json +1 -1
  133. package/driver/parts-not-completed.mjs +1 -1
  134. package/driver/pipeline-knockout.mjs +1015 -1001
  135. package/driver/pipeline.mjs +714 -9351
  136. package/driver/placement-decisions.mjs +2 -2
  137. package/driver/placement-form-io.mjs +7 -9
  138. package/driver/placement-union.mjs +0 -6
  139. package/driver/plan-stability.mjs +7 -10
  140. package/driver/portal-acks.mjs +3 -2
  141. package/driver/portal-confirmation.mjs +48 -0
  142. package/driver/portal-families.mjs +3 -2
  143. package/driver/portal-local-auth.mjs +1 -2
  144. package/driver/portal-routes/README.md +24 -0
  145. package/driver/portal-routes/admin.mjs +425 -0
  146. package/driver/portal-routes/compose.mjs +66 -0
  147. package/driver/portal-routes/config.mjs +118 -0
  148. package/driver/portal-routes/connect.mjs +283 -0
  149. package/driver/portal-routes/feedback.mjs +178 -0
  150. package/driver/portal-routes/me.mjs +165 -0
  151. package/driver/portal-routes/queue.mjs +64 -0
  152. package/driver/portal-routes/report.mjs +106 -0
  153. package/driver/portal-routes/run.mjs +508 -0
  154. package/driver/portal-routes/runs.mjs +127 -0
  155. package/driver/portal-routes/usage.mjs +82 -0
  156. package/driver/portal-runs.mjs +588 -0
  157. package/driver/portal-service.mjs +82 -2593
  158. package/driver/portal-static.mjs +3 -1
  159. package/driver/predelivery-lint.mjs +101 -9
  160. package/driver/production-pool-guard.mjs +1 -1
  161. package/driver/profiles.mjs +5 -4
  162. package/driver/progress.mjs +29 -24
  163. package/driver/publish/README.md +10 -5
  164. package/driver/publish/archive-tags.mjs +3 -2
  165. package/driver/publish/demo-marking.mjs +2 -2
  166. package/driver/publish/index.mjs +215 -140
  167. package/driver/publish/knockout.mjs +153 -107
  168. package/driver/publish/office-record-links.mjs +22 -0
  169. package/driver/publish/parse.mjs +20 -5
  170. package/driver/publish/pool-admin.mjs +9 -3
  171. package/driver/publish/render.mjs +11 -3
  172. package/driver/publish/report-dates.mjs +3 -4
  173. package/driver/publish/report-registry.mjs +7 -10
  174. package/driver/publish/seed-pool.mjs +3 -2
  175. package/driver/publish/shell.mjs +106 -0
  176. package/driver/publish/templates/report.css +9 -7
  177. package/driver/queue-order.mjs +4 -3
  178. package/driver/record-carry.mjs +0 -9
  179. package/driver/record-discard.mjs +1 -4
  180. package/driver/record-fold.mjs +3 -3
  181. package/driver/record-goods.mjs +79 -23
  182. package/driver/reference-score.mjs +2 -3
  183. package/driver/register-capabilities.mjs +0 -6
  184. package/driver/register-count.mjs +3 -2
  185. package/driver/register-digest-record.mjs +7 -7
  186. package/driver/register-fixture-marker.mjs +3 -3
  187. package/driver/register-plan.mjs +2 -2
  188. package/driver/register-records.mjs +2 -2
  189. package/driver/register-taint.mjs +3 -3
  190. package/driver/register-unit-record.mjs +48 -9
  191. package/driver/register-unreachable.mjs +4 -3
  192. package/driver/registry-fidelity.mjs +79 -34
  193. package/driver/repair-composers.mjs +14 -9
  194. package/driver/repair-digest.mjs +4 -6
  195. package/driver/repair-scope.mjs +3 -3
  196. package/driver/repair-targets.mjs +24 -9
  197. package/driver/repairs.mjs +44 -58
  198. package/driver/replay-archive.mjs +7 -7
  199. package/driver/report-card-record.mjs +3 -3
  200. package/driver/report-overview-record.mjs +4 -4
  201. package/driver/research-answers.mjs +38 -6
  202. package/driver/research-checks.mjs +4 -4
  203. package/driver/result-noun-fields.mjs +28 -11
  204. package/driver/review-addresses.mjs +163 -0
  205. package/driver/rule-shape.mjs +1 -1
  206. package/driver/run-delivered.mjs +340 -0
  207. package/driver/run-economics.mjs +8 -26
  208. package/driver/run-failed.mjs +545 -0
  209. package/driver/run-integrity.mjs +1 -1
  210. package/driver/run-outcome.mjs +314 -0
  211. package/driver/run-park.mjs +23 -0
  212. package/driver/run-quote.mjs +32 -0
  213. package/driver/run-record.mjs +352 -0
  214. package/driver/run-requirements.mjs +22 -0
  215. package/driver/run-shell.mjs +55 -0
  216. package/driver/runner.mjs +71 -33
  217. package/driver/saved-register-pages.mjs +4 -4
  218. package/driver/score-redaction.mjs +2 -2
  219. package/driver/search-policy.mjs +12 -13
  220. package/driver/settle-stamp.mjs +4 -3
  221. package/driver/skeptic-record.mjs +2 -2
  222. package/driver/skeptic-search.mjs +1 -1
  223. package/driver/skills/README.md +7 -7
  224. package/driver/skills/blind-frame/SKILL.md +1 -2
  225. package/driver/skills/case-law-citation/SKILL.md +9 -37
  226. package/driver/skills/case-law-citation/sources/courtlistener.md +1 -3
  227. package/driver/skills/case-law-citation/sources/eurlex.md +8 -11
  228. package/driver/skills/case-law-citation/sources/legaldatahunter.md +1 -1
  229. package/driver/skills/clearance-common-law/SKILL.md +45 -111
  230. package/driver/skills/clearance-common-law/perplexity-prompts.md +7 -79
  231. package/driver/skills/clearance-register/SKILL.md +15 -33
  232. package/driver/skills/clearance-register/digest.md +35 -96
  233. package/driver/skills/clearance-register/providers/clarivate.md +2 -2
  234. package/driver/skills/clearance-register/providers/corsearch.md +5 -5
  235. package/driver/skills/clearance-register/providers/euipo.md +1 -2
  236. package/driver/skills/clearance-register/providers/free-tier.md +0 -19
  237. package/driver/skills/clearance-register/providers/signa.md +6 -25
  238. package/driver/skills/clearance-register/providers/uspto-local.md +0 -24
  239. package/driver/skills/clearance-register/register-recipes.md +8 -15
  240. package/driver/skills/clearance-register/status-rules.md +6 -24
  241. package/driver/skills/clearance-register/unit.md +11 -20
  242. package/driver/skills/clearance-search/delivery-contract.md +24 -120
  243. package/driver/skills/clearance-search/field-doctrine-pharma.md +1 -5
  244. package/driver/skills/clearance-search/firm-wide-reasoning.md +24 -43
  245. package/driver/skills/clearance-search/phase2-execution.md +29 -77
  246. package/driver/skills/clearance-search/report-prose.md +3 -4
  247. package/driver/skills/clearance-search/risk-framework-demo.md +1 -1
  248. package/driver/skills/clearance-search/risk-framework-triage.manifest.json +3 -3
  249. package/driver/skills/clearance-search/risk-framework-triage.md +7 -9
  250. package/driver/skills/clearance-search/risk-framework.manifest.json +1 -1
  251. package/driver/skills/clearance-search/risk-framework.md +1 -1
  252. package/driver/skills/clearance-search/synthesis-rules.md +30 -107
  253. package/driver/skills/clearance-search/worked-examples.md +5 -5
  254. package/driver/skills/clearance-variants/SKILL.md +46 -45
  255. package/driver/skills/clearance-variants/transliteration-scripts.md +4 -4
  256. package/driver/skills/frame-diff/SKILL.md +1 -1
  257. package/driver/skills/knockout-assess/SKILL.md +6 -14
  258. package/driver/skills/knockout-frame/SKILL.md +1 -1
  259. package/driver/skills/matter-frame/SKILL.md +7 -12
  260. package/driver/skills/matter-frame/watchlist-reference.md +1 -4
  261. package/driver/skills/narrative-refutation/SKILL.md +20 -30
  262. package/driver/skills/placement-inquiry/SKILL.md +10 -20
  263. package/driver/skills-store-provenance.mjs +1 -1
  264. package/driver/stage-context.mjs +32 -35
  265. package/driver/stage-freshness.mjs +127 -11
  266. package/driver/stages-knockout.mjs +49 -22
  267. package/driver/stages.mjs +89 -288
  268. package/driver/status-snapshot.mjs +2 -1
  269. package/driver/steps/correction-cycle.mjs +311 -0
  270. package/driver/steps/corrections.mjs +644 -0
  271. package/driver/steps/delivery.mjs +1287 -0
  272. package/driver/steps/frame-comparison.mjs +927 -0
  273. package/driver/steps/intake.mjs +84 -0
  274. package/driver/steps/open-run.mjs +419 -0
  275. package/driver/steps/overview-and-cards.mjs +899 -0
  276. package/driver/steps/placement-and-digest.mjs +23 -0
  277. package/driver/steps/register-sweep.mjs +1563 -0
  278. package/driver/steps/skeptic-and-follow-up.mjs +836 -0
  279. package/driver/steps/synthesis.mjs +261 -0
  280. package/driver/steps/verdict-gate.mjs +968 -0
  281. package/driver/suite-census.json +456 -96
  282. package/driver/surface-exit-verdict.mjs +0 -8
  283. package/driver/synthesis-record.mjs +72 -6
  284. package/driver/terminal-clamp.mjs +10 -0
  285. package/driver/tokens.mjs +8 -62
  286. package/driver/tool-calls.mjs +2 -2
  287. package/driver/unexecuted-asserts.json +2 -2
  288. package/driver/unit-state-verdict.mjs +1 -1
  289. package/driver/usage-ledger.mjs +2 -1
  290. package/driver/verify-knockout.mjs +20 -35
  291. package/driver/verify.mjs +47 -36
  292. package/driver/web-grid.mjs +3 -4
  293. package/driver/whatif-memo-run.mjs +2 -2
  294. package/driver/whatif-queue.mjs +4 -3
  295. package/driver/withheld-families.mjs +14 -15
  296. package/driver/worker-heartbeat.mjs +3 -2
  297. package/driver/write-up-form.mjs +0 -3
  298. package/mcp-server/CHANGELOG.md +8 -0
  299. package/mcp-server/http-server.mjs +11 -12
  300. package/mcp-server/lib/brief.mjs +22 -4
  301. package/mcp-server/lib/events.mjs +2 -2
  302. package/mcp-server/lib/evidence.mjs +3 -2
  303. package/mcp-server/lib/findings.mjs +2 -1
  304. package/mcp-server/lib/knockout.mjs +9 -10
  305. package/mcp-server/lib/ops.mjs +9 -9
  306. package/mcp-server/lib/runs.mjs +9 -10
  307. package/mcp-server/lib/trace.mjs +1 -1
  308. package/mcp-server/lib/whatif.mjs +2 -3
  309. package/mcp-server/package.json +1 -1
  310. package/mcp-server/server.mjs +5 -5
  311. package/node_modules/buffers/package.json +1 -1
  312. package/package.json +2 -1
  313. package/portal-ui/dist/assets/{index-fPqAU0sx.js → index-CYaO2ygd.js} +26 -14
  314. package/portal-ui/dist/assets/{index-AtB9ZpDH.css → index-izLa9apq.css} +2 -2
  315. package/portal-ui/dist/index.html +4 -4
  316. package/portal-ui/package.json +3 -3
  317. package/providers/README.md +1 -1
  318. package/providers/_shared/answer-memory.mjs +4 -5
  319. package/providers/_shared/execute-plan.mjs +48 -1
  320. package/providers/_shared/records-from-search.mjs +46 -0
  321. package/providers/clarivate/README.md +2 -2
  322. package/providers/clarivate/src/adapter.js +147 -0
  323. package/providers/clarivate/src/core.js +1 -14
  324. package/{driver/engine/mcp/clarivate-server.mjs → providers/clarivate/src/mount.js} +5 -10
  325. package/providers/corsearch/README.md +3 -3
  326. package/providers/corsearch/src/adapter.js +80 -0
  327. package/providers/corsearch/src/core.js +14 -11
  328. package/{driver/engine/mcp/corsearch-server.mjs → providers/corsearch/src/mount.js} +5 -10
  329. package/providers/euipo/README.md +2 -2
  330. package/providers/euipo/src/adapter.js +85 -0
  331. package/providers/euipo/src/core.js +1 -1
  332. package/providers/euipo/src/euipo-client.js +1 -2
  333. package/{driver/engine/mcp/euipo-server.mjs → providers/euipo/src/mount.js} +5 -10
  334. package/providers/free-tier/README.md +2 -2
  335. package/providers/free-tier/src/adapter.js +127 -0
  336. package/{driver/engine/mcp/free-tier-server.mjs → providers/free-tier/src/mount.js} +5 -10
  337. package/providers/jx-subclass/coverage.mjs +1 -6
  338. package/providers/jx-subclass/score-truth.mjs +2 -1
  339. package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
  340. package/providers/oauth-mcp-bridge/package.json +1 -1
  341. package/providers/perplexity/src/core.js +2 -2
  342. package/providers/signa/README.md +2 -2
  343. package/providers/signa/src/adapter.js +157 -0
  344. package/providers/signa/src/capabilities.js +0 -3
  345. package/providers/signa/src/core.js +2 -2
  346. package/{driver/engine/mcp/signa-server.mjs → providers/signa/src/mount.js} +7 -12
  347. package/providers/signa/src/offices.generated.js +17 -15
  348. package/providers/uspto-local/README.md +1 -1
  349. package/providers/uspto-local/bin/verify-index.mjs +1 -1
  350. package/providers/uspto-local/src/adapter.js +75 -0
  351. package/{driver/engine/mcp/uspto-local-server.mjs → providers/uspto-local/src/mount.js} +5 -10
  352. package/scripts/band-shape-probe.mjs +2 -2
  353. package/scripts/citation-line-check.mjs +7 -7
  354. package/scripts/compare.mjs +1 -1
  355. package/scripts/dead-names.mjs +2 -2
  356. package/scripts/e2e-first-time.mjs +19 -7
  357. package/scripts/e2e.mjs +13 -13
  358. package/scripts/engine-probe.mjs +1 -1
  359. package/scripts/env-audit.mjs +7 -4
  360. package/scripts/env-classify.mjs +5 -1
  361. package/scripts/feedback-mint.mjs +1 -1
  362. package/scripts/freeze-example-run.mjs +7 -7
  363. package/scripts/mint-suite-census.mjs +2 -2
  364. package/scripts/nightly-notice.mjs +1 -1
  365. package/scripts/release-cut-decision.mjs +7 -2
  366. package/scripts/release-note-required.mjs +26 -9
  367. package/scripts/release-notes-lint.mjs +3 -2
  368. package/scripts/release-version-pr-checks.mjs +1 -1
  369. package/scripts/render-check.mjs +1 -1
  370. package/scripts/settings-render-check.mjs +23 -3
  371. package/scripts/test-run.mjs +5 -5
  372. package/scripts/travelling-predicates.mjs +1 -1
  373. package/scripts/undeclared-field-census.mjs +1 -1
  374. package/scripts/unexecuted-asserts.mjs +3 -3
  375. package/scripts/verify-publishable.mjs +1 -1
  376. package/shared/client-door.mjs +1 -1
  377. package/shared/connect-clients.mjs +1 -1
  378. package/shared/connector-signin-probe.mjs +1 -1
  379. package/shared/customer-store.mjs +3 -2
  380. package/shared/env-aliases.mjs +1 -1
  381. package/shared/invocation.mjs +14 -2
  382. package/shared/names-in-force.mjs +2 -0
  383. package/shared/register-selection.mjs +2 -2
  384. package/shared/store-in-repo.mjs +3 -3
  385. package/shared/summary-blocks.mjs +0 -3
  386. package/shared/trigger-lane.mjs +1 -1
  387. package/shared/vacuous-pass.mjs +2 -2
  388. package/shared/verb-shim.mjs +4 -2
  389. package/vendor/buffers/package.json +1 -1
  390. package/node_modules/exceljs/README.md +0 -3023
@@ -37,7 +37,7 @@
37
37
 
38
38
  import { readFileSync, writeFileSync, readdirSync, existsSync, statSync, copyFileSync } from "node:fs";
39
39
  import { join } from "node:path";
40
- import { DRIVER_DIR } from "../shared/driver-dir.mjs"; //
40
+ import { DRIVER_DIR, readJsonOrNull } from "./run-record.mjs";
41
41
 
42
42
  export const RECEIPT_VERSION = 2;
43
43
 
@@ -49,7 +49,6 @@ export function receiptPath(poolRoot, id) {
49
49
  return join(String(poolRoot ?? ""), "..", `_e2e-doors-${String(id).toUpperCase()}.json`);
50
50
  }
51
51
 
52
- const readJson = (p) => { try { return JSON.parse(readFileSync(p, "utf8")); } catch { return null; } };
53
52
  const iso = (ms) => new Date(ms).toISOString();
54
53
 
55
54
  /**
@@ -281,7 +280,7 @@ export function findRunsByRef(ref, workspaceRoot) {
281
280
  for (const e of entries) {
282
281
  const p = join(dir, e.name);
283
282
  if (e.isFile() && e.name === "status.json") {
284
- const st = readJson(p);
283
+ const st = readJsonOrNull(p);
285
284
  if (st && String(st.ref ?? "").startsWith(String(ref))) {
286
285
  let mtime = 0;
287
286
  try { mtime = statSync(p).mtimeMs; } catch { /* the sort key degrades; the hit still counts */ }
@@ -410,7 +409,7 @@ export function selectRound(rounds, requestedToken = null) {
410
409
  */
411
410
  export function previousRunDir({ refs = [], workspaceRoot = null, runDir = null } = {}) {
412
411
  if (!runDir) return { error: "no run dir given — previousRunDir needs the run it should find the predecessor of" };
413
- const st = readJson(join(runDir, "status.json"));
412
+ const st = readJsonOrNull(join(runDir, "status.json"));
414
413
  if (!st) return { error: `${join(runDir, "status.json")} is missing or does not parse — a run's own ref is the only way to say which round it belongs to` };
415
414
  const thisRef = String(st.ref ?? "");
416
415
  if (!thisRef) return { error: `${join(runDir, "status.json")} carries no \`ref\`, so this run belongs to no nameable round` };
@@ -102,6 +102,9 @@ These are the one place the record holds the program's words: an expired sign-in
102
102
  `stop_sequence` and nothing else. `stopReason` stays verbatim beside them, and none of the three moves a
103
103
  verdict.
104
104
 
105
+ An adapter whose repair turns need a home that outlasts one turn also exports `makeStageHome(stage)` and
106
+ `releaseStageHome(home)`; `runStage` makes the home once per stage and passes it to each turn as `stageHome`.
107
+
105
108
  `runStage()` folds that into what the pipeline consumes — `{ok, json, attempts, text, sessionKey, …}` —
106
109
  and journals usage/wall/status on the way past.
107
110
 
@@ -16,6 +16,8 @@ does not exist — that is the design, and [`CONTRACT.md`](CONTRACT.md) is the d
16
16
  | `auth.mjs` | `resolveAuthMode()` — subscription, API key or (Claude only) cloud account, resolved once per turn and stamped on the telemetry |
17
17
  | `probe.mjs` | Drives one cheap turn through whichever adapter is configured, to prove the engine can complete a turn at all. What `npm run setup` spends |
18
18
  | `common.mjs` | Helpers both adapters share |
19
+ | `registry.mjs` | Which adapters this driver ships and which one `CLEAROTRON_AI` selects; the gateway asks it and names no engine |
20
+ | `stamps.mjs` | What the `engine` word on a saved attempt row means: the vendor billed, how its model is keyed, whether it is a native-language row |
19
21
  | `deny-authority-write.mjs` | A PreToolUse hook. `--add-dir` has no read-only form, so the read-only intent over the skills tree is enforced here |
20
22
  | [`mcp/`](mcp/README.md) | The tool servers a stage mounts, and the per-stage grant table |
21
23
 
@@ -21,8 +21,8 @@ import { statSync } from "node:fs";
21
21
  import { tmpdir } from "node:os";
22
22
  import { join, dirname } from "node:path";
23
23
  import { fileURLToPath } from "node:url";
24
- import { resolveSpawnCwd, spawnGraceMs } from "./common.mjs";
25
- import { resolveEngineProgram } from "../driver.config.mjs"; // — the one place that finds the program; it reads every spelling of the setting
24
+ import { WRITE_DISCIPLINE, absolutizeSkillRefs, resolveSpawnCwd, spawnGraceMs } from "./common.mjs";
25
+ import { resolveEngineProgram, resolveModel } from "../driver.config.mjs"; // — the one place that finds the program; it reads every spelling of the setting
26
26
  import { authorityTrees } from "../authority-trees.mjs";
27
27
  import { recordEngineChild, clearEngineChild } from "./child-record.mjs"; //
28
28
  import { engineEnv } from "./engine-env.mjs"; // — the program's environment, by list (see spawnEnv)
@@ -202,7 +202,7 @@ export function claudeModel(model) {
202
202
  // does not know, it says so and the turn fails loudly — which is the honest end of a bad pin.
203
203
  return /^claude-(?:[a-z]+-\d|\d)/.test(bare) ? bare : fam;
204
204
  }
205
- throw new Error(`anthropic-agent: no claude model mapped for "${model}" — this engine runs claude only. Pass opus/sonnet/haiku/fable or a concrete claude-* id. (It used to substitute sonnet silently and log the alias you asked for: #238 corruption 3.)`);
205
+ throw new Error(`anthropic-agent: no claude model mapped for "${model}" — this engine runs claude only. Pass opus/sonnet/haiku/fable or a concrete claude-* id. (It used to substitute sonnet silently and log the alias you asked for.)`);
206
206
  }
207
207
 
208
208
  // ── thinking tier → `claude --effort` ────────────────────────────────────────────────────────────────
@@ -239,39 +239,8 @@ export function mapUsage(u) {
239
239
  return { input, output, cacheRead, cacheWrite, total: input + output + cacheRead + cacheWrite };
240
240
  }
241
241
 
242
- // The Write-tool discipline the stages assume but claude -p doesn't infer from "write your output to <path>".
243
- // Byte-identical with engine/common.mjs's copy (this module deliberately imports nothing but node built-ins);
244
- // engine.common.test.mjs asserts the two never drift. See that copy's header for the repair exception's why.
245
- export const WRITE_DISCIPLINE =
246
- "OUTPUT DISCIPLINE — read carefully: when the task instructs you to write output to an absolute file path, " +
247
- "you MUST create that file by CALLING THE WRITE TOOL with that exact path and the full content. Output you " +
248
- "place only in your text reply is DISCARDED and the task is scored as FAILED. Do the actual work, write every " +
249
- "required file via the Write tool (overwrite if it exists), and only THEN reply — with just the path(s) you " +
250
- "wrote and a 2-3 line summary. Never claim a file is written unless you invoked the Write tool to write it. " +
251
- "EXCEPTION — REPAIRS: when the task instructs you to FIX or CORRECT an EXISTING file, use the Edit tool and " +
252
- "change only what the correction names — a file corrected with the Edit tool counts as written. Rewriting a " +
253
- "whole file to fix a few lines risks degrading content that already passed. If the file does not exist, the " +
254
- "rule above stands: create it in full with the Write tool.";
255
-
256
- // The shared stage prompts reference skills by the convention `skills/foo/SKILL.md` — a workspace agent
257
- // resolves these against its workspace cwd, but `claude -p` (cwd = a neutral tmpdir, to avoid loading the
258
- // repo CLAUDE.md) resolves them against /tmp → missing_file (the 2026-06-16 matter-frame blocker). Rewrite
259
- // every `skills/…md` token to an ABSOLUTE path under the configured compute-skills tree (`config.skillsDir`,
260
- // default <driverDir>/skills as of the Phase-3 skills move; was <workspaceDir>/skills before). The refs keep
261
- // their `skills/` prefix, so we join them onto the PARENT of skillsDir — i.e. join(dirname(skillsDir),
262
- // "skills/foo.md"). Engine-localized: the caller's original message is NEVER mutated. The
263
- // negative lookbehind on [\w/.] makes the rewrite IDEMPOTENT — an already-absolute path that contains
264
- // `skills/` (the rewritten form, or a corrective/warm re-wrap of an absolutized message) is preceded by
265
- // `/` and so is never double-prefixed.
266
- const SKILL_REF = /(?<![\w/.])skills\/[A-Za-z0-9._/-]+\.md/g;
267
- // `resolve` (optional) maps a `skills/...` ref to the file that should actually be read — the layered
268
- // overlay-over-base lookup (driver.config.resolveSkillPath). Without it the legacy single-dir behaviour
269
- // stands, so this stays a pure function over its inputs and every existing caller/test is unaffected.
270
- export function absolutizeSkillRefs(message, skillsDir, resolve = null) {
271
- if (!message || (!skillsDir && !resolve)) return message;
272
- const base = skillsDir ? dirname(skillsDir) : null; // skillsDir ends in /skills; refs carry their own `skills/` prefix
273
- return message.replace(SKILL_REF, (m) => (resolve ? resolve(m) : join(base, m)));
274
- }
242
+ // The Write-tool discipline and the skill-reference rewrite are shared with the Codex adapter: engine/common.mjs.
243
+ export { WRITE_DISCIPLINE, absolutizeSkillRefs };
275
244
 
276
245
  // Returns { args, input }: `args` is the flag list with `-p` as a BARE flag (no positional prompt), and
277
246
  // `input` is the absolutized prompt to write to the child's STDIN. The prompt is NOT an argv element:
@@ -499,7 +468,7 @@ export function writeBoundarySettings({ skillsRoots = [], profilesDir = null, ru
499
468
  // and ships with it, so "missing" means a broken deploy, and a broken deploy that stops loudly beats one
500
469
  // that runs every clearance with no boundary and says nothing.
501
470
  try { statSync(hook); }
502
- catch { throw new Error(`write_boundary_hook_missing:${hook} (the #595 deny-hook is not in this deployment; a missing hook command fails OPEN in the CLI, so the dispatch is refused rather than run unprotected)`); }
471
+ catch { throw new Error(`write_boundary_hook_missing:${hook} (the deny-hook is not in this deployment; a missing hook command fails OPEN in the CLI, so the dispatch is refused rather than run unprotected)`); }
503
472
  const payload = Buffer.from(JSON.stringify({ trees, runDir: runDir ?? null }), "utf8").toString("base64");
504
473
  return JSON.stringify({
505
474
  hooks: {
@@ -537,6 +506,8 @@ export const anthropicAgentEngine = {
537
506
  // doctrine tree, the profile store and `<runDir>/_driver/` at the moment of the write. That is a real
538
507
  // boundary and this engine has it.
539
508
  writeBoundary: "enforced",
509
+ // The id a turn's rows record as asked for: the tier through Claude's catalog, `opus` → `anthropic/claude-opus`.
510
+ resolveModelId(model) { return resolveModel(model); },
540
511
  async runTurn({ message, model, thinking, timeoutSec, resumeRef, mcpConfig, allowedTools, cwd, skillsDir, skillsGrantRoots, profilesDir, resolveSkill, runDir, seatWrites = null, grantDispatch = null, stallSec, progressFiles, streamFile = null } = {}) {
541
512
  if (!message) throw new Error("anthropic-agent.runTurn: message is required");
542
513
  const { args, input, grantNote } = buildClaudeArgs({ message, model, thinking, resumeRef, mcpConfig, allowedTools, cwd, skillsDir, skillsGrantRoots, profilesDir, resolveSkill, runDir, seatWrites, grantDispatch });
@@ -604,10 +575,10 @@ export const anthropicAgentEngine = {
604
575
  const maxBuffer = engineMaxBufferChars();
605
576
  let lastMove = Date.now();
606
577
  let lastProgress = Date.now(); // honest-progress clock: token movement / agent-loop steps / artifact writes ONLY
607
- let firstOutputAt = null; // #1692/#1813 — first byte of the PROTOCOL (stdout only); until then every clock below is timing STARTUP
578
+ let firstOutputAt = null; // first byte of the PROTOCOL (stdout only); until then every clock below is timing STARTUP
608
579
  let atKill = null; // what the watchdog had seen when it decided to kill — recording only, see killDecision
609
580
  let silentIdleMs = null; // the no-progress clock at the watchdog's last look before the child spoke — recording only
610
- const GRACE = spawnGraceMs(); // one source of the grace: common.mjs, where #1703 set it
581
+ const GRACE = spawnGraceMs(); // one source of the grace: common.mjs sets it
611
582
  let sawAnyEvent = false; // ANY parseable stream event (incl. system:init) — false on close = the CLI died before streaming (startup-class failure)
612
583
  let rateLimitEvent = null; // a 429 session-cap rejection rides a `rate_limit_event` (status:"rejected" + resetsAt)
613
584
  // Streamed-usage accumulator: what the turn PROVABLY moved, observed from the stream itself, so a
@@ -878,7 +849,7 @@ export const anthropicAgentEngine = {
878
849
  // classification and no recovery park, or the turn never settles with its watchdog already gone.
879
850
  // Same belt-and-braces as the thinking gauge's `?.some?.()` on the line above.
880
851
  for (const b of Array.isArray(ev.message?.content) ? ev.message.content : []) {
881
- if (b?.type === "tool_use") { toolCalls++; countTool(toolCallsByName, b?.name); } // #1111 — every tool, not only Read; the count and its split by name
852
+ if (b?.type === "tool_use") { toolCalls++; countTool(toolCallsByName, b?.name); } // every tool, not only Read; the count and its split by name
882
853
  if (b?.type === "tool_use" && b?.id != null) toolNameById.set(String(b.id), String(b?.name ?? "?"));
883
854
  if (b?.type === "tool_use" && COMMAND_TOOLS.includes(b?.name)) commandToolCalls++;
884
855
  if (b?.type === "tool_use" && FILE_WRITE_TOOLS.includes(b?.name) && b?.id != null) writeAsks.add(String(b.id));
@@ -1090,7 +1061,7 @@ export const anthropicAgentEngine = {
1090
1061
  const overflowKill = () => { if (overflow) return; overflow = true; killTree(); settle(1); };
1091
1062
  child.stdout.on("data", (d) => {
1092
1063
  if (settled || overflow) return;
1093
- if (firstOutputAt === null) firstOutputAt = Date.now(); // #1692 — the child has spoken; startup is over
1064
+ if (firstOutputAt === null) firstOutputAt = Date.now(); // the child has spoken; startup is over
1094
1065
  chunkSeq += 1; // see toolAskedChunk
1095
1066
  chunkBytes = d.length;
1096
1067
  chunkGapMs = prevChunkAt === null ? 0 : Date.now() - prevChunkAt;
@@ -1221,7 +1192,7 @@ export const anthropicAgentEngine = {
1221
1192
  // true = the 500-path cap dropped at least one further distinct file (so a `read:false` derived
1222
1193
  // from this list is unreliable and the consumer must downgrade it to "not observed").
1223
1194
  reads: [...reads], readsTruncated,
1224
- toolCalls, toolWaitMs: settledToolWaitMs, // #1111 — two integers, no content
1195
+ toolCalls, toolWaitMs: settledToolWaitMs, // two integers, no content
1225
1196
  // The same calls by tool name (values sum to toolCalls), and what the session went through: every
1226
1197
  // result, cut, refusal and restart (session-record.mjs). `stream` is the raw stream's file and size,
1227
1198
  // or why it was not kept. Recording only — `failed` above still reads the last result alone.
@@ -168,3 +168,77 @@ export function resolveAuthMode({ engineName, env = process.env } = {}) {
168
168
 
169
169
  return { provider: name || "unknown", mode: "unknown", apiBilled: false };
170
170
  }
171
+
172
+ /**
173
+ * What a reader calls the account a cloud mode bills: "Google Cloud", "Microsoft Azure", "Amazon Bedrock"
174
+ * or "Gateway". Null for no cloud.
175
+ *
176
+ * ONE TABLE OF CLOUD NAMES, NOT TWO. `CLOUD_CREDENTIAL_CHECK` in engine/auth.mjs already names each cloud
177
+ * the way a reader knows it, for the advice a refused sign-in prints, and this reads it rather than keeping
178
+ * a second list that could name a cloud differently on the page. It writes the gateway "the gateway", for
179
+ * use inside a sentence; a label on a page drops the article and starts with a capital, and that one
180
+ * adjustment is the whole of what this adds.
181
+ */
182
+ export function cloudName(cloud) {
183
+ const who = CLOUD_CREDENTIAL_CHECK[cloud]?.who;
184
+ if (!who) return null;
185
+ const bare = who.replace(/^the /, "");
186
+ return bare.charAt(0).toUpperCase() + bare.slice(1);
187
+ }
188
+
189
+ /**
190
+ * WHY A BILLING SETTING REFUSES EVERY SEARCH, as data: which refusal it is and the names involved, so the
191
+ * config page words it once, in plain English, without reading the resolver's sentence apart.
192
+ *
193
+ * `kind` is one of:
194
+ * switch-beside-mode subscription or api-key, and a cloud's switch on beside it (`clouds`)
195
+ * two-clouds cloud, and more than one cloud switched on (`clouds`)
196
+ * no-cloud cloud, and no cloud switched on and no gateway address (`clouds` lists every
197
+ * switch, and `gateway` the gateway's setting, as the choices to make)
198
+ * not-a-mode a word that is not a billing mode (`modes` are the ones this engine takes)
199
+ * cloud-on-codex cloud, on the Codex engine, which a cloud account cannot pay for (`engineSetting`
200
+ * and `engineChoice` name the Claude engine only where it would pay: one cloud
201
+ * switched on, or none and a gateway address; otherwise that move is one more refusal)
202
+ * unclassified a refusal this list does not name; the page says only that searches are refused.
203
+ * Not "other": that is an assistant's id in connect-clients.mjs, and a surface may
204
+ * not name one in code
205
+ *
206
+ * `defaulted` says the billing setting is blank, so `subscription` is the default and not a word anybody
207
+ * wrote: a page that said "payment is set to subscription" would send a reader looking for a line their
208
+ * settings file does not have. It is the state measured on Foundry, a switch on and the word unset.
209
+ *
210
+ * THE SAME PREDICATES AS THE RESOLVER, IN ITS ORDER. `resolveAuthMode` refuses by throwing a sentence and
211
+ * nothing else, so the kind is read back from the same environment through the same functions it uses
212
+ * (`billingMode`, `cloudsSwitchedOn`), in the order it checks them. Called only once it has thrown.
213
+ *
214
+ * NAMES, NEVER A VALUE. `mode` is sent only when it is one of the three modes; the word in a `not-a-mode`
215
+ * refusal is whatever was typed, and it is not sent at all.
216
+ */
217
+ export function billingRefusalReason(id, env = process.env) {
218
+ const mode = billingMode(env);
219
+ const setting = "CLEAROTRON_AI_BILLING";
220
+ const clouds = (ids) => ids.map((c) => ({ name: cloudName(c), setting: CLOUD_SWITCH[c] }));
221
+ const defaulted = String(env[setting] ?? "").trim() === "";
222
+ const base = { setting, mode: null, defaulted, clouds: [], modes: [], gateway: null, engineSetting: null, engineChoice: null };
223
+ if (id === "openai-agent") {
224
+ if (mode === "cloud") {
225
+ // The resolver's own test for a cloud the Claude engine would pay through, in its words: one switch,
226
+ // or no switch and a gateway address.
227
+ const on = cloudsSwitchedOn(env);
228
+ const claudeWouldPay = on.length === 1 || (!on.length && Boolean(env.ANTHROPIC_BASE_URL));
229
+ return { ...base, kind: "cloud-on-codex", mode, modes: ["subscription", "api-key"],
230
+ ...(claudeWouldPay ? { engineSetting: "CLEAROTRON_AI", engineChoice: "anthropic-agent" } : {}) };
231
+ }
232
+ if (mode !== "subscription" && mode !== "api-key") return { ...base, kind: "not-a-mode", modes: ["subscription", "api-key"] };
233
+ }
234
+ if (id === "anthropic-agent") {
235
+ const on = cloudsSwitchedOn(env);
236
+ if ((mode === "subscription" || mode === "api-key") && on.length) return { ...base, kind: "switch-beside-mode", mode, clouds: clouds(on) };
237
+ if (mode === "cloud" && on.length > 1) return { ...base, kind: "two-clouds", mode, clouds: clouds(on) };
238
+ if (mode === "cloud" && !on.length) {
239
+ return { ...base, kind: "no-cloud", mode, clouds: clouds(Object.keys(CLOUD_SWITCH)), gateway: "ANTHROPIC_BASE_URL" };
240
+ }
241
+ if (!BILLING_MODES.includes(mode)) return { ...base, kind: "not-a-mode", modes: [...BILLING_MODES] };
242
+ }
243
+ return { ...base, kind: "unclassified", mode: BILLING_MODES.includes(mode) ? mode : null };
244
+ }
@@ -44,7 +44,7 @@
44
44
 
45
45
  import { writeFileSync, readFileSync, rmSync } from "node:fs";
46
46
  import { spawnSync } from "node:child_process";
47
- import { driverDir } from "../../shared/driver-dir.mjs";
47
+ import { driverDir } from "../run-record.mjs";
48
48
  import { procStarttime, parseClaimSidecar } from "../claim-liveness.mjs";
49
49
  import { endWindowsTree } from "./engine-spawn.mjs"; // Windows has no process group to signal
50
50
 
@@ -45,7 +45,7 @@
45
45
 
46
46
  import { readFileSync, appendFileSync } from "node:fs";
47
47
 
48
- import { driverDir } from "../../shared/driver-dir.mjs"; //
48
+ import { paths } from "../run-record.mjs"; //
49
49
  import { denyReason } from "../authority-trees.mjs";
50
50
  import { isEntrypoint } from "../../shared/is-entrypoint.mjs"; //
51
51
 
@@ -136,7 +136,7 @@ const deny = (reason) => {
136
136
  // journal lands, because a boundary that depends on a successful write is not one.
137
137
  function journal(runDir, row) {
138
138
  if (!runDir) return;
139
- try { appendFileSync(driverDir(runDir, "authority-denials.jsonl"), JSON.stringify(row) + "\n"); } catch { /* the deny still stands */ }
139
+ try { appendFileSync(paths(runDir).authorityDenials, JSON.stringify(row) + "\n"); } catch { /* the deny still stands */ }
140
140
  }
141
141
 
142
142
  function main() {
@@ -132,15 +132,23 @@ export async function makeJxTurnRunner({
132
132
  thinking = JX_THINKING,
133
133
  // Names the lane in the one message a caller shows a human when the configuration refuses.
134
134
  lane = "the jx lanes",
135
+ // The run the lanes serve. A run that recorded its engine when it started keeps it here as its stages do
136
+ // (engine/run-choices.mjs), so its lanes never run on another engine. Absent, or a run with no record: the
137
+ // machine's setting, read as below.
138
+ runDir = null,
135
139
  } = {}) {
140
+ const rec = runDir ? (await import("./run-choices.mjs")).readRunChoices(runDir) : { state: "none" };
141
+ if (rec.state === "unreadable") return { error: `this run's engine record ${rec.detail}, so ${lane} do not run on the machine's engine in its place` };
142
+ if (rec.state === "recorded" && !ENGINE_BINARIES[rec.engine])
143
+ return { error: `this run started on the "${rec.engine}" engine, which this driver does not ship; ${lane} keep that engine rather than switch` };
136
144
  // NO AI CHOSEN IS NOT THE DEFAULT AI. With CLEAROTRON_AI unset this door resolved the code's default, so an
137
145
  // install with no AI chosen got a turn runner on that AI's program, billed to whatever it was signed in to:
138
146
  // the portal booted "brief reading ON — engine=anthropic-agent", and Describe-it would have spent a turn
139
147
  // there (measured on a fresh install of 0.5.1-beta.0, 2026-11-07). A search with no AI chosen is refused at
140
148
  // order time, before a lane could ask; the portal's reader asks at boot. So the door refuses here, in the
141
149
  // order-time gate's own words, and reads the setting as that gate reads it: blank is not chosen.
142
- if (!String(env.CLEAROTRON_AI ?? "").trim()) return { error: whatIsMissing([{ about: "ai" }]) };
143
- const id = String(env.CLEAROTRON_AI).trim().toLowerCase();
150
+ if (rec.state !== "recorded" && !String(env.CLEAROTRON_AI ?? "").trim()) return { error: whatIsMissing([{ about: "ai" }]) };
151
+ const id = rec.state === "recorded" ? rec.engine : String(env.CLEAROTRON_AI).trim().toLowerCase();
144
152
  if (!ENGINE_BINARIES[id]) return { error: `CLEAROTRON_AI=${id} is not an engine this driver ships` };
145
153
 
146
154
  let auth;
@@ -54,7 +54,7 @@ wiring as a `config.toml` through `codex-config.mjs`, and `../../test/engine.gat
54
54
  | `codex-config.mjs` | The same wiring rendered as a codex `config.toml`, so `gather-config.mjs` stays the one source |
55
55
  | `stdio-server.mjs` | `serve()` — the shared JSON-RPC stdio scaffolding, and the writer of the per-run `_driver/tool-calls.jsonl`, where a `started` line with no `settled` line is the only evidence that a killed call ever happened |
56
56
  | `http-dispatcher.mjs` | Side-effect import: raises undici's 300s headers timeout for long grid/register calls |
57
- | `corsearch-server.mjs`, `clarivate-server.mjs`, `euipo-server.mjs`, `signa-server.mjs`, `uspto-local-server.mjs`, `free-tier-server.mjs` | One per register provider, all under the neutral `register_*` names |
57
+ | `register-server.mjs` | The one server for every register provider, mounting `providers/<id>/src/mount.js` by name, under the neutral `register_*` names |
58
58
  | `supplemental.mjs` | Mint-and-execute for model-proposed register queries; bound by each server that serves `register_propose_supplemental` |
59
59
  | `perplexity-server.mjs` | `perplexity_research` (the common-law grid and open-web research); calls the Perplexity agent API under `PERPLEXITY_API_KEY`. It served `record_dispositions` too until — a record tool on a key FOUR stages hold, so three of them were granted a writer into the common-law lane's ruling ledger that no doctrine of theirs ordered |
60
60
  | `band-server.mjs` | Read-only lookups over the run's frozen register band; every call appended to the reading audit |
@@ -18,7 +18,7 @@
18
18
  // CLEAROTRON_GATHER_SESSION_KEY / CLEAROTRON_GATHER_AGENT (attribution for the reading log).
19
19
  import { readFileSync, readdirSync, appendFileSync, existsSync, mkdirSync } from "node:fs";
20
20
  import { join, dirname } from "node:path";
21
- import { driverDir } from "../../../shared/driver-dir.mjs"; //
21
+ import { paths, readJson } from "../../run-record.mjs"; //
22
22
  import { serve } from "./stdio-server.mjs";
23
23
  import { answerBudget, quotedBytes } from "../../../shared/answer-parts.mjs";
24
24
  import { classifyRecord, prepareTargets, SHAPE_TIERS, isLiveRecord, niceClassKey, withoutPlacementOrders } from "../../band-shape.mjs";
@@ -34,9 +34,9 @@ const SESSION = process.env.CLEAROTRON_GATHER_SESSION_KEY || "";
34
34
  const AGENT = process.env.CLEAROTRON_GATHER_AGENT || "";
35
35
 
36
36
  const bandPath = () => join(RUN_DIR, "register-named-band.json");
37
- const shapeJsonPath = () => driverDir(RUN_DIR, "band-shape.json");
37
+ const shapeJsonPath = () => paths(RUN_DIR).bandShape;
38
38
  const shapeMdPath = () => join(RUN_DIR, "band-shape.md");
39
- const readingLogPath = () => driverDir(RUN_DIR, "reading-log.jsonl");
39
+ const readingLogPath = () => paths(RUN_DIR).readingLog;
40
40
  // — THE RUN'S OWN RECORD LEDGER, which this tool did not know about.
41
41
  //
42
42
  // A fetch writes here; `_records/` is populated from it by a union that does not run until the END of
@@ -48,7 +48,7 @@ const readingLogPath = () => driverDir(RUN_DIR, "reading-log.jsonl");
48
48
  //
49
49
  // Run-scoped by construction, so no prefix filter is needed: this file lives in the run dir and every
50
50
  // line in it belongs to this run.
51
- const recordLedgerPath = () => driverDir(RUN_DIR, "register-record-bodies.jsonl");
51
+ const recordLedgerPath = () => paths(RUN_DIR).registerRecordBodies;
52
52
 
53
53
  /**
54
54
  * The record body this run has already fetched, or null.
@@ -88,7 +88,7 @@ function logRead(tool, args, result) {
88
88
  } catch { /* best-effort — a log failure must never break a lookup */ }
89
89
  }
90
90
 
91
- const loadJson = (p) => JSON.parse(readFileSync(p, "utf8"));
91
+ const loadJson = (p) => readJson(p);
92
92
 
93
93
  // ── bounded serving: the transport cap is TOKENS, not the 256KB Read cap ─────────────────────────────────
94
94
  // The engine carries a tool result over MCP, and claude -p caps one tool output at
@@ -164,12 +164,14 @@ const NOISE_KEYS = new Set(["raw", "highlight", "score", "poca_scores", "onomati
164
164
  // the extra provenance is the answer ("which owner slice found this?"). The FILTER always reads the
165
165
  // band file itself, never this projection, so matching is unaffected either way.
166
166
  const singleton = (v, first) => !Array.isArray(v) || v.length <= 1 || (v.length === 1 && v[0] === first);
167
+ // A record's set-aside is served as its classes and reason. The shape's recorded answer for that wording (`test`) is
168
+ // read into `goods_words`, and is not served on its own.
167
169
  const project = (r) => Object.fromEntries(Object.entries(r).filter(([k, v]) => {
168
170
  if (NOISE_KEYS.has(k)) return false;
169
171
  if (k === "_qids") return !singleton(v, r?._qid);
170
172
  if (k === "_queries") return !singleton(v, r?._query);
171
173
  return true;
172
- }));
174
+ }).map(([k, v]) => (k === "goods_set_aside" && v && typeof v === "object" ? [k, { classes: v.classes, reason: v.reason }] : [k, v])));
173
175
 
174
176
  const norm = (s) => String(s ?? "").trim().toLowerCase();
175
177
  // A3 (addendum 2026-07-30): the READER lowercases the incoming uri — reader-side ONLY. The archived
@@ -232,7 +234,7 @@ function resolveRecordFile(dir, uri) {
232
234
  for (const f of files) {
233
235
  if (!f.toLowerCase().startsWith(base + "-")) continue; // an instance suffix, or an unrelated id
234
236
  let body;
235
- try { body = JSON.parse(readFileSync(join(dir, f), "utf8")); } catch { continue; }
237
+ try { body = readJson(join(dir, f)); } catch { continue; }
236
238
  if (typeof body?._uri === "string" && normalizeRecordUri(body._uri) === canon)
237
239
  confirmed.push({ file: join(dir, f), uri: body._uri });
238
240
  }
@@ -299,7 +301,7 @@ const shapeGoodsTest = () => {
299
301
  if (testCache) return testCache;
300
302
  let words = [];
301
303
  try { words = loadJson(shapeJsonPath()).groups?.goods_test?.words ?? []; } catch { words = []; }
302
- testCache = { words, matched: goodsWordsMatched(words, { stems: true }) };
304
+ testCache = { words, matched: goodsWordsMatched(words, { stems: true, setAsideTest: true }) };
303
305
  return testCache;
304
306
  };
305
307
  // THE REGISTER'S OWN PAGES THE RUN'S RESEARCH SAVED (saved-register-pages.mjs), read again at the start of each lookup
@@ -560,9 +562,11 @@ function bandRecord(params = {}) {
560
562
  logRead("band_record", { record_id: uri }, { ok: false, reason: hit.miss, ...(failed ? { fetch_failed: true } : {}) });
561
563
  return { isError: true, text: `${why} ${rest}` };
562
564
  }
563
- const goodsLines = statements.map((g) => JSON.stringify({ class: g.classes.join(",") || null, text: g.text,
564
- goods_from: g.cut ? "search answer, cut by the register" : g.unknown ? "search answer, completeness not established"
565
- : g.page ? registerPageLabel(g.page.question) : "search answer" }));
565
+ // A class whose goods text the merged band set aside is said as set aside, with no text: never an empty statement.
566
+ const goodsLines = statements.map((g) => JSON.stringify(g.setAside ? { class: g.classes.join(",") || null, text: null, goods_from: SET_ASIDE_FROM }
567
+ : { class: g.classes.join(",") || null, text: g.text,
568
+ goods_from: g.cut ? "search answer, cut by the register" : g.unknown ? "search answer, completeness not established"
569
+ : g.page ? registerPageLabel(g.page.question) : "search answer" }));
566
570
  const text = [why, ...goodsLines, rest].join("\n");
567
571
  const parts = splitAtLines(text, RESPONSE_CHARS);
568
572
  const wanted = Number(params.part ?? 1);
@@ -574,6 +578,9 @@ function bandRecord(params = {}) {
574
578
  + (part < parts.length ? `\n[end of part ${part}/${parts.length} — part ${part + 1} is available with {"record_id": "${uri}", "part": ${part + 1}}]` : "") };
575
579
  }
576
580
 
581
+ // What `band_record` says of a class whose goods text the merged band set aside (named-band.mjs `rowAsHanded`).
582
+ const SET_ASIDE_FROM = "set aside from this run's band, outside the order's classes: not shown, and not the register listing no goods";
583
+
577
584
  // The band row a record id names, from the band file, read once per server. null where the band holds none.
578
585
  let bandRowsCache = null;
579
586
  function bandRowFor(uri) {
@@ -600,7 +607,7 @@ const GROUP_PAGES = process.env.CLEAROTRON_BAND_GROUPS === "1";
600
607
  // served the shape without them (the owner's ruling, 2026-10-14). Each is removed with the space before it, inside
601
608
  // its line, so no line moves and the line each listed mark is printed on, which `linesByPart` reads, still holds.
602
609
  // (band-shape.mjs `withoutPlacementOrders` removes them, with the shape's other placement-only orders and its group-page commands.)
603
- const LOOKUP_DESCRIPTION = "Look up enumerated records in this run's frozen register band (read-only; logged to the reading audit). Filters AND together: record_id (exact uri), owner (substring), nice_class, tier (identical|near-identical|same-family|other|unclassifiable — classified against the shape's frozen targets), qid (exact plan-entry id — the plan-execution ledger join; a record surfaced by several slices matches under EVERY one of them), query (the _query slice that surfaced the record), text (substring of mark_text), status (substring), live_only, goods (words: records whose goods contain any of them, as whole words, singular or plural; a record with no goods on file matches too), group (a, b, c, d, rest or no_goods: that list's lines in the shape's order, one per mark of an owner), limit (default 20, max 100), offset (default 0: where in the matching records or lines to start — a capped answer names the offset where the next page starts). On each record served, `goods_words` gives the client's goods words its goods hold, as the shape tests them (k of N: the words), or null where its goods cannot be read; `goods_from` says what those goods rest on: official record; official record, cut by the register; official record, completeness not established; official record, no goods listed; search answer; search answer, cut by the register; search answer, completeness not established; the register's own page, saved by research question <N>; fetch failed; or nothing held. The goods text is in band_record. Matching un-enumerated crowd descriptors ride along so a lookup can never mistake a counted-only zone for a clean.";
610
+ const LOOKUP_DESCRIPTION = "Look up enumerated records in this run's frozen register band (read-only; logged to the reading audit). Filters AND together: record_id (exact uri), owner (substring), nice_class, tier (identical|near-identical|same-family|other|unclassifiable — classified against the shape's frozen targets), qid (exact plan-entry id — the plan-execution ledger join; a record surfaced by several slices matches under EVERY one of them), query (the _query slice that surfaced the record), text (substring of mark_text), status (substring), live_only, goods (words: records whose goods contain any of them, as whole words, singular or plural; a record with no goods on file matches too, and so does one with a class's goods text set aside where the rest holds none of the words), group (a, b, c, d, rest or no_goods: that list's lines in the shape's order, one per mark of an owner), limit (default 20, max 100), offset (default 0: where in the matching records or lines to start — a capped answer names the offset where the next page starts). On each record served, `goods_words` gives the client's goods words its goods hold, as the shape tests them (k of N: the words), or null where its goods cannot be read; `goods_from` says what those goods rest on: official record; official record, cut by the register; official record, completeness not established; official record, no goods listed; search answer; search answer, cut by the register; search answer, completeness not established; the register's own page, saved by research question <N>; fetch failed; or nothing held. The band row names omitted classes in `goods_set_aside`. When the goods served come from the trimmed search answer, `goods_from` names those omissions; a separately fetched official record may supply their wording. A saved goods-word result records the outcome of the shape's stated word test on the wording available when the band was merged. It supports grouping and order. It does not establish that the omitted goods are legally unrelated. `band_record` shows what wording is available to read now. The goods text is in band_record, except a set-aside class's text where no official record was fetched. Matching un-enumerated crowd descriptors ride along so a lookup can never mistake a counted-only zone for a clean.";
604
611
  const LOOKUP_GROUP_CLAUSE = "group (a, b, c, d, rest or no_goods: that list's lines in the shape's order, one per mark of an owner), ";
605
612
  const LOOKUP_OFFSET_GROUPS = "offset (default 0: where in the matching records or lines to start — a capped answer names the offset where the next page starts)";
606
613
  const LOOKUP_OFFSET_BAND = "offset (default 0: where in the matching records to start — a capped answer names the offset where the next page starts)";
@@ -633,7 +640,7 @@ serve({
633
640
  },
634
641
  {
635
642
  name: "band_record",
636
- description: "The OFFICIAL registry record the driver fetched into this run's _records/ for a given record_id (/mark/... uri) — the fetched document itself, for detail the band row does not carry. Cite the uri in whatever form the band, the findings or the provider gave you: case, a wrapping provider URL and the registration-instance suffix are all resolved to the same document. Read-only: it never fetches. An unfetched record returns an honest miss listing what is on file, with the goods the register's search answer listed for it where it listed any; a record that IS on file but cannot be opened says so — both are gaps to state, never records without documents. Every call is logged to the reading audit.",
643
+ description: "The OFFICIAL registry record the driver fetched into this run's _records/ for a given record_id (/mark/... uri) — the fetched document itself, for detail the band row does not carry. Cite the uri in whatever form the band, the findings or the provider gave you: case, a wrapping provider URL and the registration-instance suffix are all resolved to the same document. Read-only: it never fetches. A fetched record is served whole, every class. An unfetched record returns an honest miss listing what is on file, with the goods the register's search answer listed for it where it listed any, except the text of a class outside the order's classes, which this run's band set aside and names as set aside; a record that IS on file but cannot be opened says so — both are gaps to state, never records without documents. Every call is logged to the reading audit.",
637
644
  inputSchema: { type: "object", required: ["record_id"], properties: { record_id: { type: "string", description: "the /mark/<cc>/<id> uri" }, part: { type: "number", description: "1-based part number when an oversize record is served in parts (default 1)" } } },
638
645
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
639
646
  handler: bandRecord,
@@ -5,7 +5,7 @@
5
5
  // exact server/tool wiring. Two inputs, both produced today by the gateway gather block:
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { dirname, join } from "node:path";
8
- import { tomlString } from "../../../shared/toml-string.mjs"; import { driverDir } from "../../../shared/driver-dir.mjs";
8
+ import { tomlString } from "../../../shared/toml-string.mjs"; import { driverDir } from "../../run-record.mjs";
9
9
 
10
10
  // • mcpConfig — the claude-shaped JSON string `{mcpServers:{name:{command,args,env,connectionTimeoutMs?}}}`
11
11
  // (buildGatherMcpConfig → JSON.stringify)
@@ -36,9 +36,8 @@
36
36
  import { serve } from "./stdio-server.mjs";
37
37
  import { recordDeclinations } from "../../declination-tool.mjs";
38
38
  import { MAX_DECLINATIONS_PER_CALL, DECLINATION_REASONS, DECLINATION_REASON_TOKENS } from "../../declination-call.mjs";
39
- import { readFileSync } from "node:fs";
40
39
  import { join } from "node:path";
41
- import { driverDir } from "../../../shared/driver-dir.mjs"; //
40
+ import { driverDir, readJson } from "../../run-record.mjs"; //
42
41
 
43
42
  const DECLINATION_SPEC = "declination-spec.json";
44
43
 
@@ -55,7 +54,7 @@ const DECLINATION_SPEC = "declination-spec.json";
55
54
  * which is the failure the doubt-closure transport's own loader records in the same words.
56
55
  */
57
56
  function loadDeclinationSpec(runDir) {
58
- const spec = JSON.parse(readFileSync(driverDir(runDir, DECLINATION_SPEC), "utf8"));
57
+ const spec = readJson(driverDir(runDir, DECLINATION_SPEC));
59
58
  return {
60
59
  runDir,
61
60
  rows: Array.isArray(spec?.rows) ? spec.rows : [],
@@ -49,7 +49,6 @@
49
49
  // makes and the only one that matters for a grant review. `validateGridSpec` is imported from the
50
50
  // perplexity core for the same reason it always was: the spec is that core's format, and re-deriving a
51
51
  // validator here would be a second opinion about one file's shape.
52
- import { readFileSync } from "node:fs";
53
52
  import { serve } from "./stdio-server.mjs";
54
53
  import { validateGridSpec } from "../../../providers/perplexity/src/core.js";
55
54
  import { underStudioSegment } from "../../../shared/path-seps.mjs"; // Windows builds the path with "\"
@@ -61,6 +60,7 @@ import { MAX_ROWS_PER_CALL } from "../../disposition-call.mjs";
61
60
  // own module and its own file, never a row in the disposition form — see record_coverage_status below.
62
61
  import { recordCoverageStatus, COMMON_LAW_COVERAGE_STATUSES } from "../../common-law-coverage-status.mjs";
63
62
  import { insideRun } from "../../../shared/inside-run.mjs"; // a path a tool is handed is served only inside this run
63
+ import { readJson } from "../../run-record.mjs";
64
64
 
65
65
  // ── B — THE TYPED DISPOSITION TRANSPORT ─────────────────────────────────────────────────────────────
66
66
  //
@@ -82,7 +82,7 @@ function specFrom(params) {
82
82
  if (runDir && !insideRun(runDir, grid_spec_path))
83
83
  return { error: "ERROR: grid_spec_path is outside this run's folder. The driver writes the spec inside the run; use the path it gave you." };
84
84
  let spec;
85
- try { spec = validateGridSpec(JSON.parse(readFileSync(grid_spec_path, "utf8"))); }
85
+ try { spec = validateGridSpec(readJson(grid_spec_path)); }
86
86
  catch (err) { return { error: `ERROR: grid_spec_path unreadable/invalid (${err.message}). The driver writes this file; do not hand-author it.` }; }
87
87
  if (!underStudioSegment(spec.output_path)) // either spelling: an install keeps the studio segment it has
88
88
  return { error: `ERROR: grid spec.output_path must be within a studio/clearance-search run dir; got ${spec.output_path}` };
@@ -159,7 +159,7 @@ serve({
159
159
  // a time. The wording below is the refusal text, so the advertisement and the refusal now say
160
160
  // the same thing in the same words.
161
161
  segment_index: { type: "integer", description: "The NUMBER of the numbered passage you relied on, in the snippet of the receipt you ruled on (1, 2, …). Required for rows the answer marks as owing proof of reading." },
162
- fragment: { type: "string", description: "OPTIONAL, and never refused — #1172. The driver extracts the quote it stores from `segment_index` ALONE, so pointing at the passage is the whole obligation. If a few characters of that passage come easily, send them and they are recorded as a transcription check; if the script is one you cannot reproduce, omit it and nothing is lost. Do not translate: a translation is not a copy, and an empty field is better than a wrong one." },
162
+ fragment: { type: "string", description: "OPTIONAL, and never refused. The driver extracts the quote it stores from `segment_index` ALONE, so pointing at the passage is the whole obligation. If a few characters of that passage come easily, send them and they are recorded as a transcription check; if the script is one you cannot reproduce, omit it and nothing is lost. Do not translate: a translation is not a copy, and an empty field is better than a wrong one." },
163
163
  // — THE HONEST EXIT. Declared here because a seat can only take an exit it can see: the
164
164
  // one row that killed a production run was refused 217 times by a seat that had no way to say
165
165
  // it could not rule, and the schema is the half its tool-calling binds to.