clearotron 0.5.1-beta.2 → 0.6.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) 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 +49 -18
  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 +147 -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/best-draft.mjs +3 -3
  37. package/driver/blind-frame-record.mjs +2 -2
  38. package/driver/cancel.mjs +3 -2
  39. package/driver/carry-through.mjs +2 -2
  40. package/driver/citation-census.json +3 -3
  41. package/driver/clearance-variants-record.mjs +4 -10
  42. package/driver/common-law-coverage-status.mjs +3 -3
  43. package/driver/common-law-receipts.mjs +2 -2
  44. package/driver/compare.mjs +1 -1
  45. package/driver/config-inventory.mjs +6 -79
  46. package/driver/consumption-ledger.mjs +2 -1
  47. package/driver/contract-dictation-registry.mjs +5 -0
  48. package/driver/contract-e3-backlog.mjs +45 -66
  49. package/driver/contract-e3-baseline.json +16 -16
  50. package/driver/contract-vocabulary.mjs +8 -6
  51. package/driver/corrections-feedforward.mjs +3 -1
  52. package/driver/coverage-form-io.mjs +7 -8
  53. package/driver/coverage-tool.mjs +1 -1
  54. package/driver/declination-tool.mjs +2 -2
  55. package/driver/degraded-parts.mjs +9 -9
  56. package/driver/demo-container.mjs +5 -4
  57. package/driver/deploy-live-run-guard.mjs +19 -7
  58. package/driver/derived-state.mjs +2 -2
  59. package/driver/dev-portal.mjs +2 -1
  60. package/driver/dispatch-record.mjs +1 -1
  61. package/driver/disposition-tool.mjs +2 -1
  62. package/driver/doubt-closure-tool.mjs +2 -2
  63. package/driver/driver.config.mjs +35 -724
  64. package/driver/e2e-rounds.mjs +3 -4
  65. package/driver/engine/CONTRACT.md +3 -0
  66. package/driver/engine/README.md +2 -0
  67. package/driver/engine/anthropic-agent.mjs +8 -37
  68. package/driver/engine/auth.mjs +74 -0
  69. package/driver/engine/child-record.mjs +1 -1
  70. package/driver/engine/deny-authority-write.mjs +2 -2
  71. package/driver/engine/jx-turn.mjs +10 -2
  72. package/driver/engine/mcp/README.md +1 -1
  73. package/driver/engine/mcp/band-server.mjs +6 -6
  74. package/driver/engine/mcp/codex-config.mjs +1 -1
  75. package/driver/engine/mcp/declination-server.mjs +2 -3
  76. package/driver/engine/mcp/dispositions-server.mjs +3 -3
  77. package/driver/engine/mcp/gather-config.mjs +24 -19
  78. package/driver/engine/mcp/grid-provenance.mjs +1 -1
  79. package/driver/engine/mcp/held-answers.mjs +5 -5
  80. package/driver/engine/mcp/perplexity-server.mjs +16 -7
  81. package/driver/engine/mcp/recording-server.mjs +7 -6
  82. package/driver/engine/mcp/register-server.mjs +29 -0
  83. package/driver/engine/mcp/stdio-server.mjs +5 -5
  84. package/driver/engine/mcp/supplemental.mjs +9 -9
  85. package/driver/engine/openai-agent.mjs +5 -2
  86. package/driver/engine/registry.mjs +103 -0
  87. package/driver/engine/run-choices.mjs +162 -0
  88. package/driver/engine/stamps.mjs +35 -0
  89. package/driver/enqueue-schema.mjs +4 -4
  90. package/driver/envelope-settle.mjs +3 -2
  91. package/driver/feedback-issues.mjs +1 -1
  92. package/driver/feedback-mint.mjs +3 -2
  93. package/driver/feedback-store.mjs +3 -2
  94. package/driver/findings-model.mjs +1 -1
  95. package/driver/flag-snapshot.mjs +5 -4
  96. package/driver/floor-duty.mjs +3 -3
  97. package/driver/foreign-record-links.mjs +1 -1
  98. package/driver/frame-diff-record.mjs +2 -8
  99. package/driver/framework.mjs +1 -1
  100. package/driver/gate-metrics.mjs +10 -11
  101. package/driver/gateway.mjs +220 -839
  102. package/driver/goods-evidence.mjs +10 -6
  103. package/driver/jx-lanes.mjs +3 -3
  104. package/driver/jx-units.mjs +31 -37
  105. package/driver/jx.mjs +44 -59
  106. package/driver/knockout-assess-record.mjs +3 -3
  107. package/driver/knockout-caveats.mjs +21 -0
  108. package/driver/knockout-correction-record.mjs +58 -28
  109. package/driver/knockout-frame-record.mjs +2 -2
  110. package/driver/knockout-register-read.mjs +38 -21
  111. package/driver/knockout-register-record.mjs +5 -6
  112. package/driver/knockout-review-record.mjs +12 -11
  113. package/driver/ladder/model-gauge.mjs +88 -0
  114. package/driver/ladder/next-rung.mjs +296 -0
  115. package/driver/ladder/rescue.mjs +146 -0
  116. package/driver/ladder/stage-tools.mjs +57 -0
  117. package/driver/ladder/turn-failure.mjs +166 -0
  118. package/driver/log.mjs +2 -2
  119. package/driver/matter-frame-record.mjs +4 -4
  120. package/driver/methodology-witness.mjs +2 -2
  121. package/driver/narrative-refutation-record.mjs +145 -42
  122. package/driver/one-build-per-run.mjs +62 -0
  123. package/driver/outbox-backoff.mjs +4 -4
  124. package/driver/owner-screen.mjs +0 -10
  125. package/driver/owner-use-check.mjs +2 -28
  126. package/driver/package.json +1 -1
  127. package/driver/partial-payload-baseline.json +1 -1
  128. package/driver/parts-not-completed.mjs +1 -1
  129. package/driver/pipeline-knockout.mjs +1015 -1001
  130. package/driver/pipeline.mjs +511 -9265
  131. package/driver/placement-decisions.mjs +2 -2
  132. package/driver/placement-form-io.mjs +7 -9
  133. package/driver/placement-union.mjs +0 -6
  134. package/driver/plan-stability.mjs +7 -10
  135. package/driver/portal-acks.mjs +3 -2
  136. package/driver/portal-confirmation.mjs +48 -0
  137. package/driver/portal-families.mjs +3 -2
  138. package/driver/portal-local-auth.mjs +1 -2
  139. package/driver/portal-routes/README.md +24 -0
  140. package/driver/portal-routes/admin.mjs +425 -0
  141. package/driver/portal-routes/compose.mjs +66 -0
  142. package/driver/portal-routes/config.mjs +118 -0
  143. package/driver/portal-routes/connect.mjs +283 -0
  144. package/driver/portal-routes/feedback.mjs +178 -0
  145. package/driver/portal-routes/me.mjs +165 -0
  146. package/driver/portal-routes/queue.mjs +64 -0
  147. package/driver/portal-routes/report.mjs +106 -0
  148. package/driver/portal-routes/run.mjs +508 -0
  149. package/driver/portal-routes/runs.mjs +127 -0
  150. package/driver/portal-routes/usage.mjs +82 -0
  151. package/driver/portal-runs.mjs +588 -0
  152. package/driver/portal-service.mjs +78 -2592
  153. package/driver/portal-static.mjs +3 -1
  154. package/driver/predelivery-lint.mjs +92 -9
  155. package/driver/production-pool-guard.mjs +1 -1
  156. package/driver/profiles.mjs +5 -4
  157. package/driver/progress.mjs +29 -24
  158. package/driver/publish/README.md +10 -5
  159. package/driver/publish/archive-tags.mjs +3 -2
  160. package/driver/publish/demo-marking.mjs +2 -2
  161. package/driver/publish/index.mjs +215 -140
  162. package/driver/publish/knockout.mjs +153 -107
  163. package/driver/publish/office-record-links.mjs +22 -0
  164. package/driver/publish/parse.mjs +20 -5
  165. package/driver/publish/pool-admin.mjs +9 -3
  166. package/driver/publish/render.mjs +11 -3
  167. package/driver/publish/report-dates.mjs +3 -4
  168. package/driver/publish/report-registry.mjs +7 -10
  169. package/driver/publish/seed-pool.mjs +3 -2
  170. package/driver/publish/shell.mjs +106 -0
  171. package/driver/publish/templates/report.css +3 -1
  172. package/driver/queue-order.mjs +4 -3
  173. package/driver/record-carry.mjs +0 -9
  174. package/driver/record-discard.mjs +1 -4
  175. package/driver/record-fold.mjs +3 -3
  176. package/driver/record-goods.mjs +5 -5
  177. package/driver/reference-score.mjs +2 -3
  178. package/driver/register-capabilities.mjs +0 -6
  179. package/driver/register-count.mjs +3 -2
  180. package/driver/register-digest-record.mjs +7 -7
  181. package/driver/register-fixture-marker.mjs +3 -3
  182. package/driver/register-plan.mjs +2 -2
  183. package/driver/register-records.mjs +2 -2
  184. package/driver/register-taint.mjs +3 -3
  185. package/driver/register-unit-record.mjs +48 -9
  186. package/driver/register-unreachable.mjs +4 -3
  187. package/driver/registry-fidelity.mjs +79 -34
  188. package/driver/repair-composers.mjs +14 -9
  189. package/driver/repair-digest.mjs +4 -6
  190. package/driver/repair-scope.mjs +3 -3
  191. package/driver/repair-targets.mjs +24 -9
  192. package/driver/repairs.mjs +44 -58
  193. package/driver/replay-archive.mjs +7 -7
  194. package/driver/report-card-record.mjs +3 -3
  195. package/driver/report-overview-record.mjs +4 -4
  196. package/driver/research-answers.mjs +38 -6
  197. package/driver/research-checks.mjs +4 -4
  198. package/driver/result-noun-fields.mjs +28 -11
  199. package/driver/review-addresses.mjs +163 -0
  200. package/driver/rule-shape.mjs +1 -1
  201. package/driver/run-delivered.mjs +340 -0
  202. package/driver/run-economics.mjs +8 -26
  203. package/driver/run-failed.mjs +545 -0
  204. package/driver/run-integrity.mjs +1 -1
  205. package/driver/run-outcome.mjs +314 -0
  206. package/driver/run-park.mjs +23 -0
  207. package/driver/run-quote.mjs +32 -0
  208. package/driver/run-record.mjs +352 -0
  209. package/driver/run-requirements.mjs +22 -0
  210. package/driver/run-shell.mjs +55 -0
  211. package/driver/runner.mjs +71 -33
  212. package/driver/saved-register-pages.mjs +4 -4
  213. package/driver/score-redaction.mjs +2 -2
  214. package/driver/search-policy.mjs +12 -13
  215. package/driver/settle-stamp.mjs +4 -3
  216. package/driver/skeptic-record.mjs +2 -2
  217. package/driver/skeptic-search.mjs +1 -1
  218. package/driver/skills/README.md +7 -7
  219. package/driver/skills/blind-frame/SKILL.md +1 -2
  220. package/driver/skills/case-law-citation/SKILL.md +9 -37
  221. package/driver/skills/case-law-citation/sources/courtlistener.md +1 -3
  222. package/driver/skills/case-law-citation/sources/eurlex.md +8 -11
  223. package/driver/skills/case-law-citation/sources/legaldatahunter.md +1 -1
  224. package/driver/skills/clearance-common-law/SKILL.md +45 -111
  225. package/driver/skills/clearance-common-law/perplexity-prompts.md +7 -79
  226. package/driver/skills/clearance-register/SKILL.md +15 -33
  227. package/driver/skills/clearance-register/digest.md +31 -92
  228. package/driver/skills/clearance-register/providers/clarivate.md +2 -2
  229. package/driver/skills/clearance-register/providers/corsearch.md +5 -5
  230. package/driver/skills/clearance-register/providers/euipo.md +1 -2
  231. package/driver/skills/clearance-register/providers/free-tier.md +0 -19
  232. package/driver/skills/clearance-register/providers/signa.md +6 -25
  233. package/driver/skills/clearance-register/providers/uspto-local.md +0 -24
  234. package/driver/skills/clearance-register/register-recipes.md +8 -15
  235. package/driver/skills/clearance-register/status-rules.md +6 -24
  236. package/driver/skills/clearance-register/unit.md +11 -20
  237. package/driver/skills/clearance-search/delivery-contract.md +24 -120
  238. package/driver/skills/clearance-search/field-doctrine-pharma.md +1 -5
  239. package/driver/skills/clearance-search/firm-wide-reasoning.md +24 -43
  240. package/driver/skills/clearance-search/phase2-execution.md +29 -77
  241. package/driver/skills/clearance-search/report-prose.md +3 -4
  242. package/driver/skills/clearance-search/risk-framework-demo.md +1 -1
  243. package/driver/skills/clearance-search/risk-framework-triage.manifest.json +3 -3
  244. package/driver/skills/clearance-search/risk-framework-triage.md +7 -9
  245. package/driver/skills/clearance-search/risk-framework.manifest.json +1 -1
  246. package/driver/skills/clearance-search/risk-framework.md +1 -1
  247. package/driver/skills/clearance-search/synthesis-rules.md +30 -107
  248. package/driver/skills/clearance-search/worked-examples.md +5 -5
  249. package/driver/skills/clearance-variants/SKILL.md +46 -45
  250. package/driver/skills/clearance-variants/transliteration-scripts.md +4 -4
  251. package/driver/skills/frame-diff/SKILL.md +1 -1
  252. package/driver/skills/knockout-assess/SKILL.md +6 -14
  253. package/driver/skills/knockout-frame/SKILL.md +1 -1
  254. package/driver/skills/matter-frame/SKILL.md +7 -12
  255. package/driver/skills/matter-frame/watchlist-reference.md +1 -4
  256. package/driver/skills/narrative-refutation/SKILL.md +20 -30
  257. package/driver/skills/placement-inquiry/SKILL.md +8 -18
  258. package/driver/skills-store-provenance.mjs +1 -1
  259. package/driver/stage-context.mjs +32 -35
  260. package/driver/stage-freshness.mjs +127 -11
  261. package/driver/stages-knockout.mjs +49 -22
  262. package/driver/stages.mjs +88 -283
  263. package/driver/status-snapshot.mjs +2 -1
  264. package/driver/steps/correction-cycle.mjs +311 -0
  265. package/driver/steps/corrections.mjs +644 -0
  266. package/driver/steps/delivery.mjs +1287 -0
  267. package/driver/steps/frame-comparison.mjs +922 -0
  268. package/driver/steps/intake.mjs +84 -0
  269. package/driver/steps/open-run.mjs +419 -0
  270. package/driver/steps/overview-and-cards.mjs +899 -0
  271. package/driver/steps/placement-and-digest.mjs +23 -0
  272. package/driver/steps/register-sweep.mjs +1563 -0
  273. package/driver/steps/skeptic-and-follow-up.mjs +831 -0
  274. package/driver/steps/synthesis.mjs +261 -0
  275. package/driver/steps/verdict-gate.mjs +968 -0
  276. package/driver/suite-census.json +403 -91
  277. package/driver/surface-exit-verdict.mjs +0 -8
  278. package/driver/synthesis-record.mjs +72 -6
  279. package/driver/terminal-clamp.mjs +10 -0
  280. package/driver/tokens.mjs +8 -62
  281. package/driver/tool-calls.mjs +2 -2
  282. package/driver/unit-state-verdict.mjs +1 -1
  283. package/driver/usage-ledger.mjs +2 -1
  284. package/driver/verify-knockout.mjs +20 -35
  285. package/driver/verify.mjs +47 -36
  286. package/driver/web-grid.mjs +3 -4
  287. package/driver/whatif-memo-run.mjs +2 -2
  288. package/driver/whatif-queue.mjs +4 -3
  289. package/driver/withheld-families.mjs +14 -15
  290. package/driver/worker-heartbeat.mjs +3 -2
  291. package/driver/write-up-form.mjs +0 -3
  292. package/mcp-server/CHANGELOG.md +8 -0
  293. package/mcp-server/http-server.mjs +1 -1
  294. package/mcp-server/lib/brief.mjs +22 -4
  295. package/mcp-server/lib/events.mjs +2 -2
  296. package/mcp-server/lib/evidence.mjs +3 -2
  297. package/mcp-server/lib/findings.mjs +2 -1
  298. package/mcp-server/lib/knockout.mjs +9 -10
  299. package/mcp-server/lib/ops.mjs +9 -9
  300. package/mcp-server/lib/runs.mjs +9 -10
  301. package/mcp-server/lib/trace.mjs +1 -1
  302. package/mcp-server/lib/whatif.mjs +2 -3
  303. package/mcp-server/package.json +1 -1
  304. package/mcp-server/server.mjs +5 -5
  305. package/package.json +2 -1
  306. package/portal-ui/dist/assets/{index-fPqAU0sx.js → index-D5rkCjDc.js} +26 -14
  307. package/portal-ui/dist/index.html +1 -1
  308. package/portal-ui/package.json +3 -3
  309. package/providers/README.md +1 -1
  310. package/providers/_shared/answer-memory.mjs +4 -5
  311. package/providers/_shared/execute-plan.mjs +48 -1
  312. package/providers/_shared/records-from-search.mjs +46 -0
  313. package/providers/clarivate/README.md +2 -2
  314. package/providers/clarivate/src/adapter.js +147 -0
  315. package/providers/clarivate/src/core.js +1 -14
  316. package/{driver/engine/mcp/clarivate-server.mjs → providers/clarivate/src/mount.js} +5 -10
  317. package/providers/corsearch/README.md +3 -3
  318. package/providers/corsearch/src/adapter.js +80 -0
  319. package/providers/corsearch/src/core.js +14 -11
  320. package/{driver/engine/mcp/corsearch-server.mjs → providers/corsearch/src/mount.js} +5 -10
  321. package/providers/euipo/README.md +2 -2
  322. package/providers/euipo/src/adapter.js +85 -0
  323. package/providers/euipo/src/core.js +1 -1
  324. package/providers/euipo/src/euipo-client.js +1 -2
  325. package/{driver/engine/mcp/euipo-server.mjs → providers/euipo/src/mount.js} +5 -10
  326. package/providers/free-tier/README.md +2 -2
  327. package/providers/free-tier/src/adapter.js +127 -0
  328. package/{driver/engine/mcp/free-tier-server.mjs → providers/free-tier/src/mount.js} +5 -10
  329. package/providers/jx-subclass/coverage.mjs +1 -6
  330. package/providers/jx-subclass/score-truth.mjs +2 -1
  331. package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
  332. package/providers/oauth-mcp-bridge/package.json +1 -1
  333. package/providers/perplexity/src/core.js +2 -2
  334. package/providers/signa/README.md +2 -2
  335. package/providers/signa/src/adapter.js +157 -0
  336. package/providers/signa/src/capabilities.js +0 -3
  337. package/providers/signa/src/core.js +2 -2
  338. package/{driver/engine/mcp/signa-server.mjs → providers/signa/src/mount.js} +7 -12
  339. package/providers/signa/src/offices.generated.js +17 -15
  340. package/providers/uspto-local/README.md +1 -1
  341. package/providers/uspto-local/bin/verify-index.mjs +1 -1
  342. package/providers/uspto-local/src/adapter.js +75 -0
  343. package/{driver/engine/mcp/uspto-local-server.mjs → providers/uspto-local/src/mount.js} +5 -10
  344. package/scripts/band-shape-probe.mjs +2 -2
  345. package/scripts/citation-line-check.mjs +7 -7
  346. package/scripts/compare.mjs +1 -1
  347. package/scripts/dead-names.mjs +2 -2
  348. package/scripts/e2e-first-time.mjs +19 -7
  349. package/scripts/e2e.mjs +13 -13
  350. package/scripts/engine-probe.mjs +1 -1
  351. package/scripts/env-audit.mjs +7 -4
  352. package/scripts/env-classify.mjs +5 -1
  353. package/scripts/feedback-mint.mjs +1 -1
  354. package/scripts/freeze-example-run.mjs +7 -7
  355. package/scripts/mint-suite-census.mjs +2 -2
  356. package/scripts/nightly-notice.mjs +1 -1
  357. package/scripts/release-cut-decision.mjs +7 -2
  358. package/scripts/release-note-required.mjs +26 -9
  359. package/scripts/release-notes-lint.mjs +3 -2
  360. package/scripts/release-version-pr-checks.mjs +1 -1
  361. package/scripts/settings-render-check.mjs +23 -3
  362. package/scripts/test-run.mjs +5 -5
  363. package/scripts/travelling-predicates.mjs +1 -1
  364. package/scripts/undeclared-field-census.mjs +1 -1
  365. package/scripts/unexecuted-asserts.mjs +1 -1
  366. package/scripts/verify-publishable.mjs +1 -1
  367. package/shared/client-door.mjs +1 -1
  368. package/shared/connect-clients.mjs +1 -1
  369. package/shared/connector-signin-probe.mjs +1 -1
  370. package/shared/env-aliases.mjs +1 -1
  371. package/shared/invocation.mjs +14 -2
  372. package/shared/names-in-force.mjs +2 -0
  373. package/shared/register-selection.mjs +2 -2
  374. package/shared/store-in-repo.mjs +3 -3
  375. package/shared/summary-blocks.mjs +0 -3
  376. package/shared/trigger-lane.mjs +1 -1
  377. package/shared/vacuous-pass.mjs +2 -2
  378. package/shared/verb-shim.mjs +4 -2
  379. package/node_modules/exceljs/README.md +0 -3023
