clearotron 0.6.0 → 0.7.0-beta.1

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 (146) 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/architecture/04-configuration-reference.md +105 -8
  12. package/docs/branding.md +4 -4
  13. package/docs/report-data/clearance-1.schema.json +320 -0
  14. package/docs/report-data/knockout-1.schema.json +268 -0
  15. package/driver/CHANGELOG.md +77 -0
  16. package/driver/cancel.mjs +19 -0
  17. package/driver/connotation-search.mjs +1 -1
  18. package/driver/contract-e3-backlog.mjs +41 -41
  19. package/driver/contract-vocabulary.mjs +1 -1
  20. package/driver/coverage-ledger.mjs +18 -2
  21. package/driver/deferral-row.mjs +1 -1
  22. package/driver/degraded-parts.mjs +1 -0
  23. package/driver/driver.config.mjs +5 -5
  24. package/driver/effective-scope.mjs +3 -1
  25. package/driver/engagement-receipt.mjs +3 -3
  26. package/driver/engine/anthropic-agent.mjs +15 -1
  27. package/driver/engine/common.mjs +7 -0
  28. package/driver/engine/mcp/band-server.mjs +7 -16
  29. package/driver/engine/mcp/codex-config.mjs +3 -0
  30. package/driver/engine/mcp/recording-server.mjs +45 -34
  31. package/driver/engine/openai-agent.mjs +74 -7
  32. package/driver/engine/session-record.mjs +44 -2
  33. package/driver/findings-model.mjs +14 -2
  34. package/driver/follow-up-twins.mjs +86 -0
  35. package/driver/gateway.mjs +77 -12
  36. package/driver/jx-units.mjs +3 -1
  37. package/driver/jx.mjs +13 -5
  38. package/driver/manuals-inline.mjs +98 -0
  39. package/driver/manuals-seen.mjs +134 -0
  40. package/driver/mark-logos.mjs +174 -0
  41. package/driver/methodology-witness.mjs +2 -1
  42. package/driver/owner-use-check.mjs +8 -4
  43. package/driver/package.json +1 -1
  44. package/driver/pipeline-knockout.mjs +23 -4
  45. package/driver/pipeline.mjs +128 -15
  46. package/driver/portal-local-auth.mjs +6 -2
  47. package/driver/portal-report.mjs +45 -14
  48. package/driver/portal-routes/me.mjs +4 -1
  49. package/driver/portal-runs.mjs +19 -16
  50. package/driver/predelivery-lint.mjs +7 -5
  51. package/driver/profiles.mjs +4 -4
  52. package/driver/publish/README.md +9 -7
  53. package/driver/publish/email-conditions.mjs +22 -5
  54. package/driver/publish/evidence-words.mjs +21 -0
  55. package/driver/publish/index.mjs +304 -211
  56. package/driver/publish/knockout.mjs +297 -247
  57. package/driver/publish/office-record-links.mjs +11 -9
  58. package/driver/publish/page-shell.mjs +98 -0
  59. package/driver/publish/pool-admin.mjs +2 -2
  60. package/driver/publish/publish-inputs.mjs +4 -0
  61. package/driver/publish/regions.mjs +28 -3
  62. package/driver/publish/register-record-html.mjs +105 -0
  63. package/driver/publish/register-record.mjs +165 -0
  64. package/driver/publish/render-knockout.mjs +299 -671
  65. package/driver/publish/render.mjs +561 -492
  66. package/driver/publish/report-data.mjs +226 -13
  67. package/driver/publish/report-document.mjs +353 -0
  68. package/driver/publish/search-depth.mjs +88 -7
  69. package/driver/publish/shell.mjs +41 -1
  70. package/driver/publish/strings.mjs +810 -0
  71. package/driver/publish/templates/clearance-print.css +23 -0
  72. package/driver/publish/templates/knockout.css +224 -0
  73. package/driver/publish/templates/report.css +112 -53
  74. package/driver/publish/xlsx.mjs +158 -139
  75. package/driver/record-goods.mjs +42 -0
  76. package/driver/reference-score.mjs +4 -1
  77. package/driver/register-count.mjs +5 -1
  78. package/driver/register-reach.mjs +39 -0
  79. package/driver/registry-fidelity.mjs +155 -37
  80. package/driver/repair-composers.mjs +7 -3
  81. package/driver/repair-targets.mjs +4 -1
  82. package/driver/replay-archive.mjs +4 -3
  83. package/driver/run-delivered.mjs +14 -8
  84. package/driver/run-record.mjs +1 -0
  85. package/driver/runner.mjs +73 -29
  86. package/driver/scope-facts.mjs +27 -6
  87. package/driver/search-policy.mjs +9 -4
  88. package/driver/skills/clearance-search/report-prose.md +3 -0
  89. package/driver/skills/knockout-assess/SKILL.md +8 -0
  90. package/driver/stage-freshness.mjs +8 -5
  91. package/driver/stages.mjs +69 -43
  92. package/driver/steps/delivery.mjs +9 -5
  93. package/driver/steps/overview-and-cards.mjs +54 -15
  94. package/driver/steps/register-sweep.mjs +5 -4
  95. package/driver/steps/skeptic-and-follow-up.mjs +3 -2
  96. package/driver/steps/verdict-gate.mjs +35 -14
  97. package/driver/suite-census.json +579 -87
  98. package/driver/synthesis-record.mjs +4 -3
  99. package/driver/terminal-clamp.mjs +6 -1
  100. package/driver/withdrawn-rating.mjs +72 -0
  101. package/mcp-server/CHANGELOG.md +8 -0
  102. package/mcp-server/lib/audit-view.mjs +5 -2
  103. package/mcp-server/lib/brief.mjs +6 -2
  104. package/mcp-server/lib/evidence.mjs +94 -23
  105. package/mcp-server/lib/findings.mjs +19 -2
  106. package/mcp-server/lib/knockout.mjs +13 -4
  107. package/mcp-server/lib/scrub.mjs +1 -1
  108. package/mcp-server/package.json +1 -1
  109. package/mcp-server/server.mjs +22 -3
  110. package/package.json +4 -1
  111. package/portal-ui/dist/assets/{index-CYaO2ygd.js → index-BBlN4CYq.js} +238 -80
  112. package/portal-ui/dist/assets/{index-izLa9apq.css → index-CxAkJXIT.css} +25 -5
  113. package/portal-ui/dist/index.html +2 -2
  114. package/portal-ui/package.json +3 -3
  115. package/providers/_shared/ledger.mjs +30 -2
  116. package/providers/_shared/record-uri.mjs +15 -0
  117. package/providers/clarivate/src/adapter.js +11 -0
  118. package/providers/clarivate/src/core.js +17 -1
  119. package/providers/jx/src/core.js +4 -4
  120. package/providers/jx/src/judge.js +1 -3
  121. package/providers/jx/src/nativeread.js +1 -3
  122. package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
  123. package/providers/oauth-mcp-bridge/package.json +1 -1
  124. package/scripts/README.md +147 -3
  125. package/scripts/added-reference-check.mjs +35 -7
  126. package/scripts/e2e-first-time.mjs +4 -4
  127. package/scripts/env-audit.mjs +16 -9
  128. package/scripts/freeze-example-run.mjs +3 -3
  129. package/scripts/mint-public-residue.mjs +3 -3
  130. package/scripts/mint-search-level-tags.mjs +61 -0
  131. package/scripts/mint-source-pin-census.mjs +89 -0
  132. package/scripts/release-note-required.mjs +65 -6
  133. package/scripts/test-durations-reporter.mjs +25 -0
  134. package/scripts/test-full.mjs +72 -18
  135. package/scripts/test-run.mjs +18 -1
  136. package/shared/brand.mjs +93 -6
  137. package/shared/inline-markdown.mjs +53 -0
  138. package/shared/names-in-force.mjs +0 -1
  139. package/shared/portal-tokens.mjs +2 -1
  140. package/shared/reference-guard-classes.mjs +43 -2
  141. package/shared/register-selection.mjs +8 -3
  142. package/shared/search-level-tags.json +25 -0
  143. package/shared/source-spans.mjs +91 -0
  144. package/shared/tools/derive-band-pairs.mjs +10 -0
  145. package/driver/own-rights.mjs +0 -83
  146. package/driver/use-check.mjs +0 -85
