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
@@ -16,6 +16,7 @@
16
16
 
17
17
  import { mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
18
18
  import { basename, dirname, join } from "node:path";
19
+ import { createHash } from "node:crypto";
19
20
  import { nativeScriptIndexGap } from "./script-form.mjs"; import { floorOf, moreThan } from "../../shared/register-floor.mjs";
20
21
  import { entryTermIssues, goodsTermsList } from "./term-shape.mjs";
21
22
  import { awaitsReadingTurn, releasedFamiliesFile } from "./plan-guards.mjs";
@@ -451,6 +452,42 @@ export function makeExecutePlan(deps) {
451
452
  // and only that, asks it again (`reaskTimedOut` on the driver's own call context, which no tool argument
452
453
  // reaches), once per run (envelope-settle.mjs, settle_tried).
453
454
  let latestByQid = null;
455
+ // ── A QUESTION THIS RUN ALREADY HOLDS AN ANSWER TO IS NOT SENT AGAIN (ruled 2026-11-11) ─────────────────────────
456
+ // A register answer is paid for, and it does not change within the run. A unit runs its plan again when its pass was
457
+ // parked, when a stage whose record of what it read is missing runs again, or when a call is made twice; each of those
458
+ // sent every question again, answered or not. A held answer now stands for its question, from this axis's band or
459
+ // from a band a parked pass left, on three conditions. It answered the same question: each block records what was
460
+ // sent for it (`sent`, the provider and the query as built), and a question that would now send anything else is a
461
+ // new question. It completed: a failed answer, and a slice a check took out of the band, are unfinished work and are
462
+ // asked again. And the executor wrote it: a block with no record of what was sent cannot show it answered this
463
+ // question. A reused answer is not a new search, so it counts nothing against the follow-up allowance.
464
+ const sentKeyOf = (e) => {
465
+ try {
466
+ const query = withPlanRegions(buildEntryQuery(e, predicateParams(e), plan), plan);
467
+ return createHash("sha256").update(JSON.stringify({ provider: capabilities?.id ?? null, kind: e?.expected_kind === "count" ? "count" : "enumerate", query }))
468
+ .digest("hex").slice(0, 16);
469
+ } catch { return null; } // a question that cannot be built is not matched to any answer
470
+ };
471
+ let completedOnRecord = null;
472
+ const answerOnRecord = (e) => {
473
+ const key = sentKeyOf(e);
474
+ if (!key) return null;
475
+ if (!completedOnRecord) {
476
+ completedOnRecord = new Map();
477
+ for (const band of bandsOnRecord()) {
478
+ try {
479
+ for (const b of asAnswers(band)) {
480
+ if (b?.qid && b.error !== true && (b.state === "enumerated" || b.state === "incomplete") && typeof b.sent === "string") {
481
+ const of = completedOnRecord.get(String(b.qid)) ?? [];
482
+ of.push(b);
483
+ completedOnRecord.set(String(b.qid), of);
484
+ }
485
+ }
486
+ } catch { /* no band, or one that cannot be read: nothing held from it */ }
487
+ }
488
+ }
489
+ return (completedOnRecord.get(String(e?.qid)) ?? []).filter((b) => b.sent === key).at(-1) ?? null;
490
+ };
454
491
  const timedOutBefore = (qid) => {
455
492
  if (!latestByQid) {
456
493
  latestByQid = new Map();
@@ -778,11 +815,18 @@ export function makeExecutePlan(deps) {
778
815
  const runEntry = async (e) => {
779
816
  const held = heldAnswer(e);
780
817
  if (held) {
781
- blocks.push({ ...held, qid: e.qid, query: describeEntry(e) });
818
+ blocks.push({ ...held, qid: e.qid, query: describeEntry(e), ...(held.error ? {} : { sent: sentKeyOf(e) }) });
782
819
  stateByQid.set(e.qid, held.error ? "error" : held.state);
783
820
  keepAnswersSoon();
784
821
  return;
785
822
  }
823
+ const kept = answerOnRecord(e);
824
+ if (kept) {
825
+ blocks.push({ ...kept });
826
+ stateByQid.set(e.qid, kept.state);
827
+ keepAnswersSoon();
828
+ return;
829
+ }
786
830
  if (pastSendUntil(tctx)) { notReached.push(e.qid); return; }
787
831
  if (driverDir && followUpClass(e, { identicalTerms }) === "counted") {
788
832
  const room = followUpRoom(driverDir, FOLLOW_UP_SEARCH_LIMIT, e, { answered: answeredBefore });
@@ -799,8 +843,11 @@ export function makeExecutePlan(deps) {
799
843
  ...(Array.isArray(e.romanizedTerms) && e.romanizedTerms.length ? { romanized: e.romanizedTerms.map(String) } : {}),
800
844
  ...(room.retry ? { retry: `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}` } : {}) });
801
845
  }
846
+ const at = blocks.length;
802
847
  try {
803
848
  await dispatchEntry(e);
849
+ // What was sent is recorded on a completed answer only: a failed one is asked again whatever it records.
850
+ for (const b of blocks.slice(at)) if (b?.qid === e.qid && b.error !== true) b.sent = sentKeyOf(e);
804
851
  } catch (err) {
805
852
  // `describeEntry` is itself one of the things that can throw here, so the recovery block must
806
853
  // not depend on it succeeding — a backstop that can fail is not a backstop.
@@ -0,0 +1,46 @@
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
+ // ── The record-listing shim ( part 5) ───────────────────────────────────────────────────────────
4
+ //
5
+ // Every provider core already answers a search with normalized rows, and every core's row vocabulary is
6
+ // the same flat corsearch-shaped one (`record_id`, `mark_text`, `owner_name`, `classes`, `status`) —
7
+ // euipo/row.js states that key naming IS the contract, and uspto-local follows it. So the driver-side
8
+ // listing needs no new core: it is doSearch, parsed, with the errors read the way every other kernel
9
+ // reads them.
10
+ //
11
+ // ONE COPY, because the provider adapters would otherwise carry five copies of the same parse and the
12
+ // same ERROR-prefix check, and a provider whose copy drifted would report a failed fetch as an empty
13
+ // list of filings — the exact "absence reads as a finding" defect this lane exists to avoid.
14
+ //
15
+ // THE URL IS BUILT HERE, not in the renderer, because it is provider knowledge: a row that already
16
+ // carries a resolved link keeps it, and otherwise the provider's own public origin is joined to the
17
+ // record ref. A provider with no public record URL yields null, and the surfaces print the reference
18
+ // without a link rather than inventing an address.
19
+ export function recordsFromSearch(run, { origin = null } = {}) {
20
+ return async (params, tctx) => {
21
+ let r;
22
+ try { r = await run(params, tctx); }
23
+ catch (e) { return { ok: false, records: null, reason: `record listing threw: ${e.message}` }; }
24
+ const text = typeof r?.text === "string" ? r.text : "";
25
+ if (r?.isError || text.startsWith("ERROR")) return { ok: false, records: null, reason: text.slice(0, 300) || "provider error" };
26
+ let parsed;
27
+ try { parsed = JSON.parse(text); }
28
+ catch { return { ok: false, records: null, reason: "unparseable search response on the record listing" }; }
29
+ if (!Array.isArray(parsed?.results))
30
+ return { ok: false, records: null, reason: "the search response carried no results[], so nothing was listed — which is not the same as no filings" };
31
+ const link = (row) => {
32
+ const resolved = row?.resolved_link ?? row?.record_url ?? null;
33
+ if (typeof resolved === "string" && /^https?:\/\//i.test(resolved)) return resolved;
34
+ const ref = row?.record_id;
35
+ return (origin && typeof ref === "string" && ref.startsWith("/")) ? `${origin}${ref}` : null;
36
+ };
37
+ return {
38
+ ok: true,
39
+ records: parsed.results.map((row) => ({ ...row, record_url: link(row) })),
40
+ // NULL, never the row count, when the body carried no integer. `fetched` under a null `total` is
41
+ // an honest "we do not know how many more there are"; under a minted total it is a lie about
42
+ // completeness — the count kernel's one rule, applied to the listing.
43
+ total: Number.isFinite(parsed?.total_hits) ? parsed.total_hits : null,
44
+ };
45
+ };
46
+ }
@@ -43,9 +43,9 @@ What it notably cannot do, each declared as data in `src/capabilities.js`:
43
43
 
44
44
  - [`../../driver/register-capabilities.mjs`](../../driver/register-capabilities.mjs) imports `CAPABILITIES`
45
45
  at module load; the planner takes it as a parameter and never imports a vendor.
46
- - [`../../driver/driver.config.mjs`](../../driver/driver.config.mjs) lazy-imports `src/core.js` for the
46
+ - [`src/adapter.js`](src/adapter.js) lazy-imports `src/core.js` for the
47
47
  in-process lanes under `credEnv: "CLARIVATE_API_KEY"`, selected by `CLEAROTRON_DATABASE=clarivate`.
48
- - [`../../driver/engine/mcp/clarivate-server.mjs`](../../driver/engine/mcp/clarivate-server.mjs) wraps the
48
+ - [`src/mount.js`](src/mount.js) wraps the
49
49
  same core as a standalone MCP server, mounting seven of the eight neutral `register_*` tools — the
50
50
  missing one is the phoneme expansion above.
51
51
  - Paging, counting, screening and the ledger are the shared kernel in [`../_shared/`](../_shared/).
@@ -0,0 +1,147 @@
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
+ // The clarivate register's driver-side adapter: what the driver itself asks this register, with no model in the path.
4
+ // `driver.config.mjs` lists it in PROVIDERS. The core is imported only when a call needs it.
5
+
6
+ export const adapter = {
7
+ id: "clarivate",
8
+ label: "Clarivate Compumark",
9
+ credEnv: "CLARIVATE_API_KEY",
10
+ skillDoc: "skills/clearance-register/providers/clarivate.md",
11
+ hasPublicRecordUrl: false, // Compumark Content has no public record URL — cite the office register
12
+ //, ruling 2026-08-20 — WHAT A CARD SHOWS WHERE A LINK CANNOT GO. A UI exists for this
13
+ // provider and we do not know its per-record URL, so the card says so and says it is unfinished.
14
+ // "placeholder" is the reader-facing admission; anything else would read as a citation.
15
+ recordCitation: "placeholder",
16
+ async recordFetch(uri, { agentId, sessionKey, recordLog = null }) {
17
+ if (!process.env.CLARIVATE_API_KEY) return { ok: false, cause: "CLARIVATE_API_KEY absent from driver env" };
18
+ let doRecordFetch, DEFAULT_BASE;
19
+ try { ({ doRecordFetch, DEFAULT_BASE } = await import("./core.js")); }
20
+ catch (e) { return { ok: false, cause: `plugin core unavailable: ${e.message}` }; }
21
+ const base = process.env.CLARIVATE_API_BASE || DEFAULT_BASE;
22
+ try {
23
+ const r = await doRecordFetch(process.env.CLARIVATE_API_KEY, base,
24
+ { record_ids: [uri] }, { kind: "record_fetch", agentId, sessionKey, sessionId: null, recordLog });
25
+ const err = typeof r?.text === "string" && r.text.startsWith("ERROR") ? r.text : null;
26
+ return err ? { ok: false, cause: err.slice(0, 140) } : { ok: true };
27
+ } catch (e) { return { ok: false, cause: `fetch threw: ${e.message}` }; }
28
+ },
29
+ // Depth 2's count, same contract as corsearch's (see above). A TRUE count-only call here: POST
30
+ // /count fetches no records and works at any magnitude. regions[] is mandatory on this provider,
31
+ // so a worldwide count is a disclosed capability gap rather than a number — register-count.mjs
32
+ // refuses the run up front instead of letting every mark fail one at a time.
33
+ async countHits({ name, matchMode, classes, regions }, { agentId, sessionKey, recordLog = null }) {
34
+ if (!process.env.CLARIVATE_API_KEY) return { ok: false, total: null, reason: "CLARIVATE_API_KEY absent from driver env" };
35
+ let doCountHits, DEFAULT_BASE;
36
+ try { ({ doCountHits, DEFAULT_BASE } = await import("./core.js")); }
37
+ catch (e) { return { ok: false, total: null, reason: `plugin core unavailable: ${e.message}` }; }
38
+ const base = process.env.CLARIVATE_API_BASE || DEFAULT_BASE;
39
+ try {
40
+ return await doCountHits(process.env.CLARIVATE_API_KEY, base,
41
+ { ...(Array.isArray(name) ? { names: name } : { name }), match_mode: matchMode, nice_classes: classes ?? [], ...(regions?.length ? { regions } : {}) },
42
+ { kind: "count_hits", agentId, sessionKey, sessionId: null, recordLog });
43
+ } catch (e) { return { ok: false, total: null, reason: `count threw: ${e.message}` }; }
44
+ },
45
+ // part 5 — TWO calls, not a per-record bill. Compumark's POST /search answers with record
46
+ // IDENTIFIERS and nothing else (normalizeSearchResponse fills mark_text, classes, status and
47
+ // owner_name with null on every row, by construction), so the fields a filings list prints have to
48
+ // be fetched. But the fetch is a BATCH: TEXT_BATCH_MAX is 100 ids per call and POST /text hydrates
49
+ // every id in the call. A 100-filing listing for one name is ONE search plus ONE screen call.
50
+ //
51
+ // An earlier draft of this method refused here and priced the listing at "up to 100 extra billed
52
+ // calls per name". That was wrong by the batch factor, and it mattered: clarivate is the register
53
+ // wired on the test deployment, so the refusal would have shipped this whole part inert on the one
54
+ // provider that runs. `screenSource: "billed-record-fetch"` states that the fields cost a fetch —
55
+ // it does not state that the fetch is per record, and doRecordFetch chunks at the same 100.
56
+ //
57
+ // THE CAP IS APPLIED TO THE IDS, BEFORE THE SCREEN, because this provider's search is single-shot:
58
+ // capabilities.pageParams is empty and POST /search returns the COMPLETE guid set up to the 30000
59
+ // ceiling. Screening whatever came back would be exactly the runaway the cap exists to prevent.
60
+ //
61
+ // Class scope comes from the SEARCH (`classFilter: "native"`), as on every other provider here.
62
+ // `in_scope_classes` is deliberately NOT sent to the screen: there it drives `screen_verdict`, a
63
+ // keep/drop judgment, and this lane adds none — it prints what the register said.
64
+ async listRecords({ name, matchMode, classes, regions, limit }, { agentId, sessionKey, recordLog = null }) {
65
+ if (!process.env.CLARIVATE_API_KEY) return { ok: false, records: null, reason: "CLARIVATE_API_KEY absent from driver env" };
66
+ let doSearch, doBatchScreen, DEFAULT_BASE;
67
+ try { ({ doSearch, doBatchScreen, DEFAULT_BASE } = await import("./core.js")); }
68
+ catch (e) { return { ok: false, records: null, reason: `plugin core unavailable: ${e.message}` }; }
69
+ const base = process.env.CLARIVATE_API_BASE || DEFAULT_BASE;
70
+ const tctx = { kind: "record_list", agentId, sessionKey, sessionId: null, recordLog };
71
+ const readJson = (r, what) => {
72
+ const text = typeof r?.text === "string" ? r.text : "";
73
+ if (r?.isError || text.startsWith("ERROR")) return { err: text.slice(0, 300) || `provider error on the ${what}` };
74
+ try { return { doc: JSON.parse(text) }; }
75
+ catch { return { err: `unparseable ${what} response on the record listing` }; }
76
+ };
77
+ let ids, total;
78
+ try {
79
+ const { doc, err } = readJson(await doSearch(process.env.CLARIVATE_API_KEY, base,
80
+ { name, match_mode: matchMode, nice_classes: classes ?? [], ...(regions?.length ? { regions } : {}) }, tctx), "search");
81
+ if (err) return { ok: false, records: null, reason: err };
82
+ if (!Array.isArray(doc?.results))
83
+ return { ok: false, records: null, reason: "the search response carried no results[], so nothing was listed — which is not the same as no filings" };
84
+ // NULL, never the id count: the same rule the rest of this lane runs on.
85
+ total = Number.isFinite(doc?.total_hits) ? doc.total_hits : null;
86
+ const want = Number.isFinite(limit) && limit >= 1 ? Math.floor(limit) : doc.results.length;
87
+ ids = doc.results.map((row) => row?.record_id).filter((u) => typeof u === "string" && u).slice(0, want);
88
+ } catch (e) { return { ok: false, records: null, reason: `record listing threw: ${e.message}` }; }
89
+ // Nothing to hydrate is a real, answered zero — and it keeps the screen call unmade.
90
+ if (!ids.length) return { ok: true, records: [], total };
91
+ try {
92
+ const { doc, err } = readJson(await doBatchScreen(process.env.CLARIVATE_API_KEY, base, { uris: ids }, tctx), "screen");
93
+ if (err) return { ok: false, records: null, reason: err };
94
+ if (!Array.isArray(doc?.rows))
95
+ return { ok: false, records: null, reason: "the screen response carried no rows[], so nothing was listed — which is not the same as no filings" };
96
+ // A PARTIAL HYDRATE IS NOT A LISTING. doBatchScreen only hard-errors when EVERY chunk failed;
97
+ // one failed chunk among several comes back as rows plus a populated `errors`, and returning
98
+ // those rows would present a short list as the whole answer — the same lie the count lane
99
+ // refuses when it declines to sum a partial variant sweep. Fewer rows than ids with NO errors is
100
+ // a different thing (an id the register no longer resolves) and rides through as a real result.
101
+ if (Array.isArray(doc.errors) && doc.errors.length)
102
+ return { ok: false, records: null, reason: `the hydrate failed on ${doc.errors.length} of ${Math.ceil(ids.length / 100)} batch(es), so this listing would be short without saying so: ${String(doc.errors[0]).slice(0, 200)}` };
103
+ return { ok: true, total, records: doc.rows.map((row) => ({
104
+ record_id: row?.uri ?? null,
105
+ mark_text: row?.mark_text ?? null,
106
+ // The screen row names this `owner`; the neutral record reads `owner_name`. Mapped here so the
107
+ // seam is in one place rather than as a second spelling inside register-records.mjs.
108
+ owner_name: row?.owner ?? null,
109
+ owner_country: row?.owner_country ?? null,
110
+ status: row?.status ?? null,
111
+ classes: Array.isArray(row?.classes) ? row.classes : null,
112
+ office: row?.office ?? null,
113
+ application_date: row?.application_date ?? null,
114
+ registration_date: row?.registration_date ?? null,
115
+ // The office's own numbers: publish addresses the filing at the office's page from these, the
116
+ // way it does for this register's clearance findings. Compumark states no filing route or IR
117
+ // number of its own, so a Madrid designation is addressed as the national filing it is listed as.
118
+ application_number: row?.application_number ?? null,
119
+ registration_number: row?.registration_number ?? null,
120
+ // hasPublicRecordUrl:false on this provider — there is no per-record page to link, and a
121
+ // fabricated one would be worse than none.
122
+ record_url: null,
123
+ })) };
124
+ } catch (e) { return { ok: false, records: null, reason: `record hydrate threw: ${e.message}` }; }
125
+ },
126
+ // The repair-first plan-direct-execute lane, same contract as corsearch's (see above). Without it
127
+ // Clarivate would silently fall back to the LLM followup at the fan-in gate — a model turn doing
128
+ // what code can do deterministically, which is the transcription lane this whole design closes.
129
+ // Signature note: the clarivate core takes (apiKey, base, params, tctx), not corsearch's
130
+ // (sessionKey, params, tctx) — the base is threaded explicitly here.
131
+ async executePlan({ planPath, axis, outputPath, qids }, { agentId, sessionKey, recordLog = null, reaskTimedOut = false }) {
132
+ if (!process.env.CLARIVATE_API_KEY) return { ok: false, cause: "CLARIVATE_API_KEY absent from driver env" };
133
+ let doExecutePlan, DEFAULT_BASE;
134
+ try { ({ doExecutePlan, DEFAULT_BASE } = await import("./core.js")); }
135
+ catch (e) { return { ok: false, cause: `plugin core unavailable: ${e.message}` }; }
136
+ const base = process.env.CLARIVATE_API_BASE || DEFAULT_BASE;
137
+ try {
138
+ const r = await doExecutePlan(process.env.CLARIVATE_API_KEY, base,
139
+ { plan_path: planPath, axis, output_path: outputPath, ...(Array.isArray(qids) && qids.length ? { qids } : {}) },
140
+ { kind: "execute_plan", agentId, sessionKey, sessionId: null, recordLog, ...(reaskTimedOut ? { reaskTimedOut: true } : {}) });
141
+ const text = typeof r?.text === "string" ? r.text : "";
142
+ if (text.startsWith("ERROR")) return { ok: false, cause: text.slice(0, 200) };
143
+ try { const summary = JSON.parse(text); return { ok: true, states: summary.states ?? {}, executed: summary.executed, skipped: summary.skipped ?? [] }; }
144
+ catch { return { ok: false, cause: `unparseable execute_plan summary: ${text.slice(0, 120)}` }; }
145
+ } catch (e) { return { ok: false, cause: `execute_plan threw: ${e.message}` }; }
146
+ },
147
+ };
@@ -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
  // The Clarivate register adapter — pure logic + HTTP helpers + telemetry, with ZERO plugin-SDK or
4
4
  // TypeBox imports (node built-ins, global fetch and providers/_shared only). Everything this provider
5
- // does lives here: driver/engine/mcp/clarivate-server.mjs wraps the module as a standalone MCP server,
5
+ // does lives here: src/mount.js wraps the module for the one register MCP server,
6
6
  // driver.config.mjs lazy-imports it for the in-process lanes, and the tests import it directly.
7
7
  //
8
8
  // PACKAGING NOTE: this core imports the shared ledger, screen primitives and enumerate kernel from
@@ -1589,19 +1589,6 @@ export async function resolveCompany(apiKey, base, { companyName, regions }, tct
1589
1589
  return { ok: true, companies, reason: null };
1590
1590
  }
1591
1591
 
1592
- export async function doResolveCompany(apiKey, base, params, tctx) {
1593
- const companyName = params?.company_name ?? params?.owner ?? null;
1594
- const out = await resolveCompany(apiKey, base, { companyName, regions: params?.regions }, tctx);
1595
- if (!out.ok) return { type: "text", text: `ERROR: clarivate_resolve_company — ${out.reason}` };
1596
- const threshold = Number.isFinite(Number(params?.min_confidence)) ? Number(params.min_confidence) : OWNER_RESOLUTION_MIN_CONFIDENCE;
1597
- return { type: "text", text: JSON.stringify({
1598
- company_name: companyName,
1599
- min_confidence: threshold,
1600
- accepted: out.companies.filter((c) => (c.confidence ?? 0) >= threshold).map((c) => c.applicant_name),
1601
- companies: out.companies,
1602
- }, null, 2) };
1603
- }
1604
-
1605
1592
  /**
1606
1593
  * Expand an owner sweep's terms with the resolved exact applicant names. ADDITIVE by construction:
1607
1594
  * the caller's own terms are always kept, so this can only widen. Returns the params to sweep plus a
@@ -1,7 +1,6 @@
1
- #!/usr/bin/env node
2
1
  // SPDX-License-Identifier: AGPL-3.0-only
3
2
  // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
4
- // Standalone MCP server wrapping the clarivate CORE (pure node+fetch) so a `claude -p` process can
3
+ // The clarivate register's tools, as driver/engine/mcp/register-server.mjs mounts them, wrapping its CORE (pure node+fetch) so a `claude -p` process can
5
4
  // call the register-search tools off-gateway. Pure glue: the core owns all logic. Auth = CLARIVATE_API_KEY
6
5
  // (X-ApiKey header); base = CLARIVATE_API_BASE || the core's DEFAULT_BASE. Telemetry: the core writes
7
6
  // CLEAROTRON_REGISTER_CALL_LOG / CLEAROTRON_REGISTER_RECORD_LOG (the SHARED register ledger — one provider
@@ -28,14 +27,10 @@
28
27
  // them against that capability flag, so flipping the contract without wiring a tool fails CI.
29
28
  // `match_mode: "phonetic"` on register_search / register_enumerate remains fully available; it is the
30
29
  // PREVIEW of the expansion that this provider cannot give, not phonetic search itself.
31
- import { serve } from "./stdio-server.mjs";
32
- import { sendUntilFromEnv } from "../../../providers/_shared/send-until.mjs";
33
- import { crowdNoteFor } from "./crowd-note.mjs"; // how the unit decides on a crowd, beside an answer that carries one
30
+ import { sendUntilFromEnv } from "../../_shared/send-until.mjs";
34
31
  import {
35
32
  CAPABILITIES, doSearch, doRecordFetch, doImageFetch, doBatchScreen, doEnumerate, doExecutePlan, DEFAULT_BASE,
36
- } from "../../../providers/clarivate/src/core.js";
37
- import { proposeSupplemental } from "./supplemental.mjs";
38
- import { CLARIVATE_PROPOSE_TOOL } from "./clarivate-propose-tool.mjs";
33
+ } from "./core.js";
39
34
 
40
35
  const API_KEY = process.env.CLARIVATE_API_KEY || "";
41
36
  const BASE = process.env.CLARIVATE_API_BASE || DEFAULT_BASE;
@@ -64,8 +59,8 @@ const QUERY_PROPS = {
64
59
  resolve_owner: { type: "boolean", description: "enumerate only: resolve an owner term to exact applicant names first (default true)" },
65
60
  };
66
61
 
67
- serve({
68
- name: "register", version: "0.2.0", noteFor: crowdNoteFor,
62
+ export const mount = ({ proposeSupplemental, CLARIVATE_PROPOSE_TOOL }) => ({
63
+ version: "0.2.0",
69
64
  tools: [
70
65
  {
71
66
  name: "register_search",
@@ -9,7 +9,7 @@ a global aggregator, so it declares no enumerable covered office set; see the la
9
9
  |---|---|
10
10
  | `src/capabilities.js` | The capability contract, and the **reference copy** — signa's and clarivate's contracts point here for what the file is and why |
11
11
  | `src/core.js` | Transport: the flat query language, paging, screening, phoneme expansion, the call ledger |
12
- | ~~`src/index.js`~~ | RETIRED. It was a plugin-SDK entry for an agent platform this product does not ship: TypeBox schemas plus tool-factory registration of six`corsearch_*` tools, importing a package no `package.json` here declares. The adapter reaches this engine through `driver/engine/mcp/corsearch-server.mjs`, which is the only path any run has used |
12
+ | ~~`src/index.js`~~ | RETIRED. It was a plugin-SDK entry for an agent platform this product does not ship: TypeBox schemas plus tool-factory registration of six`corsearch_*` tools, importing a package no `package.json` here declares. The adapter reaches this engine through `src/mount.js`, which is the only path any run has used |
13
13
  | `test/` | Characterisation and fault-lane tests |
14
14
 
15
15
  Environment: `CORSEARCH_SESSION_KEY` is required, and it is a **session cookie**, not a bearer token —
@@ -39,10 +39,10 @@ What it notably cannot do, each declared as data in `src/capabilities.js`:
39
39
 
40
40
  - [`../../driver/register-capabilities.mjs`](../../driver/register-capabilities.mjs) imports `CAPABILITIES`
41
41
  at module load; the planner takes it as a parameter and never imports a vendor.
42
- - [`../../driver/driver.config.mjs`](../../driver/driver.config.mjs) lazy-imports `src/core.js` for the
42
+ - [`src/adapter.js`](src/adapter.js) lazy-imports `src/core.js` for the
43
43
  in-process lanes under `credEnv: "CORSEARCH_SESSION_KEY"`, selected by
44
44
  `CLEAROTRON_DATABASE=corsearch`.
45
- - [`../../driver/engine/mcp/corsearch-server.mjs`](../../driver/engine/mcp/corsearch-server.mjs) wraps the
45
+ - [`src/mount.js`](src/mount.js) wraps the
46
46
  same core as a standalone MCP server, mounting all eight neutral `register_*` tools.
47
47
  - Paging, counting, screening and the ledger are the shared kernel in [`../_shared/`](../_shared/);
48
48
  `core.js` spreads `CAPABILITIES.kernel` straight into it, so no literal can drift from the contract.
@@ -0,0 +1,80 @@
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
+ // The corsearch register's driver-side adapter: what the driver itself asks this register, with no model in the path.
4
+ // `driver.config.mjs` lists it in PROVIDERS. The core is imported only when a call needs it.
5
+ import { recordsFromSearch } from "../../_shared/records-from-search.mjs";
6
+
7
+ export const adapter = {
8
+ id: "corsearch",
9
+ label: "Corsearch",
10
+ credEnv: "CORSEARCH_SESSION_KEY",
11
+ skillDoc: "skills/clearance-register/providers/corsearch.md",
12
+ hasPublicRecordUrl: true,
13
+ // WP-receipts W2: the public per-record origin (publicRecordOrigin + /mark/<jur>/<id> is a working
14
+ // link) — replaces the fragile resolved-link-origin inference at render for receipt-carrying runs.
15
+ publicRecordOrigin: "https://tm.corsearch.com",
16
+ async recordFetch(uri, { agentId, sessionKey, recordLog = null }) {
17
+ if (!process.env.CORSEARCH_SESSION_KEY) return { ok: false, cause: "CORSEARCH_SESSION_KEY absent from driver env" };
18
+ let doRecordFetch;
19
+ try { ({ doRecordFetch } = await import("./core.js")); }
20
+ catch (e) { return { ok: false, cause: `plugin core unavailable: ${e.message}` }; }
21
+ try {
22
+ const r = await doRecordFetch(process.env.CORSEARCH_SESSION_KEY,
23
+ { record_id: uri }, { kind: "record_fetch", agentId, sessionKey, sessionId: null, recordLog });
24
+ const err = typeof r?.text === "string" && r.text.startsWith("ERROR") ? r.text : null;
25
+ return err ? { ok: false, cause: err.slice(0, 140) } : { ok: true };
26
+ } catch (e) { return { ok: false, cause: `fetch threw: ${e.message}` }; }
27
+ },
28
+ // Depth 2 (knockout-register): "how many filings match this name?" and nothing else. Same lazy
29
+ // import + credential guard as recordFetch above; the counting itself is the shared kernel
30
+ // (providers/_shared/count.mjs), so every provider answers in one shape. ONE BILLABLE SEARCH per
31
+ // call on this provider (the count rides page 0 — capabilities.countProbe "cheap").
32
+ async countHits({ name, matchMode, classes, regions }, { agentId, sessionKey, recordLog = null }) {
33
+ if (!process.env.CORSEARCH_SESSION_KEY) return { ok: false, total: null, reason: "CORSEARCH_SESSION_KEY absent from driver env" };
34
+ let doCountHits;
35
+ try { ({ doCountHits } = await import("./core.js")); }
36
+ catch (e) { return { ok: false, total: null, reason: `plugin core unavailable: ${e.message}` }; }
37
+ try {
38
+ return await doCountHits(process.env.CORSEARCH_SESSION_KEY,
39
+ { name, match_mode: matchMode, nice_classes: classes ?? [], ...(regions?.length ? { regions } : {}) },
40
+ { kind: "count_hits", agentId, sessionKey, sessionId: null, recordLog });
41
+ } catch (e) { return { ok: false, total: null, reason: `count threw: ${e.message}` }; }
42
+ },
43
+ // part 5 — the FILINGS behind the narrow counts. A SECOND billable search per term, and it
44
+ // cannot be folded into the count above: that call rides `cheapCountParams` (`limit:1,
45
+ // fields:["uri"]`, the smallest response the API gives) and makeEnumerate builds the same probe, so
46
+ // widening it to carry rows would change what every enumerate call fetches. The listing pays its
47
+ // own way and the receipts ledger stamps `stage:"records"` on it so the two are told apart.
48
+ async listRecords({ name, matchMode, classes, regions, limit }, { agentId, sessionKey, recordLog = null }) {
49
+ if (!process.env.CORSEARCH_SESSION_KEY) return { ok: false, records: null, reason: "CORSEARCH_SESSION_KEY absent from driver env" };
50
+ let doSearch;
51
+ try { ({ doSearch } = await import("./core.js")); }
52
+ catch (e) { return { ok: false, records: null, reason: `plugin core unavailable: ${e.message}` }; }
53
+ return recordsFromSearch(
54
+ (p, t) => doSearch(process.env.CORSEARCH_SESSION_KEY, p, t),
55
+ { origin: "https://tm.corsearch.com" },
56
+ )({ name, match_mode: matchMode, nice_classes: classes ?? [], ...(regions?.length ? { regions } : {}), limit },
57
+ { kind: "record_list", agentId, sessionKey, sessionId: null, recordLog });
58
+ },
59
+ // Repair-first (2026-07-05): the fan-in plan-direct-execute repair. Re-runs ONLY the dictated qids
60
+ // that own no band block, as pure code at the gate (no agent turn, no gateway lane) — the tool's
61
+ // qid-ownership merge preserves every untargeted/judgment block, and the chunked doEnumerate under
62
+ // it is the same executor the initial gather used. Corsearch-only today: providers without an
63
+ // executePlan adapter fall back to the LLM followup at the gate. (Corsearch + Clarivate carry one
64
+ // as of phase 5, 2026-07-21; Signa does not — it has no enumerate/execute surface yet.)
65
+ async executePlan({ planPath, axis, outputPath, qids }, { agentId, sessionKey, recordLog = null, reaskTimedOut = false }) {
66
+ if (!process.env.CORSEARCH_SESSION_KEY) return { ok: false, cause: "CORSEARCH_SESSION_KEY absent from driver env" };
67
+ let doExecutePlan;
68
+ try { ({ doExecutePlan } = await import("./core.js")); }
69
+ catch (e) { return { ok: false, cause: `plugin core unavailable: ${e.message}` }; }
70
+ try {
71
+ const r = await doExecutePlan(process.env.CORSEARCH_SESSION_KEY,
72
+ { plan_path: planPath, axis, output_path: outputPath, ...(Array.isArray(qids) && qids.length ? { qids } : {}) },
73
+ { kind: "execute_plan", agentId, sessionKey, sessionId: null, recordLog, ...(reaskTimedOut ? { reaskTimedOut: true } : {}) });
74
+ const text = typeof r?.text === "string" ? r.text : "";
75
+ if (text.startsWith("ERROR")) return { ok: false, cause: text.slice(0, 200) };
76
+ try { const summary = JSON.parse(text); return { ok: true, states: summary.states ?? {}, executed: summary.executed, skipped: summary.skipped ?? [] }; }
77
+ catch { return { ok: false, cause: `unparseable execute_plan summary: ${text.slice(0, 120)}` }; }
78
+ } catch (e) { return { ok: false, cause: `execute_plan threw: ${e.message}` }; }
79
+ },
80
+ };
@@ -266,15 +266,18 @@ export function normalizeSearchResponse(body, echoQuery, matchMode) {
266
266
  };
267
267
  }
268
268
 
269
- // ── Search (with per-run dedup) ───────────────────────────────────────────────
270
- // The plugin runs in the long-lived gateway daemon, so this module-level Map persists across tool
271
- // calls within a run. A run issues the SAME search more than once (~12% of this build's baseline run
272
- // were exact-duplicate sweeps — the name sweep and the JP and CN transliteration sweeps, each issued twice),
273
- // invisible to telemetry because the dup counter watched record_fetch only. We cache the normalized
274
- // result keyed on the GATEWAY session key (per-run, unique → no cross-run collision) + the FULL
275
- // canonical upstream query tail (so a different page / field-set is NOT a dup). On an exact repeat we
276
- // return the byte-identical cached payload and meter it cache_hit:true (counted, billed-as-saved).
277
- // Floor-neutral: identical query+params ⇒ identical upstream results.
269
+ // ── Search (with a per-process, per-session dedup) ─────────────────────────────────────────────────
270
+ // This module-level Map lives as long as the process that loaded this module, and its key starts with
271
+ // the caller's session key. One register server is started per stage session (driver/engine/mcp/
272
+ // register-server.mjs), so it catches a repeat within one session, or within the driver's own calls under
273
+ // one session key. A question asked again by another stage, another axis or a repair dispatch reaches the
274
+ // register again: this is not a run-wide memory (providers/_shared/answer-memory.mjs holds that, for the
275
+ // registers it lists). A session does issue the SAME search more than once (~12% of an older build's
276
+ // baseline run were exact-duplicate sweeps — the name sweep and the JP and CN transliteration sweeps, each
277
+ // issued twice), invisible to telemetry because the dup counter watched record_fetch only. The key is the
278
+ // session key + the FULL canonical upstream query tail (so a different page / field-set is NOT a dup). On
279
+ // an exact repeat we return the byte-identical cached payload and meter it cache_hit:true (counted,
280
+ // billed-as-saved). Floor-neutral: identical query+params ⇒ identical upstream results.
278
281
  const SEARCH_CACHE = new Map();
279
282
  const SEARCH_CACHE_MAX = 2000; // bounded over daemon lifetime; eviction only ever costs a re-fetch, never recall.
280
283
 
@@ -295,7 +298,7 @@ export async function doSearch(sessionKey, params, tctx) {
295
298
  const fieldList = Array.isArray(params.fields) && params.fields.length > 0 ? params.fields : DEFAULT_SEARCH_FIELDS;
296
299
  urlParams.set("fieldsInclude", fieldList.join(","));
297
300
 
298
- // Dedup key: per-run scope (gateway sessionKey) + the exact canonical query tail actually sent
301
+ // Dedup key: the caller's session key + the exact canonical query tail actually sent
299
302
  // upstream (urlParams captures query+limit+page+sort+ascending+fieldsInclude after defaulting).
300
303
  const cacheKey = `${tctx?.sessionKey ?? ""}|${urlParams.toString()}`;
301
304
  const callTctx = { ...tctx, target: queryStr.slice(0, 200) };
@@ -439,7 +442,7 @@ export async function doExpandPhoneme(sessionKey, params, tctx) {
439
442
  // sign-off (the GATE) — so it is inert today.
440
443
 
441
444
  // The pure screening primitives now live in providers/_shared/screen.mjs (one implementation for every
442
- // provider); they are RE-EXPORTED here unchanged so every existing importer — engine/mcp/corsearch-server.mjs,
445
+ // provider); they are RE-EXPORTED here unchanged so every existing importer — src/mount.js,
443
446
  // register-plan.mjs, the driver — keeps resolving them from this module with identical semantics.
444
447
  // classifyStatus carries brand-json's vocabulary (Valid/Pending/GracePeriod live; Invalid/Expired dead;
445
448
  // anything else AMBIGUOUS → never auto-drop). BATCH_SCREEN_CHUNK = 100 matches the brand-json page size.
@@ -1,17 +1,12 @@
1
- #!/usr/bin/env node
2
1
  // SPDX-License-Identifier: AGPL-3.0-only
3
2
  // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
4
- // Standalone MCP server wrapping the corsearch CORE (pure node+fetch) so a `claude -p` process can
3
+ // The corsearch register's tools, as driver/engine/mcp/register-server.mjs mounts them, wrapping its CORE (pure node+fetch) so a `claude -p` process can
5
4
  // call the register-search tools off-gateway. Pure glue: the cores own all logic. Auth = CORSEARCH_SESSION_KEY
6
5
  // (the cookie). Telemetry: the cores write CLEAROTRON_REGISTER_CALL_LOG / CLEAROTRON_REGISTER_RECORD_LOG keyed by the GATEWAY
7
6
  // session key (tctx.sessionKey) — we thread the run's session key via CLEAROTRON_GATHER_SESSION_KEY so the
8
7
  // $0 provider-usage diff still attributes calls to the run.
9
- import { serve } from "./stdio-server.mjs";
10
- import { sendUntilFromEnv } from "../../../providers/_shared/send-until.mjs";
11
- import { crowdNoteFor } from "./crowd-note.mjs"; // how the unit decides on a crowd, beside an answer that carries one
12
- import { CAPABILITIES, doSearch, doRecordFetch, doImageFetch, doExpandPhoneme, doBatchScreen, doEnumerate, doExecutePlan } from "../../../providers/corsearch/src/core.js";
13
- import { proposeSupplemental } from "./supplemental.mjs";
14
- import { narrowingFields } from "./proposal-fields.mjs";
8
+ import { sendUntilFromEnv } from "../../_shared/send-until.mjs";
9
+ import { CAPABILITIES, doSearch, doRecordFetch, doImageFetch, doExpandPhoneme, doBatchScreen, doEnumerate, doExecutePlan } from "./core.js";
15
10
 
16
11
  const COOKIE = process.env.CORSEARCH_SESSION_KEY || "";
17
12
  const tctx = (kind) => ({
@@ -27,8 +22,8 @@ const guard = (fn) => async (args) => {
27
22
  return passthrough(await fn(args));
28
23
  };
29
24
 
30
- serve({
31
- name: "register", version: "0.2.0", noteFor: crowdNoteFor,
25
+ export const mount = ({ proposeSupplemental, narrowingFields }) => ({
26
+ version: "0.2.0",
32
27
  tools: [
33
28
  {
34
29
  name: "register_search",
@@ -19,10 +19,10 @@ nothing downstream can mistake one for the other. Set `production` explicitly.
19
19
 
20
20
  ## What reads it
21
21
 
22
- - `../../driver/driver.config.mjs` — the `euipo` provider entry, which lazily imports `src/core.js`
22
+ - `src/adapter.js` — the `euipo` provider entry, which lazily imports `src/core.js`
23
23
  for `recordFetch`, `countHits`, `listRecords` and `executePlan`. `credEnv` is `EUIPO_CLIENT_ID`
24
24
  with `EUIPO_CLIENT_SECRET` in `credEnvAlso`, so preflight checks the whole pair.
25
- - `../../driver/engine/mcp/euipo-server.mjs` — the model-facing surface, under the neutral
25
+ - `src/mount.js` — the model-facing surface, under the neutral
26
26
  `register_*` names. `register_expand_phoneme` is absent on purpose: the planner stamps a phonetic
27
27
  slice `unsupported` and it is disclosed as a deferred coverage row.
28
28
  - `../../driver/register-capabilities.mjs` — imports `src/capabilities.js` statically at module load,