@@ -1,5 +1,152 @@
1
1
  # clearotron-driver
2
2
 
3
+ ## 0.6.0-beta.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Fixed: When setup stops at a refused register credential, it now says what it had already installed, instead of saying nothing was written.
8
+ - New: Searches on the Signa register now reach Brazil and Italy, so an order naming either country is searched there rather than reported as not covered.
9
+ - For operators: A run on Signa now reuses an answer it already holds instead of asking the register the same question again. Set `CLEAROTRON_SIGNA_ANSWER_MEMORY=off` to ask every time.
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixed: A summary panel citing a finding the search does not have, or a recommended step resting on a finding that is gone, is now sent back for correction before delivery.
14
+ - Fixed: The report link in the assistant's summary of a clearance now opens the report in the portal. It used to point at an address the portal does not serve.
15
+ - Fixed: In the demo, a search ordered under the default company now opens that search's finished example instead of being refused.
16
+ - Fixed: The first `clearotron start` on a new install no longer warns that the reports folder is not set. It records its configuration with the folders it creates, as it already did for its services.
17
+ - Fixed: When a client asks for a full-depth Japanese- or Korean-language search that this version cannot run, the report now says so in plain words.
18
+ - Fixed: The assistant's summary of a Knockout batch now lists every name screened, with its report link, including a name whose data could not be saved.
19
+ - Fixed: A Knockout correction can now update another screened name when the same finding or a dependent answer requires it. Those changes go to review instead of causing the correction to be discarded.
20
+ - Fixed: A Knockout search now delivers each name's report when the audit workbook or one name's data file cannot be written, where before it delivered nothing. The run records which file is missing, and the report, its email and the run's record offer only the files that exist.
21
+ - Fixed: A Knockout search's email now names the product as its report does. Its subject and first line say "Knockout search", where they said "Knockout trademark review".
22
+ - For operators: When a Knockout search fails after retrying on its own, its failure notice now says how many automatic recovery attempts it made, as a clearance's does.
23
+ - For operators: When a Knockout search fails, its failure notice now says why it stopped and whether retrying can help, in the sentences a clearance's notice already uses. The requester's copy is unchanged.
24
+ - For operators: A Knockout search now keeps the order it was accepted on, as a clearance does. A batch of several marks can then be resumed from the command line without its job file; before, that resume was refused as a different matter.
25
+ - Fixed: A Knockout search paused to recover from a failure now retains the information needed to resume automatically. Previously, missing information could leave it waiting for someone to restart it.
26
+ - Fixed: A Knockout search that reaches the AI provider's usage limit while reading the register or correcting now pauses and resumes, as a clearance does. It no longer finishes without that step.
27
+ - Fixed: When a Knockout search fails during a stage because a credential or configuration is invalid, it now stops retrying and sends the same failure notice as a clearance.
28
+ - Fixed: Installed from a package file inside a project folder, setup and `clearotron doctor` no longer warn that a different `clearotron` is earlier on your PATH when it is the same install, and the commands they print use the plain `clearotron` name.
29
+ - Fixed: The report and its email no longer flag a party named in a recommended step as unexplained when the report already shows that party among its open coverage items or its web and marketplace names.
30
+ - Fixed: A recheck can now flag a previously excluded record that a correction added to the report, so that flag no longer leaves the delivery marked as unchecked.
31
+ - Fixed: A report no longer reads as clear when a repeated review says so while an open point found by a check still stands; it now lists that point.
32
+ - For operators: Re-rendering a published report now refuses one made by a different version of Clearotron, and leaves its saved report as it was.
33
+ - Fixed: Where a web or marketplace name rests on the run's own common-law search record, the report now says so in words. It used to print that record's file name as a link that opened nothing.
34
+ - Fixed: A clearance that resumes after its register cross-checks were added keeps them in its audit record.
35
+ - Fixed: A clearance search that resumes now runs a step again when its saved work has no record of what it was made from. Running a register step again no longer pays again for answers the search already holds.
36
+ - Fixed: A clearance interrupted just after its report was published now sends the same covering email when it resumes, with the link to download the audit workbook. Before, the resumed email left that link out.
37
+ - Fixed: A Knockout search resumed without its original order now keeps each name's own classes and reference as the order gave them. Before, the resume could search a name across all the batch's classes instead.
38
+ - Fixed: A Knockout search that resumes no longer searches the web again for what a filing's owner sells when it already holds that answer. Before, every resume paid for that search again.
39
+ - Fixed: A Knockout search interrupted just after its report was published no longer publishes it a second time when it resumes; it delivers the report it already published, as a clearance does.
40
+ - Fixed: A Knockout search that resumes after something a step read has changed, such as its plan, now runs that step again, as a clearance does. Before, it could deliver a rating of the earlier plan.
41
+ - Fixed: A search that stops and resumes now continues on the register it started on, even if the register setting changed in between. If this server cannot use that register or AI engine, the search waits and resumes by itself on one that can.
42
+ - Fixed: A search that stopped before its search type was settled now resumes as the search that was ordered, Knockout search included. Before, it could be delivered under the name of a search type no longer offered, or refused.
43
+ - Fixed: A search that stops and resumes now finishes on the AI engine it started on, even if the engine setting changed in between. Before, a resumed search switched to whichever engine was set at the time, and its record did not say so.
44
+ - Fixed: When the review flags a coverage line, a recommended step or a summary section, the correction now goes to that part by its address, not by matching words. A flag that names a finding the review was not given is sent back to the reviewer at once.
45
+ - For operators: A run resumed outside the queue that pauses for an automatic retry after its report is published now resumes on its own. It used to stay paused until someone resumed it again.
46
+ - Fixed: `clearotron run` on an install with no AI or register chosen now says what is missing and how to set it up, as `clearotron doctor` does. It used to name a program nobody had chosen.
47
+ - Fixed: A search gap that a run recorded twice is now listed once in its report.
48
+ - Fixed: A search step that runs again, after a retry or a resume, no longer sends a web research question it already has the answer to. Before, every rerun paid for those questions again.
49
+ - For operators: A stopped clearance now records what it spent up to the stop in the account's usage and refreshes the run list, as a Knockout search does.
50
+ - For operators: A search stopped by request now reads as stopped in the staff run list, with the reason its stop recorded. Before, it read as running until newer searches pushed it off the list.
51
+ - For operators: `clearotron update` now waits while a search is parked, as it already waited for one that is running. A search started before an update is no longer resumed after it: it ends with the usual failure notice, and nothing is asked of the register again.
52
+ - Fixed: Closing the terminal window that runs `clearotron start` or `clearotron demo` now stops it completely, as its banner says. It used to keep running at full processor use and leave the demo's folder behind.
53
+ - Fixed: With no AI chosen, `clearotron doctor` no longer lists a program's path among what a search needs.
54
+ - Fixed: When no AI is chosen, `clearotron doctor` now prints where setup installed the AI program and how to sign it in, as the guides say it does.
55
+ - Fixed: When findings for the same conflict are grouped, each court decision now appears under its own finding.
56
+ - Fixed: Installation settings now show the setup command for a missing engine program as a command, without the backticks around it.
57
+ - Fixed: Knockout reports now call their scale the Knockout risk scale and its middle level Moderate, as clearance reports do, and clearance reports call theirs the Standard risk scale.
58
+ - Fixed: Leaving New clearance before changing anything no longer asks whether to discard unsaved changes.
59
+ - Fixed: New clearance now stops a search that a company's own territories cannot fill, as it already did for territories typed into the form.
60
+ - New: A Spanish or Mexican registration found on the Signa register now links to the office's own page for that registration. Brazilian and Italian registrations are cited by number.
61
+ - Fixed: In the demo, New clearance now says that new searches are unavailable and that the example report, its audit trail and the assistant connection need no engine, instead of saying they are live right now.
62
+
63
+ ## 0.5.1
64
+
65
+ ### Patch Changes
66
+
67
+ - Fixed: On a beta, the setup and check commands the portal names now install and run the beta, not the stable release.
68
+ - Fixed: The README and the quickstart now give the beta's own install and demo commands, and the README no longer says `npx` asks only once before downloading.
69
+ - Fixed: With no AI chosen, the portal no longer offers to read a brief with an AI nobody chose, and `clearotron start` says why it is off.
70
+ - Fixed: Cancelling setup now says what it had already installed, instead of saying nothing was written.
71
+ - Fixed: For the Legal Data Hunter case-law source, `clearotron doctor` no longer says to ask whoever provisioned it; it says the source is optional and a Full country search runs without it.
72
+ - Fixed: Before the first `clearotron start`, `clearotron doctor` no longer says the install did not finish; it says `clearotron start` starts the client connector and `clearotron start --background` sets it up as a service.
73
+ - Fixed: When a report's correction fixes a wrong statement about what was searched, it now keeps the true results that shared that passage.
74
+ - Fixed: An assistant connected to a demo can read and explain its sample reports and can no longer start work. The connection has its own name, uses only that demo's folder, and stops working when the folder is gone.
75
+ - New: A demo now names the command that connects an assistant other than Claude Code. Run it in a second terminal and pick the assistant.
76
+ - Fixed: A demo started after `demo --once` or `demo --keep` now keeps the folder and reports those left, and says how to remove it, instead of deleting them when it closes.
77
+ - Fixed: In a demo, the free preview no longer tells a connected assistant to start the search, which a demo cannot do.
78
+
79
+ Fixed: On a machine without Claude Code, the demo now says so before its connect line, which needs it.
80
+ - Fixed: In a demo, the descriptions and guidance a connected assistant reads no longer tell it to start a search, which a demo cannot do.
81
+ - Fixed: A demo's first screen no longer lists its services' startup details. They go to a file in the demo's folder, which the screen names. Warnings and failures still show.
82
+ - Fixed: A Knockout again checks the web use of at most three owners per name, instead of every owner it marks.
83
+ - Fixed: A knockout search now reads the client's own request and the goods of each filing it fetched when it rates a name.
84
+ - Fixed: A Knockout search now reads the register the way a clearance does, instead of taking an equal share of 100 filings in the register's order. It looks at each name's counts and reads each list it selects in full. It narrows a crowd by the client's goods, classes and markets. It chooses near spellings, wider searches and sound-alike searches from what it read. An independent check can now send a material defect back to the rating step, and reads the corrected record again. The report lists a name's filings before its web use, and can give different risk bands to different groups of classes where the evidence divides.
85
+ - Fixed: A Knockout started before a register is chosen now stops at once and names the setting it needs, instead of waiting to retry on its own.
86
+ - Fixed: Setup no longer tells an install from npm to take updates with `git pull`, and the settings file it writes names the command that wrote it.
87
+ - Fixed: A port chosen with `clearotron start --port` is now refused when it is busy, as a port set by its variable is, instead of being moved.
88
+ - Fixed: A report now prints the search and issue dates from its own record. Republishing a report, or opening a demo's example, no longer shows today as the day it was searched or issued.
89
+ - Fixed: A running search's second and third steps now read "Searching registers and common law" and "Investigating and exploring findings".
90
+ - Fixed: A `clearotron start` that fails after starting its doors now stops them, instead of leaving them running.
91
+ - Fixed: A run that stops now prints a `clearotron run` command to resume it, and one that waits names `clearotron run-queue --watch`, in place of a `node` path.
92
+ - Fixed: A name containing AND, OR or NOT is now searched on Clarivate instead of being set aside, by searching its words in order.
93
+ - Fixed: After `clearotron start --background`, `clearotron doctor` no longer warns about an unset deployment name; it says that only Clearotron's own servers set one.
94
+ - Fixed: Right after setup, `clearotron doctor` no longer warns that the key revocation list cannot be read or that portal saves are refused; it says the first `clearotron start` sets both up.
95
+ - Fixed: On a machine with background services, `clearotron doctor` now reports the AI, the program and the billing those services use, not what your shell happens to set.
96
+ - Fixed: `clearotron doctor` now opens with whether a search can run and what stops one. Before, that answer came about halfway down its output.
97
+ - Fixed: With no AI chosen, `clearotron doctor` no longer reports the program, billing or sign-in of an AI nobody chose, and `--probe-engine` spends no turn.
98
+ - Fixed: `clearotron doctor` and `clearotron start` now say that a revocation list the client door cannot read makes it refuse every key; they said the opposite.
99
+ - Fixed: Setup and `doctor` no longer tell you to set a register on the Installation settings page, which shows each setting but cannot change one. They tell you to re-run setup.
100
+
101
+ Fixed: Setup's opening now says that a paid register key is written on your word, because checking it would cost you. It also says that your organisation's name is the one answer you cannot skip. With no register chosen, setup's closing lines no longer suggest a first real clearance that would be refused.
102
+
103
+ Fixed: After `doctor --probe-engine` runs a test turn, its last line no longer says that nothing was written: the AI program keeps its own files from that turn.
104
+ - Fixed: Setup's figure for the disk space the AI's program takes now matches what it installs.
105
+ - Fixed: After a declined or failed test turn, setup now asks whether to go on without an AI. If you go back to the AI question instead, the AI you picked is the default.
106
+ - Fixed: Setup's messages now name the AI as Claude or Codex, and the portal's pages by the names the portal uses, instead of the program's internal names.
107
+ - Fixed: On an npm install, setup's refusal of a configuration folder inside the program no longer speaks of a checkout and `git pull`.
108
+ - Fixed: Setup and the portal's settings list now say what the SerpAPI key is for: the Chinese marketplace search.
109
+ - Fixed: Before its test turn, setup now says the AI is saved only once the turn works, and that the turn costs nothing while the AI is not signed in.
110
+
111
+ Fixed: Setup's sign-in steps now say to use a second terminal and which question to answer yes to, and a missing Codex sign-in is reported in plain words.
112
+ - Fixed: Setup's test turn now names your AI and says how the turn is paid for, in the words of the question before it.
113
+ - Fixed: `clearotron --help` and setup's closing screen now name the four processes `clearotron start` runs.
114
+ - Fixed: `clearotron start` no longer says that ordering starts a search when the install cannot run one yet. It says what is missing and the command that sets it up.
115
+ - Fixed: The audit workbook now lists a part as not completed when the run could not add a coverage row. It does the same when the run could not finish a machine check, or its check of the official records behind the cards. Before, the report shipped without that part and nothing said so.
116
+ - Fixed: When setup installed Claude itself, the line `clearotron start` prints to connect an assistant now names that copy by its full path, so the command is found.
117
+ - Fixed: The portal's connect page and `clearotron connect` now name the Claude program setup installed, so the command they give runs on a machine with no other copy.
118
+ - Fixed: Installing with `npx` no longer ends with a false warning that a different `clearotron` comes earlier on the PATH.
119
+ - Fixed: The demo no longer reads a pasted brief with the AI engine and no longer runs queued searches, so its portal makes no paid call; its closing lines no longer say an order commits money.
120
+ - Fixed: In the demo, New clearance offers Review search again, and an order opens the finished example without asking whether to leave the page.
121
+ - Fixed: Setup's closing summary now names the AI, and when no AI or register is chosen it no longer says that nothing needs running again.
122
+ - Fixed: With no AI chosen, `clearotron doctor` no longer names a default AI; it says a search is refused until one is chosen, as its search check already did.
123
+ - Fixed: The install guide now says, where it offers the free US register, that downloading it needs a free USPTO.gov account with ID.me identity verification.
124
+ - Fixed: The install guide now gives an npm install its own commands to update, resume a run and connect an assistant, and marks the steps meant only for the source code.
125
+ - Fixed: The install guide now gives the beta's global install, a removal command that removes the program, and the folder Codex's turns leave behind.
126
+ - Fixed: The install guide's removal list now names the folder a tarball install creates, npm's download cache and Claude Code's own cache.
127
+
128
+ Fixed: The install guide now lists an AI among the settings a search requires, and no longer calls one AI the default.
129
+ - Fixed: The install guide now takes a new reader from install and setup through the free demo to the portal, where they order their first search.
130
+ - Fixed: The install guide now gives how long the sample runs in the demo took, about an hour for each clearance, instead of a figure from an older sample.
131
+ - Fixed: The install guide now says that `clearotron start` runs the portal, the engine door, the client door and the worker, and that Ctrl-C stops all of them.
132
+ - Fixed: The install guide now names all three ports `clearotron start` opens, says that `--port` moves all three, and says when a port in use is moved rather than refused; the README says which ports the demo opens.
133
+ - Fixed: The install guide now says a demo can be signed in to and ordered from, and the README says what a demo leaves: npm's own copy of the package, and any folder `--once` or `--keep` kept.
134
+ - Fixed: The README, the quickstart and the install guide now say what the SerpAPI key is for: it searches Chinese marketplaces for the native-language investigation of China, Hong Kong, Taiwan or Macau.
135
+ - Fixed: The README, the quickstart and the install guide now agree that a Knockout search runs without a Perplexity key, and that the three clearance searches need one.
136
+ - Fixed: Starting Clearotron or the demo no longer logs the portal's own check of the engine connection as a rejected request.
137
+ - Fixed: On a first start in a terminal, the log no longer says the passphrase is not printed just above the box that prints it.
138
+ - Fixed: An install that cannot run a search yet now says so on Home and on New clearance, before a search is filled in. The person who runs the install is told what is missing and the command that sets it up.
139
+
140
+ Fixed: The Installation settings page now shows an AI that was never chosen as not set, instead of showing the default as configured.
141
+ - Fixed: The quickstart's link to the four searches now leads to a page that describes them.
142
+ - Fixed: When an install cannot search yet, the portal, `clearotron start` and the run's log now say where the missing settings go and what to restart.
143
+ - Fixed: Setup's register question no longer says there is no default beside the answer Enter picks.
144
+ - Fixed: The install guide's removal list now names the folder setup installs the AI program into, the files that program keeps for itself, and the copy `npx` keeps; it no longer says the demo leaves the program behind.
145
+ - Fixed: The install guide's sample settings now select Signa, the register the guide recommends, and list each register's key once.
146
+ - Fixed: While a search stops, its card and the stop dialog no longer put the step's name inside a sentence. The dialog names the current step on a line of its own.
147
+ - Fixed: The portal no longer shows "[object Object]" on a company's profile, sends requests that fail before a company is picked, or prints its address hint twice.
148
+ - Fixed: On an npm install, `clearotron update` now says what it does there and no longer speaks of `git pull` and `npm ci`. Where it names an npm command, a beta install stays on the beta.
149
+
3
150
  ## 0.5.1-beta.2