@@ -60,6 +60,7 @@ import { runLog } from "./log.mjs"; // what the transport read a call as goes
60
60
  import { pageNameLines, stepPartyNames, textNamesParty } from "./predelivery-lint.mjs"; // a step's parties, read as the reference check reads them
61
61
  import { recordOriginsOr, blankOnRepeat, recordBlanking, FOREIGN_HOST_TOKEN } from "./foreign-record-links.mjs"; // a foreign record link: refused once, then blanked
62
62
  import { driverDir, paths, readJson } from "./run-record.mjs";
63
+ import { followUpKindsOf } from "./follow-up-twins.mjs"; // the search each deferred directive recorded
63
64
  export const NARRATIVE_FILE = "narrative.md";
64
65
  export const FINDINGS_FILE = "findings.json";
65
66
 
@@ -965,7 +966,7 @@ export function mergeSynthesisPatch(stored, patch, { positions = null } = {}) {
965
966
  * `stored` and `saved` are the findings documents before and after the save. Returns `{actions, kept}`: `kept` names
966
967
  * each step held, as `{id, ordinals}`, and `actions` is the saved list with those steps' citations put back.
967
968
  */
968
- export function stepsOnWithdrawnSupport(stored, saved) {
969
+ export function stepsOnWithdrawnSupport(stored, saved, followUpKinds = null) {
969
970
  const actions = saved?.actions;
970
971
  if (!Array.isArray(actions) || !Array.isArray(stored?.actions)) return { actions, kept: [] };
971
972
  const rows = Array.isArray(saved?.findings) ? saved.findings : [];
@@ -976,7 +977,7 @@ export function stepsOnWithdrawnSupport(stored, saved) {
976
977
  .filter((t) => typeof t === "string" && t.trim()).join("\n");
977
978
  const coverage = Array.isArray(saved?.coverage) ? saved.coverage : [];
978
979
  const openRows = coverage.filter((c) => c?.state === "open").map((c) => `${c.area ?? ""} ${c.note ?? ""}`).join("\n");
979
- const introduced = [...pageNameLines({ coverage }), parties(rows.filter((f) => f?.disposition !== "withdrawn"))].join("\n");
980
+ const introduced = [...pageNameLines({ coverage, followUpKinds }), parties(rows.filter((f) => f?.disposition !== "withdrawn"))].join("\n");
980
981
  const withdrawnOnly = parties(rows.filter((f) => f?.disposition === "withdrawn"));
981
982
  const identifies = (a) => {
982
983
  const names = stepPartyNames(a);
@@ -1206,7 +1207,7 @@ export function recordSynthesis(runDir, received, opts = {}) {
1206
1207
  call = merged.merged;
1207
1208
  }
1208
1209
  // A STEP WHOSE ONLY SUPPORT WAS WITHDRAWN keeps its citations when the save sends it back with none (`stepsOnWithdrawnSupport`).
1209
- const held = stored ? stepsOnWithdrawnSupport(stored.findings, call?.findings) : { kept: [] };
1210
+ const held = stored ? stepsOnWithdrawnSupport(stored.findings, call?.findings, followUpKindsOf(runDir)) : { kept: [] };
1210
1211
  if (held.kept.length) call = { ...call, findings: { ...call.findings, actions: held.actions } };
1211
1212
 
1212
1213
  // A RECORD LINK ON A HOST THIS REGISTER DOES NOT PUBLISH is gated here as verify.mjs gates the saved
@@ -113,8 +113,13 @@ export const ENGINE_TOKEN_RE = /\b\w+_\w+(?::\d+)?\b/;
113
113
  * sidecar, because the token shape above has no underscore to find in it. Kept to the coined names, measured
114
114
  * on every stored clause and reason of the saved runs: only that sentence matched. A phrase list over client
115
115
  * text can eat a real mark, so this one withholds a condition and never rewrites one.
116
+ *
117
+ * The coverage floor's three other sentences joined it on 2026-11-18: "the lawyer judged a material slice not fully
118
+ * cleared", "follow-ups left open this run" and "(policy: clamp)", which the floor now stores with no clause. Measured
119
+ * the same day over 234 stored verdicts, 231 on the test, pre-production and production installs and 3 in the demos:
120
+ * the three phrases matched 89 stored texts, and every one was one of those three sentences.
116
121
  */
117
- export const ENGINE_PHRASE_RE = /\b(?:frame[- ]diff|blind frame|re-?open(?:ing)? pass|frame[- ]reopen)\b/i;
122
+ export const ENGINE_PHRASE_RE = /\b(?:frame[- ]diff|blind frame|re-?open(?:ing)? pass|frame[- ]reopen|material slice not fully cleared|follow-ups left open this run)\b|\(policy: clamp\)/i;
118
123
 
119
124
  /** Does a condition's text carry the engine's words? ONE test, read by every reader of a condition. PURE. */
120
125
  export const carriesEngineWords = (text) => ENGINE_TOKEN_RE.test(String(text ?? "")) || ENGINE_PHRASE_RE.test(String(text ?? ""));
@@ -0,0 +1,72 @@
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
+ //
4
+ // A RIGHT WHOSE RATING WAS WITHDRAWN STAYS ON THE PAGE, AS LEFT OPEN. The review can withdraw a finding whose right
5
+ // still stands, because the rating it carried cannot be supported: its goods wording could not be used. Such a
6
+ // finding keeps `disposition: "withdrawn"`, so no card, total, logo or summary counts it as rated, and it says so with
7
+ // `rating_withdrawn_ground` (findings-model.mjs RATING_WITHDRAWN_GROUNDS). Before that field, the right left the
8
+ // delivered page with the findings the review rejected, and the overview's optional Methodology note was the only
9
+ // place a writer could still mention it, a note the page does not show.
10
+ //
11
+ // Here each such finding becomes one "Open item" coverage row, written by code the way the native-script rows are:
12
+ // the finding as the report names it, and the approved sentence for its ground. The row reaches every surface that
13
+ // reads `coverage[]`. A finding the review rejected (no ground) writes nothing, as before.
14
+ //
15
+ // THE SENTENCE IS THE OWNER'S, word for word, and follows the right's identifying detail under "Left open". A ground with no
16
+ // approved sentence writes no row: the reader is never shown words nobody approved, and the finding stays where it was.
17
+ import { existsSync, readFileSync } from "node:fs";
18
+ import { parseFindingsJson } from "./findings-model.mjs";
19
+ import { writeFindings } from "./stage-freshness.mjs";
20
+ import { runLog } from "./log.mjs";
21
+
22
+ /** The sentence each ground's row carries, as the owner approved it (2026-11-19); a ground with none writes no row. */
23
+ export const WITHDRAWN_RATING_NOTES = Object.freeze({
24
+ "goods-wording-unavailable": "We could not rate this earlier right because we could not verify which goods its record covers.",
25
+ });
26
+
27
+ /** The finding as the report names one: its mark, its owner and the territories of its registrations. PURE. */
28
+ export function withdrawnRatingArea(f) {
29
+ const mark = String(f?.mark ?? "").trim();
30
+ const owner = String(f?.owner?.name ?? "").trim();
31
+ const where = [...new Set((f?.owner?.registrations ?? []).map((r) => String(r?.jurisdiction ?? "").trim()).filter(Boolean))];
32
+ return `${mark}${owner ? ` — ${owner}` : ""}${where.length ? ` (${where.join(", ")})` : ""}`;
33
+ }
34
+
35
+ /**
36
+ * The Left open rows a findings record owes for its withdrawn ratings, one per finding, in ordinal order. PURE.
37
+ * @param {object} doc the findings record
38
+ * @param {Record<string, string|null>} [notes] each ground's approved sentence
39
+ * @returns {{area: string, state: "open", note: string}[]}
40
+ */
41
+ export function withdrawnRatingRows(doc, notes = WITHDRAWN_RATING_NOTES) {
42
+ return (Array.isArray(doc?.findings) ? doc.findings : [])
43
+ .filter((f) => f?.disposition === "withdrawn" && typeof notes[f?.rating_withdrawn_ground] === "string"
44
+ && notes[f.rating_withdrawn_ground].trim() && String(f?.mark ?? "").trim())
45
+ .sort((a, b) => (a.ordinal ?? 0) - (b.ordinal ?? 0))
46
+ .map((f) => ({ area: withdrawnRatingArea(f), state: "open", note: notes[f.rating_withdrawn_ground] }));
47
+ }
48
+
49
+ /**
50
+ * Writes the rows `withdrawnRatingRows` owes into findings.json. Idempotent by area and note, so a resume or a second
51
+ * pass after a findings rewrite never doubles a row. Never throws: a failure is noted and recorded for the audit, as
52
+ * every coverage adder's is, and the run goes on.
53
+ */
54
+ export function injectWithdrawnRatingCoverage(P, runDir, note, { notes = WITHDRAWN_RATING_NOTES } = {}) {
55
+ try {
56
+ if (!existsSync(P.findings)) return;
57
+ const doc = JSON.parse(readFileSync(P.findings, "utf8"));
58
+ if (!Array.isArray(doc.coverage)) doc.coverage = [];
59
+ const owed = withdrawnRatingRows(doc, notes)
60
+ .filter((r) => !doc.coverage.some((c) => String(c?.area ?? "") === r.area && String(c?.note ?? "") === r.note));
61
+ if (!owed.length) return;
62
+ doc.coverage.push(...owed);
63
+ parseFindingsJson(JSON.stringify(doc)); // re-validate the shape (throws → catch keeps original)
64
+ writeFindings(runDir, doc, { why: "withdrawn-rating-coverage-rows", settles: [] });
65
+ note(`[withdrawn-rating] wrote ${owed.length} Left open row(s) for right(s) that stand with their rating withdrawn`);
66
+ } catch (e) {
67
+ const fail = String(e?.message || e).replace(/\s+/g, " ");
68
+ note(`[withdrawn-rating] coverage injection skipped: ${fail.slice(0, 100)}`);
69
+ try { runLog(runDir, { event: "coverage-row-not-added", adder: "withdrawn-rating", fail: fail.slice(0, 200) }); }
70
+ catch { /* the note above still stands */ }
71
+ }
72
+ }
@@ -1,5 +1,13 @@
1
1
  # trademark-artifacts-mcp
2
2
 
3
+ ## 0.7.0-beta.1
4
+
5
+ No changes in this release.
6
+
7
+ ## 0.7.0-beta.0
8
+
9
+ No changes in this release.
10
+
3
11
  ## 0.6.0
4
12
 
5
13
  No changes in this release.
@@ -110,9 +110,12 @@ export function scrubBlocks(items) {
110
110
  */
111
111
  export function accountFinding(f) {
112
112
  if (!f || typeof f !== "object") return f;
113
- const [only] = scrubBlocks([f]);
113
+ // The register's own goods wording is held apart from the scrub: it is the register's text, copied, and every
114
+ // scrub pass rewrites (lib/evidence.mjs, the second exception). A withdrawn block refuses before it travels.
115
+ const { goodsAsRegistered, ...block } = f;
116
+ const [only] = scrubBlocks([block]);
114
117
  if (!only) throw new Error(`finding "${f.id ?? "?"}" was withdrawn during the run and does not appear in the delivered record`);
115
- return only;
118
+ return goodsAsRegistered ? { ...only, goodsAsRegistered } : only;
116
119
  }
117
120
 
118
121
  /** list_findings on the raw path — {source, kind, items}. The cards path never reaches here. */
@@ -33,6 +33,7 @@ import { join } from "node:path";
33
33
  import { parseReport } from "./driver.mjs";
34
34
  import { readReportData, productIdentityFor } from "./runs.mjs";
35
35
  import { readJson, readJsonOrNull } from "../../driver/run-record.mjs";
36
+ import { reportDocumentOf } from "./findings.mjs"; // the run's report document, where it has one
36
37
 
37
38
  // THE LINE FOR A SCREENED NAME WITH NO DATA FILE, beside its report link: the brief cannot read its rating, and says so
38
39
  // rather than leaving the name out. Design's wording (2026-11-11), printed only where the name's report was published.
@@ -75,12 +76,15 @@ function clearanceLine(f) {
75
76
  */
76
77
  export function buildBrief(run) {
77
78
  const { P } = run;
78
- const fm = existsSync(P.report) ? parseReport(P.report).fm : {};
79
+ // The report's front matter as publishing parsed it, where the run's document holds it (findings.mjs reportDocumentOf).
80
+ const prose = reportDocumentOf(P)?.prose;
81
+ const fm = prose ? prose.frontMatter : existsSync(P.report) ? parseReport(P.report).fm : {};
79
82
  const docs = readReportData(run);
80
83
  const product = productIdentityFor(run, docs);
81
84
  const clearance = docs.find((d) => d?.kind === "clearance") ?? null;
82
85
  // The knockout shape carries no `kind` at all and is told apart by `marks[]` — the same discrimination
83
- // portal-service.mjs makes. Both lanes stamp `schema: 'report-data/1'`, so the schema string cannot.
86
+ // portal-service.mjs makes. The schema string names the shape on new runs (`report-data/clearance-1`,
87
+ // `report-data/knockout-1`), but runs stored before that carry `report-data/1` for both, so the shape decides.
84
88
  const koDocs = docs.filter((d) => d?.kind !== "clearance" && Array.isArray(d?.marks));
85
89
  // A NAME WHOSE DATA FILE COULD NOT BE WRITTEN IS STILL A NAME SCREENED. A Knockout batch publishes every name's
86
90
  // report when one name's data file fails, and lists that name in meta.reports with no data file. Read from the
@@ -31,26 +31,30 @@
31
31
  // `coverage_judgment.reason` is NOT forwarded: render.mjs gates it `!CLIENT` as engine wording, so it stays
32
32
  // internal here too.
33
33
  //
34
+ // THE SECOND EXCEPTION, ruled 2026-11-18: a cited register record's goods in the register's own words. The report
35
+ // now prints a registration's goods in English, or the vendor's machine translation marked as one, and points a
36
+ // reader who wants the original wording to their assistant. So get_finding carries, for the one register record
37
+ // its block names, the goods as the register holds them (registrationGoods below). It is the REGISTER's text,
38
+ // copied from the record the run saved, never the firm's: no scrub pass touches it, because each one rewrites.
39
+ // Only a record a delivered block names is read, one file, never the archive at large.
40
+ //
34
41
  // AND THE LESSON THE CORPUS ADDED (see valueField): "structured field" is not a synonym for "safe value".
35
42
  // A model free-typing into `classes:` welded an engine clause onto a class list. Structured KEYS are the
36
43
  // allowlist; structured VALUES still have to be recognised, not trusted.
37
44
 
38
- import { existsSync } from "node:fs";
45
+ import { existsSync, readFileSync } from "node:fs";
39
46
  import { join } from "node:path";
40
47
  import { parseAudit, stripEngineInternals } from "./driver.mjs";
41
- import { readRecordArtifacts } from "../../driver/registry-fidelity.mjs";
48
+ import { readRecordArtifacts, normalizeRecordUri } from "../../driver/registry-fidelity.mjs";
49
+ import { recordGoodsAsRegistered } from "../../driver/record-goods.mjs";
42
50
  import { readJson } from "../../driver/run-record.mjs";
51
+ import { reportDocumentOf } from "./findings.mjs"; // the run's report document, where it has one
52
+ import { REPORT_PAGE } from "../../driver/publish/strings.mjs";
43
53
 
44
- // The client report's own display word per coverage state (publish/render.mjs COV_STATE). Carried here so
45
- // the connector and the PDF call the same state the same thing; a state absent from the map degrades to
46
- // its raw token rather than being dropped (an unknown state is still a fact about the run).
47
- const COV_WORD = {
48
- "confirmed-clean": "Searched — clean",
49
- "coverage-limited": "Partially covered",
50
- open: "Open item",
51
- "not-searched": "Not run this run",
52
- note: "Note",
53
- };
54
+ // The client report's own display word per coverage state, read from the catalogue the report reads, so the
55
+ // connector and the PDF call the same state the same thing; a state absent from the map degrades to its raw
56
+ // token rather than being dropped (an unknown state is still a fact about the run).
57
+ const COV_WORD = REPORT_PAGE.coverageStates;
54
58
 
55
59
  // The coverage-note transform, chosen to MATCH the client report's own rendering of these exact strings
56
60
  // rather than to be maximally strict — scrub.mjs's warning applies in full here: "a scrubber stricter than
@@ -152,13 +156,21 @@ export function evidenceRecords(run) {
152
156
  // storefront page) came back `false`, which the account SKILL.md reads as "rests on the write-up, not on
153
157
  // a fetched record". Telling a client their real evidence is unverified is the exact inverse of the
154
158
  // safeguard's purpose, so the question is only asked where the archive can answer it.
155
- const retrievedFor = (layer, url) => {
159
+ //
160
+ //
161
+ // A FINDING NAMES ITS RECORDS BY ITS REGISTRATIONS TOO, not only by its link. A register finding with no link of its
162
+ // own still lists the record URIs it rests on, and a record the run fetched and saved under one of them was retrieved:
163
+ // reading the link alone told a client's assistant that a fetched record rested on the write-up. One saved record is
164
+ // enough for `true`, which says the finding has retrieved evidence, not that every registration it names was fetched.
165
+ //
166
+ // A RECORD IS MATCHED BY ITS WHOLE IDENTITY, office and number. The link was matched as a substring either way round,
167
+ // so a link to a registration whose number only began with a saved one's read as retrieved, and so would a short
168
+ // fragment of a saved record's path.
169
+ const retrievedFor = (layer, url, registrations = []) => {
156
170
  if (layer !== "register") return null; // not a question this archive can answer
157
171
  if (!archived.size) return null; // no archive on this run — unknown, not false
158
- if (!url) return false;
159
- const u = String(url).toLowerCase();
160
- for (const uri of archived.keys()) if (u.includes(uri) || uri.includes(u)) return true;
161
- return false;
172
+ if (registrations.some((r) => archived.has(normalizeRecordUri(r)))) return true;
173
+ return url ? archived.has(normalizeRecordUri(url)) : false;
162
174
  };
163
175
 
164
176
  // The provenance signal that DOES span both layers, straight out of findings.json's own contract:
@@ -208,17 +220,19 @@ export function evidenceRecords(run) {
208
220
  const mark = typeof f?.mark === "string" ? f.mark.trim() : "";
209
221
  if (!mark) continue;
210
222
  const url = asUrl(f?.source?.resolved_link); // — shape, not type
223
+ // A run records each registration as its record URI, `{uri}`; an older one wrote the string itself.
224
+ const registrations = Array.isArray(f?.owner?.registrations)
225
+ ? f.owner.registrations.map((r) => (typeof r === "string" ? r : r?.uri)).filter((r) => typeof r === "string" && r) : [];
211
226
  records.set(`${normMark(mark)}|${normOwner(f?.owner?.name)}`, {
212
227
  mark,
213
228
  layer: layerOf(f?.source?.source_type),
214
229
  owner: valueField(f?.owner?.name),
215
230
  ownerCountry: valueField(f?.owner?.country),
216
- registrations: Array.isArray(f?.owner?.registrations)
217
- ? f.owner.registrations.filter((r) => typeof r === "string") : [],
231
+ registrations,
218
232
  classes: [], // findings.json carries no class list; the audit block below may
219
233
  status: null,
220
234
  url,
221
- retrieved: retrievedFor(layerOf(f?.source?.source_type), url),
235
+ retrieved: retrievedFor(layerOf(f?.source?.source_type), url, registrations),
222
236
  basis: basisOf(f),
223
237
  // The FLAG, never the reason. publish/audit-from-spine.mjs documents the copper-gantry defect:
224
238
  // shipping an asserted claim beside its refutation with nothing saying which won. Omitting the
@@ -434,7 +448,9 @@ function outcomeOf(result) {
434
448
  export function searchLog(run) {
435
449
  const { P } = run;
436
450
  let blocks = [];
437
- try { blocks = existsSync(P.audit) ? (parseAudit(P.audit).negatives ?? []) : []; } catch { blocks = []; }
451
+ // audit.md's search log as publishing parsed it, where the run's document holds it (findings.mjs reportDocumentOf).
452
+ const parsed = reportDocumentOf(P)?.reviewer?.audit;
453
+ try { blocks = parsed ? (parsed.negatives ?? []) : existsSync(P.audit) ? (parseAudit(P.audit).negatives ?? []) : []; } catch { blocks = []; }
438
454
  const searches = blocks.map((b, i) => {
439
455
  const raw = deMarkup(typeof b.search_term === "string" ? b.search_term : "");
440
456
  return {
@@ -465,8 +481,12 @@ export function searchLog(run) {
465
481
  * surface that is meant to match the client report must not out-disclose it.
466
482
  */
467
483
  export function coverageStatement(run) {
468
- const doc = readFindingsJson(run.runDir);
469
- const areas = (Array.isArray(doc?.coverage) ? doc.coverage : []).map((c) => ({
484
+ // THE DELIVERED ROWS, where the run has its report document: the rows the page prints, an exact repeat printed once and
485
+ // a run whose assessment did not complete answered from its own coverage record. findings.json for a run published
486
+ // before the document.
487
+ const delivered = reportDocumentOf(run.P)?.client?.coverage;
488
+ const rows = Array.isArray(delivered) ? delivered : readFindingsJson(run.runDir)?.coverage;
489
+ const areas = (Array.isArray(rows) ? rows : []).map((c) => ({
470
490
  area: clean(c?.areaLabel || c?.area), // — the reader label the report prints, falling back to the identifier on an archived row
471
491
  state: typeof c?.state === "string" ? c.state : null,
472
492
  stateLabel: COV_WORD[c?.state] ?? (typeof c?.state === "string" ? c.state : null),
@@ -479,3 +499,54 @@ export function coverageStatement(run) {
479
499
  : "This run records no coverage ledger.",
480
500
  };
481
501
  }
502
+
503
+ // ---- a finding's registrations, as the report delivered them ---------------------------------------
504
+
505
+ /**
506
+ * The registration facts the report delivered for one audit block, from the run's report document: the finding that cites
507
+ * the record the block names, its owner as the page binds it, and each registration it cites, kept apart, with the classes,
508
+ * status and dates the page shows for it. The owner's country is the saved record's, as the page's register record states
509
+ * it. null where the run has no document, the block names no register record, or no delivered finding cites it, so a run
510
+ * published before the document answers from its audit.md as it always did.
511
+ */
512
+ export function deliveredRegistration(run, block) {
513
+ const uri = normalizeRecordUri(block?.url ?? "");
514
+ const findings = uri ? reportDocumentOf(run?.P)?.client?.findings : null;
515
+ if (!Array.isArray(findings)) return null;
516
+ const uriOf = (r) => normalizeRecordUri(typeof r === "string" ? r : r?.uri);
517
+ const finding = findings.find((f) => (Array.isArray(f?.owner?.registrations) ? f.owner.registrations : []).some((r) => uriOf(r) === uri));
518
+ if (!finding) return null;
519
+ const registrations = finding.owner.registrations.filter((r) => uriOf(r)).map((r) => ({
520
+ registration: uriOf(r),
521
+ classes: Array.isArray(r?.classes) ? r.classes.map(String) : [],
522
+ status: typeof r?.status === "string" ? r.status : null,
523
+ filed: typeof r?.filed === "string" ? r.filed : null,
524
+ expiry: typeof r?.expiry === "string" ? r.expiry : null,
525
+ }));
526
+ const record = run?.runDir ? readRecordArtifacts(run.runDir).get(uri) : null;
527
+ return {
528
+ finding: finding.ordinal ?? null,
529
+ owner: valueField(finding.owner?.name),
530
+ ownerCountry: valueField(record?.ownerCountry) ?? valueField(finding.owner?.country),
531
+ registration: registrations.find((r) => r.registration === uri),
532
+ registrations,
533
+ };
534
+ }
535
+
536
+ // ---- a cited record's goods, as the register holds them ------------------------------------------
537
+
538
+ /**
539
+ * The goods of the ONE register record a finding's block names, as the register holds them: {registration,
540
+ * statements} or null. `url` is the block's own link; only a register record URI resolves, and only to the file
541
+ * the run saved for it (named as driver/registry-fidelity.mjs writeRecordArtifacts names it). Nothing here
542
+ * reads the archive at large, so nothing the delivered record does not name can be reached.
543
+ */
544
+ export function registrationGoods(run, url) {
545
+ const uri = normalizeRecordUri(url ?? "");
546
+ if (!uri || !run?.runDir) return null;
547
+ const name = uri.replace(/^\/mark\//, "").replace(/[^a-z0-9]+/gi, "-") + ".json";
548
+ let body;
549
+ try { body = JSON.parse(readFileSync(join(run.runDir, "_records", name), "utf8")); } catch { return null; }
550
+ const statements = recordGoodsAsRegistered(body);
551
+ return statements.length ? { registration: uri, statements } : null;
552
+ }
@@ -45,7 +45,22 @@ function parseAuditText(md) {
45
45
  }
46
46
 
47
47
  // { findings, negatives, audit, source } — never throws; empty lists + source:"none" if nothing parseable.
48
+ /**
49
+ * The run's report document (driver/publish/report-document.mjs) when the run has one of this product's kind, else null.
50
+ * A run published before the document existed has none, and its readers read the run's files as they always did.
51
+ */
52
+ export function reportDocumentOf(P, kind = "clearance") {
53
+ try {
54
+ if (!P?.reportDocument || !existsSync(P.reportDocument)) return null;
55
+ const doc = readJson(P.reportDocument);
56
+ return doc?.document === `report-document/${kind}-1` ? doc : null;
57
+ } catch { return null; }
58
+ }
59
+
48
60
  export function loadFindings(P) {
61
+ // audit.md as publishing parsed it, where the run's document holds it: the same parse, so the same lists and ids.
62
+ const parsed = reportDocumentOf(P)?.reviewer?.audit;
63
+ if (parsed) return { ...idStamp(parsed), source: "audit.md" };
49
64
  if (existsSync(P.audit)) {
50
65
  try { return { ...idStamp(parseAudit(P.audit)), source: "audit.md" }; } catch { /* fall through to backstop */ }
51
66
  }
@@ -90,9 +105,11 @@ export function filterFindings(P, { kind, sourceLayer } = {}) {
90
105
 
91
106
  // The curated client-report cards: group (on-field/off-field/out-of-scope) + the read + the source URL.
92
107
  export function loadCards(P) {
93
- if (!existsSync(P.report)) return { fm: {}, cards: [], note: "report.md not present" };
108
+ // report.md as publishing parsed it, where the run's document holds it.
109
+ const prose = reportDocumentOf(P)?.prose;
110
+ if (!prose && !existsSync(P.report)) return { fm: {}, cards: [], note: "report.md not present" };
94
111
  try {
95
- const { fm, cards } = parseReport(P.report);
112
+ const { fm, cards } = prose ? { fm: prose.frontMatter, cards: prose.cards } : parseReport(P.report);
96
113
  return {
97
114
  fm,
98
115
  cards: cards.map((c) => ({
@@ -46,7 +46,11 @@ export function isKnockoutRun(run) {
46
46
 
47
47
  /** The assessment artifact, parsed. `null` when the run has not reached the assess stage (or it failed). */
48
48
  export function knockoutDoc(run) {
49
- return run?.runDir ? readJsonOrNull(koPaths(run.runDir).findings) : null;
49
+ if (!run?.runDir) return null;
50
+ // The findings record as publishing held it, where the run's report document has it; the run's own file otherwise.
51
+ const document = readJsonOrNull(paths(run.runDir).reportDocument);
52
+ if (document?.document === "report-document/knockout-1" && document.client?.findings) return document.client.findings;
53
+ return readJsonOrNull(koPaths(run.runDir).findings);
50
54
  }
51
55
 
52
56
  const marksOf = (doc) => (Array.isArray(doc?.marks) ? doc.marks : []);
@@ -328,8 +332,13 @@ export function knockoutCoverage(run) {
328
332
  + `${(m.findings ?? []).length} conflict(s) recorded, ${(m.negatives ?? []).length} search(es) recorded as returning nothing.`,
329
333
  }));
330
334
 
331
- const recordsDoc = readJsonOrNull(koPaths(run.runDir).registerRecords);
332
- const countsDoc = readJsonOrNull(koPaths(run.runDir).registerCounts);
335
+ // THE DELIVERED EDITION (2026-11-19): the register record and counts the report was published with, where the run's
336
+ // report document holds them. A resume after publishing can settle more in the run's files; those stay evidence, and
337
+ // the report's coverage answer is the one it delivered. The run's files for a run published before the document.
338
+ const document = readJsonOrNull(paths(run.runDir).reportDocument);
339
+ const delivered = document?.document === "report-document/knockout-1" ? document.client : null;
340
+ const recordsDoc = delivered ? delivered.registerRecords : readJsonOrNull(koPaths(run.runDir).registerRecords);
341
+ const countsDoc = delivered ? delivered.registerCounts : readJsonOrNull(koPaths(run.runDir).registerCounts);
333
342
  if (recordsDoc || countsDoc) {
334
343
  areas.push({
335
344
  area: "Register",
@@ -341,7 +350,7 @@ export function knockoutCoverage(run) {
341
350
  } else {
342
351
  areas.push({
343
352
  area: "Register",
344
- state: "Not run this run",
353
+ state: "Not searched",
345
354
  detail: "This run has no register component — the assessment rests on the common-law and marketplace sweep.",
346
355
  });
347
356
  }
@@ -11,7 +11,7 @@
11
11
  // connector: a signed-in client ACCOUNT can also reach the run's EVIDENCE — the records considered and the
12
12
  // searches run — which the report narrates but does not enumerate. That is deliberately more than the PDF,
13
13
  // because a lawyer defending a filing decision needs the records, and it is bounded by a different
14
- // mechanism (a structured-field projection, never prose) in lib/evidence.mjs. Read that file's header
14
+ // mechanism (a structured-field projection, never the firm's prose; a cited record's goods travel in the register's own words) in lib/evidence.mjs. Read that file's header
15
15
  // before widening anything here; the line it draws is evidence vs METHOD, and method stays sealed.
16
16
  // publish/render.mjs no longer renders a Methodology section to the client (the 2026-09-16 report redesign) and
17
17
  // deliberately names the register provider (provenance honesty, receipts, enforcement telemetry). A scrubber
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trademark-artifacts-mcp",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-beta.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": true,
6
6
  "description": "MCP server to interrogate clearotron trademark-clearance runs — list/read artifacts, trace the full decision flow, telemetry/cost, coverage, single-run search, and a gated single-step what-if. Imports the clearotron-driver read-only; touches no driver/template/deploy files.",
@@ -80,7 +80,7 @@ import { authorize, visibleTools, USER_ARTIFACTS, ACCOUNT_ARTIFACTS, accountMayR
80
80
  import { accountRun, accountTrace, accountTimeline, accountFinding, accountFindingList,
81
81
  accountWhatIfPlan, accountWhatIfQueued, accountWhatIfResult, CLIENT_FAILURE_NOTE as clientFailureNote } from "./lib/audit-view.mjs";
82
82
  import { scrubMarkdown, scrubBody, scrubFrontMatter, scrubCards } from "./lib/scrub.mjs";
83
- import { evidenceRecords, searchLog, coverageStatement } from "./lib/evidence.mjs";
83
+ import { evidenceRecords, searchLog, coverageStatement, registrationGoods, deliveredRegistration } from "./lib/evidence.mjs";
84
84
  // The knockout lane's projections. Every audit tool below branches on `isKnockoutRun` because the
85
85
  // clearance projections read artifacts this product does not write, and returned empty rather than saying
86
86
  // so.
@@ -262,6 +262,12 @@ function channelState(runDir) {
262
262
 
263
263
  // ---- tool implementations ----------------------------------------------------------------------
264
264
 
265
+ /** Whether an audit block's "Filed …; Expiry …" line states the delivered registration's dates, "—" standing for none. */
266
+ function sameDates(line, { filed, expiry }) {
267
+ const at = (word) => { const v = String(line ?? "").match(new RegExp(`${word}\\s+([^;]+)`, "i"))?.[1]?.trim(); return v && v !== "—" ? v : null; };
268
+ return at("Filed") === (filed ?? null) && at("Expiry") === (expiry ?? null);
269
+ }
270
+
265
271
  const tools = {
266
272
  // / AGPL §13. One line, because the answer is not this file's to compose: shared/product-identity.mjs
267
273
  // is the single place all three network faces read, so the portal's About page, this tool and the CLI
@@ -438,7 +444,20 @@ const tools = {
438
444
  const run = mustRun(runId);
439
445
  const f = getFinding(run.P, id);
440
446
  if (!f) throw new Error(`finding "${id}" not found in ${runId}. Use list_findings to see ids (F#, NR#, AT#).`);
441
- return f;
447
+ // THE REPORT'S FINDING (2026-11-19): where the run's report document delivered the record this block names, its
448
+ // owner, classes, status and dates are the delivered ones, and each registration the finding cites is listed apart.
449
+ // The id stays the block's. A run published before the document answers from its audit.md (lib/evidence.mjs).
450
+ const delivered = deliveredRegistration(run, f);
451
+ const answer = delivered ? {
452
+ ...f, owner: delivered.owner ?? f.owner, owner_country: delivered.ownerCountry ?? f.owner_country,
453
+ classes: delivered.registration.classes.join(", ") || f.classes, status: delivered.registration.status ?? f.status,
454
+ dates: sameDates(f.dates, delivered.registration) ? f.dates
455
+ : [delivered.registration.filed && `Filed ${delivered.registration.filed}`, delivered.registration.expiry && `Expiry ${delivered.registration.expiry}`].filter(Boolean).join("; ") || f.dates,
456
+ registrations: delivered.registrations,
457
+ } : f;
458
+ // The register record this block names, its goods in the register's own words (lib/evidence.mjs).
459
+ const goods = registrationGoods(run, f.url);
460
+ return goods ? { ...answer, goodsAsRegistered: goods } : answer;
442
461
  },
443
462
  trace({ runId, target, depth, shallow }) {
444
463
  const run = mustRun(runId);
@@ -662,7 +681,7 @@ const TOOL_DEFS = [
662
681
  { name: "read_artifact", description: "Read a run artifact's raw text (or one '# Section', or its front-matter). For briefing a person, the report is the plain-language layer; the rest are internal working documents. Names: report, audit, narrative, registerFindings, commonLaw, placement, matterContext, variantManifest, skepticFlags, seniorEyeReview, caseLaw, clientSummary (internal cover-note source; ops only), a register axis (e.g. primary-sweep), status.json, run.jsonl.", inputSchema: { type: "object", properties: { ...runIdProp, name: { type: "string" }, section: { type: "string", description: "Return only this '# Section'." }, frontMatterOnly: { type: "boolean" } }, required: ["runId", "name"] } },
663
682
  { name: "list_evidence", description: "The records this search considered — every register and common-law entry, including ones the report does not name individually. Each carries the mark, owner and country, the classes, the register status, the source link, whether the provider record was actually retrieved (`retrieved`), and `superseded: true` if a later pass withdrew it. Use this to answer 'what exactly did you find, and who owns it?'. Filter with layer: register | common-law.", inputSchema: { type: "object", properties: { ...runIdProp, layer: { type: "string", enum: ["register", "common-law"] } }, required: ["runId"] } },
664
683
  { name: "list_searches", description: "What the search looked for and where — the searches that came back empty as well as the ones that surfaced something. Each row carries the term, the match shapes tried (exact, fuzzy, phonetic, transliteration…), the classes and jurisdictions, the register office where one was named, and the outcome (no-hit | found | out-of-scope | screened-out | excluded-own-rights | negligible). This is the defensibility record: proof of where the search looked and found nothing. Filter by outcome.", inputSchema: { type: "object", properties: { ...runIdProp, outcome: { type: "string", enum: ["no-hit", "found", "out-of-scope", "screened-out", "excluded-own-rights", "negligible", "recorded"] } }, required: ["runId"] } },
665
- { name: "get_search_coverage", description: "What the search covered and what is still open, in the report's own words — each area with its state (Searched — clean / Partially covered / Open item / Not run this run). An area that is not clean is NOT cleared: read it as open. Reach for this whenever a result looks clean and the user is about to rely on it.", inputSchema: { type: "object", properties: { ...runIdProp }, required: ["runId"] } },
684
+ { name: "get_search_coverage", description: "What the search covered and what is still open, in the report's own words — each area with its state (Searched — clean / Partially covered / Open item / Not searched). An area that is not clean is NOT cleared: read it as open. Reach for this whenever a result looks clean and the user is about to rely on it.", inputSchema: { type: "object", properties: { ...runIdProp }, required: ["runId"] } },
666
685
  { name: "list_findings", description: "Structured findings from the deterministic audit. kind: findings (default) | negatives | audit (audit-trail). Filter by sourceLayer (Register/Common-law). Pass group (on-field/off-field/out-of-scope) to get the curated report cards instead — the cards' one-liners are already plain-language.", inputSchema: { type: "object", properties: { ...runIdProp, kind: { type: "string", enum: ["findings", "negatives", "audit"] }, sourceLayer: { type: "string" }, group: { type: "string", enum: ["on-field", "off-field", "out-of-scope"] } }, required: ["runId"] } },
667
686
  { name: "get_finding", description: "One finding/negative/audit-trail record by id (F#, NR#, AT#).", inputSchema: { type: "object", properties: { ...runIdProp, id: { type: "string" } }, required: ["runId", "id"] } },
668
687
  { name: "trace", description: "ENGINEERING/AUDIT view — HOW a conclusion was reached; use only when the user asks how/why, not for briefing findings. Walks the full logic flow from any target (a stage, an artifact name, a finding id, or 'verdict') back through the stage that emitted it (and whether a failover occurred), its inputs (with sha-at-consumption vs now), the audit-trail rationale, search terms + record URL, skeptic escalations, and the refutation verdict. Pass shallow:true for a fast skeleton (stage→input lineage + verdict only; skips the findings rebuild and the live provider-usage tally).", inputSchema: { type: "object", properties: { ...runIdProp, target: { type: "string", description: "stage | artifact | finding id (F#/NR#/AT#) | 'verdict' | a mark/owner substring" }, depth: { type: "number", description: "upstream recursion depth (default 2)" }, shallow: { type: "boolean", description: "Fast skeleton: lineage + verdict only, skipping the slow enrichments. Use when a full trace is slow or you only need the chain." } }, required: ["runId", "target"] } },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "clearotron",
3
3
  "mcpName": "io.github.CordilleraSarl/clearotron",
4
4
  "type": "module",
5
- "version": "0.6.0",
5
+ "version": "0.7.0-beta.1",
6
6
  "license": "AGPL-3.0-only",
7
7
  "repository": {
8
8
  "type": "git",
@@ -130,6 +130,9 @@
130
130
  "driver/skills/clearance-search/worked-examples.md",
131
131
  "driver/skills/clearance-search/worked-examples-demo.md",
132
132
  "!scripts/secret-scanner-fetch.mjs",
133
+ "!scripts/measure-test-durations.mjs",
134
+ "!scripts/count-manual-pins.mjs",
135
+ "!scripts/test-durations.json",
133
136
  "!scripts/home-render-check.mjs",
134
137
  "!scripts/ai-page-render-check.mjs",
135
138
  "!scripts/composer-render-check.mjs",