clearotron 0.5.1 → 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 +60 -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 +4 -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 +4 -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
@@ -34,10 +34,10 @@
34
34
  // PURE except `heldRecordProvenance` and `readRunCallRows`, which read the run's files.
35
35
  import { readFileSync, existsSync, readdirSync } from "node:fs";
36
36
  import { join } from "node:path";
37
- import { normalizeRecordUri, readRecordArtifacts, forEachLedgerLine, recordBodyHasContent } from "./registry-fidelity.mjs";
37
+ import { normalizeRecordUri, readRecordArtifacts, forEachLedgerLine, recordBodyHasContent, lineMayMatchRun } from "./registry-fidelity.mjs";
38
38
  import { recordGoodsProvenance } from "./record-goods.mjs";
39
- import { driverDir } from "../shared/driver-dir.mjs";
40
39
  import { runPrefixSpellings } from "../shared/pre-rename-spellings.mjs";
40
+ import { driverDir, paths, readJson } from "./run-record.mjs";
41
41
 
42
42
  export const GOODS_EVIDENCE_SCHEMA_VERSION = 1;
43
43
  export const GOODS_EVIDENCE_FILE = "goods-evidence.json";
@@ -71,7 +71,7 @@ export function heldRecordProvenance(runDir) {
71
71
  session: facts.session ?? prev?.session ?? null, ts: facts.ts ?? prev?.ts ?? null, goods: recordGoodsProvenance(body) });
72
72
  };
73
73
  let text = "";