4
151
 
5
152
  ### Patch Changes
package/driver/README.md CHANGED
@@ -71,7 +71,16 @@ kind of thing a module is before you open it.
71
71
  | `engine/` | The swappable compute substrate (`engine/CONTRACT.md`). `anthropic-agent.mjs` is the production adapter (`claude -p`, stream-json, warm `--resume`); `registerEngine()`/`selectEngine()` key on `CLEAROTRON_AI`. `engine/mcp/` hosts the per-provider gather servers. |
72
72
  | `gateway.mjs` | `runStage()` — the engine-agnostic orchestration ladder: blocking call, output parse, file-truth gating, failure classification, bounded retries (fresh session key each), warm-resume. |
73
73
  | `stages.mjs` | The single per-stage table (agent/model-tier/thinking/timeout/skillReads/output/validator/message). Centralizes tiers (fixes the old cross-file drift). |
74
- | `pipeline.mjs` | The sequence: Phase-0 (code) → fan-out (batched) → fan-in barrier → placement → digest → skeptic+escalation → synthesis → (case-law) → refutation+verdict gate → publish+outbox → archive. CLI: `node pipeline.mjs --job <file.json>`. |
74
+ | `pipeline.mjs` | The clearance run: the run slot, the preflight and the freezes, then its ordered steps, handed to `runShell` in `run-shell.mjs`. CLI: `node pipeline.mjs --job <file.json>`. |
75
+ | `pipeline-knockout.mjs` | The Knockout run: its own steps, handed to the same `runShell`. |
76
+ | `run-shell.mjs` | What every run does around its steps, for both products: it runs the steps in order, ends a failure through `run-failed.mjs` and a delivery through the product's ending. |
77
+ | `run-failed.mjs` | The failure path of both products: postpone, stop, park for recovery or end, and the notice it sends. |
78
+ | `run-delivered.mjs` | How a clearance ends delivered: the publish, the packet, the delivered state and the archive. |
79
+ | `run-outcome.mjs` | How a run that cannot finish is described: the failure a stage raises, the designed refusal, and the packet that tells the requester. |
80
+ | `run-park.mjs` | The one writer of `.postponed`, the marker a parked run resumes from. |
81
+ | `run-record.mjs` | The one door to a run's files: where they are, and how they are read and written. |
82
+ | `steps/` | One module for each phase of a run, called in order from `pipeline.mjs`, and `corrections.mjs`, the functions the correction phases share. This row is its front door, so it has no README of its own. |
83
+ | `ladder/` | The stage ladder's steps, carved out of `gateway.mjs` `runStageLadder` one at a time; each file's header says which step it is. This row is its front door, so it has no README of its own. |
75
84
  | `phase0.mjs` | Pure: slug, codename (re-rolled on run-dir collision), run-dir, customer template. |
