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
package/driver/verify.mjs CHANGED
@@ -9,7 +9,6 @@
9
9
 
10
10
  import { readFileSync, existsSync, readdirSync } from "node:fs";
11
11
  import { dirname, join, basename } from "node:path";
12
- import { driverDir } from "../shared/driver-dir.mjs"; //
13
12
  import { findReceiptViolations, findGridLedgerViolations, findUnranDictatedCells, findPlatformIdentityViolations, parsePrRiskQueries, MEANING_SEAT, erroredConnotationQueriesAmong } from "./common-law-receipts.mjs";
14
13
  // Conversion 2 — the discriminator the two rulings above key on. PURE-ish: one existsSync-shaped read.
15
14
  import { matterFrameWasRecorded, frameRatifiedForms } from "./matter-frame-record.mjs"; import { lastAcceptedOverview, acceptReportOverview, readReportIdentity } from "./report-overview-record.mjs";
@@ -43,6 +42,7 @@ import { parseBlindFrameModel } from "./blind-frame-model.mjs";
43
42
  import { parseFrameDiff } from "./frame-diff-model.mjs";
44
43
  import { parseVariantManifestModel, variantRomanizationGaps, variantCompletenessGaps, variantTermShapeGaps } from "./variant-manifest-model.mjs";
45
44
  import { digestAccountingGap } from "./register-digest-record.mjs";
45
+ import { driverDir, paths, readJson } from "./run-record.mjs";
46
46
 
47
47
  // ── WS-B: the run-scoped profile sidecar ────────────────────────────────────────────────────────────
48
48
  // _driver/profile.json carries the run's frozen customer values (floor, platform list) for these
@@ -53,9 +53,9 @@ import { digestAccountingGap } from "./register-digest-record.mjs";
53
53
  // a corrupt one is a code/filesystem bug that must surface loudly, never silently downgrade floors.
