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
@@ -0,0 +1,352 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
3
+ // run-record.mjs — the one door to a run's files: where they are, how they are read, how they are written.
4
+ //
5
+ // It imports node builtins and `shared/driver-dir.mjs` and nothing else, so any module can import it without
6
+ // joining an import loop. File names on disk do not change here: the bench and the archive read them.
7
+ //
8
+ // ── TWO READERS, BECAUSE THE TWO FAILURES MEAN DIFFERENT THINGS ──────────────────────────────────────
9
+ //
10
+ // A missing or corrupt file has to stay what it was at each call site. `readJson` throws, so a run that needs
11
+ // the file stops and says why. `readJsonOr` hands back the fallback the caller names, for a file whose absence
12
+ // the caller has already decided how to treat, and `readJsonOrNull` is that reader with null. One reader for
13
+ // both would turn some thrown error into a null, and a null reads as "nothing there" where the truth was
14
+ // "could not look".
15
+
16
+ import { readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
17
+ import { join } from "node:path";
18
+
19
+ import { driverRel } from "../shared/driver-dir.mjs";
20
+
21
+ export { DRIVER_DIR, RUN_DIR_MODE, driverDir, driverFileName, driverRel, ensureDriverDir, labelOfDriverFile } from "../shared/driver-dir.mjs";
22
+
23
+ /** The parsed JSON at `file`. Throws when the file is missing, unreadable or not JSON. */
24
+ export function readJson(file) {
25
+ return JSON.parse(readFileSync(file, "utf8"));
26
+ }
27
+
28
+ /** The parsed JSON at `file`, or `fallback` when the file is missing, unreadable or not JSON. */
29
+ export function readJsonOr(file, fallback) {
30
+ try { return readJson(file); }
31
+ catch { return fallback; }
32
+ }
33
+
34
+ /** The parsed JSON at `file`, or null when the file is missing, unreadable or not JSON. */
35
+ export function readJsonOrNull(file) {
36
+ return readJsonOr(file, null);
37
+ }
38
+
39
+ // The tmp lives in the TARGET's directory (a sibling name), so the rename never crosses a device; a reader
40
+ // sees the old complete file or the new one, never a truncation.
41
+ export function atomicWrite(file, text) {
42
+ // unique tmp name: concurrent runs can rollup the same STATUS.md — a shared .tmp would cross-rename/ENOENT
43
+ // between writers (content is derived-from-disk either way, so last-writer-wins on the RENAME is fine; the
44
+ // tmp file itself must not be shared).
45
+ const tmp = `${file}.${process.pid}.${Date.now().toString(36)}.tmp`;
46
+ writeFileSync(tmp, text);
47
+ try { renameSync(tmp, file); }
48
+ catch (e) {
49
+ try { unlinkSync(tmp); } catch { /* cleanup is best-effort — the rename failure is the real error */ }
50
+ throw e;
51
+ }
52
+ }
53
+
54
+ /** The record of the research behind the findings' use checks, by name inside a run folder. */
55
+ export const RESEARCH_CHECKS_FILE = "research-checks.md";
56
+
57
+ // Absolute run-dir file paths. The agent write tool gets ABSOLUTE paths; the driver checks the same
58
+ // absolute paths with existsSync. Skill reads stay workspace-relative (skills/ lives in the agent workspace).
59
+ export function paths(runDir) {
60
+ const p = (f) => join(runDir, f);
61
+ return {
62
+ runDir,
63
+ matterContext: p("matter-context.md"),
64
+ inboundRequest: p("inbound-request.txt"), // A5 — the verbatim forwarded request, untouched
65
+ confirmationBrief: p("confirmation-brief.md"), // B1 — the intake brief exactly as sent to the requester
66
+ customerBind: p("customer-bind.json"), // B5b — late-bound applicant {customer, exclusions[]} dropped by the forwarding agent
67
+ variantManifest: p("variant-manifest.md"),
68
+ // WS2 (B2) — the structured sibling the register-plan compiler consumes
69
+ variantManifestModel: p("variant-manifest.json"),
70
+ scopeLedger: p("scope-ledger.json"), // CODE-DERIVED from the manifest's `### Scope ledger` (frame-omission design)
71
+ formNeighbourhood: p("form-neighbourhood.json"), // CODE-DERIVED mechanical FORM band (edit-1 ∪ phonetic-family ∪ visual-confusable ∪ transliteration ∪ spacing-punctuation) — the model-free variant floor the register funnel searches, plus the `variant_floor` block marking which terms code generated and which the model added
72
+ // Property 1 — the frame-STARVED cold re-derivation. The STRUCTURED model is the stage's ONLY output
73
+ //: the prose twin `blind-frame.md` was retired because nothing in the repo ever read it — not
74
+ // frame-diff, not the driver, not a renderer, on any run type. Archived runs keep their copy on disk;
75
+ // no code path opens it, so replay over them is unaffected.
76
+ blindFrameModel: p("blind-frame-model.json"), // the frame-diff and the reopen gate consume this
77
+ frameDiff: p("frame-diff.md"), // the blind-model-vs-actual-scope diff (prose reasoning)
78
+ frameDiffModel: p("frame-diff.json"), // its STRUCTURED reopen directives + dominant_element_gap (CODE consumes this)
79
+ commonLaw: p("common-law-findings.md"),
80
+ commonLawGrid: p("common-law-grid.json"), // machine receipts — the grid call's stdout JSON, saved verbatim
81
+ // A1 SPLIT — the per-half stage artifacts (half ∈ {"a","b"}): each concurrent half-grid member reads its
82
+ // own spec sidecar, writes its own findings + ledger, and the driver merges them into the canonical
83
+ // commonLaw/commonLawGrid pair above (common-law-receipts.mergeGrids / mergeCommonLawFindings).
84
+ commonLawHalf: (half) => p(`common-law-findings.half-${half}.md`),
85
+ commonLawGridHalf: (half) => p(`common-law-grid.half-${half}.json`),
86
+ // — the seat's meaning-sweep dispositions, STRUCTURED. One row per recorded query: the query, the
87
+ // id of the receipt it was ruled on, and the ruling. The prose disposition table in the canonical
88
+ // findings file is RENDERED from this by the driver, so no identifier is ever retyped to prove a
89
+ // receipt was read — the failure that cost ten of fourteen refusals on the 2026-08-06 evidence.
90
+ commonLawDispositionsHalf: (half) => p(`common-law-dispositions.half-${half}.json`),
91
+ commonLawDispositions: p("common-law-dispositions.json"),
92
+ // The CANONICAL grid spec the driver dictates (the validator/receipts join and the coverage-closure
93
+ // recompute all key on it). It was the one grid artifact reached by a path LITERAL rather than
94
+ // through paths() — which is how the --experiment sandbox came to have no idea it existed, and why
95
+ // the stageInputs drift guard, whose matcher is derived from these paths, could not see it
96
+ // either. Declared here, used from here.
97
+ gridSpec: p(driverRel("grid-spec.json")),
98
+ gridSpecHalf: (half) => p(driverRel(`grid-spec.half-${half}.json`)),
99
+ // — which common-law path this run took and which term of the selector decided it. Written on
100
+ // EVERY run, split or not: the 2026-08-12 round could not explain why two builds took different
101
+ // paths because the unsplit path emitted nothing at all, and "no event" is not a record.
102
+ commonLawPath: p(driverRel("common-law-path.json")),
103
+ // Closure/frame-reopen top-ups: the driver dictates a supplementary grid SPEC (its own output_path)
104
+ // and the PLUGIN writes the supplementary LEDGER — the same deterministic write the initial gather
105
+ // uses, never an agent hand-append. `tag` names the lane (only "closure" today; frame-reopen source
106
+ // channels stay prose/byte-diff). Split → per-half siblings the extended readHalfLedger folds; non-
107
+ // split (half=null) → a sibling of the canonical ledger the driver folds via mergeGrids in code. The
108
+ // driver owns these names so the agent never invents (and never corrupts) a canonical/half ledger.
109
+ commonLawGridSupp: (half, tag) => p(half ? `common-law-grid.half-${half}.supp-${tag}.json` : `common-law-grid.supp-${tag}.json`),
110
+ gridSpecSupp: (half, tag) => p(driverRel(half ? `grid-spec.half-${half}.supp-${tag}.json` : `grid-spec.supp-${tag}.json`)),
111
+ registerUnit: (axis) => p(join("register-units", `${axis}.md`)),
112
+ // judgment-relocation (2026-06-23): the COMPLETE NAMED BAND the funnel emits per axis (a JSON ARRAY of
113
+ // {state:"enumerated"|"incomplete", …} blocks from register_enumerate — see named-band.mjs). This is what
114
+ // crosses the lifted firewall: the real material judgment reads, NOT a pre-pruned digest.
115
+ registerBand: (axis) => p(join("register-units", `${axis}-band.json`)),
116
+ registerNamedBand: p("register-named-band.json"), // the driver-merged UNION of every axis band (mergeNamedBands)
117
+ // — the SLIM HIT LIST, a third projection of the merged band, written in the same
118
+ // pass as the shape and the owner screen and for the same reason: a stage must never read a list
119
+ // older than the band it was derived from.
120
+ registerHitList: p("register-hit-list.json"),
121
+ // PR-8 (reading layer) — the deterministic band SHAPE, derived by the driver after every named-band
122
+ // re-merge (band-shape.mjs): mechanical tiers + the unconditional floors + census + blind spots.
123
+ // Judgment reads the md whole (band_shape tool / <256KB Read) and looks records up via the band
124
+ // tools; machine checks keep reading the complete band above.
125
+ bandShape: p(driverRel("band-shape.json")),
126
+ bandShapeMd: p("band-shape.md"),
127
+ researchChecks: p(RESEARCH_CHECKS_FILE), // the research behind the findings' use checks, written by the writer's record for the review
128
+ readingLog: p(driverRel("reading-log.jsonl")), // band-server appends every lookup — audit.md "# Reading audit" renders from it
129
+ // P2-A (the recall spine) — three driver-derived sidecars:
130
+ // the retrieved→judgment reconciliation (recall-reconciliation.mjs join, re-derived after EVERY
131
+ // digest pass; an unended position ships named and clamps the verdict), the exact-identity positions projection (charter
132
+ // P2d — same right → one position, territories listed; the band stays per-registration), and the
133
+ // read-before-rate join (charter P2c — verified-from-record stamps × _records × reading log).
134
+ recallReconciliation: p(driverRel("recall-reconciliation.json")),
135
+ // — the placement→digest carry join: every candidate placement-inquiry placed ends on a
136
+ // findings surface, in a Negative-results drop row, or in a Disagreement-resolutions row, and
137
+ // the ones that end nowhere are counted BY NAME. The band-keyed joins above cannot see a
138
+ // common-law-shaped placement (records:[] ⇒ no uri ⇒ no band row), which is the class of
139
+ // candidate the digest drops silently. Disclosure only — it never re-tiers and never gates.
140
+ placementCarry: p(driverRel("placement-carry.json")),
141
+ surfaceDuty: p(driverRel("surface-duty.json")), // item 3
142
+ // — THE FLOOR DUTY. Every floor row (live, in-class, identical/near-identical) either comes
143
+ // back on the placement form by record id or it does not, and until this artifact existed nothing
144
+ // asked. Measured on two delivered runs: 45 of 207 and 99 of 225 never reached the form, all live.
145
+ // Disclosure only — it never re-tiers, never gates and never sends a followup.
146
+ floorDuty: p(driverRel("floor-duty.json")),
147
+ // — the RETRIEVAL→findings trace, one row per retrieved register record: did it become a
148
+ // finding, and if not, which seam it stopped at, on what ground, and WHERE THAT GROUND WAS
149
+ // AUTHORED. The carry join above starts one seam too late — it can only speak about candidates
150
+ // placement already selected — and the seam that lost the jx lane's own target (ten banded 澜珀
151
+ // registrations, four REGISTERED, none reaching any placement) is the one before it. Disclosure
152
+ // only: it never re-retrieves, never keeps a record the funnel dropped, and never gates.
153
+ recordCarry: p(driverRel("record-carry.json")),
154
+ // — the common-law path's own trace. A SIBLING of record-carry.json, not a widening: the two
155
+ // join on different keys (a canonical `/mark` uri there, a canonicalised URL here) and one file
156
+ // holding both is how the key decision gets reversed later.
157
+ commonLawCarry: p(driverRel("commonlaw-carry.json")),
158
+ jxZhCarry: p(driverRel("jx", "zh-carry.json")),
159
+ jxZhGrid: p(driverRel("jx", "zh-grid.json")),
160
+ registerPositions: p(driverRel("register-positions.json")),
161
+ // — RENAMED from read-verification.json with the pass it recorded. The old artifact was the
162
+ // receipt of a model turn that re-asserted its own stamps; this is the machine's own derivation
163
+ // record: every meter whose `verified-from-record` claim the reading log could not support, and
164
+ // what it became. Written on EVERY settle, empty arrays and all, so a reader can tell "nothing was
165
+ // demoted" from "nobody looked".
166
+ basisDerivation: p(driverRel("basis-derivation.json")),
167
+ // P2-B (charter P2b) — the owner×element screen's own receipt: one row per watchlist owner
168
+ // saying whether its slice enumerated, what it attributed, or the mechanical reason it did NOT
169
+ // run. A projection (plan × plan-execution × band), never a coverage authority.
170
+ ownerScreen: p(driverRel("owner-screen.json")),
171
+ placement: p("placement-recommendations.md"),
172
+ // B2 (charter 2026-07-31) — the STRUCTURED mirror of placement's four tier sections: one entry per
173
+ // candidate {mark, owner, jurisdiction, records[], tier, reason} (reason = a short paragraph, the
174
+ // stated reasoning downstream argues with — see placement-model.mjs). The rulings tail (band
175
+ // reconciliation, disagreements, coverage rulings, open questions) stays PROSE in the md above.
176
+ placementModel: p("placements.json"),
177
+ // — the seat's own form. `placements.json` beside it is now DRIVER-RENDERED from this file's
178
+ // accumulated rows, so the two are no longer two copies of one judgment: this is what the seat writes
179
+ // and that is what the driver publishes.
180
+ placementForm: p("placement-form.json"),
181
+ // — placement's set-asides that stand on the run's files, as the reading step and the writer are told them: one
182
+ // entry per decision, with its ground, the records it covers and its exceptions. Driver-written after every
183
+ // placement pass, with no clock in it, so it changes only when a decision does; both stages declare it.
184
+ placementDecisions: p(driverRel("placement-decisions.json")),
185
+ // — the driver's own flag-by-flag account of the corrective pass: which findings each reviewer
186
+ // flag names, and whether any of them actually moved. Handed to the recheck as data so it argues
187
+ // with evidence rather than re-reading two documents to re-derive what the driver already knows.
188
+ correctionsApplied: p(driverRel("corrections-applied.json")),
189
+ registerFindings: p("register-findings.md"),
190
+ registerCoverageLedger: p("register-coverage-ledger.json"), // WS-A machine contract — the digest's JSON mirror of the Coverage ledger
191
+ skepticFlags: p("skeptic-flags.md"),
192
+ frameReopenReceipt: p(driverRel("frame-reopen.json")), // A3 — the reopen receipt is a first-class judgment input
193
+ // (t1cd) — the digest-trigger funnel's durable work queue (digest-queue.mjs): mechanisms
194
+ // mint re-digest work here instead of calling the digest; written atomically on every mint/flush
195
+ // and loaded on resume BEFORE the trigger blocks run, so per-mechanism bounds survive resumes.
196
+ digestQueue: p(driverRel("digest-queue.json")),
197
+ // WS2 (B3) — the frozen deterministic search plan + its execution receipt + the
198
+ // code-authoritative instructed scope (what the JOB fields said, before any model breathed on them)
199
+ registerPlan: p(driverRel("register-plan.json")),
200
+ enforcerSignals: p(driverRel("enforcer-signals.json")), // D2 — provider enforcement telemetry (aim-attention)
201
+ // crowd-context (2026-07-22) — driver-gathered crowded-field EVIDENCE over material un-enumerated
202
+ // slices (per-term live counts, in-scope-class counts, the fully-enumerated exact/near-identical
203
+ // subset). OPTIONAL synthesis input: evidence to the coverage judgment, never a gate; absent on any
204
+ // run without a qualifying slice (or whose evidence pass failed) and the run is unaffected.
205
+ crowdContext: p(driverRel("crowd-context.json")),
206
+ crowdContextMd: p("crowd-context.md"), // the readable mirror the lawyer actually reads
207
+ planExecution: p(driverRel("plan-execution.json")),
208
+ // What was DECIDED about the receipt's deferrals, and when — kept apart from plan-execution.json,
209
+ // which is an execution-FACTS receipt several validators fail-closed on. See envelope-settle.mjs.
210
+ envelopeDecision: p(driverRel("envelope-decision.json")),
211
+ instructedScope: p(driverRel("instructed-scope.json")), defaultTerritories: p(driverRel("default-territories.json")), // the stored account defaults the engine cannot search — written at intake, read by no stage (pipeline.mjs writes it)
212
+ // compute-don't-author — the per-class scope truth (scope-facts.mjs): instructed × frozen plan ×
213
+ // band states × coverage ledger. The masthead classes/coverage_line are stamped FROM this sidecar.
214
+ scopeFacts: p(driverRel("scope-facts.json")),
215
+ // D1 — arms the registerFindings off-enum status gate; — the SAME sentinel carries the coverage
216
+ // form's era stamp (`form_required`/`form_path`). One file, two facts, written by runDigest before
217
+ // every digest pass it dispatches and BEFORE the form itself, so a failed form write fails closed.
218
+ coverageEnum: p(driverRel("coverage-enum.json")),
219
+ // — the seat-facing coverage form. DICTATED here so the stray-artifact sweep knows the
220
+ // driver put it there; the accumulator beside it in `_driver/` is derived from this name.
221
+ narrative: p("narrative.md"),
222
+ findings: p("findings.json"), // Phase 1 — the per-finding machine contract; synthesis mirrors its RATED findings into this JSON, the report/Excel render consume it
223
+ caseLaw: p("case-law-findings.md"),
224
+ // — the RETRIEVAL RECORD beside the prose. Until this existed, `case-law-findings.md` was the
225
+ // only artifact case law produced and its whole contract was a non-empty check, so "the sweep ran"
226
+ // and "the dive read something" were unanswerable and the record trace had nothing to join to.
227
+ caseLawCitations: p("case-law-citations.json"),
228
+ seniorEyeReview: p("senior-eye-review.md"),
229
+ // delivery contract (file-gated; rendered to the page by the pure-code publish step)
230
+ report: p("report.md"), // CODE (assembleReportMd) — the assembled client report (overview + per-card)
231
+ reportOverview: p("report-overview.md"), // CODE (report-overview-record.mjs) since conversion 4 — the driver renders the shell off the record_report_overview call; NO card bodies
232
+ reportCardsDir: p("report-cards"), // B1 — per-finding card files (one isolated LLM call each)
233
+ reportCard: (ord) => p(join("report-cards", `${ord}.md`)), // B1 — LLM (report-card): ONE card from finding[ord]'s own record
234
+ audit: p("audit.md"), // CODE (buildAuditMd from the spine) — full audit record
235
+ // THE SEAT WRITES THIS ONE, so it cannot live in `_driver/`. That write boundary makes
236
+ // `<runDir>/_driver/**` a tree a seat may NEVER write into (`authorityTrees()` in authority-trees.mjs, `live: true`) —
237
+ // and this stage's dispatch handed the seat a path inside it. The deny fires, the seat writes the
238
+ // only place it can (the run root), the validator looks in `_driver/` and reports `missing_file`,
239
+ // and the escalation ladder burns out on an artifact that exists. Two consecutive rounds died this
240
+ // way with 3 attempts each. Of the 27 P paths under `_driver/`, this was the ONLY stage output —
241
+ // every other one is driver-authored, which is what that tree is for.
242
+ doubtClosure: p("doubt-closure.md"), // LLM (doubt-closure) — one dictated SETTLED/OPEN line per stitch-open doubt; code re-verifies every quote
243
+ // RETIRED STAGE, ARCHIVE READ HANDLE (2026-08-01). No stage writes this any more — the
244
+ // `client-summary` stage is deleted. The path constant is KEPT because it is how archived runs'
245
+ // client-summary.md is still reached: mcp-server's read_artifact (name "clientSummary"),
246
+ // lib/coverage.mjs artifactStatus, and lib/brief.mjs (which prefers the client-voiced summary over
247
+ // the report cards) all resolve it through paths(). Deleting the entry would not delete those
248
+ // reads — it would leave them resolving `undefined`, which existsSync() turns into a silent miss
249
+ // rather than an error, so the archive would quietly read as having no summary.
250
+ clientSummary: p("client-summary.md"),
251
+ emailBody: p("email-body.md"), // CODE (composeEmailHtml) — the inline-HTML reply (review headline + client table + link)
252
+ // The rest of the run's own record, named once so that a file's name is one edit.
253
+ asks: p(driverRel("asks.json")),
254
+ authorityDenials: p(driverRel("authority-denials.jsonl")),
255
+ bandRefusedRecords: p(driverRel("band-refused-records.json")),
256
+ blindFrameCalls: p(driverRel("blind-frame-calls")),
257
+ cardFolds: p(driverRel("card-folds.json")),
258
+ caseLawRecord: p(driverRel("case-law.jsonl")),
259
+ clearanceVariantsCalls: p(driverRel("clearance-variants-calls")),
260
+ clientSummaryScope: p(driverRel("client-summary-scope.json")),
261
+ connotationReceipts: p(driverRel("connotation-receipts.json")),
262
+ connotationReceiptsJson: p(driverRel("connotation-receipts.json.tmp")),
263
+ correctionsState: p(driverRel("corrections-state.json")),
264
+ correctionsStateJson: p(driverRel("corrections-state.json.tmp")),
265
+ correctiveCycle: p(driverRel("corrective-cycle.json")),
266
+ correctiveRepair: p(driverRel("corrective-repair.json")),
267
+ correctiveRollback: p(driverRel("corrective-rollback.json")),
268
+ coverageClosure: p(driverRel("coverage-closure.json")),
269
+ crowdContextBand: p(driverRel("crowd-context-band.json")),
270
+ crowdContextPlan: p(driverRel("crowd-context-plan.json")),
271
+ deadlineEnrich: p(driverRel("deadline-enrich.json")),
272
+ declinations: p(driverRel("declinations.json")),
273
+ declinationSpec: p(driverRel("declination-spec.json")),
274
+ delivery: p(driverRel("delivery.json")),
275
+ deliveryStale: p(driverRel("delivery-stale.json")),
276
+ doubtClosureSpec: p(driverRel("doubt-closure-spec.json")),
277
+ doubts: p(driverRel("doubts.json")),
278
+ economics: p(driverRel("economics.json")),
279
+ escalationState: p(driverRel("escalation-state.json")),
280
+ evidenceClaimViolations: p(driverRel("evidence-claim-violations.json")),
281
+ experimentContext: p(driverRel("experiment-context.json")),
282
+ failure: p(driverRel("failure.json")),
283
+ findingsBrokenAtDelivery: p(driverRel("findings-broken-at-delivery.json")),
284
+ findingsFailedCorrection: p(driverRel("findings-failed-correction.json")),
285
+ findingsPreCorrective: p(driverRel("findings-pre-corrective.json")),
286
+ findingsPreCorrectiveJson: p(driverRel("findings-pre-corrective.json.tmp")),
287
+ findingsUnfolded: p(driverRel("findings-unfolded.json")),
288
+ fold: p(driverRel("fold.json")),
289
+ frameDiffCalls: p(driverRel("frame-diff-calls")),
290
+ framework: p(driverRel("framework.json")),
291
+ goodsEvidence: p(driverRel("goods-evidence.json")),
292
+ intakeAsks: p(driverRel("intake-asks.json")),
293
+ intakeAsksJson: p(driverRel("intake-asks.json.tmp")),
294
+ jx: p(driverRel("jx")),
295
+ jxCompletions: p(driverRel("jx-completions.jsonl")),
296
+ jxLanes: p(driverRel("jx-lanes.json")),
297
+ jxUnits: p(driverRel("jx/units.json")),
298
+ knockoutChunks: p(driverRel("knockout-chunks.json")),
299
+ knockoutCorrections: p(driverRel("knockout-corrections.json")),
300
+ knockoutCorrectionWork: p(driverRel("knockout-correction-work.json")),
301
+ knockoutFrameCalls: p(driverRel("knockout-frame-calls")),
302
+ knockoutRegisterCalls: p(driverRel("knockout-register-calls")),
303
+ knockoutReviewCalls: p(driverRel("knockout-review-calls")),
304
+ knockoutSweep: p(driverRel("knockout-sweep.jsonl")),
305
+ marksOwedAFinding: p(driverRel("marks-owed-a-finding.json")),
306
+ matterFrameCalls: p(driverRel("matter-frame-calls")),
307
+ noResultRemoved: p(driverRel("no-result-removed.jsonl")),
308
+ ownerCheck: p(driverRel("owner-check.jsonl")),
309
+ ownerChecks: p(driverRel("owner-checks.json")),
310
+ placementBandIds: p(driverRel("placement-band-ids.json")),
311
+ placementFormAccumulator: p(driverRel("placement-form.form.json")),
312
+ postRepairCorrections: p(driverRel("post-repair-corrections.json")),
313
+ postRepairReview: p(driverRel("post-repair-review.json")),
314
+ postRepairState: p(driverRel("post-repair-state.json")),
315
+ predeliveryLint: p(driverRel("predelivery-lint.json")),
316
+ profile: p(driverRel("profile.json")),
317
+ rankingReadByWriter: p(driverRel("ranking-read-by-writer.json")),
318
+ reasoningIntegrity: p(driverRel("reasoning-integrity.json")),
319
+ receipts: p(driverRel("receipts.json")),
320
+ refutationCalls: p(driverRel("refutation-calls")),
321
+ registerCount: p(driverRel("register-count.jsonl")),
322
+ registerCounts: p(driverRel("register-counts.json")),
323
+ registerCoverageFormAccumulator: p(driverRel("register-coverage-form.form.json")),
324
+ registerDigestCalls: p(driverRel("register-digest-calls")),
325
+ registerRecall: p(driverRel("register-recall.json")),
326
+ registerRecordBodies: p(driverRel("register-record-bodies.jsonl")),
327
+ registerRecords: p(driverRel("register-records.json")),
328
+ registerTaint: p(driverRel("register-taint.json")),
329
+ registerUnitCalls: p(driverRel("register-unit-calls")),
330
+ registerXcheck: p(driverRel("register-xcheck.json")),
331
+ repairs: p(driverRel("repairs.json")),
332
+ reportCardCalls: p(driverRel("report-card-calls")),
333
+ reportOverviewCalls: p(driverRel("report-overview-calls")),
334
+ researchAnswers: p(driverRel("research-answers.jsonl")),
335
+ reviewAfterRepair: p(driverRel("review-after-repair.md")),
336
+ reviewBeforeRepair: p(driverRel("review-before-repair.md")),
337
+ reviewExclusionsFull: p(driverRel("review-exclusions-full.json")),
338
+ run: p(driverRel("run.jsonl")),
339
+ screenGateEvidence: p(driverRel("screen-gate-evidence.json")),
340
+ screenGateUnresolved: p(driverRel("screen-gate-unresolved.json")),
341
+ searchPolicy: p(driverRel("search-policy.json")),
342
+ sendReceipts: p(driverRel("send-receipts.json")),
343
+ seniorRights: p(driverRel("senior-rights.json")),
344
+ skepticCalls: p(driverRel("skeptic-calls")),
345
+ stageContracts: p(driverRel("stage-contracts.json")),
346
+ synthesisCalls: p(driverRel("synthesis-calls")),
347
+ toolCalls: p(driverRel("tool-calls.jsonl")),
348
+ verdict: p(driverRel("verdict.json")),
349
+ verdictJson: p(driverRel("verdict.json.tmp")),
350
+ webResults: p(driverRel("web-results")),
351
+ };
352
+ }
@@ -368,6 +368,14 @@ export function whatIsMissing(rows = []) {
368
368
  return MISSING_WORDS.filter(([k]) => kinds.has(k)).map(([, words]) => words).join(" and ");
369
369
  }
370
370
 
371
+ /**
372
+ * The order-time rows a person is told to set. With no AI chosen, the program and payment rows are the default AI's,
373
+ * which nobody chose, for the reason `whatIsMissing` gives: choosing an AI is what settles them.
374
+ */
375
+ export function rowsToName(rows = []) {
376
+ return rows.some((r) => r.about === "ai") ? rows.filter((r) => r.about !== "program" && r.about !== "payment") : rows;
377
+ }
378
+
371
379
  /**
372
380
  * What the person who runs the install is told to do, for how the refusing process runs (the owner's words,
373
381
  * 2026-11-07). `how` is driver/how-it-runs.mjs's answer. The portal and the run's refusal say the same remedy;
@@ -415,6 +423,20 @@ export function cannotSearchYet(missing, install = "clearotron install", how = n
415
423
  return remedy ? `${head} ${remedy}` : `${head} Run \`${install}\` in a terminal to set it up.`;
416
424
  }
417
425
 
426
+ /**
427
+ * What `clearotron run` says before anything else when the install cannot run a search: doctor's sentence for the
428
+ * same install, from the same composer. Null when no order-time setting is missing, or when what is missing has no
429
+ * phrase; then the run's own doors speak, as before.
430
+ *
431
+ * Measured in a stranger walk of a beta, 2026-11-10: with no AI chosen, setup, doctor and the portal said "no AI is
432
+ * chosen", and the run refused by naming the default AI's program and its setting, which nobody had chosen, and did
433
+ * not mention the missing register. PURE.
434
+ */
435
+ export function commandLineRefusal(env = {}, tables = {}, install = "clearotron install") {
436
+ const gap = whatIsMissing(missingRequirements(env, tables).atOrder);
437
+ return gap ? cannotSearchYet(gap, install) : null;
438
+ }
439
+
418
440
  /**
419
441
  * The order-time refusal, in two vocabularies, from ONE list.
420
442
  *
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
3
+ //
4
+ // run-shell.mjs — what every run does around its own steps, the same for a clearance and a Knockout.
5
+ //
6
+ // Each product keeps its own ordered steps: a narrower level of clearance has its own evidence work, inputs and
7
+ // outputs. What runs them, and what a run does when they end, is shared: `runShell` runs a product's steps in order,
8
+ // a failure ends through run-failed.mjs, and a delivery through the ending below.
9
+ import { endAnswerMemory } from "../providers/_shared/answer-memory.mjs";
10
+ import { endTheFailedRun } from "./run-failed.mjs";
11
+ import { note } from "./log.mjs";
12
+ import { rollupStatus, writeRunStatus } from "./progress.mjs";
13
+ import { writeSettleStamp } from "./settle-stamp.mjs";
14
+
15
+ /**
16
+ * Run a product's steps in order, and end the run as both products end one. `steps` is the product's own ordered
17
+ * recipe, each `{ name, run }`. The first step that returns a result ends the run with it: the last step returns the
18
+ * delivered run, and an earlier one may end the run sooner. A throw from any step ends through run-failed.mjs, with
19
+ * the product's data (`ending`) and the helpers the failure path takes from it.
20
+ */
21
+ export async function runShell({ P, agent, ctx, job, run }, { ending, helpers, steps }) {
22
+ try {
23
+ let result;
24
+ for (const step of steps) {
25
+ result = await step.run();
26
+ if (result !== undefined) return result;
27
+ }
28
+ return result;
29
+ } catch (e) {
30
+ return await endTheFailedRun({ P, agent, ctx, e, job, run, product: ending }, helpers);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * The delivered ending, the same for both products once a run's report is published and its packet is out: the run's
36
+ * status, the pool copy's settle stamp, the held answers closed, the archive, the run list and `.delivered`, in that
37
+ * order. Status goes before the archive so the moved status.json carries the delivered state, and the run list is
38
+ * rebuilt after it, since it scans the archive too. A product hands in its own fields for each record, whole, and
39
+ * `delivered` is given the archive's path. Returns that path, or null when the run could not be archived.
40
+ */
41
+ export function endTheDeliveredRun({ ctx, run, published, archive, sentinel }, { status, settle, delivered }) {
42
+ writeRunStatus(ctx, status);
43
+ // — THE POOL COPY LEARNS ITS OWN TERMINAL STATE, HERE AND NOWHERE ELSE.
44
+ // `meta.json` cannot carry this: it is composed inside publish, before this line runs, so the state
45
+ // did not exist yet when it was written. This is the one moment where the terminal state and the
46
+ // pool directory are both in hand. Best-effort by construction — the report is already published
47
+ // and the run is already settled, so a failure to stamp is logged and the delivery proceeds.
48
+ const stamp = writeSettleStamp(published.poolRunDir, settle);
49
+ if (!stamp.written) note(`delivery: settle stamp not written (${stamp.reason})`);
50
+ endAnswerMemory(run.runDir); // the held answers do not travel into the archive
51
+ const archived = archive(run);
52
+ rollupStatus(run.studioRoot);
53
+ sentinel(archived ?? run.runDir, ".delivered", delivered(archived));
54
+ return archived;
55
+ }