76
85
  | `verify.mjs` | Structural file-truth validators + `parseVerdict` (the verdict gate). |
77
86
  | `runner.mjs` | Drains **every** queue (`config.queueDirs`) **concurrently across queues** (serial within one; per-queue failure isolation); per job: atomic claim (+ claimer-pid sidecar so a live claim is never re-claimed; an orphaned claim is re-claimed next activation), run, mark `.done`/`.failed` in the origin queue. |
@@ -81,6 +90,7 @@ kind of thing a module is before you open it.
81
90
  | `profiles.mjs` + `profiles/` | Per-customer config: `profileKey`-then-forwarder-domain resolution, derived floor/batch, the run-frozen `_driver/profile.json` sidecar. Real customer bundles load from an EXTERNAL store via `CLEAROTRON_CUSTOMERS_DIR`; the repo ships `generic` + synthetic demo customers. See `profiles/README.md`. |
82
91
  | `coverage-ledger.mjs` | Machine coverage-ledger contract: strict JSON-mirror parser (token-first throws), prose parser, `REGISTER_AXES`/`decideAxes`. |
83
92
  | `enqueue-schema.mjs` | Job-file shape + `validateJob`. |
93
+ | `portal-service.mjs` · `portal-routes/` · `portal-runs.mjs` · `portal-confirmation.mjs` | The portal: the service, its routes grouped one module per area (`portal-routes/README.md`), the runs a reader can see, and the token that confirms an order. |
84
94
  | `dev-portal.mjs` | Loopback-only dev-instance UI (static pool + `/profiles/*` proxy) for dry-run testing — see `../docs/E2E.md` Tier 1b. |