54
54
  function readRunProfile(p) {
55
55
  for (const dir of [dirname(p), dirname(dirname(p))]) {
56
- const f = driverDir(dir, "profile.json");
56
+ const f = paths(dir).profile;
57
57
  if (!existsSync(f)) continue;
58
- try { return { profile: JSON.parse(readFileSync(f, "utf8")), invalid: false }; }
58
+ try { return { profile: readJson(f), invalid: false }; }
59
59
  catch { return { profile: null, invalid: true }; }
60
60
  }
61
61
  return { profile: null, invalid: false };
@@ -69,7 +69,7 @@ function readRunProfile(p) {
69
69
  // corrupt one is a bug that must surface, never a silent downgrade to the wrong vocabulary).
70
70
  function readRunFramework(p) {
71
71
  for (const dir of [dirname(p), dirname(dirname(p))]) {
72
- const f = driverDir(dir, "framework.json");
72
+ const f = paths(dir).framework;
73
73
  if (!existsSync(f)) continue; let manifest;
74
74
  try { manifest = parseFrameworkManifest(readFileSync(f, "utf8")); } catch { return { manifest: null, invalid: true }; }
75
75
  const m = readFrozenMethod(driverDir(dir, FROZEN_METHOD_FILE), manifest); return { manifest, method: m.method, methodInvalid: m.invalid ?? null, invalid: false }; // + the frozen method beside it (framework-method.mjs): null when none, `methodInvalid` when it does not read back
@@ -89,10 +89,10 @@ function readRunFramework(p) {
89
89
  // batch closes; the plan-execution reads got the same split).
90
90
  function readGridSpec(p) {
91
91
  for (const dir of [dirname(p), dirname(dirname(p))]) {
92
- const f = driverDir(dir, "grid-spec.json");
92
+ const f = paths(dir).gridSpec;
93
93
  if (!existsSync(f)) continue;
94
94
  try {
95
- const spec = JSON.parse(readFileSync(f, "utf8"));
95
+ const spec = readJson(f);
96
96
  // — a spec is well-formed when it dictates SOME work, not when it dictates CELLS. The
97
97
  // meaning seat carries `terms: []` and the whole meaning sweep, and reading that as malformed
98
98
  // would fail the one seat whose entire dispatch is the meaning work.
@@ -118,7 +118,7 @@ function readGridSpecHalf(p, half) {
118
118
  const f = driverDir(dir, `grid-spec.half-${half}.json`);
119
119
  if (!existsSync(f)) continue;
120
120
  try {
121
- const spec = JSON.parse(readFileSync(f, "utf8"));
121
+ const spec = readJson(f);
122
122
  // — a spec is well-formed when it dictates SOME work, not when it dictates CELLS. The
123
123
  // meaning seat carries `terms: []` and the whole meaning sweep, and reading that as malformed
124
124
  // would fail the one seat whose entire dispatch is the meaning work.
@@ -891,6 +891,15 @@ export function parsePositions(line) {
891
891
  const ids = [...new Set(raw.split(",").map((s) => s.trim()).filter(Boolean))];
892
892
  return ids.length ? ids : null;
893
893
  }
894
+ // The other parts of the report a flag is about, by the address the dispatch's address list gave each
895
+ // (review-addresses.mjs). Absent ⇒ null: the flag declared none, and the render writes the token only then.
896
+ const CORRECTION_LINES_RE = /\[lines:\s*([^\]]*?)\s*\]/i;
897
+ export function parseLines(line) {
898
+ const raw = String(line ?? "").match(CORRECTION_LINES_RE)?.[1];
899
+ if (raw == null) return null;
900
+ const addresses = [...new Set(raw.split(",").map((s) => s.trim()).filter(Boolean))];
901
+ return addresses.length ? addresses : null;
902
+ }
894
903
  // ── — WHAT COUNTS AS A FLAG, AND WHY IT IS NOT "ANY BULLET" ──────────────────────────────────
895
904
  //
896
905
  // The old selector was `^(?:[-*•]|\d+[.)])\s+\S`, and it skipped EVERY typed correction the reviewer
@@ -1074,7 +1083,9 @@ export function parseCorrections(reviewMd) {
1074
1083
  // — the findings this flag declares itself to be about. null ⇒ undeclared ⇒ scopes to all.
1075
1084
  ordinals: parseOn(ln),
1076
1085
  ...(parsePositions(ln) ? { positions: parsePositions(ln) } : {}),
1077
- text: content.replace(CORRECTION_KIND_RE, "").replace(CORRECTION_ON_RE, "").replace(CORRECTION_POSITIONS_RE, "").replace(/\s{2,}/g, " ").trim(),
1086
+ ...(parseLines(ln) ? { lines: parseLines(ln) } : {}),
1087
+ text: content.replace(CORRECTION_KIND_RE, "").replace(CORRECTION_ON_RE, "").replace(CORRECTION_POSITIONS_RE, "").replace(CORRECTION_LINES_RE, "")
1088
+ .replace(/\s{2,}/g, " ").trim(),
1078
1089
  });
1079
1090
  }
1080
1091
  return rows;
@@ -1733,7 +1744,7 @@ export const validators = {
1733
1744
  // sentinel flipped real archived replay verdicts on 2026-07-31; that lesson is why this line exists.
1734
1745
  const recorded = matterFrameWasRecorded(dirname(String(p ?? "")));
1735
1746
  if (recorded) {
1736
- const scopeFile = driverDir(dirname(String(p ?? "")), "instructed-scope.json");
1747
+ const scopeFile = paths(dirname(String(p ?? ""))).instructedScope;
1737
1748
  if (existsSync(scopeFile)) {
1738
1749
  // The stamp is a fixed heading the renderer always emits when it has a record to stamp from. Its
1739
1750
  // ABSENCE against a present intake record means the render ran without the values — the one way
@@ -1750,14 +1761,14 @@ export const validators = {
1750
1761
  // unparseable fails closed with a name (stagecontracts_invalid) — the marker is DRIVER-written, so
1751
1762
  // a corrupt one is a code/fs bug, never a waiver (post-merge audit 2 (c), same handling as the
1752
1763
  // romanisation-floor read in variantManifest below).
1753
- const contractsMarker = driverDir(dirname(String(p ?? "")), "stage-contracts.json");
1764
+ const contractsMarker = paths(dirname(String(p ?? ""))).stageContracts;
1754
1765
  if (existsSync(contractsMarker)) {
1755
- try { meaningMinted = Boolean(JSON.parse(readFileSync(contractsMarker, "utf8"))?.["matter-frame"]?.meaningAngles); }
1766
+ try { meaningMinted = Boolean(readJson(contractsMarker)?.["matter-frame"]?.meaningAngles); }
1756
1767
  catch { return fail("stagecontracts_invalid"); }
1757
1768
  }
1758
1769
  if (meaningMinted && !MEANING_ANGLES_RE.test(c)) return fail("meaning_angles_missing");
1759
1770
  let scope = null;
1760
- try { scope = JSON.parse(readFileSync(driverDir(dirname(String(p ?? "")), "instructed-scope.json"), "utf8")); }
1771
+ try { scope = readJson(paths(dirname(String(p ?? ""))).instructedScope); }
1761
1772
  catch { return base; } // no receipt = legacy run — replay never flips
1762
1773
  const squash = (s) => String(s ?? "").replace(/\s+/g, " ").trim();
1763
1774
  const hay = squash(c);
@@ -1819,9 +1830,9 @@ export const validators = {
1819
1830
  // driver-written sidecars (readRunProfile / readRunFramework / readGridSpec) says it must surface
1820
1831
  // with a name. One catch over both reads would waive BOTH floors on exactly the runs they govern.
1821
1832
  let contract = null;
1822
- const marker = driverDir(dir, "stage-contracts.json");
1833
+ const marker = paths(dir).stageContracts;
1823
1834
  if (existsSync(marker)) {
1824
- try { contract = variantsStageContract(JSON.parse(readFileSync(marker, "utf8"))); } // either name: see variantsStageContract
1835
+ try { contract = variantsStageContract(readJson(marker)); } // either name: see variantsStageContract
1825
1836
  catch { return fail("stagecontracts_invalid"); }
1826
1837
  }
1827
1838
  if (!contract?.romanization && !contract?.completeness && !contract?.term_shape) return sib;
@@ -1844,7 +1855,7 @@ export const validators = {
1844
1855
  // (a legacy or replayed run) ⇒ no jurisdictions ⇒ the per-script arm cannot fire and the
1845
1856
  // category floor stands exactly as before, so archived verdicts do not flip.
1846
1857
  let jurisdictions = [];
1847
- try { jurisdictions = JSON.parse(readFileSync(driverDir(dir, "instructed-scope.json"), "utf8"))?.jurisdictions ?? []; }
1858
+ try { jurisdictions = readJson(paths(dir).instructedScope)?.jurisdictions ?? []; }
1848
1859
  catch { /* no frozen scope on this run — category floor only */ }
1849
1860
  const gaps = variantCompletenessGaps(model, { jurisdictions: Array.isArray(jurisdictions) ? jurisdictions : [jurisdictions] });
1850
1861
  if (gaps.length)
@@ -1864,7 +1875,7 @@ export const validators = {
1864
1875
  // D1 fail-closed (pre-existing, UNCHANGED): on a fresh run — the instructed-scope sentinel — the
1865
1876
  // structured sibling itself is REQUIRED; sentinel-era archives all carry the sibling, so this arm
1866
1877
  // never fires on replay.
1867
- if (existsSync(driverDir(dir, "instructed-scope.json"))) return fail("variantmodel_missing");
1878
+ if (existsSync(paths(dir).instructedScope)) return fail("variantmodel_missing");
1868
1879
  return base;
1869
1880
  },
1870
1881
  // Property 1 (frame-omission design): the stage's ONE output is the structured model the frame-diff
@@ -1905,9 +1916,9 @@ export const validators = {
1905
1916
  // sentinel proves a FRESH run — legacy/archived replays lack it, so replay verdicts never flip;
1906
1917
  // a plan-less resume (no run-dir register-plan.json) keeps the lenient path too.
1907
1918
  if (bandName.endsWith("-band.json") && !existsSync(join(dirname(String(p ?? "")), bandName))
1908
- && existsSync(driverDir(join(dirname(String(p ?? "")), ".."), "instructed-scope.json"))) {
1919
+ && existsSync(paths(join(dirname(String(p ?? "")), "..")).instructedScope)) {
1909
1920
  try {
1910
- const plan = JSON.parse(readFileSync(driverDir(join(dirname(String(p ?? "")), ".."), "register-plan.json"), "utf8"));
1921
+ const plan = readJson(paths(join(dirname(String(p ?? "")), "..")).registerPlan);
1911
1922
  const axis = basename(String(p ?? "")).replace(/\.md$/i, "");
1912
1923
  if ((plan?.entries ?? []).some((e) => e?.axis === axis)) {
1913
1924
  // — SAME EVIDENCE, TWO CAUSES, and this is where the wrong one used to be picked.
@@ -1949,10 +1960,10 @@ export const validators = {
1949
1960
  // replay verdicts and legacy resumes never flip; only runs whose plan was attached by new code
1950
1961
  // (exactly those receiving the new stage message + enumerate exclusion) are enforced.
1951
1962
  try {
1952
- const plan = JSON.parse(readFileSync(driverDir(join(dirname(String(p ?? "")), ".."), "register-plan.json"), "utf8"));
1963
+ const plan = readJson(paths(join(dirname(String(p ?? "")), "..")).registerPlan);
1953
1964
  const axis = basename(String(p ?? "")).replace(/\.md$/i, "");
1954
1965
  if (plan?.contract?.supplemental_lane && (plan.entries ?? []).some((e) => e?.axis === axis)) {
1955
- const blocks = JSON.parse(readFileSync(join(dirname(String(p ?? "")), bandName), "utf8"));
1966
+ const blocks = readJson(join(dirname(String(p ?? "")), bandName));
1956
1967
  const unplanned = (Array.isArray(blocks) ? blocks : []).filter((b) => b && typeof b === "object" && !b.qid);
1957
1968
  if (unplanned.length)
1958
1969
  return fail(`band_block_unplanned:${abbrev(unplanned.map((b) => abbrev(String(b.query ?? "un-labelled"), 40)).join(","), 140)}`);
@@ -2042,7 +2053,7 @@ export const validators = {
2042
2053
  if (sib) return sib.ok && placementAccountArmed(dir) ? placementAccountVerdict(dir) : sib; // placementAccount: see the block at the end of this file
2043
2054
  let structured = false;
2044
2055
  let formEra = false;
2045
- const marker = driverDir(dir, "stage-contracts.json");
2056
+ const marker = paths(dir).stageContracts;
2046
2057
  // ABSENT marker = not minted under the B2 prompt — pre-B2 rules apply (every archive). PRESENT but
2047
2058
  // unparseable is a different fact (post-merge audit 2 (c), the convention set for the
2048
2059
  // variantManifest twin above): the marker is DRIVER-written (pipeline.mjs recordStageContract), so a
@@ -2050,7 +2061,7 @@ export const validators = {
2050
2061
  // floor on exactly the runs the floor governs. Fail closed, with a name.
2051
2062
  if (existsSync(marker)) {
2052
2063
  try {
2053
- const m = JSON.parse(readFileSync(marker, "utf8"))?.["placement-inquiry"];
2064
+ const m = readJson(marker)?.["placement-inquiry"];
2054
2065
  structured = Boolean(m?.structuredPlacements);
2055
2066
  formEra = m?.placementForm === 1;
2056
2067
  } catch { return fail("stagecontracts_invalid"); }
@@ -2209,7 +2220,7 @@ export const validators = {
2209
2220
  // never carry it and replay verdicts never flip — off-enum shapes ("N/A", "confirmed", "✅",
2210
2221
  // "not-searched (immaterial by design)") sit in 27 of 64 corpus register-findings.md files,
2211
2222
  // including July-2026 runs, so an unkeyed gate would mass-flip the replay harness to NO-GO.
2212
- if (existsSync(driverDir(dirname(p), "coverage-enum.json"))) {
2223
+ if (existsSync(paths(dirname(p)).coverageEnum)) {
2213
2224
  const offEnum = parseCoverageLedgerFull(c).offEnum;
2214
2225
  if (offEnum.length)
2215
2226
  return fail(`coverage_status_offenum:${short(offEnum[0].status)} (axis ${offEnum[0].axis}${offEnum.length > 1 ? ` +${offEnum.length - 1} more` : ""} — the Status cell is EXACTLY one bare token of: ${COVERAGE_STATUSES.join(" / ")}; qualifiers move into reason)`);
@@ -2239,7 +2250,7 @@ export const validators = {
2239
2250
  // same tokens, byte-identical construction, because the replay corpus compares verdict STRINGS.
2240
2251
  // `unexecuted` and `skipped` never had a join, so findUnexecutedCleanClaims runs on BOTH paths.
2241
2252
  let planExecRaw = null;
2242
- try { planExecRaw = readFileSync(driverDir(dirname(p), "plan-execution.json"), "utf8"); } catch { /* no receipt — plan gate inactive (legacy/replay) */ }
2253
+ try { planExecRaw = readFileSync(paths(dirname(p)).planExecution, "utf8"); } catch { /* no receipt — plan gate inactive (legacy/replay) */ }
2243
2254
  if (planExecRaw != null) {
2244
2255
  let exec = null;
2245
2256
  try { exec = JSON.parse(planExecRaw); } catch { /* falls through to the shape fail below */ }
@@ -2264,11 +2275,11 @@ export const validators = {
2264
2275
  // truth). Sanctioned crowds (count-kind, single-term saturated) never fire — crowd = dilution
2265
2276
  // stays judgment's call. Needs the run-dir plan + bands; either unreadable ⇒ inactive.
2266
2277
  try {
2267
- const plan = parseRegisterPlan(readFileSync(driverDir(dirname(p), "register-plan.json"), "utf8"));
2278
+ const plan = parseRegisterPlan(readFileSync(paths(dirname(p)).registerPlan, "utf8"));
2268
2279
  const bands = {};
2269
2280
  for (const s of (exec.skeleton ?? [])) {
2270
2281
  try {
2271
- const parsed = JSON.parse(readFileSync(join(dirname(p), "register-units", `${s.axis}-band.json`), "utf8"));
2282
+ const parsed = readJson(join(dirname(p), "register-units", `${s.axis}-band.json`));
2272
2283
  bands[s.axis] = Array.isArray(parsed) ? parsed : (Array.isArray(parsed?.blocks) ? parsed.blocks : []);
2273
2284
  } catch { /* band unreadable — parse defects are the unit validator's */ }
2274
2285
  }
@@ -2403,7 +2414,7 @@ export const validators = {
2403
2414
  // Sidecar-gated (archived runs have no sidecar → never fires; replay-safe); the refutation stays
2404
2415
  // the semantic backstop — this is the deterministic floor.
2405
2416
  try {
2406
- const asksRaw = readFileSync(driverDir(dirname(p), "intake-asks.json"), "utf8");
2417
+ const asksRaw = readFileSync(paths(dirname(p)).intakeAsks, "utf8");
2407
2418
  const asks = JSON.parse(asksRaw);
2408
2419
  if (Array.isArray(asks) && asks.length) {
2409
2420
  const sec = String(c ?? "").match(/^##\s*Answers to your instructions\s*\n([\s\S]*?)(?=^#{1,2}\s|$(?![\s\S]))/im)?.[1] ?? "";
@@ -2455,7 +2466,7 @@ export const validators = {
2455
2466
  // names marketplace/platform coverage AND recommends a re-run/further search as a next step.
2456
2467
  const cv = findCoverageRecommendations(c);
2457
2468
  if (cv.length) {
2458
- const receipt = existsSync(driverDir(dirname(p), "coverage-closure.json"));
2469
+ const receipt = existsSync(paths(dirname(p)).coverageClosure);
2459
2470
  return fail(receipt
2460
2471
  ? `coverage_recommendation:${abbrev(cv[0], 100)}`
2461
2472
  : `coverage_gap_unexplained:${abbrev(cv[0], 100)}`);
@@ -2483,9 +2494,9 @@ export const validators = {
2483
2494
  if (!base.ok) return base;
2484
2495
  const dir = dirname(String(p ?? ""));
2485
2496
  let contract = null;
2486
- const marker = driverDir(dir, "stage-contracts.json");
2497
+ const marker = paths(dir).stageContracts;
2487
2498
  if (existsSync(marker)) {
2488
- try { contract = JSON.parse(readFileSync(marker, "utf8"))?.["case-law"] ?? null; }
2499
+ try { contract = readJson(marker)?.["case-law"] ?? null; }
2489
2500
  catch { return fail("stagecontracts_invalid"); }
2490
2501
  }
2491
2502
  if (!contract?.citations) return base;
@@ -2518,7 +2529,7 @@ export const validators = {
2518
2529
  // as the registerFindings read — a receipt PRESENT but corrupt fails loud instead of silently
2519
2530
  // waiving the audit requirement (the sidecar is driver-written; a corrupt one is a bug).
2520
2531
  let planExecRaw = null;
2521
- try { planExecRaw = readFileSync(driverDir(dirname(String(p ?? "")), "plan-execution.json"), "utf8"); } catch { /* no receipt — audit not required */ }
2532
+ try { planExecRaw = readFileSync(paths(dirname(String(p ?? ""))).planExecution, "utf8"); } catch { /* no receipt — audit not required */ }
2522
2533
  if (planExecRaw != null) {
2523
2534
  try { JSON.parse(planExecRaw); }
2524
2535
  catch { return fail("plan_execution_unreadable: _driver/plan-execution.json is corrupt (driver-written — this is a bug, not a model defect)"); }
@@ -2601,7 +2612,7 @@ function checkClientSummaryJoin(p, c) {
2601
2612
  const fw = v4 ? readRunFramework(p) : { manifest: null, invalid: false };
2602
2613
  if (v4 && fw.invalid) return fail("framework_manifest_unreadable: _driver/framework.json is corrupt");
2603
2614
  if (v4 && !fw.manifest) return fail("framework_manifest_missing_for_v4: cannot judge client band words without the frozen framework");
2604
- try { verdictDoc = JSON.parse(readFileSync(driverDir(dirname(p), "verdict.json"), "utf8")); } catch { /* optional */ }
2615
+ try { verdictDoc = readJson(paths(dirname(p)).verdict); } catch { /* optional */ }
2605
2616
  const blocks = [...String(c ?? "").matchAll(/^##\s+([^\n]+)\n([\s\S]*?)(?=^##\s|\s*$)/gm)];
2606
2617
  for (const [, head, body] of blocks) {
2607
2618
  const risk = body.match(/^-\s*risk:\s*([A-Za-z –-]+)$/m)?.[1]?.trim();
@@ -2628,7 +2639,7 @@ function checkClientSummaryJoin(p, c) {
2628
2639
  // report un-signable (VIBRANTE dropped on a group mislabel). Gated on the sidecar existing, which only
2629
2640
  // fresh runs write — archived runs and replay never flip. Failures ride the stage's corrective ladder.
2630
2641
  try {
2631
- const scope = JSON.parse(readFileSync(driverDir(dirname(p), "client-summary-scope.json"), "utf8"));
2642
+ const scope = readJson(paths(dirname(p)).clientSummaryScope);
2632
2643
  const blockOrds = new Set(blocks.map(([, , body]) => parseBlockOrd(body)).filter((o) => o != null));
2633
2644
  for (const s of scope?.rated ?? []) {
2634
2645
  if (!blockOrds.has(s.ord))
@@ -2676,7 +2687,7 @@ const short = (v) => String(v ?? "").replace(/\s+/g, " ").trim().slice(0, 40);
2676
2687
  // before this arm existed, and this must not change it.
2677
2688
  function placementAccountArmed(dir) {
2678
2689
  try {
2679
- return JSON.parse(readFileSync(driverDir(dir, "stage-contracts.json"), "utf8"))?.["placement-inquiry"]?.placementAccount === 1;
2690
+ return readJson(paths(dir).stageContracts)?.["placement-inquiry"]?.placementAccount === 1;
2680
2691
  } catch { return false; }
2681
2692
  }
2682
2693
  function placementAccountVerdict(dir) {
@@ -2740,14 +2751,14 @@ function placementAccountVerdict(dir) {
2740
2751
  // ARMED ON ITS OWN STAMP KEY (`placementSaidBack: 1`), so an archived run replays to the verdict it was minted under.
2741
2752
  function placementSaidBackArmed(dir) {
2742
2753
  try {
2743
- return JSON.parse(readFileSync(driverDir(dir, "stage-contracts.json"), "utf8"))?.["placement-inquiry"]?.placementSaidBack === 1;
2754
+ return readJson(paths(dir).stageContracts)?.["placement-inquiry"]?.placementSaidBack === 1;
2744
2755
  } catch { return false; }
2745
2756
  }
2746
2757
  const capped = (items) => `${items.slice(0, 8).join("; ")}${items.length > 8 ? "; …" : ""}`;
2747
2758
  /** The band's floors. A shape that cannot be read holds none, and the rule reads as before. */
2748
2759
  function shapeFloors(dir) {
2749
2760
  try {
2750
- const floors = JSON.parse(readFileSync(driverDir(dir, "band-shape.json"), "utf8"))?.floors?.in_class_identical_or_near;
2761
+ const floors = readJson(paths(dir).bandShape)?.floors?.in_class_identical_or_near;
2751
2762
  return Array.isArray(floors) ? floors : [];
2752
2763
  } catch { return []; }
2753
2764
  }
@@ -22,9 +22,8 @@
22
22
  //
23
23
  // What the frame set aside goes to the audit workbook with its reason, beside the withheld searches, and
24
24
  // never to the report.
25
- import { readFileSync } from "node:fs";
26
- import { driverDir } from "../shared/driver-dir.mjs";
27
25
  import { lastAcceptedMatterFrame } from "./matter-frame-record.mjs";
26
+ import { paths, readJson } from "./run-record.mjs";
28
27
 
29
28
  const str = (v) => String(v ?? "").trim();
30
29
  const key = (v) => str(v).toLowerCase();
@@ -58,7 +57,7 @@ export function frameWebChoiceFor(runDir) {
58
57
  * that was never asked, and only the second may keep the old full grid.
59
58
  */
60
59
  export function frameAskedForWebGrid(runDir) {
61
- try { return Boolean(JSON.parse(readFileSync(driverDir(runDir, "stage-contracts.json"), "utf8"))?.["matter-frame"]?.webGrid); }
60
+ try { return Boolean(readJson(paths(runDir).stageContracts)?.["matter-frame"]?.webGrid); }
62
61
  catch { return false; }
63
62
  }
64
63
 
@@ -142,7 +141,7 @@ export function closureBlocksOf(cells) {
142
141
  */
143
142
  export function frameSetAsideRows(runDir) {
144
143
  try {
145
- const spec = JSON.parse(readFileSync(driverDir(runDir, "grid-spec.json"), "utf8"));
144
+ const spec = readJson(paths(runDir).gridSpec);
146
145
  return (Array.isArray(spec?.set_aside) ? spec.set_aside : [])
147
146
  .filter((x) => str(x?.store) && str(x?.reason))
148
147
  .map((x) => ({ area: str(x.store), state: "not-searched", note: str(x.reason), done: "", left: str(x.reason) }));
@@ -31,8 +31,8 @@ import { createHash } from "node:crypto";
31
31
  import { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync, renameSync, statSync } from "node:fs";
32
32
  import { join, dirname } from "node:path";
33
33
  import { fileURLToPath } from "node:url";
34
- import { driverDir, DRIVER_DIR } from "../shared/driver-dir.mjs"; // the subtree name from its one definition, never a literal
35
34
  import { composeMemo } from "./whatif-memo.mjs";
35
+ import { DRIVER_DIR, paths as runPaths } from "./run-record.mjs"; // the subtree name from its one definition, never a literal
36
36
 
37
37
  export const SKILL_ROOT = join(dirname(fileURLToPath(import.meta.url)), "skills");
38
38
 
@@ -124,7 +124,7 @@ export function splitMemoFootprint(moved = []) {
124
124
 
125
125
  /** The profile key the PARENT rated under — read from its frozen sidecar, never re-resolved. */
126
126
  export function parentRatedUnder(runDir, { read = readFileSync } = {}) {
127
- try { return JSON.parse(read(driverDir(runDir, "profile.json"), "utf8"))?.profileKey ?? null; }
127
+ try { return JSON.parse(read(runPaths(runDir).profile, "utf8"))?.profileKey ?? null; }
128
128
  catch { return null; }
129
129
  }
130
130
 
@@ -44,9 +44,10 @@
44
44
  // re-running a CLEARANCE twice costs a second billable search and a second report to a lawyer. The
45
45
  // cheaper failure buys a much simpler protocol, and the asymmetry is the whole reason to state it.
46
46
 
47
- import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
47
+ import { existsSync, mkdirSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
48
48
  import { join } from "node:path";
49
49
  import { randomUUID } from "node:crypto";
50
+ import { readJson } from "./run-record.mjs";
50
51
 
51
52
  // ── WHICH RUNS A WHAT-IF MAY TOUCH — ONE DECLARATION, TWO READERS ───────────────────────────────────
52
53
  //
@@ -186,7 +187,7 @@ export function claimWhatIf(entry) {
186
187
  if (!entry.stale) {
187
188
  try { renameSync(entry.path, target); } catch { return null; }
188
189
  }
189
- try { return { ...JSON.parse(readFileSync(target, "utf8")), _path: target }; }
190
+ try { return { ...readJson(target), _path: target }; }
190
191
  catch (e) {
191
192
  try { writeFileSync(pathFor(entry.runDir, entry.id, "failed"), JSON.stringify({ id: entry.id, state: "failed", error: `unreadable manifest: ${e.message}` }, null, 2)); } catch { /* best-effort */ }
192
193
  return null;
@@ -222,7 +223,7 @@ export function readWhatIf(runDir, id) {
222
223
  const p = pathFor(runDir, id, suffix);
223
224
  if (!existsSync(p)) continue;
224
225
  let body = null;
225
- try { body = JSON.parse(readFileSync(p, "utf8")); } catch { /* a mid-write terminal reads as its state with no body */ }
226
+ try { body = readJson(p); } catch { /* a mid-write terminal reads as its state with no body */ }
226
227
  return { id, state, ...(body ?? {}) };
227
228
  }
228
229
  return { id, state: "unknown", note: "no what-if with that id on this run" };
@@ -14,12 +14,12 @@
14
14
  //
15
15
  // One file per axis, because the reading turn fans out one seat per axis and two seats writing one file
16
16
  // would lose each other's calls. The axis is bound by the server, never taken from the payload.
17
- import { readFileSync, writeFileSync, renameSync, existsSync, readdirSync, mkdirSync } from "node:fs";
17
+ import { writeFileSync, renameSync, readdirSync, mkdirSync } from "node:fs";
18
18
  import { dirname, join } from "node:path";
19
- import { driverDir } from "../shared/driver-dir.mjs";
20
19
  import { awaitsReadingTurn, releasedFamiliesFile } from "../providers/_shared/plan-guards.mjs";
21
20
  import { entryQuestionKey } from "./register-plan.mjs";
22
21
  import { seatBannedTokens } from "./coverage-form.mjs";
22
+ import { driverDir, paths, readJsonOrNull } from "./run-record.mjs";
23
23
 
24
24
  export const WITHHELD_REASON_MAX = 600;
25
25
  const FILE_RE = /^withheld-families-(.+)\.json$/;
@@ -30,7 +30,6 @@ export const withheldFamiliesPath = (runDir, axis) => driverDir(runDir, `withhel
30
30
  export const releasedFamiliesPath = (runDir, axis) => driverDir(runDir, releasedFamiliesFile(axis));
31
31
  const RELEASED_RE = /^released-families-(.+)\.json$/;
32
32
 
33
- const readJson = (p) => { try { return existsSync(p) ? JSON.parse(readFileSync(p, "utf8")) : null; } catch { return null; } };
34
33
 
35
34
  /** Every axis's record, merged: `{ [qid]: { axis, reason } }`. An unreadable file contributes nothing. */
36
35
  export function readWithheldFamilies(runDir) {
@@ -40,7 +39,7 @@ export function readWithheldFamilies(runDir) {
40
39
  for (const name of names) {
41
40
  const m = FILE_RE.exec(name);
42
41
  if (!m) continue;
43
- const doc = readJson(driverDir(runDir, name));
42
+ const doc = readJsonOrNull(driverDir(runDir, name));
44
43
  for (const [qid, v] of Object.entries(doc?.families ?? {})) {
45
44
  const reason = String(v?.reason ?? "").trim();
46
45
  if (qid && reason) out[qid] = { axis: String(doc?.axis ?? m[1]), reason };
@@ -57,7 +56,7 @@ export function readReleasedFamilies(runDir) {
57
56
  for (const name of names) {
58
57
  const m = RELEASED_RE.exec(name);
59
58
  if (!m) continue;
60
- const doc = readJson(driverDir(runDir, name));
59
+ const doc = readJsonOrNull(driverDir(runDir, name));
61
60
  for (const [qid, v] of Object.entries(doc?.families ?? {})) {
62
61
  const reason = String(v?.reason ?? "").trim();
63
62
  if (qid && reason) out[qid] = { axis: String(doc?.axis ?? m[1]), reason };
@@ -111,15 +110,15 @@ export function waitingFamiliesOn(plan, axis, supplementals = [], released = new
111
110
  * what it refused, and never throws.
112
111
  */
113
112
  export function recordWithheldFamilies(runDir, { axis, families } = {}) {
114
- const plan = readJson(driverDir(runDir, "register-plan.json"));
113
+ const plan = readJsonOrNull(paths(runDir).registerPlan);
115
114
  if (!plan || !Array.isArray(plan.entries)) return { refused: "no frozen register plan in this run — there are no waiting families to record against" };
116
115
  if (!Array.isArray(families) || !families.length) return { refused: "families must list at least one { qids, reason }" };
117
- const supp = readJson(join(runDir, "register-units", `${axis}-supplemental-plan.json`));
118
- const released = new Set(Object.keys(readJson(releasedFamiliesPath(runDir, axis))?.families ?? {}));
116
+ const supp = readJsonOrNull(join(runDir, "register-units", `${axis}-supplemental-plan.json`));
117
+ const released = new Set(Object.keys(readJsonOrNull(releasedFamiliesPath(runDir, axis))?.families ?? {}));
119
118
  const { waiting, unasked } = waitingFamiliesOn(plan, axis, Array.isArray(supp?.entries) ? supp.entries : [], released);
120
119
  const waitingQids = new Set(waiting.map((e) => e.qid));
121
120
  const path = withheldFamiliesPath(runDir, axis);
122
- const doc = readJson(path) ?? { axis, families: {} };
121
+ const doc = readJsonOrNull(path) ?? { axis, families: {} };
123
122
  const recorded = [], rejected = [];
124
123
  for (const item of families) {
125
124
  const qids = (Array.isArray(item?.qids) ? item.qids : [item?.qids ?? item?.qid]).map((q) => String(q ?? "").trim()).filter(Boolean);
@@ -143,7 +142,7 @@ export function recordWithheldFamilies(runDir, { axis, families } = {}) {
143
142
  renameSync(tmp, path);
144
143
  // A withholding replaces a release of the same family: one decision per family, the latest.
145
144
  const rPath = releasedFamiliesPath(runDir, axis);
146
- const r = readJson(rPath);
145
+ const r = readJsonOrNull(rPath);
147
146
  if (r?.families && recorded.some((q) => q in r.families)) {
148
147
  for (const q of recorded) delete r.families[q];
149
148
  const rTmp = `${rPath}.${process.pid}.tmp`;
@@ -166,12 +165,12 @@ export function recordWithheldFamilies(runDir, { axis, families } = {}) {
166
165
  * refused, and never throws.
167
166
  */
168
167
  export function recordReleasedFamilies(runDir, { axis, families } = {}) {
169
- const plan = readJson(driverDir(runDir, "register-plan.json"));
168
+ const plan = readJsonOrNull(paths(runDir).registerPlan);
170
169
  if (!plan || !Array.isArray(plan.entries)) return { refused: "no frozen register plan in this run — there are no waiting families to record against" };
171
170
  if (!Array.isArray(families) || !families.length) return { refused: "families must list at least one { qids, reason }" };
172
- const supp = readJson(join(runDir, "register-units", `${axis}-supplemental-plan.json`));
171
+ const supp = readJsonOrNull(join(runDir, "register-units", `${axis}-supplemental-plan.json`));
173
172
  const path = releasedFamiliesPath(runDir, axis);
174
- const doc = readJson(path) ?? { axis, families: {} };
173
+ const doc = readJsonOrNull(path) ?? { axis, families: {} };
175
174
  const { waiting } = waitingFamiliesOn(plan, axis, Array.isArray(supp?.entries) ? supp.entries : []);
176
175
  const waitingQids = new Set(waiting.map((e) => e.qid));
177
176
  const recorded = [], rejected = [];
@@ -197,7 +196,7 @@ export function recordReleasedFamilies(runDir, { axis, families } = {}) {
197
196
  renameSync(tmp, path);
198
197
  // A release replaces a withholding of the same family: one decision per family, the latest.
199
198
  const wPath = withheldFamiliesPath(runDir, axis);
200
- const w = readJson(wPath);
199
+ const w = readJsonOrNull(wPath);
201
200
  if (w?.families && recorded.some((q) => q in w.families)) {
202
201
  for (const q of recorded) delete w.families[q];
203
202
  const wTmp = `${wPath}.${process.pid}.tmp`;
@@ -206,7 +205,7 @@ export function recordReleasedFamilies(runDir, { axis, families } = {}) {
206
205
  }
207
206
  } catch (e) { return { write_failed: String(e?.message ?? e).slice(0, 200) }; }
208
207
  }
209
- const withheldNow = readJson(withheldFamiliesPath(runDir, axis))?.families ?? {};
208
+ const withheldNow = readJsonOrNull(withheldFamiliesPath(runDir, axis))?.families ?? {};
210
209
  const { unasked } = waitingFamiliesOn(plan, axis, Array.isArray(supp?.entries) ? supp.entries : [], new Set(Object.keys(doc.families)));
211
210
  const still = unasked.filter((e) => !withheldNow[e.qid]).map((e) => e.qid);
212
211
  return { axis, recorded, rejected, still_to_judge: still, waiting: waiting.length };
@@ -22,9 +22,10 @@
22
22
  // Lives in the run-lock dir because that is already the one directory every process in an install shares
23
23
  // — the same place `acquireRunSlot` coordinates the concurrency cap.
24
24
 
25
- import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
25
+ import { writeFileSync, mkdirSync } from "node:fs";
26
26
  import { join, dirname } from "node:path";
27
27
  import { procStarttime } from "./claim-liveness.mjs";
28
+ import { readJson } from "./run-record.mjs";
28
29
 
29
30
  export const HEARTBEAT_FILE = "worker.heartbeat";
30
31
 
@@ -60,7 +61,7 @@ export function beat(dir, { now = Date.now(), pid = process.pid, starttimeOf = p
60
61
  */
61
62
  export function workerAlive(dir, { now = Date.now(), staleMs = 3 * 90_000, starttimeOf = procStarttime } = {}) {
62
63
  let rec;
63
- try { rec = JSON.parse(readFileSync(heartbeatPath(dir), "utf8")); } catch { return false; }
64
+ try { rec = readJson(heartbeatPath(dir)); } catch { return false; }
64
65
  if (!rec || typeof rec.pid !== "number" || typeof rec.at !== "number") return false;
65
66
  if (now - rec.at > staleMs) return false;
66
67
  // A recycled pid is the case the birth stamp exists for: the number is live and belongs to something
@@ -31,9 +31,6 @@
31
31
  // and renders a single-member group as a short entry, so it is a property of the population. This returns
32
32
  // `full` or `entry`, and the grouping pass turns `entry` into one or the other.
33
33
 
34
- /** The two answers this function can give. `entry` becomes a short entry or a grouped line downstream. */
35
- export const WRITE_UP_FORMS = Object.freeze(["full", "entry"]);
36
-
37
34
  /**
38
35
  * The form one finding earns.
39
36
  *
@@ -1,5 +1,9 @@
1
1
  # trademark-artifacts-mcp
2
2
 
3
+ ## 0.6.0-beta.0
4
+
5
+ No changes in this release.
6
+
3
7
  ## 0.5.1
4
8
 
5
9
  No changes in this release.
@@ -249,7 +249,7 @@ if (isMain) {
249
249
  // does not have the feature" looking identical, which is the confusion this issue is about.
250
250
  log(KEY_SOCKET
251
251
  ? `key path: ${KEY_SOCKET} (mode ${KEY_SOCKET_MODE.toString(8)} once open) — a scoped access key is accepted HERE and nowhere else; the network door never honours one`
252
- : "key path: none configured (TRADEMARK_MCP_KEY_SOCKET unset) — a program on this box holding an access key has no door on this process");
252
+ : "key path: none (TRADEMARK_MCP_KEY_SOCKET is not set), so a program on this machine cannot use an access key here; the client door accepts them");
253
253
 
254
254
  // ── THE ROSTER THIS PROCESS CAN ACTUALLY SEE ──────────────────────────────────────────────────────
255
255
  //
@@ -28,9 +28,15 @@
28
28
  // printed no conflicts because a file was absent would read as a clean search — the worst answer this tool
29
29
  // can give. An absence is reported as an absence. Read-only.
30
30
 
31
- import { existsSync, readFileSync } from "node:fs";
31
+ import { existsSync } from "node:fs";
32
+ import { join } from "node:path";
32
33
  import { parseReport } from "./driver.mjs";
33
34
  import { readReportData, productIdentityFor } from "./runs.mjs";
35
+ import { readJson, readJsonOrNull } from "../../driver/run-record.mjs";
36
+
37
+ // THE LINE FOR A SCREENED NAME WITH NO DATA FILE, beside its report link: the brief cannot read its rating, and says so
38
+ // rather than leaving the name out. Design's wording (2026-11-11), printed only where the name's report was published.
39
+ const NO_DATA_FOR_NAME = "_No published data file for this name — its rating is in its report._";
34
40
 
35
41
  // Drop internal-only context (::p:: marker) and the leading risk-formula clause ("Level N Risk = … →").
36
42
  // APPLIED ONLY TO report.md-DERIVED TEXT (the archived-run fallback below). Strings out of report-data.json
@@ -76,6 +82,15 @@ export function buildBrief(run) {
76
82
  // The knockout shape carries no `kind` at all and is told apart by `marks[]` — the same discrimination
77
83
  // portal-service.mjs makes. Both lanes stamp `schema: 'report-data/1'`, so the schema string cannot.
78
84
  const koDocs = docs.filter((d) => d?.kind !== "clearance" && Array.isArray(d?.marks));
85
+ // A NAME WHOSE DATA FILE COULD NOT BE WRITTEN IS STILL A NAME SCREENED. A Knockout batch publishes every name's
86
+ // report when one name's data file fails, and lists that name in meta.reports with no data file. Read from the
87
+ // data files alone, the brief left the name out and nothing said another was screened.
88
+ const koMeta = clearance || !run.poolDir ? null : readJsonOrNull(join(run.poolDir, "meta.json"));
89
+ const briefed = new Set(koDocs.flatMap((d) => (d.marks ?? []).map((m) => m.name)));
90
+ const koWithoutData = (Array.isArray(koMeta?.reports) ? koMeta.reports : [])
91
+ .filter((r) => r?.mark && !r.dataFile && !briefed.has(r.mark))
92
+ // THE SENTENCE SAYS THE RATING IS IN THE REPORT, so it is said only of a report that is there.
93
+ .filter((r) => typeof r.file === "string" && r.file && existsSync(join(run.poolDir, r.file)));
79
94
  const delivered = run.state === "delivered" || Boolean(run.deliveredAt);
80
95
  const lines = [];
81
96
 
@@ -132,8 +147,8 @@ export function buildBrief(run) {
132
147
  for (const c of conditions) lines.push(`- ${c}`);
133
148
  }
134
149
  if (clearance.url) lines.push("", `Report: ${clearance.url}`);
135
- } else if (koDocs.length) {
136
- source = "report-data";
150
+ } else if (koDocs.length || koWithoutData.length) {
151
+ source = koDocs.length ? "report-data" : "report-list";
137
152
  // A batch writes one file per name, each with that name's own band and its own report link — so the
138
153
  // link belongs on the mark line, not on the run.
139
154
  const summary = koDocs.map((d) => d.summary).find(Boolean);
@@ -164,6 +179,9 @@ export function buildBrief(run) {
164
179
  }
165
180
  }
166
181
  }
182
+ for (const r of koWithoutData) {
183
+ lines.push(`- **${r.mark}** — ${NO_DATA_FOR_NAME}${r.url ? ` Report: ${r.url}` : ""}`);
184
+ }
167
185
  const caveats = [...new Set(koDocs.flatMap((d) => d.caveats ?? []).filter(Boolean))];
168
186
  if (caveats.length) {
169
187
  lines.push("", "**Scope of this screen:**");
@@ -185,7 +203,7 @@ export function buildBrief(run) {
185
203
  // line stays as the fallback for archived runs, whose findings carry no `net`.
186
204
  const netByOrd = new Map();
187
205
  try {
188
- const doc = JSON.parse(readFileSync(P.findings, "utf8"));
206
+ const doc = readJson(P.findings);
189
207
  for (const f of (doc?.findings ?? [])) if (f?.net) netByOrd.set(String(f.ordinal), String(f.net));
190
208
  } catch { /* no findings.json on this run — the card line stands */ }
191
209
  for (const c of main)
@@ -14,13 +14,13 @@
14
14
 
15
15
  import { existsSync, readFileSync } from "node:fs";
16
16
  import { join } from "node:path";
17
- import { driverDir } from "../../shared/driver-dir.mjs"; //
18
17
  import { readCapped } from "./util.mjs";
19
18
  import { stepForStage } from "./driver.mjs";
19
+ import { paths } from "../../driver/run-record.mjs";
20
20
 
21
21
  export function readEvents(runDir) {
22
22
  try {
23
- return readCapped(driverDir(runDir, "run.jsonl"))
23
+ return readCapped(paths(runDir).run)
24
24
  .trim().split("\n").map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean);
25
25
  } catch { return []; }
26
26
  }