clearotron 0.6.0 → 0.7.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 (110) hide show
  1. package/INSTALL.md +7 -4
  2. package/QUICKSTART.md +1 -0
  3. package/README.md +5 -2
  4. package/THIRD-PARTY-NOTICES.md +1 -1
  5. package/bin/clearotron.mjs +4 -2
  6. package/bin/onboard.mjs +158 -29
  7. package/build-info.json +2 -2
  8. package/docs/CLIENT-MCP.md +3 -1
  9. package/docs/DELIVERY.md +6 -3
  10. package/docs/architecture/02-architecture.md +1 -1
  11. package/docs/branding.md +4 -4
  12. package/docs/report-data/clearance-1.schema.json +320 -0
  13. package/docs/report-data/knockout-1.schema.json +268 -0
  14. package/driver/CHANGELOG.md +39 -0
  15. package/driver/connotation-search.mjs +1 -1
  16. package/driver/contract-e3-backlog.mjs +1 -1
  17. package/driver/coverage-ledger.mjs +18 -2
  18. package/driver/deferral-row.mjs +1 -1
  19. package/driver/degraded-parts.mjs +1 -0
  20. package/driver/driver.config.mjs +4 -3
  21. package/driver/effective-scope.mjs +3 -1
  22. package/driver/engagement-receipt.mjs +3 -3
  23. package/driver/engine/anthropic-agent.mjs +15 -1
  24. package/driver/engine/common.mjs +7 -0
  25. package/driver/engine/mcp/band-server.mjs +7 -16
  26. package/driver/engine/mcp/codex-config.mjs +3 -0
  27. package/driver/engine/mcp/recording-server.mjs +45 -34
  28. package/driver/engine/openai-agent.mjs +74 -7
  29. package/driver/gateway.mjs +67 -10
  30. package/driver/jx.mjs +13 -5
  31. package/driver/manuals-seen.mjs +146 -0
  32. package/driver/mark-logos.mjs +144 -0
  33. package/driver/methodology-witness.mjs +2 -1
  34. package/driver/owner-use-check.mjs +3 -3
  35. package/driver/package.json +1 -1
  36. package/driver/pipeline-knockout.mjs +4 -0
  37. package/driver/pipeline.mjs +92 -7
  38. package/driver/portal-local-auth.mjs +6 -2
  39. package/driver/portal-report.mjs +43 -12
  40. package/driver/portal-routes/me.mjs +4 -1
  41. package/driver/portal-runs.mjs +6 -9
  42. package/driver/profiles.mjs +4 -4
  43. package/driver/publish/README.md +9 -7
  44. package/driver/publish/email-conditions.mjs +2 -2
  45. package/driver/publish/evidence-words.mjs +21 -0
  46. package/driver/publish/index.mjs +104 -90
  47. package/driver/publish/knockout.mjs +75 -49
  48. package/driver/publish/office-record-links.mjs +11 -9
  49. package/driver/publish/page-shell.mjs +98 -0
  50. package/driver/publish/publish-inputs.mjs +4 -0
  51. package/driver/publish/regions.mjs +24 -3
  52. package/driver/publish/register-record.mjs +150 -0
  53. package/driver/publish/render-knockout.mjs +195 -642
  54. package/driver/publish/render.mjs +270 -363
  55. package/driver/publish/report-data.mjs +225 -12
  56. package/driver/publish/strings.mjs +662 -0
  57. package/driver/publish/templates/knockout.css +200 -0
  58. package/driver/publish/templates/report.css +72 -52
  59. package/driver/publish/xlsx.mjs +148 -125
  60. package/driver/record-goods.mjs +42 -0
  61. package/driver/reference-score.mjs +4 -1
  62. package/driver/register-reach.mjs +39 -0
  63. package/driver/registry-fidelity.mjs +3 -8
  64. package/driver/repair-composers.mjs +6 -2
  65. package/driver/repair-targets.mjs +4 -1
  66. package/driver/run-delivered.mjs +6 -1
  67. package/driver/runner.mjs +73 -29
  68. package/driver/scope-facts.mjs +27 -6
  69. package/driver/search-policy.mjs +9 -4
  70. package/driver/stages.mjs +3 -3
  71. package/driver/steps/overview-and-cards.mjs +50 -14
  72. package/driver/steps/verdict-gate.mjs +33 -13
  73. package/driver/suite-census.json +368 -68
  74. package/driver/terminal-clamp.mjs +6 -1
  75. package/mcp-server/CHANGELOG.md +4 -0
  76. package/mcp-server/lib/audit-view.mjs +5 -2
  77. package/mcp-server/lib/brief.mjs +2 -1
  78. package/mcp-server/lib/evidence.mjs +31 -4
  79. package/mcp-server/lib/knockout.mjs +1 -1
  80. package/mcp-server/lib/scrub.mjs +1 -1
  81. package/mcp-server/package.json +1 -1
  82. package/mcp-server/server.mjs +5 -3
  83. package/package.json +4 -1
  84. package/portal-ui/dist/assets/{index-CYaO2ygd.js → index-CtkllKJ2.js} +225 -77
  85. package/portal-ui/dist/assets/{index-izLa9apq.css → index-CxAkJXIT.css} +25 -5
  86. package/portal-ui/dist/index.html +2 -2
  87. package/portal-ui/package.json +3 -3
  88. package/providers/_shared/ledger.mjs +30 -2
  89. package/providers/_shared/record-uri.mjs +15 -0
  90. package/providers/clarivate/src/adapter.js +11 -0
  91. package/providers/clarivate/src/core.js +17 -1
  92. package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
  93. package/providers/oauth-mcp-bridge/package.json +1 -1
  94. package/scripts/README.md +147 -3
  95. package/scripts/e2e-first-time.mjs +3 -3
  96. package/scripts/freeze-example-run.mjs +3 -3
  97. package/scripts/mint-search-level-tags.mjs +61 -0
  98. package/scripts/mint-source-pin-census.mjs +89 -0
  99. package/scripts/release-note-required.mjs +65 -6
  100. package/scripts/test-durations-reporter.mjs +25 -0
  101. package/scripts/test-full.mjs +72 -18
  102. package/scripts/test-run.mjs +18 -1
  103. package/shared/brand.mjs +85 -5
  104. package/shared/inline-markdown.mjs +53 -0
  105. package/shared/portal-tokens.mjs +2 -1
  106. package/shared/register-selection.mjs +8 -3
  107. package/shared/search-level-tags.json +25 -0
  108. package/shared/tools/derive-band-pairs.mjs +10 -0
  109. package/driver/own-rights.mjs +0 -83
  110. package/driver/use-check.mjs +0 -85