85
95
  | `systemd/*` | `clearotron-worker.service` is the live worker and what a deployment runs. The path/timer/oneshot drain units and the outbox-wake units beside them are RETIRED: the built-in worker replaced that posture. Their files stay until the production rebuild — `unit-inventory.mjs` records the ruling and the reason, and reports a retired unit's absence as expected rather than as a fault. They keep their original names because a deployed box still holds them under those names. |
86
96
 
@@ -26,8 +26,7 @@
26
26
 
27
27
  import { existsSync, readFileSync, appendFileSync } from "node:fs";
28
28
  import { join } from "node:path";
29
- import { driverDir, ensureDriverDir } from "../shared/driver-dir.mjs";
30
- import { atomicWrite } from "./progress.mjs";
29
+ import { atomicWrite, driverDir, ensureDriverDir, readJsonOrNull } from "./run-record.mjs";
31
30
 
32
31
  export const ACCEPTED_ORDER_FILE = "accepted-order.json";
33
32
  export const ORDER_AMENDMENTS_FILE = "order-amendments.jsonl";
@@ -44,12 +43,21 @@ export function orderSnapshot(job) {
44
43
  try { return JSON.parse(JSON.stringify(job)); } catch { return null; }
45
44
  }
46
45
 
47
- const readJson = (file) => { try { return existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : null; } catch { return null; } };
48
46
  const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