74
- try { text = readFileSync(driverDir(runDir, "register-record-bodies.jsonl"), "utf8"); } catch { text = ""; }
74
+ try { text = readFileSync(paths(runDir).registerRecordBodies, "utf8"); } catch { text = ""; }
75
75
  for (const line of text.split("\n")) {
76
76
  if (!line.trim()) continue;
77
77
  let row; try { row = JSON.parse(line); } catch { continue; }
@@ -98,7 +98,7 @@ export function heldBodiesOf(runDir, uris) {
98
98
  if (!want.size) return out;
99
99
  // A ledger row is written with its `target` before its `body` (providers/_shared/ledger.mjs), so the first target
100
100
  // on a line is the row's own, and only the rows of the records asked about are parsed.
101
- forEachLedgerLine(driverDir(runDir, "register-record-bodies.jsonl"), (line) => {
101
+ forEachLedgerLine(paths(runDir).registerRecordBodies, (line) => {
102
102
  const t = /"target":("(?:[^"\\]|\\.)*")/.exec(line);
103
103
  let target = null;
104
104
  try { target = t ? JSON.parse(t[1]) : null; } catch { target = null; }
@@ -112,7 +112,7 @@ export function heldBodiesOf(runDir, uris) {
112
112
  for (const uri of want) {
113
113
  const name = names.get(`${uri.replace(/^\/mark\//, "").replace(/[^a-z0-9]+/gi, "-")}.json`.toLowerCase());
114
114
  if (!name) continue;
115
- let body; try { body = JSON.parse(readFileSync(join(runDir, "_records", name), "utf8")); } catch { continue; }
115
+ let body; try { body = readJson(join(runDir, "_records", name)); } catch { continue; }
116
116
  if (!body || typeof body !== "object" || Array.isArray(body)) continue;
117
117
  const { _uri, _receipt, ...rest } = body;
118
118
  if ((_uri == null || uriKey(_uri) === uri) && recordBodyHasContent(rest)) out.set(uri, rest);
@@ -129,7 +129,11 @@ const inRun = (row, runPrefix) => !runPrefix || runPrefixSpellings(runPrefix).so
129
129
  /** This run's rows of the register call ledger. A missing file is no rows; one that cannot be read says so. IMPURE. */
130
130
  export function readRunCallRows(callLogPath, runPrefix) {
131
131
  const rows = [];
132
+ // The call log is shared by every run on the machine: a line naming none of this run's prefix spellings is
133
+ // skipped before it is parsed. With no prefix every row is the run's, so every line is read.
134
+ const mayMatch = runPrefix ? lineMayMatchRun(runPrefix) : () => true;
132
135
  const read = forEachLedgerLine(callLogPath, (line) => {
136
+ if (!mayMatch(line)) return;
133
137
  let row; try { row = JSON.parse(line); } catch { return; }
134
138
  if (inRun(row, runPrefix)) rows.push(row);
135
139
  });
@@ -271,7 +275,7 @@ export function deriveGoodsEvidence({ records = [], goods = null, held = null, f
271
275
  const readDriverJson = (runDir, name) => {
272
276
  const p = driverDir(runDir, name);
273
277
  if (!existsSync(p)) return null;
274
- try { return JSON.parse(readFileSync(p, "utf8")); } catch { return null; }
278
+ try { return readJson(p); } catch { return null; }
275
279
  };
276
280
 
277
281
  /** The record the run wrote, or null when there is none or it will not parse. IMPURE. */
@@ -135,9 +135,9 @@ export function scopeJurisdictions(job, profile) {
135
135
  *
136
136
  * Depth: the customer's jxPolicy.laneDepth[lane] when set ("off" excludes the lane); else
137
137
  * "candidates" — the component being selected means the customer bought deepening. `depth` records
138
- * the depth the CONFIG ASKED FOR and nothing else: no code reads it to gate a slice. The retrieval
139
- * slices arm on CLEAROTRON_NATIVE_LANGUAGE_<code> alone since item 8 deleted the per-slice arms (driver/jx.mjs
140
- * JX_SLICES, driver/jx-units.mjs), which are env and therefore not this pure module's business.
138
+ * the depth the CONFIG ASKED FOR and nothing else: no code reads it to gate a slice. No switch arms the
139
+ * retrieval slices: the per-slice arms and the per-language off switch are both retired (driver/jx.mjs
140
+ * JX_SLICES, driver/jx-units.mjs).
141
141
  *
142
142
  * THIS RECORD DOES NOT SAY WHAT EXECUTED. It is frozen at mint, before any slice runs, so the
143
143
  * per-lane `executes: "candidates"` it used to carry was a constant asserting that slices 2–3 do not
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-only
2
2
  // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
3
3
  // jx-units.mjs — the Phase-4 Stage-1.5 SHADOW units (spec 10.5/10.6): the zh SERP platform grid
4
- // (slice 2) and jx-nativeread:zh (slice 3). Called from two never-kill blocks in pipelineInner;
4
+ // (slice 2) and jx-nativeread:zh (slice 3). Called from two never-kill blocks, in the intake and synthesis steps;
5
5
  // everything here degrades and receipts — nothing throws past its own boundary.
6
6
  //
7
7
  // ARTIFACT BOUNDARY (was the "ship dark" invariant, and it outlived the switches): every artifact these
@@ -13,9 +13,8 @@
13
13
  // still ahead of us and a run as byte-identical "with every unit flag off"; both sentences outlived the
14
14
  // thing they described by naming a Phase-5 that has happened. There is no flag to turn off and no
15
15
  // byte-identical slice-1 run to fall back to — the consume seam is unconditional, gated only on
16
- // conditions a run already discloses. `laneEnvOn("zh")` is the one leg that stayed, and it stayed
17
- // because an incident kill is a switch someone would actually use; jxAimForSynthesis below carries that
18
- // reasoning where the seam is.
16
+ // conditions a run already discloses. The per-language off switch that outlived them is retired too
17
+ // (2026-11-11): no deployment set it, and a lane runs wherever the frozen lane decision carries it.
19
18
  //
20
19
  // Grid contract (slice 2): the driver DICTATES `_driver/jx/<lane>-grid-spec.json` (terms × platforms,
21
20
  // frozen on first dictation — a resume never re-dictates); a pure code-side executor fills every cell
@@ -31,15 +30,15 @@
31
30
  // enforces record_uri ∈ the inlined slice (else the item demotes to a lead); severity_hint is a
32
31
  // triage hint and NEVER sets a band — Claude stays the sole rating authority.
33
32
 
34
- import { readFileSync, writeFileSync, renameSync, appendFileSync, mkdirSync, existsSync } from "node:fs";
33
+ import { readFileSync, writeFileSync, renameSync, appendFileSync, mkdirSync } from "node:fs";
35
34
  import { join } from "node:path";
36
- import { driverDir } from "../shared/driver-dir.mjs"; //
37
35
  import { LANGUAGE_LANES, SERP_LANES, isMirrorHost, canonicalTerm, jxBillingStamp, jxModelFields } from "./jx-lanes.mjs";
38
36
  import { jxKey, MAX_LANE_ATTEMPTS } from "./jx.mjs";
39
37
  import { abbrev } from "./repair-contract.mjs";
40
38
  import { kebab } from "./search-policy.mjs";
41
- import { SERP_PROVIDERS, JX_PROVIDERS, laneArmed } from "./driver.config.mjs";
39
+ import { SERP_PROVIDERS, JX_PROVIDERS } from "./driver.config.mjs";
42
40
  import { findGridLedgerViolations, findPlatformIdentityViolations } from "./common-law-receipts.mjs";
41
+ import { paths, readJson } from "./run-record.mjs";
43
42
 
44
43
  export const MAX_UNIT_ATTEMPTS = 3; // degraded-unit retries across resumes (repairable, never terminal)
45
44
  export const SERP_TERM_CAP = 12; // terms per grid — 12 × 7 cells = 84 paid calls, the hard ceiling
@@ -52,17 +51,13 @@ export const NATIVEREAD_GRID_ROWS_CAP = 60; // grid-findings rows inlined
52
51
  export const NATIVEREAD_SLICE_CAP = 12000; // chars of register-unit output inlined into the read payload
53
52
  const GAP_DEGRADE_FLOOR = 0.5; // >50% gapped cells ⇒ the grid attempt DEGRADES (the GRID_COVERAGE_FLOOR idiom)
54
53
 
55
- // — ONE reader for the fail-open lane switch, shared with the slice statement that describes
56
- // what this executor did. They disagreed; the statement lost, and it shipped.
57
- const laneEnvOn = (lane) => laneArmed(lane);
58
-
59
- const jxDir = (runDir) => driverDir(runDir, "jx");
54
+ const jxDir = (runDir) => paths(runDir).jx;
60
55
  const unitsPath = (runDir) => join(jxDir(runDir), "units.json");
61
56
  const atomic = (path, obj) => { writeFileSync(`${path}.tmp`, JSON.stringify(obj, null, 2) + "\n"); renameSync(`${path}.tmp`, path); };
62
57
 
63
58
  // ── Per-unit resume state (the jx.mjs fold state machine, per unit key like "serp-grid:zh") ─────────
64
59
  function readUnits(runDir) {
65
- try { return JSON.parse(readFileSync(unitsPath(runDir), "utf8")); } catch { return { schema: 1, units: {} }; }
60
+ try { return readJson(unitsPath(runDir)); } catch { return { schema: 1, units: {} }; }
66
61
  }
67
62
  function writeUnit(runDir, key, record) {
68
63
  mkdirSync(jxDir(runDir), { recursive: true });
@@ -141,7 +136,7 @@ function foldRetryable(ctx, lane) {
141
136
  // …and so does what the turn said about the model: the id it reported, or that it ran and named none —
142
137
  // see jxModelFields in jx-lanes.mjs.
143
138
  function ledgerRow(runDir, row) {
144
- try { appendFileSync(driverDir(runDir, "jx-completions.jsonl"), JSON.stringify(row) + "\n"); } catch { /* receipts best-effort */ }
139
+ try { appendFileSync(paths(runDir).jxCompletions, JSON.stringify(row) + "\n"); } catch { /* receipts best-effort */ }
145
140
  }
146
141
 
147
142
  const runPrefix = (run) => `clearance-${run?.slug ?? "run"}-${run?.codename ?? "local"}-`;
@@ -160,7 +155,7 @@ export function resolveSerpExecutor(opts, { mark, lane }) {
160
155
  exec: async ({ term, platform }) => {
161
156
  try {
162
157
  if (!table) {
163
- const parsed = JSON.parse(readFileSync(join(fixDir, `${kebab(mark)}.${lane}.serp.json`), "utf8"));
158
+ const parsed = readJson(join(fixDir, `${kebab(mark)}.${lane}.serp.json`));
164
159
  table = {};
165
160
  for (const c of parsed?.cells ?? []) table[`${canonicalTerm(c.term)}|${c.platform}`] = Array.isArray(c.hits) ? c.hits : [];
166
161
  dflt = Array.isArray(parsed?.default?.hits) ? parsed.default.hits : undefined;
@@ -175,7 +170,7 @@ export function resolveSerpExecutor(opts, { mark, lane }) {
175
170
  return { source: "serpapi", exec: (args) => SERP_PROVIDERS.serpapi.search(args) };
176
171
  }
177
172
 
178
- export function resolveJudge(opts, { mark, lane }) {
173
+ export function resolveJudge(opts, { mark, lane, runDir = null }) {
179
174
  if (typeof opts?.jxJudge === "function") return { exec: opts.jxJudge, source: "injected" };
180
175
  const fixDir = process.env.CLEAROTRON_JX_FIXTURES;
181
176
  if (fixDir) {
@@ -183,17 +178,17 @@ export function resolveJudge(opts, { mark, lane }) {
183
178
  source: `fixtures:${fixDir}`,
184
179
  exec: async ({ hits }) => {
185
180
  try {
186
- const parsed = JSON.parse(readFileSync(join(fixDir, `${kebab(mark)}.${lane}.judge.json`), "utf8"));
181
+ const parsed = readJson(join(fixDir, `${kebab(mark)}.${lane}.judge.json`));
187
182
  const byId = new Map((parsed?.judgments ?? []).map((j) => [j.id, j]));
188
183
  return { ok: true, judgments: hits.map((h) => byId.get(h.id)).filter(Boolean), tookMs: 0 };
189
184
  } catch (e) { return { ok: false, cause: `judge fixture missing/corrupt: ${abbrev(String(e.message), 120)}` }; }
190
185
  },
191
186
  };
192
187
  }
193
- return { source: "engine", exec: (args) => JX_PROVIDERS.judge.judge(args) };
188
+ return { source: "engine", exec: (args) => JX_PROVIDERS.judge.judge({ ...args, runDir }) };
194
189
  }
195
190
 
196
- export function resolveNativeread(opts, { mark, lane }) {
191
+ export function resolveNativeread(opts, { mark, lane, runDir = null }) {
197
192
  if (typeof opts?.nativereadExecutor === "function") return { exec: opts.nativereadExecutor, source: "injected" };
198
193
  const fixDir = process.env.CLEAROTRON_JX_FIXTURES;
199
194
  if (fixDir) {
@@ -201,13 +196,13 @@ export function resolveNativeread(opts, { mark, lane }) {
201
196
  source: `fixtures:${fixDir}`,
202
197
  exec: async () => {
203
198
  try {
204
- const parsed = JSON.parse(readFileSync(join(fixDir, `${kebab(mark)}.${lane}.read.json`), "utf8"));
199
+ const parsed = readJson(join(fixDir, `${kebab(mark)}.${lane}.read.json`));
205
200
  return { ok: true, items: Array.isArray(parsed?.items) ? parsed.items : [], tookMs: 0 };
206
201
  } catch (e) { return { ok: false, cause: `nativeread fixture missing/corrupt: ${abbrev(String(e.message), 120)}` }; }
207
202
  },
208
203
  };
209
204
  }
210
- return { source: "engine", exec: (args) => JX_PROVIDERS.nativeread.read(args) };
205
+ return { source: "engine", exec: (args) => JX_PROVIDERS.nativeread.read({ ...args, runDir }) };
211
206
  }
212
207
 
213
208
  // Bounded local pool (runBatched is pipeline-local; 10 lines beat an export churn).
@@ -227,9 +222,8 @@ export async function runJxSerpGrid(ctx, job, opts = {}, { runLog = () => {}, no
227
222
  try {
228
223
  // item 8 — CLEAROTRON_JX_SERP_GRID is gone. It was a default-OFF arm on a unit that has run in
229
224
  // production since 2026-08-04, so it hid a live path behind a switch nobody outside this box could
230
- // find. What remains are the conditions a run DISCLOSES: the lane not killed, a frozen lane
231
- // decision, a SERP capability entry. Each already returns a cause that reaches the slice statement.
232
- if (!laneEnvOn(lane)) return { ran: false, cause: `CLEAROTRON_NATIVE_LANGUAGE_${lane.toUpperCase()} off` };
225
+ // find. What remains are the conditions a run DISCLOSES: a frozen lane decision and a SERP capability
226
+ // entry. Each already returns a cause that reaches the slice statement.
233
227
  const laneDecision = ctx.jxLanes?.lanes?.[lane];
234
228
  if (!laneDecision) return { ran: false, cause: "no frozen zh lane decision (jurisdictions/policy)" };
235
229
  const serpSpec = SERP_LANES[lane];
@@ -244,7 +238,7 @@ export async function runJxSerpGrid(ctx, job, opts = {}, { runLog = () => {}, no
244
238
  // Dictation — frozen on first write (a resume re-USES the spec; re-dictating after a variant regen
245
239
  // would re-key the join and re-bill settled cells).
246
240
  let spec = null;
247
- try { spec = JSON.parse(readFileSync(specPath, "utf8")); } catch { /* cold — dictate below */ }
241
+ try { spec = readJson(specPath); } catch { /* cold — dictate below */ }
248
242
  if (!spec && foldRetryable(ctx, lane))
249
243
  return { ran: false, cause: "slice-1 fold degraded but retryable — deferring grid dictation to a resume (the candidates are the lane's point; no attempt burned)" };
250
244
  if (!spec) {
@@ -383,7 +377,7 @@ export async function runJxSerpGrid(ctx, job, opts = {}, { runLog = () => {}, no
383
377
  });
384
378
 
385
379
  // The judge — classification only, chunked, degrade-to-unjudged (the grid + receipts stand).
386
- const { exec: judgeExec, source: judgeSource } = resolveJudge(opts, { mark: markName, lane });
380
+ const { exec: judgeExec, source: judgeSource } = resolveJudge(opts, { mark: markName, lane, runDir: run.runDir });
387
381
  const judged = [];
388
382
  let judgeDegraded = null;
389
383
  for (let at = 0; at < judgeable.length && !judgeDegraded; at += 40) {
@@ -438,6 +432,12 @@ export async function runJxSerpGrid(ctx, job, opts = {}, { runLog = () => {}, no
438
432
  const URI_RE = /https?:\/\/[^\s|)\]"'<>]+/g;
439
433
  const normUri = (u) => String(u).replace(/[.,;:!?]+$/, "");
440
434
 
435
+ // The rows the cap keeps. The grid is in cell order, which says nothing about relevance, so use a reader could flag sat
436
+ // past the cap on most saved runs (measured in testing, 2026-11-09). The judge's own classes come first, then anything
437
+ // it could not judge, then the rest; within a class the grid's order stands.
438
+ const GRID_ROW_RANK = new Map([["use-evidence", 0], ["listing-candidate", 1], ["unjudged", 2]]);
439
+ const gridRowRank = (f) => GRID_ROW_RANK.get(f?.classification) ?? 3;
440
+
441
441
  /** Assemble the code-inlined zh evidence slice + the fetched-URI set it carries (pure over inputs). */
442
442
  export function buildNativereadPayload({ registerSliceText = "", candidates = [], cnipaSubgroups = [], gridFindings = [] }) {
443
443
  const sections = [];
@@ -452,7 +452,7 @@ export function buildNativereadPayload({ registerSliceText = "", candidates = []
452
452
  }
453
453
  let gridRowsDropped = 0;
454
454
  if (gridFindings.length) {
455
- const rows = gridFindings.slice(0, NATIVEREAD_GRID_ROWS_CAP);
455
+ const rows = [...gridFindings].sort((a, b) => gridRowRank(a) - gridRowRank(b)).slice(0, NATIVEREAD_GRID_ROWS_CAP);
456
456
  gridRowsDropped = gridFindings.length - rows.length;
457
457
  sections.push("## Platform grid findings (judged)\n"
458
458
  + rows.map((f) => `- [${f.classification}] "${f.title}" — ${f.url} (term ${f.term} on ${f.platform})${f.note ? ` — ${f.note}` : ""}`).join("\n")
@@ -488,7 +488,6 @@ export async function runJxNativeread(ctx, job, opts = {}, { runLog = () => {},
488
488
  const key = `nativeread:${lane}`;
489
489
  try {
490
490
  // item 8 — CLEAROTRON_JX_NATIVEREAD is gone, same reasoning as the grid above.
491
- if (!laneEnvOn(lane)) return { ran: false, cause: `CLEAROTRON_NATIVE_LANGUAGE_${lane.toUpperCase()} off` };
492
491
  if (!ctx.jxLanes?.lanes?.[lane]) return { ran: false, cause: "no frozen zh lane decision (jurisdictions/policy)" };
493
492
  const st = unitState(run.runDir, key);
494
493
  if (st.skip) return { ran: false, cause: st.cause };
@@ -514,12 +513,12 @@ export async function runJxNativeread(ctx, job, opts = {}, { runLog = () => {},
514
513
  try { registerSliceText = readFileSync(join(run.runDir, "register-units", "transliteration-numeric.md"), "utf8"); } catch { /* unit may not exist */ }
515
514
  const fold = ctx.jxLanes?.fold?.lanes?.[lane] ?? {};
516
515
  let gridFindings = [];
517
- try { gridFindings = JSON.parse(readFileSync(join(jxDir(run.runDir), `${lane}-grid-findings.json`), "utf8"))?.findings ?? []; } catch { /* grid unit may be off */ }
516
+ try { gridFindings = readJson(join(jxDir(run.runDir), `${lane}-grid-findings.json`))?.findings ?? []; } catch { /* grid unit may be off */ }
518
517
  const { payload, uris, sections, gridRowsDropped } = buildNativereadPayload({
519
518
  registerSliceText, candidates: fold.accepted ?? [], cnipaSubgroups: fold.cnipaSubgroups ?? [], gridFindings });
520
519
  if (!sections) return { ran: false, cause: "no zh evidence to read (no register slice, candidates or grid findings)" };
521
520
 
522
- const { exec, source } = resolveNativeread(opts, { mark: markName, lane });
521
+ const { exec, source } = resolveNativeread(opts, { mark: markName, lane, runDir: run.runDir });
523
522
  const started = Date.now();
524
523
  let r;
525
524
  try { r = await exec({ mark: markName, lane, payload }); }
@@ -573,15 +572,10 @@ export async function runJxNativeread(ctx, job, opts = {}, { runLog = () => {},
573
572
  * production since 2026-08-04, which is the definition of a dark switch: the shipped default described
574
573
  * a configuration nobody ran.
575
574
  *
576
- * `laneEnvOn("zh")` STAYS, and deleting it would have been the mistake. The CLEAROTRON_JX_LANES master leg
577
- * was retired 2026-07-27 and the reason this leg was kept still holds: an incident kill must also
578
- * silence a STALE artifact from an earlier run, not merely stop the next one. That is a switch someone
579
- * WOULD use, once, in an incident — the opposite of a dark one — so item 12's remedy applies instead of
580
- * item 8's: it is DECLARED rather than deleted. */
575
+ * The per-language off switch that once silenced this too is retired (2026-11-11): no deployment set it. */
581
576
  export function jxAimForSynthesis(runDir) {
582
- if (!laneEnvOn("zh")) return null;
583
577
  try {
584
- const a = JSON.parse(readFileSync(join(jxDir(runDir), "aim-attention.json"), "utf8"));
578
+ const a = readJson(join(jxDir(runDir), "aim-attention.json"));
585
579
  const n = (a?.items ?? []).length;
586
580
  return n ? { count: n } : null;
587
581
  } catch { return null; }
package/driver/jx.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
3
3
  // jx.mjs — the Stage-1.5 jx orchestration (Phase 2b slice 1): the frozen lane decision, the
4
4
  // candidate-generation executor chain, and the register-plan fold. Called from ONE never-kill block
5
- // in pipelineInner (after attachRegisterPlan, before decideAxes) — everything here degrades and
5
+ // in the intake step (`steps/intake.mjs`, after attachRegisterPlan, before decideAxes) — everything here degrades and
6
6
  // logs; only the pipeline's own plan-write is load-bearing.
7
7
  //
8
8
  // The fold contract (the pattern the recall probes used until the recall store was removed):
@@ -14,7 +14,6 @@
14
14
  // zero new wiring. What they carry is the ROMANISATION, not the characters — see jxPlanEntries.
15
15
  import { readFileSync, writeFileSync, renameSync, appendFileSync } from "node:fs";
16
16
  import { join } from "node:path";
17
- import { driverDir } from "../shared/driver-dir.mjs"; //
18
17
  import { decideJxLanes, candidateRefusal, canonicalTerm, romanizationSpellings, LANGUAGE_LANES, jxBillingStamp, jxModelFields } from "./jx-lanes.mjs";
19
18
  import { cnipaSubgroupsForClasses, cnipaEditionLabel } from "./jx-subclass.mjs"; // — replaces the hand-written seed table
20
19
  import { kebab } from "./search-policy.mjs";
@@ -70,70 +69,53 @@ export const jxFoldLaneRecord = ({ cause = null, ...rest } = {}) => ({
70
69
  // FIVE STATES, NOT THREE, AND THE TWO EXTRA ONES ARE THE HONEST ONES.
71
70
  // ran a durable record says it completed (units[k].done === true / lane not degraded)
72
71
  // gapped a durable record says it degraded (carries degradedCause and attempts)
73
- // not-armed the env switch that gates it is off
74
72
  // refused armed, no durable record, and a captured cause says why it declined structurally
75
73
  // not-established none of the above settles it — an absence, stated as one, never defaulted to a pass
76
74
  //
77
- // `refused` has to stay distinct from `not-armed` or the record lies about the switch: pipeline.mjs
78
- // gated the nativeread block on one arm while the unit refused on another, so a skip event could exist
79
- // for a slice that was never armed. item 8 deleted every one of those arms and the divergence with
80
- // them. Arming is still read from the ENV — CLEAROTRON_NATIVE_LANGUAGE_<code>, the one switch that survives — never from
81
- // the presence of an event; the event supplies the `why` and nothing else.
75
+ // No switch arms or silences a lane. The per-language off switch was the last one, and it is retired
76
+ // (2026-11-11): a lane in the frozen lane decision runs, and what it did is read from durable state; an
77
+ // event supplies the `why` and nothing else.
82
78
  export const JX_SLICES = [
83
79
  { name: "candidates", slice: 1, unit: null },
84
80
  { name: "serp-grid", slice: 2, unit: "serp-grid:zh", lane: "zh" },
85
81
  { name: "nativeread", slice: 3, unit: "nativeread:zh", lane: "zh" },
86
82
  ];
87
83
 
88
- import { laneArmed } from "./driver.config.mjs";
84
+ import { driverDir, paths, readJson } from "./run-record.mjs";
89
85
 
90
86
  /**
91
87
  * Derive the run's slice statement from durable state. PURE — no clock, no fs; `sidecar` is the parsed
92
88
  * jx-lanes.json, `units` the parsed _driver/jx/units.json (or null), `causes` a {sliceName: string} map
93
89
  * of skip reasons lifted from run.jsonl for DECORATION only.
94
90
  */
95
- export function deriveJxSliceStatement({ sidecar, units = null, env = process.env, causes = {} } = {}) {
91
+ export function deriveJxSliceStatement({ sidecar, units = null, causes = {} } = {}) {
96
92
  const unitRows = (units && typeof units === "object" ? units.units : null) ?? {};
97
93
  const declaredLanes = Object.keys(sidecar?.lanes ?? {});
98
94
  const foldLanes = sidecar?.fold?.lanes ?? {};
99
95
  const slices = {};
100
96
  for (const s of JX_SLICES) {
101
97
  if (s.slice === 1) {
102
- // Slice 1 is the only multi-lane slice, so it rolls up — and it never overstates: EVERY armed lane
98
+ // Slice 1 is the only multi-lane slice, so it rolls up — and it never overstates: EVERY lane
103
99
  // must be present and healthy for "ran". One gapped lane makes the whole slice gapped.
104
100
  const lanes = {};
105
101
  for (const l of declaredLanes) {
106
- // — laneArmed, NOT envOn: envOn is the default-OFF opt-in reader, and reading a
107
- // fail-open lane switch through it made every unset lane read "not-armed" on a run where
108
- // the executor had armed it and dispatched.
109
- if (!laneArmed(l, env)) { lanes[l] = "not-armed"; continue; }
110
102
  const rec = foldLanes[l];
111
103
  lanes[l] = rec == null ? "not-established" : rec.degraded === true ? "gapped" : "ran";
112
104
  }
113
- const live = Object.values(lanes).filter((v) => v !== "not-armed");
105
+ const live = Object.values(lanes);
114
106
  const state = !declaredLanes.length ? "not-established"
115
- : !live.length ? "not-armed"
116
107
  : live.includes("not-established") ? "not-established"
117
108
  : live.includes("gapped") ? "gapped" : "ran";
118
109
  const gapped = Object.entries(lanes).filter(([, v]) => v === "gapped").map(([l]) => l);
119
110
  slices[s.name] = { slice: 1, state, lanes, basis: "_driver/jx-lanes.json:fold.lanes",
120
- why: state === "ran" ? `every armed lane (${live.length}) carries a fold record stating degraded:false`
121
- : state === "not-armed" ? "no lane is armed in this run's own environment"
111
+ why: state === "ran" ? `every lane (${live.length}) carries a fold record stating degraded:false`
122
112
  : state === "gapped" ? `lane(s) ${gapped.join(", ")} degraded — see fold.lanes[].degradedCause`
123
- : "an armed lane carries no fold record at all — the receipt was never written" };
113
+ : "a lane carries no fold record at all — the receipt was never written" };
124
114
  continue;
125
115
  }
126
- // item 8 — the per-slice CLEAROTRON_JX_* arms are gone, so "armed" is now the ONE condition that
127
- // survives: the lane not killed. That warning still applies to how it is read — laneArmed is the
128
- // fail-open reader, and reading it through the old default-OFF `envOn` made every unset lane report
129
- // not-armed on a run that had dispatched.
130
- const armed = laneArmed(s.lane, env);
131
116
  const rec = unitRows[s.unit];
132
117
  const base = { slice: s.slice, lane: s.lane, unit: s.unit };
133
- if (!armed) {
134
- slices[s.name] = { ...base, state: "not-armed", basis: `env CLEAROTRON_NATIVE_LANGUAGE_${String(s.lane).toUpperCase()}`,
135
- why: `CLEAROTRON_NATIVE_LANGUAGE_${String(s.lane).toUpperCase()} off in this run's own environment when the statement was minted — the lane was killed, not merely idle` };
136
- } else if (rec && rec.degraded === true) {
118
+ if (rec && rec.degraded === true) {
137
119
  slices[s.name] = { ...base, state: "gapped", attempts: rec.attempts ?? null,
138
120
  basis: `_driver/jx/units.json:units["${s.unit}"]`, why: String(rec.degradedCause ?? "degraded, cause not recorded").slice(0, 300) };
139
121
  } else if (rec && rec.done === true) {
@@ -175,10 +157,10 @@ export function deriveJxSliceStatement({ sidecar, units = null, env = process.en
175
157
  //
176
158
  // The deep slices are zh-ONLY by construction: JX_SLICES pins `lane: "zh"` on both slice 2 and slice 3,
177
159
  // and SERP_LANES has a single row. So `laneDepth.ja = "full"` asks for something THIS BUILD DOES NOT
178
- // HAVE, which no environment can arm; `laneDepth.zh = "full"` on a box with CLEAROTRON_NATIVE_LANGUAGE_ZH off
179
- // asks for something the build has and the deployment did not turn on. Same printed shortfall, opposite
180
- // remedies — one is "buy/build the slice", the other is "arm the switch" — so they are separate causes
181
- // and never one token.
160
+ // HAVE, which no environment can arm; `laneDepth.zh = "full"` whose deep slices did not run asks for
161
+ // something the build has and the run did not deliver. Same printed shortfall, opposite remedies — one
162
+ // is "buy/build the slice", the other is "find out why it did not run" — so they are separate causes and
163
+ // never one token.
182
164
  //
183
165
  // ZERO IS NOT A PASS, in the shape this file already uses everywhere else: a lane whose slices settle to
184
166
  // nothing readable reports `ran: null` and the flag still fires. "Could not establish that full ran" is
@@ -215,9 +197,9 @@ export function deriveLaneDepthVerdicts({ sidecar, slices } = {}) {
215
197
  // that ran nothing is not established, whatever this build carries for it.
216
198
  if (!deep.length && ran === "candidates") {
217
199
  cause = "not-built-for-lane";
218
- why = `this build carries no deep slice for the ${lane} lane — the SERP grid and native read are zh-only `
219
- + `(JX_SLICES, SERP_LANES), so \`full\` cannot be delivered here by any environment. The lane ran as a `
220
- + `slice-1 candidate lane, which is what it ships as.`;
200
+ // THE CLIENT READS THIS UNDER "LEFT OPEN": the owner's sentence (2026-11-11), said only where the candidates ran.
201
+ why = `The requested full-depth ${languageOfLane(lane)}-language search is not available in this version. `
202
+ + `Only the candidate search ran; the deeper web search and native-language review were not performed.`;
221
203
  } else if (ran === null) {
222
204
  cause = "not-established";
223
205
  why = `${deep.length ? `the deep slice(s) ${deepStates.map((d) => `${d.name}=${d.state ?? "no record"}`).join(", ")} did not state that they ran, and ` : ""}`
@@ -225,8 +207,7 @@ export function deriveLaneDepthVerdicts({ sidecar, slices } = {}) {
225
207
  + `this run's own record. Not reported as candidates: that would be a claim no artifact supports.`;
226
208
  } else {
227
209
  cause = "requested-full-ran-candidates";
228
- why = `asked for full and ran candidates only — ${deepStates.map((d) => `${d.name} ${d.state ?? "no record"}`).join(", ")}`
229
- + `${deepStates.some((d) => d.state === "not-armed") ? " (an env arm is off on this deployment, not a fault in the run)" : ""}`;
210
+ why = `asked for full and ran candidates only — ${deepStates.map((d) => `${d.name} ${d.state ?? "no record"}`).join(", ")}`;
230
211
  }
231
212
  }
232
213
  out[lane] = { asked, ran, shortfall, cause, why,
@@ -250,19 +231,18 @@ export function deriveLaneDepthVerdicts({ sidecar, slices } = {}) {
250
231
  * @param {object|null} sidecar parsed _driver/jx-lanes.json
251
232
  * @param {object|null} units parsed _driver/jx/units.json, or null
252
233
  */
253
- export function laneDepthOfRun({ sidecar, units = null, env = process.env } = {}) {
234
+ export function laneDepthOfRun({ sidecar, units = null } = {}) {
254
235
  const stamped = sidecar?.fold?.depth;
255
236
  if (stamped && typeof stamped === "object" && !Array.isArray(stamped)) return stamped;
256
- return deriveLaneDepthVerdicts({ sidecar, slices: deriveJxSliceStatement({ sidecar, units, env }) });
237
+ return deriveLaneDepthVerdicts({ sidecar, slices: deriveJxSliceStatement({ sidecar, units }) });
257
238
  }
258
239
 
259
240
  const flag = (name) => ["1", "true", "yes", "on"].includes(String(process.env[name] ?? "").trim().toLowerCase());
260
- // — the private copy is gone; laneArmed (driver.config.mjs) is the one reader.
261
241
 
262
242
  // ── The frozen lane decision: minted once (cold), read verbatim forever (a resume NEVER re-decides —
263
243
  // the freezeProfile doctrine). Plain-clearotron runs never reach this (the caller gates on the component).
264
244
  export function attachJxLanes(ctx) {
265
- const sidecarPath = driverDir(ctx.run.runDir, "jx-lanes.json");
245
+ const sidecarPath = paths(ctx.run.runDir).jxLanes;
266
246
  let raw = null;
267
247
  try { raw = readFileSync(sidecarPath, "utf8"); } catch { /* ENOENT — cold start */ }
268
248
  if (raw != null) {
@@ -284,7 +264,7 @@ export function attachJxLanes(ctx) {
284
264
 
285
265
  // ── Executor chain (the knockout resolveSweepExecutor idiom): injected (tests) → CLEAROTRON_JX_FIXTURES
286
266
  // (the $0 dev seam: <mark-kebab>.<lane>.json {candidates:[…]}) → the live JX_PROVIDERS completions.
287
- export function resolveJxExecutor(opts) {
267
+ export function resolveJxExecutor(opts, { runDir = null } = {}) {
288
268
  if (typeof opts?.jxExecutor === "function") return { exec: opts.jxExecutor, source: "injected" };
289
269
  const fixDir = process.env.CLEAROTRON_JX_FIXTURES;
290
270
  if (fixDir) {
@@ -299,7 +279,7 @@ export function resolveJxExecutor(opts) {
299
279
  },
300
280
  };
301
281
  }
302
- return { source: "engine", exec: (args) => JX_PROVIDERS.completions.generate(args) };
282
+ return { source: "engine", exec: (args) => JX_PROVIDERS.completions.generate({ ...args, runDir }) };
303
283
  }
304
284
 
305
285
  /** Pure: candidates → validated plan entries for the lane. Refusals are RETURNED (the caller logs
@@ -354,7 +334,7 @@ export function jxPlanEntries({ lane, laneDecision, candidates, inScopeClasses,
354
334
  }
355
335
 
356
336
  /**
357
- * The whole slice, one never-kill call from pipelineInner. Requires ctx.registerPlan + the jxLanes
337
+ * The whole slice, one never-kill call from the intake step (`steps/intake.mjs`). Requires ctx.registerPlan + the jxLanes
358
338
  * component on the frozen policy (the caller checks the component; this checks env + lanes + resume
359
339
  * state). Returns { folded, cause? } for the pipeline's log line — it NEVER throws.
360
340
  */
@@ -365,15 +345,15 @@ export function jxPlanEntries({ lane, laneDecision, candidates, inScopeClasses,
365
345
  *
366
346
  * READS THE SIDECAR FROM DISK, never ctx.jxLanes — the same reason injectScriptScopeCoverage gives: at
367
347
  * delivery on a resume the fold block may never have re-attached it. Deriving from durable state alone
368
- * (units.json + the frozen sidecar + env) makes this a pure function of the disk, callable from any late
348
+ * (units.json + the frozen sidecar) makes this a pure function of the disk, callable from any late
369
349
  * point without having to prove every resume path traverses the jx blocks.
370
350
  *
371
351
  * NEVER re-derives `lanes` or `scope`: attachJxLanes freezes those and throws on a corrupt sidecar, so an
372
352
  * unreadable one here NOTES AND RETURNS WITHOUT WRITING rather than minting a second opinion.
373
353
  */
374
- export function stateJxSlices(runDir, { env = process.env, note = () => {}, runLog = () => {} } = {}) {
354
+ export function stateJxSlices(runDir, { note = () => {}, runLog = () => {} } = {}) {
375
355
  try {
376
- const sidecarPath = driverDir(runDir, "jx-lanes.json");
356
+ const sidecarPath = paths(runDir).jxLanes;
377
357
  // ABSENT AND UNPARSEABLE ARE NOT THE SAME FACT, and the first cut printed one sentence for both.
378
358
  // A run with no jx lane has no sidecar, and that is normal — saying "NOT writing one" there reads as
379
359
  // a withheld action. A sidecar that EXISTS and does not parse is a real defect in a driver-written
@@ -385,20 +365,20 @@ export function stateJxSlices(runDir, { env = process.env, note = () => {}, runL
385
365
  try { sidecar = JSON.parse(raw); }
386
366
  catch (e) { note(`jx slice statement: _driver/jx-lanes.json EXISTS and does not parse (${String(e?.message ?? e).slice(0, 80)}) — NOT writing one; the lane decision is frozen and is not this writer's to re-derive`); return { stated: false, reason: "unparseable" }; }
387
367
  let units = null;
388
- try { units = JSON.parse(readFileSync(driverDir(runDir, "jx", "units.json"), "utf8")); } catch { /* no retrieval slices ran — absence is read below, never as a pass */ }
368
+ try { units = readJson(driverDir(runDir, "jx", "units.json")); } catch { /* no retrieval slices ran — absence is read below, never as a pass */ }
389
369
  const causes = {};
390
370
  try {
391
- for (const line of readFileSync(driverDir(runDir, "run.jsonl"), "utf8").split("\n")) {
371
+ for (const line of readFileSync(paths(runDir).run, "utf8").split("\n")) {
392
372
  if (!line.includes("-skipped")) continue;
393
373
  let row; try { row = JSON.parse(line); } catch { continue; }
394
374
  if (row?.event === "jx-serp-grid-skipped" && row.cause) causes["serp-grid"] = row.cause;
395
375
  if (row?.event === "jx-nativeread-skipped" && row.cause) causes.nativeread = row.cause;
396
376
  }
397
377
  } catch { /* decoration only — a missing journal changes no STATE, only a `why` */ }
398
- const { executes, slices } = deriveJxSliceStatement({ sidecar, units, env, causes });
378
+ const { executes, slices } = deriveJxSliceStatement({ sidecar, units, causes });
399
379
  // — the per-lane ask-vs-got verdict, minted HERE and not at the scorer, for the reason the whole
400
- // seam exists: a reader that derives it on the fly can only speak for the box it is run on, and the
401
- // arms are environment. Stated at delivery, from this run's own env, it becomes a fact of the run.
380
+ // seam exists: a reader that derives it on the fly can only speak for the box it is run on. Stated at
381
+ // delivery, it becomes a fact of the run.
402
382
  const depth = deriveLaneDepthVerdicts({ sidecar, slices });
403
383
  // Idempotent: a delivered-then-resumed run leaves the artifact byte-identical rather than restamping.
404
384
  // `depth` JOINS the comparison rather than riding along: without it a run stamped before has a
@@ -427,14 +407,14 @@ export function stateJxSlices(runDir, { env = process.env, note = () => {}, runL
427
407
  export async function runJxCandidateFold(ctx, job, opts = {}, { runLog = () => {}, note = () => {}, inScopeClasses = [] } = {}) {
428
408
  const { run } = ctx;
429
409
  try {
430
- // (the CLEAROTRON_JX_LANES master leg was retired 2026-07-27 — the frozen lane decision below and the
431
- // per-lane CLEAROTRON_NATIVE_LANGUAGE_<code> switch are the controls; availability is settled before we get here)
410
+ // (the frozen lane decision below is the control: the CLEAROTRON_JX_LANES master leg was retired 2026-07-27 and the
411
+ // per-language off switch 2026-11-11; availability is settled before we get here)
432
412
  const { minted } = attachJxLanes(ctx);
433
413
  const lanes = ctx.jxLanes?.lanes ?? {};
434
- const laneKeys = Object.keys(lanes).filter((l) => LANGUAGE_LANES[l] && laneArmed(l)); // — the shared reader
414
+ const laneKeys = Object.keys(lanes).filter((l) => LANGUAGE_LANES[l]);
435
415
  if (!laneKeys.length) return { folded: 0, cause: minted ? "no lanes in scope (jurisdictions/policy)" : "frozen decision has no lanes" };
436
416
 
437
- const receiptPath = driverDir(run.runDir, "jx-lanes.json");
417
+ const receiptPath = paths(run.runDir).jxLanes;
438
418
  const prior = ctx.jxLanes;
439
419
  // an empty class scope can only fold entries parseRegisterPlan would REJECT on the next resume
440
420
  // (register_plan_classes_missing — the run bricks). Degrade the whole fold instead (review 2026-07-18).
@@ -496,8 +476,8 @@ export async function runJxCandidateFold(ctx, job, opts = {}, { runLog = () => {
496
476
  }
497
477
  const repairedFold = repairReceipt();
498
478
 
499
- const { exec, source } = resolveJxExecutor(opts);
500
- const ledgerPath = driverDir(run.runDir, "jx-completions.jsonl");
479
+ const { exec, source } = resolveJxExecutor(opts, { runDir: run.runDir });
480
+ const ledgerPath = paths(run.runDir).jxCompletions;
501
481
  const markName = job.markName ?? job.name;
502
482
  const productContext = String(job.goods ?? ctx.profile?.industry ?? "").slice(0, 300);
503
483
  // — spread the PRIOR fold FIRST. `executes`/`slices` are minted at delivery, after this
@@ -616,3 +596,8 @@ export async function runJxCandidateFold(ctx, job, opts = {}, { runLog = () => {
616
596
  return { folded: 0, cause: String(e?.message ?? e).slice(0, 200) };
617
597
  }
618
598
  }
599
+
600
+ /** A lane's language as a client reads it ("Japanese"), from the lane's own label ("Japanese-script deepening"). PURE. */
601
+ function languageOfLane(lane) {
602
+ return String(LANGUAGE_LANES[lane]?.label ?? "").replace(/-script deepening$/, "") || lane;
603
+ }
@@ -59,16 +59,16 @@
59
59
  // CHECK membership. Derive identity FROM the marks and the membership guard becomes the decision: a seat
60
60
  // that rates the wrong marks no longer fails a check — it writes to a different chunk file and passes.
61
61
  // That is the guard and the thing it guards collapsing into each other.
62
- import { existsSync, mkdirSync, writeFileSync, readFileSync } from "node:fs";
62
+ import { existsSync, writeFileSync, readFileSync } from "node:fs";
63
63
  import { captureCall, stampVerdict } from "./call-capture.mjs";
64
64
  import { join } from "node:path";
65
- import { driverDir } from "../shared/driver-dir.mjs";
66
65
  import { refuseUndeclared as refuseUndeclaredShared, keepIfAbsent, lastAccepted, acceptedEnvelope } from "./preserve-merge.mjs";
67
66
  // THE VALIDATOR'S OWN PREDICATE, imported rather than restated. Two spellings of one closed set is how
68
67
  // the call and the stage come to disagree about what is legal, which is the defect this check closes.
69
68
  import { normalizeKnockoutQualifier, KNOCKOUT_RATING_QUALIFIERS, heldCitationsOnly, classGroupsDefect, frozenLadder, validators } from "./verify-knockout.mjs";
70
69
  // A FINDING'S KEYS, likewise: the validator's one list, so a key the call records is a key the stage accepts.
71
70
  import { KNOCKOUT_FINDING_KEYS } from "./findings-model.mjs";
71
+ import { driverDir, readJson } from "./run-record.mjs";
72
72
 
73
73
  const SCHEMA_VERSION = 1;
74
74
 
@@ -423,7 +423,7 @@ const sourceDefectsPath = (runDir, chunkNo) => join(knockoutAssessCallPaths(Stri
423
423
  * correction. A row never leaves on its own account: the claim may survive a finding dropped or renamed, and only an accepted read settles it.
424
424
  */
425
425
  export function knockoutAssessSourceDefects(runDir, chunkNo) {
426
- try { return JSON.parse(readFileSync(sourceDefectsPath(runDir, chunkNo), "utf8")); } catch { return []; }
426
+ try { return readJson(sourceDefectsPath(runDir, chunkNo)); } catch { return []; }
427
427
  }
428
428
 
429
429
  // CODE DOES NOT JUDGE THE CLAIM. It reads whether the finding changed, and leaves whether that answers the problem to the check.
@@ -0,0 +1,21 @@
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
+ // knockout-caveats.mjs — the sentences a knockout's engine appends itself, and how to tell them from the rater's.
4
+ import { CAPABILITY_SKIPPED_NOTE } from "./search-policy.mjs";
5
+
6
+ export const SURVIVOR_BOUNDARY_RE = /not knocked out at this screen's depth/i;
7
+
8
+ /**
9
+ * Is this caveat the ENGINE'S OWN WORDS rather than the rater's?
10
+ *
11
+ * The engine appends two, both stated in code because the assessing model cannot see the facts behind
12
+ * them: the survivor boundary, and the capability-skipped note. Neither is something "the rater
13
+ * supplied", and telling them apart is the whole of — the standing-caveat lint asked
14
+ * "did the rater supply caveats?" of an array the engine had already written into, so from the moment
15
+ * the survivor sentence was appended the answer was always yes and the check could never fire again.
16
+ */
17
+ export function isEngineAppendedCaveat(text) {
18
+ const t = String(text ?? "");
19
+ if (SURVIVOR_BOUNDARY_RE.test(t)) return true;
20
+ return Object.values(CAPABILITY_SKIPPED_NOTE).some((note) => t.trim() === String(note).trim());
21
+ }