@@ -40,7 +40,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from
40
40
  import { basename, join } from "node:path";
41
41
 
42
42
  export async function runOverviewAndCards({ P, applyCoverageFloor, clampOnTheWritersDuty, ctx, followTheRecordsActions, job, run, runState, saveTheLabel, writeVerdictSidecar }, helpers) {
43
- const { StageFailure, applyScopeFrontMatterOf, asPartNotCompleted, assembleReportMd, caseLawJoin, consolidateFindingsFile, correctionsTheRestoreLacks, deriveCommonLawCarry, deriveRecordCarry, inScopeClassList, injectDeferralCoverage, injectFrontMatter, injectLaneDepthCoverage, injectMeaningGapCoverage, injectScreenGateCoverage, injectScriptScopeCoverage, keepDeliveredRecordAsHistory, localLanguageStateOf, must, openAskForClosure, originRowsForReport, planWriteUps, readFindingsForReport, readReadingLog, rebuildDeliveredRecord, reportIdentityRecord, restoreTheRecordThatPassed, rewriteFromBeforeTheSeam, runBatched, safeReadJson, settleDerivedBases, stage, stampCoverageJudgmentRows, withdrawSupersededAudit, writeScopeFactsOf, writeShortEntries } = helpers;
43
+ const { StageFailure, applyScopeFrontMatterOf, asPartNotCompleted, assembleReportMd, caseLawJoin, consolidateFindingsFile, correctionsTheRestoreLacks, deriveCommonLawCarry, deriveRecordCarry, inScopeClassList, injectDeferralCoverage, injectFrontMatter, injectLaneDepthCoverage, injectMeaningGapCoverage, injectScreenGateCoverage, injectScriptScopeCoverage, injectUncoveredMarketCoverage, keepDeliveredRecordAsHistory, localLanguageStateOf, must, openAskForClosure, originRowsForReport, planWriteUps, readFindingsForReport, readReadingLog, rebuildDeliveredRecord, reportIdentityRecord, restoreTheRecordThatPassed, rewriteFromBeforeTheSeam, safeReadJson, settleDerivedBases, stage, stampCoverageJudgmentRows, withdrawSupersededAudit, writeScopeFactsOf, writeShortEntries } = helpers;
44
44
  // Phase 3 — delivery (v14 post-mortem fix). One LLM step curates the report; the audit, the page render,
45
45
  // and the email body are deterministic CODE; a tiny LLM step only SENDS. Each step is independent — a
46
46
  // failure in the audit or the email never loses the report.
@@ -93,6 +93,9 @@ export async function runOverviewAndCards({ P, applyCoverageFloor, clampOnTheWri
93
93
  // mark+uri). The CONDITIONAL clamp came from applyCoverageFloor's screenGateGap arm above, never
94
94
  // from these coverage-limited rows.
95
95
  injectScreenGateCoverage(P, run.runDir, note, ctx);
96
+ // The fifth: every market the register service does not reach gets a "Not searched" row, written by code
97
+ // (register-reach.mjs); the coverage line names the same markets.
98
+ injectUncoveredMarketCoverage(P, run.runDir, note, ctx);
96
99
  // — the fourth sibling, and the one that REPLACES rather than adds: coverage_judgment.rows
97
100
  // is derived from the machine ledger and the plan-execution receipt instead of retyped by the seat.
98
101
  // Same seam and same reason as injectDeferralCoverage above — every synthesis re-run has settled, so
@@ -167,8 +170,30 @@ export async function runOverviewAndCards({ P, applyCoverageFloor, clampOnTheWri
167
170
  reportIdentityRecord(job, ctx, run.runDir, runState.displayVerdict)));
168
171
  runLog(run.runDir, { event: "overview-not-completed-delivery", stage: overviewOpen.stage ?? null });
169
172
  }
170
- const rov = overviewOpen ? null
171
- : await asPartNotCompleted("overview", async () => must(await stage("report-overview", { ...ctx, displayVerdict: runState.displayVerdict }, {}), "report-overview")); // T3a: a BLOCKING run now DELIVERS; its open points are rendered at assembly, not dispatched here
173
+ // ── THE OVERVIEW AND THE CARDS RUN TOGETHER, UNDER ONE CAP ──────────────────────────────────────
174
+ //
175
+ // The cards waited for the overview to finish, and neither reads the other's output: the overview reads the
176
+ // narrative and the findings and writes only its prose and its accepted call (report-overview-record.mjs), and a
177
+ // card reads its finding and the case-law join. Measured on 18 production clearances: the first card started a
178
+ // median 0.9 minutes after the overview, which was the overview's own wall. So the overview starts here and the
179
+ // cards start beside it; nothing below until the join reads anything the overview writes.
180
+ //
181
+ // ONE CAP FOR THE STEP. The overview holds one of `cardConcurrency`'s sessions while it runs, so the engine never
182
+ // sees more of this step's sessions at once than it did, and with a cap of 1 the step runs serially as before.
183
+ //
184
+ // THE CARDS SETTLE BEFORE THE OVERVIEW'S OUTCOME IS READ. An overview that fails, a usage limit included, is raised
185
+ // at the join exactly as it was raised before the cards, after every card in flight has settled: no card is
186
+ // abandoned mid-call, and each card that landed is file-gated, so a resume skips it. A card set the overview's
187
+ // failure interrupted reads on resume as the same partial set a card-side limit leaves.
188
+ let free = config.cardConcurrency;
189
+ const waiting = [];
190
+ const withSession = async (fn) => {
191
+ if (free > 0) free -= 1; else await new Promise((r) => waiting.push(r));
192
+ try { return await fn(); } finally { const next = waiting.shift(); if (next) next(); else free += 1; }
193
+ };
194
+ const overviewDone = overviewOpen ? Promise.resolve(null)
195
+ : withSession(() => asPartNotCompleted("overview", async () => must(await stage("report-overview", { ...ctx, displayVerdict: runState.displayVerdict }, {}), "report-overview"))); // T3a: a BLOCKING run now DELIVERS; its open points are rendered at assembly, not dispatched here
196
+ overviewDone.catch(() => {}); // read at the join below; never an unhandled rejection while the cards run
172
197
  const findingsRead = readFindingsForReport(P);
173
198
  const findingsForCards = findingsRead.findings;
174
199
  //: a rejected findings.json is a defect, not an emptiness. Say so HERE, where the file was read,
@@ -216,7 +241,7 @@ export async function runOverviewAndCards({ P, applyCoverageFloor, clampOnTheWri
216
241
  // A2 — cards are isolated BY DESIGN (each sees ONLY its own finding and writes its own
217
242
  // P.reportCard(ord) file), so they fan out like the gather members instead of paying 8–14 serial
218
243
  // LLM walls. The first card runs alone to warm the shared prompt-prefix cache; the rest batch at
219
- // gatherConcurrency. A failed card stays non-fatal (render shows it structured-only) and never
244
+ // `config.cardConcurrency` (CLEAROTRON_CARD_CONCURRENCY), shared with the overview while it runs. A failed card stays non-fatal (render shows it structured-only) and never
220
245
  // fails a sibling — renderCard resolves on rc.fail, it never throws. assembleReportMd runs
221
246
  // strictly after every card settles; the lint-repair re-render loop below stays serial.
222
247
  const cardFindings = findingsForCards.filter((f) => cardOrdinals.includes(f.ordinal)); // secondary findings render structured-only (no LLM call)
@@ -236,16 +261,27 @@ export async function runOverviewAndCards({ P, applyCoverageFloor, clampOnTheWri
236
261
  }
237
262
  note(`report-card[${f.ordinal}] failed (non-fatal — render shows it structured-only): ${rc.fail}`);
238
263
  };
239
- if (cardFindings.length) await renderCard(cardFindings[0]);
240
- // — THE ONE SETTING ALLOWED TO FALL BACK IS NOT ALLOWED TO DO IT QUIETLY. Every
241
- // other numeric setting refuses a value it cannot parse, by name, at the read. This one is read
242
- // mid-run and is not grade-moving, so refusing would turn a delivering search into a refusal over an
243
- // operator's typo — the run continues on the default instead. It says so here, once, in the run's own
244
- // record: a fallback nobody can see is how a deployment ends up running on a number nobody chose,
245
- // which is the same defect one register quieter.
246
- const cardCapNote = fallbackNoteFor("CLEAROTRON_CARD_CONCURRENCY");
247
- if (cardCapNote) note(`[config] ${cardCapNote}`);
248
- await runBatched(cardFindings.slice(1), config.cardConcurrency, renderCard);
264
+ // The warm-up card still runs alone among the cards, beside the overview only.
265
+ let cardsThrew = null;
266
+ try {
267
+ if (cardFindings.length) await withSession(() => renderCard(cardFindings[0]));
268
+ // — THE ONE SETTING ALLOWED TO FALL BACK IS NOT ALLOWED TO DO IT QUIETLY. Every
269
+ // other numeric setting refuses a value it cannot parse, by name, at the read. This one is read
270
+ // mid-run and is not grade-moving, so refusing would turn a delivering search into a refusal over an
271
+ // operator's typo — the run continues on the default instead. It says so here, once, in the run's own
272
+ // record: a fallback nobody can see is how a deployment ends up running on a number nobody chose,
273
+ // which is the same defect one register quieter.
274
+ const cardCapNote = fallbackNoteFor("CLEAROTRON_CARD_CONCURRENCY");
275
+ if (cardCapNote) note(`[config] ${cardCapNote}`);
276
+ // Every card settles, even when one throws, so none is left running behind the join.
277
+ const settled = await Promise.allSettled(cardFindings.slice(1).map((f) => withSession(() => renderCard(f))));
278
+ const threw = settled.find((r) => r.status === "rejected");
279
+ if (threw) throw threw.reason;
280
+ } catch (e) { cardsThrew = e; }
281
+ // THE JOIN. The overview's failure first, as when it ran before the cards; then a card that threw; then the cards'
282
+ // usage limits, collected over the fan-out.
283
+ const rov = await overviewDone;
284
+ if (cardsThrew) throw cardsThrew;
249
285
  if (cardRateLimited.length) {
250
286
  const earliest = cardRateLimited.map((c) => c.resetsAt).filter(Boolean).sort()[0] ?? null;
251
287
  runLog(run.runDir, { event: "report-cards-rate-limited", count: cardRateLimited.length,
@@ -26,6 +26,32 @@ import { clauseForDefect, gapPositivelyClosed, jointUnaccounted, orderClausesFor
26
26
  import { countCitedDefects, parseCorrections, parseVerdict } from "../verify.mjs";
27
27
  import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
28
28
 
29
+ /**
30
+ * THE COVERAGE FLOOR'S CONDITIONS, as run-record reasons and the client's clause for each, in the order the floor
31
+ * records them. PURE: the gate reads the receipts and hands their contents in.
32
+ *
33
+ * Every clause the floor composes itself is `null`: the reason stays in the run record and verdict.json, and the
34
+ * client's conditions get nothing in its place. These sentences are the engine's account of its own steps, and a
35
+ * client reads the list as the conditions on their result, so they are not ours to write (owner, 2026-09-17; ruled
36
+ * 2026-09-18 for the screen-gate line and for the class, engineering words come out of client text with nothing
37
+ * written in their place; ruled 2026-10-13 for the frame comparison). "The lawyer judged a material
38
+ * slice not fully cleared" read as a human lawyer's judgment, and "slice", "this run" and "(policy: clamp)" are
39
+ * engine words. The register lines are the exception: registerGapConditions carries clauses the owner ruled.
40
+ *
41
+ * @returns {{reason: string, clause: string|null}[]}
42
+ */
43
+ export function coverageFloorConditions({ coverageInsufficient = false, coverageReason = null, frameGap = false, frameDeferrals = [],
44
+ screenGateUnresolved = [], seniorUnverified = null, registerRows = [] } = {}) {
45
+ const out = [];
46
+ if (coverageInsufficient) out.push({ reason: `the lawyer judged a material slice not fully cleared: ${coverageReason || "register coverage gap"}`, clause: null });
47
+ if (frameGap) out.push({ reason: "the blind frame-diff flagged a dominant-element omission the reopen pass did not close", clause: null });
48
+ else if (frameDeferrals.length) out.push({ reason: `follow-ups left open this run: ${frameDeferrals.map((d) => plainDirective(d.directive)).slice(0, 3).join(", ")}`, clause: null });
49
+ if (screenGateUnresolved.length) out.push({ reason: `${screenGateUnresolved.length} in-scope mark(s) dropped on goods could not be record_fetched (unverified): ${screenGateUnresolved.map((g) => g.mark).join(", ")}`, clause: null });
50
+ if (seniorUnverified) out.push({ reason: `the oldest registration in a verdict-driving family could not be retrieved (policy: clamp): ${seniorUnverified.map((r) => r.mark).join(", ")}`, clause: null });
51
+ for (const { reason, clause } of registerRows) out.push({ reason, clause });
52
+ return out;
53
+ }
54
+
29
55
  export async function runVerdictGate({ P, agent, applyVerdictFrontMatter, correctiveCycleSettled, correctiveEntryVerdict, correctiveRecheckOk, coverageJudgment, ctx, opts, run, runState }, helpers) {
30
56
  const { StageFailure, actionsRegisterListed, conditionsFollowingTheRecord, defaultRecordFetcher, enrichFindingDeadlines, lateRecordsUnaddressed, loadCoverageLedger, loadScreenGateUnresolved, owedUrisFor, planAuditExtra, refusedRecordsLeftOut, registerGapConditions, safeReadJson, saveWithRetries, stage, withdrawByToken } = helpers;
31
57
  // U1 — coverage-honesty floor (Appendix A tripwire #2). The reviewer verdict is empirically noisy
@@ -598,19 +624,13 @@ export async function runVerdictGate({ P, agent, applyVerdictFrontMatter, correc
598
624
  // here and refused: the objection was the class, not the wording. RULED 2026-09-18, design item
599
625
  // 25 — cut the clause: it stays in the run record and leaves the client's result entirely, with
600
626
  // NOTHING written in its place. That is what the `null` clause below means.
601
- const reasons = [], clauseOf = new Map(); // run-record reason → the client's clause: the same words, with any engine token taken out
602
- const machinery = (reason, clause = reason) => { reasons.push(reason); clauseOf.set(reason, clause); };
603
- if (coverageInsufficient) machinery(`the lawyer judged a material slice not fully cleared: ${coverageJudgment.reason || "register coverage gap"}`);
604
- // The frame comparison's reason is the engine's account of its own steps: it stays in the run record, and the
605
- // client's conditions get nothing in its place (ruled 2026-10-13, as the screen-gate line below).
606
- if (frameGap) machinery("the blind frame-diff flagged a dominant-element omission the reopen pass did not close", null);
607
- else if (frameDeferrals.length) machinery(`follow-ups left open this run: ${frameDeferrals.map((d) => plainDirective(d.directive)).slice(0, 3).join(", ")}`);
608
- if (screenGateGap) machinery(`${sgUnresolved.length} in-scope mark(s) dropped on goods could not be record_fetched (unverified): ${sgUnresolved.map((g) => g.mark).join(", ")}`, null); // run record ONLY: no client clause (ruled 2026-09-18)
609
- if (seniorGap) machinery(`the oldest registration in a verdict-driving family could not be retrieved (policy: clamp): ${(ctx.seniorRights?.rows ?? []).filter((r) => r.applicable && !r.verified).map((r) => r.mark).join(", ")}`);
610
- if (registerGap) {
611
- for (const { reason, clause } of registerGapConditions(regGap)) machinery(reason, clause);
612
- // (the deferred and cut-down register lines: registerGapConditions, at the end of this file)
613
- }
627
+ const floor = coverageFloorConditions({
628
+ coverageInsufficient, coverageReason: coverageJudgment.reason, frameGap, frameDeferrals,
629
+ screenGateUnresolved: screenGateGap ? sgUnresolved : [],
630
+ seniorUnverified: seniorGap ? (ctx.seniorRights?.rows ?? []).filter((r) => r.applicable && !r.verified) : null,
631
+ registerRows: registerGap ? registerGapConditions(regGap) : [],
632
+ });
633
+ const reasons = floor.map((c) => c.reason), clauseOf = new Map(floor.map((c) => [c.reason, c.clause])); // run-record reason → the client's clause; null = the run record's alone
614
634
  // ── THE THIRD CLAMP SITE NAMES ITSELF, AND NAMES WHICH OF ITS SIX INPUTS FIRED ────────────────
615
635
  //
616
636
  // All three clamp sites emitted this event under one name with the same from/to, distinguishable