49
47
 
48
+ /**
49
+ * Does a run keep the instructed scope already on disk rather than write one from its job? Yes when its job was rebuilt
50
+ * from status and a scope is there. A rebuilt job holds what the run kept of the order, not the order: written from
51
+ * it, the scope could only lose what that reading leaves out, such as each name's own classes and reference. One
52
+ * decision for both products; each writes its own scope's shape when it does write. PURE.
53
+ */
54
+ export function keepsInstructedScope({ jobRebuiltFromStatus = false, scopeOnDisk = false } = {}) {
55
+ return Boolean(jobRebuiltFromStatus && scopeOnDisk);
56
+ }
57
+
50
58
  /** The order this run was accepted on, or null when the run holds none (an older run, or an unreadable file). */
51
59
  export function readAcceptedOrder(runDir) {
52
- const rec = readJson(driverDir(String(runDir ?? ""), ACCEPTED_ORDER_FILE));
60
+ const rec = readJsonOrNull(driverDir(String(runDir ?? ""), ACCEPTED_ORDER_FILE));
53
61
  return rec?.order && typeof rec.order === "object" ? rec.order : null;
54
62
  }
55
63
 
@@ -84,7 +92,7 @@ export function retainAcceptedOrder(runDir, order, { explicit = false, rebuilt =
84
92
  export function retainedQueueOrder(queueDir, id) {
85
93
  if (!queueDir || !id || /[\\/]/.test(String(id))) return null;
86
94
  for (const end of [".done", ".failed"]) {
87
- const order = readJson(join(queueDir, `${id}${end}`));
95
+ const order = readJsonOrNull(join(queueDir, `${id}${end}`));
88
96
  if (order && typeof order === "object" && order.id === id) return order;
89
97
  }
90
98
  return null;
@@ -0,0 +1,64 @@
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
+ // attempt-rows.mjs — what one row of a run's attempt log says: whether it is a provider attempt, and which model served it.
4
+ import { resolveModel } from "./driver.config.mjs";
5
+ import { engineStamp } from "./engine/stamps.mjs";
6
+
7
+ /**
8
+ * WHICH MODEL ACTUALLY SERVED THE TURN — the key `byModel` buckets under.
9
+ *
10
+ * `rec.model` is the TIER the stage asked for ("opus", "haiku"), and `resolveModel` is the ANTHROPIC
11
+ * catalog. Resolving one through the other is right for an Anthropic turn and wrong for every other
12
+ * engine: a codex run rolled up as `anthropic/claude-opus-5` while its own `byEngine` said
13
+ * `openai-agent` and its attempt rows said `gpt-5.6-sol`. The two halves of the same rollup contradicted
14
+ * each other, and the wrong half is the one the consumption ledger carries.
15
+ *
16
+ * The engine already answers this. gateway.mjs resolves the tier through the engine that served the
17
+ * turn (`engine.resolveModelId ?? resolveModel`) and stamps the answer on the row as `modelUsed`. So
18
+ * this reads the stamp rather than re-deriving it — one resolution, at the point that knows.
19
+ */
20
+ export function modelKey(rec) {
21
+ if (typeof rec.modelUsed === "string" && rec.modelUsed) return rec.modelUsed;
22
+
23
+ // NO STAMP. Two different situations, and guessing the same way for both is what caused the bug.
24
+ const engine = typeof rec.engine === "string" ? rec.engine : "";
25
+
26
+ // A TURN THAT NAMED NO MODEL, a native-language row recording `modelActual: null` (see isAttemptRow),
27
+ // has no id at all. Its tokens still account, under a key that says the model is missing rather than
28
+ // one built from the absent field. Asked FIRST, so no row keys as `undefined` because the catalog was
29
+ // handed nothing to resolve.
30
+ if (typeof rec.model !== "string") return `${engine || "unknown"}/no-model-reported`;
31
+
32
+ // Rows predating the stamp are Anthropic — that was the only engine when they were written — and
33
+ // resolving keeps every historical rollup keyed exactly as it was.
34
+ //
35
+ // A NATIVE-LANGUAGE ROW IS STAMPED WITH ITS VENDOR, NOT AN ENGINE (jxBillingStamp in jx-lanes.mjs), and
36
+ // its `model` is the id that served the turn. An Anthropic one is normalised through the catalog like
37
+ // any served Claude id, so it keys as `anthropic/claude-haiku-4-5`, apart from a stage's
38
+ // `anthropic/claude-haiku` — the split ruled on and accepted with recording the tier. It used to fall
39
+ // to the branch below and key as `anthropic/unstamped:<id>`, a name for a missing stamp on a row that
40
+ // carries one. An OpenAI one keys as its served id, which is what an openai-agent stage row carries.
41
+ const { catalog } = engineStamp(engine);
42
+ if (!engine || catalog === "tier") return resolveModel(rec.model);
43
+ if (catalog === "served") return rec.model;
44
+
45
+ // Any OTHER engine with no stamp. The tier is not a model id and this catalog is not that engine's,
46
+ // so there is no honest id to key under. Name the gap instead: the tokens still account (dropping
47
+ // them would break byModel summing to total, and an invisible gap is the failure this file already
48
+ // fixed once for byEngine), and the key says what is missing rather than asserting an Anthropic
49
+ // model produced them.
50
+ return `${engine}/unstamped:${rec.model}`;
51
+ }
52
+
53
+ /**
54
+ * WHETHER A ROW IS A PROVIDER ATTEMPT, the one test rollupTokens and servedModels both apply. A row that
55
+ * names a model is one: every stage attempt row carries the tier it asked for, and a native-language row
56
+ * the id its turn reported. So is a native-language row whose turn ran and named no model, which records
57
+ * `modelActual: null` instead (jxModelFields in jx-lanes.mjs). Without that second half, such a turn's
58
+ * attempt and the tokens it reported were dropped from every total, and a run made only of such turns
59
+ * read as one where nothing was looked at. A row with neither field is not a turn: the run log's events,
60
+ * a tool call, a native-language call no provider served.
61
+ */
62
+ export function isAttemptRow(rec) {
63
+ return Boolean(rec) && (typeof rec.model === "string" || rec.modelActual === null);
64
+ }
@@ -43,7 +43,7 @@
43
43
  // sidecar writer in this directory follows.
44
44
 
45
45
  import { appendFileSync } from "node:fs";
46
- import { ensureDriverDir, driverDir } from "../shared/driver-dir.mjs";
46
+ import { ensureDriverDir, driverDir } from "./run-record.mjs";
47
47
 
48
48
  /** The fields that would make a row a SEAT dispatch. Named so the guard and the writer cannot disagree. */
49
49
  export const DISPATCH_FIELDS = Object.freeze(["attempt", "key", "status"]);
@@ -46,7 +46,7 @@
46
46
 
47
47
  import { realpathSync, statSync } from "node:fs";
48
48
  import { resolve, win32, posix } from "node:path";
49
- import { driverDir } from "../shared/driver-dir.mjs"; //
49
+ import { driverDir } from "./run-record.mjs"; //
50
50
 
51
51
  /**
52
52
  * Is `child` inside `root` — by path segment, never by string prefix? PURE.
@@ -29,9 +29,9 @@
29
29
  // The store lives under `_driver/` — it survives a park and a `--resume`, and it is deliberately NOT an
30
30
  // artifact version (`_history/` is where superseded outputs go for compare.mjs). Keyed by STAGE LABEL, so
31
31
  // `common-law-half:a` and `common-law-half:b` never collide.
32
- import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
32
+ import { copyFileSync, existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
33
33
  import { join, basename } from "node:path";
34
- import { driverDir } from "../shared/driver-dir.mjs"; //
34
+ import { driverDir, readJson } from "./run-record.mjs";
35
35
 
36
36
  const safe = (label) => String(label).replace(/[^\w.:-]/g, "_");
37
37
 
@@ -53,7 +53,7 @@ export function beatsBest(quantity, prior) {
53
53
  export function readBestDraft(runDir, label) {
54
54
  try {
55
55
  const d = bestDraftDir(runDir, label);
56
- const rec = JSON.parse(readFileSync(join(d, "score.json"), "utf8"));
56
+ const rec = readJson(join(d, "score.json"));
57
57
  const p = join(d, rec.file);
58
58
  return existsSync(p) ? { ...rec, path: p } : null;
59
59
  } catch { return null; }
@@ -27,16 +27,16 @@
27
27
  import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
28
28
  import { captureCall, stampVerdict } from "./call-capture.mjs";
29
29
  import { join } from "node:path";
30
- import { driverDir } from "../shared/driver-dir.mjs"; //
31
30
  import { refuseUndeclared as refuseUndeclaredShared, keepIfAbsent, lastAccepted, acceptedEnvelope } from "./preserve-merge.mjs";
32
31
  import { parseBlindFrameModel } from "./blind-frame-model.mjs";
32
+ import { paths } from "./run-record.mjs";
33
33
 
34
34
  export const MODEL_FILE = "blind-frame-model.json";
35
35
  const SCHEMA_VERSION = 1;
36
36
 
37
37
  /** Where the call's evidence lives — the driver's own record of what the seat handed it. */
38
38
  export function blindFrameCallPaths(runDir) {
39
- const dir = driverDir(runDir, "blind-frame-calls");
39
+ const dir = paths(runDir).blindFrameCalls;
40
40
  return { dir, payload: join(dir, "call-001.json"), accepted: join(dir, "accepted.json") };
41
41
  }
42
42
 
package/driver/cancel.mjs CHANGED
@@ -18,8 +18,9 @@
18
18
  // other path already handled it. A cancel that could be undone by a resume two minutes later is the
19
19
  // failure mode this whole file exists to prevent.
20
20
 
21
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
21
+ import { existsSync, writeFileSync } from "node:fs";
22
22
  import { join } from "node:path";
23
+ import { readJson } from "./run-record.mjs";
23
24
 
24
25
  export const CANCEL_MARKER = ".cancel";
25
26
 
@@ -33,7 +34,7 @@ export function isCancelled(runDir) {
33
34
 
34
35
  /** The cancel record, or null. Best-effort: a corrupt marker still means CANCELLED (isCancelled is the gate). */
35
36
  export function readCancel(runDir) {
36
- try { return JSON.parse(readFileSync(cancelPath(runDir), "utf8")); } catch { return null; }
37
+ try { return readJson(cancelPath(runDir)); } catch { return null; }
37
38
  }
38
39
 
39
40
  /**
@@ -38,9 +38,9 @@
38
38
 
39
39
  import { existsSync, readFileSync, readdirSync } from "node:fs";
40
40
  import { join } from "node:path";
41
+ import { readJsonOrNull } from "./run-record.mjs";
41
42
 
42
43
  const readText = (p) => { try { return readFileSync(p, "utf8"); } catch { return ""; } };
43
- const readJson = (p) => { try { return JSON.parse(readFileSync(p, "utf8")); } catch { return null; } };
44
44
 
45
45
  export const ARRIVAL_ARTIFACTS = ["findings.json", "narrative.md", "placements.json"];
46
46
 
@@ -191,7 +191,7 @@ export function carryThrough(runDir) {
191
191
  * traced back to that axis contradicts it. The trace is the axis band file that names the URI.
192
192
  */
193
193
  export function coverageConflicts(runDir, lost) {
194
- const ledger = readJson(join(runDir, "register-coverage-ledger.json"));
194
+ const ledger = readJsonOrNull(join(runDir, "register-coverage-ledger.json"));
195
195
  if (!Array.isArray(ledger)) return { computable: false, reason: "register-coverage-ledger.json is absent or not a list", conflicts: [] };
196
196
  const unitsDir = join(runDir, "register-units");
197
197
  if (!existsSync(unitsDir)) return { computable: false, reason: "register-units/ is absent, so a lost record cannot be traced to an axis", conflicts: [] };
@@ -1,5 +1,5 @@
1
1
  {
2
- "citations": 257,
3
- "files": 3469,
4
- "checkable": 245
2
+ "citations": 235,
3
+ "files": 3945,
4
+ "checkable": 244
5
5
  }
@@ -31,14 +31,14 @@
31
31
  // the ledger for code from the SAME values. The parse does not change hands — it stops existing. That is
32
32
  // the difference between this conversion and matter-frame's, whose consumers still re-parse the driver's
33
33
  // own render (recorded honestly at that conversion's retirement site rather than claimed away).
34
- import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
34
+ import { readFileSync, writeFileSync } from "node:fs";
35
35
  import { captureCall, stampVerdict } from "./call-capture.mjs";
36
36
  import { join } from "node:path";
37
- import { driverDir } from "../shared/driver-dir.mjs"; //
38
37
  import { refuseUndeclared as refuseUndeclaredShared, keepIfAbsent, lastAccepted, acceptedEnvelope } from "./preserve-merge.mjs";
39
38
  import { parseVariantManifestModel } from "./variant-manifest-model.mjs";
40
39
  // THE LEDGER'S CLOSED VOCABULARIES, IMPORTED — never re-declared here. See the note at their re-export.
41
40
  import { SCOPE_LAYERS, SCOPE_STATUSES as SCOPE_STATUS } from "./scope-ledger.mjs";
41
+ import { paths, readJson } from "./run-record.mjs";
42
42
 
43
43
  export const MODEL_FILE = "variant-manifest.json";
44
44
  export const PROSE_FILE = "variant-manifest.md";
@@ -46,7 +46,7 @@ const SCHEMA_VERSION = 1;
46
46
 
47
47
  /** Where the call's evidence lives — the driver's own record of what the seat handed it. */
48
48
  export function clearanceVariantsCallPaths(runDir) {
49
- const dir = driverDir(runDir, "clearance-variants-calls");
49
+ const dir = paths(runDir).clearanceVariantsCalls;
50
50
  return { dir, payload: join(dir, "call-001.json"), accepted: join(dir, "accepted.json") };
51
51
  }
52
52
 
@@ -340,12 +340,6 @@ export function recordClearanceVariants(runDir, received, { now = () => new Date
340
340
  };
341
341
  }
342
342
 
343
- /** The typed scope-ledger rows, for the driver's own serialisation. PURE — no re-parse of the table. */
344
- export function recordedScopeRows(received) {
345
- const v = acceptClearanceVariants(received);
346
- return v.ok ? v.scopeRows : [];
347
- }
348
-
349
343
  /**
350
344
  * This run's scope-ledger rows AS RECORDED, or `null` when the manifest did not come through the tool.
351
345
  *
@@ -374,7 +368,7 @@ export function recordedScopeLedgerRows(runDir) {
374
368
  // FALLBACK: runs that predate the base, which have a capture and no accepted.json. Unchanged
375
369
  // behaviour for them, and it is why this is a fallback rather than a replacement.
376
370
  let captured;
377
- try { captured = JSON.parse(readFileSync(clearanceVariantsCallPaths(dir0).payload, "utf8")); }
371
+ try { captured = readJson(clearanceVariantsCallPaths(dir0).payload); }
378
372
  catch { return null; } // no call — the prose path is the answer
379
373
  const v = acceptClearanceVariants(captured?.params);
380
374
  return v.ok ? v.scopeRows : null; // a refused call never wrote a manifest either
@@ -28,7 +28,7 @@
28
28
  // stages.mjs's paths() dictates, and a test holds the two equal.
29
29
  import { readFileSync, writeFileSync, mkdirSync, readdirSync } from "node:fs";
30
30
  import { join, dirname, basename } from "node:path";
31
- import { driverDir } from "../shared/driver-dir.mjs";
31
+ import { driverDir, readJson } from "./run-record.mjs";
32
32
 
33
33
  /**
34
34
  * The three statuses a common-law coverage ledger row may carry, as data and as prose alike. Not the
@@ -47,7 +47,7 @@ export const findingsPathForSpec = (spec) =>
47
47
 
48
48
  const readStatuses = (file) => {
49
49
  let doc;
50
- try { doc = JSON.parse(readFileSync(file, "utf8")); } catch { return null; }
50
+ try { doc = readJson(file); } catch { return null; }
51
51
  const rows = doc?.coverage_status;
52
52
  return rows && typeof rows === "object" && !Array.isArray(rows) ? rows : null;
53
53
  };
@@ -128,7 +128,7 @@ export function recordStatusesFromFindings(findingsPath, { half = null, now = ()
128
128
  if (!findingsPath) return null;
129
129
  const file = coverageStatusPath(findingsPath);
130
130
  let existing = null;
131
- try { existing = JSON.parse(readFileSync(file, "utf8")); } catch { existing = null; }
131
+ try { existing = readJson(file); } catch { existing = null; }
132
132
  if (existing && existing.source !== "findings") return null; // the seat recorded its own statuses
133
133
  let text;
134
134
  try { text = readFileSync(String(findingsPath), "utf8"); } catch { return null; }
@@ -17,7 +17,7 @@
17
17
  // have MORE rows per variant, never fewer).
18
18
  import { readFileSync, existsSync } from "node:fs";
19
19
  import { join } from "node:path";
20
- import { driverDir } from "../shared/driver-dir.mjs"; // — one definition of where a run's _driver/ is
20
+ import { driverDir } from "./run-record.mjs"; // — one definition of where a run's _driver/ is
21
21
 
22
22
  export const MIN_CELLS_PER_VARIANT = 7;
23
23
 
@@ -881,7 +881,7 @@ export function mergeCommonLawFindings(parts) {
881
881
  // FALSE against the real ledger, and the arm failed the very run it was derived from:
882
882
  //
883
883
  // • `candidates[]` is RAW, UNJUDGED web-search output — the grid program records up to 8 candidates
884
- // per cell "without judging similarity" (skills/clearance-common-law/perplexity-prompts.md), and the
884
+ // per cell, unjudged (`buildGridProgramTask`, providers/perplexity/src/core.js), and the
885
885
  // filtering is explicitly the model's. The real cell `CORAL FREEZE × vitaminshoppe.com` holds three:
886
886
  // a BCAA how-to video, a Hawaiian shaved-ice supplement and a Dallas store-locator page. The
887
887
  // model's "No results" means "no relevant listing", and no deterministic test can tell that page
@@ -11,7 +11,7 @@
11
11
 
12
12
  import { readFileSync, existsSync, readdirSync } from "node:fs";
13
13
  import { join, basename, isAbsolute } from "node:path";
14
- import { driverDir, driverFileName } from "../shared/driver-dir.mjs"; //
14
+ import { driverDir, driverFileName } from "./run-record.mjs"; //
15
15
  import { fileURLToPath } from "node:url";
16
16
  import { STAGES, paths } from "./stages.mjs";
17
17
  import { isEntrypoint } from "../shared/is-entrypoint.mjs"; // — one entry-point test, all spellings