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
@@ -41,7 +41,7 @@
41
41
  --accent-gradient: linear-gradient(90deg, #860F09, #4E030F, #AE5B58); /* JUDGED: composed from the three locked palette crimsons — no new hue */
42
42
  --border-hairline: #E4DACA; /* brand --line */
43
43
  --border-strong: #D8CCB8; /* brand --line2 */
44
- --focus-ring: #860F09; /* brand --crimson */
44
+ --focus-ring: #860F09; /* brand --crimson; dark takes the dark --text-accent, since crimson on the dark page is too faint to see a focus by */
45
45
  --font-body: 'Plus Jakarta Sans','Helvetica Neue',system-ui,sans-serif; /* brand --font */
46
46
  --font-mono: 'Fira Code',ui-monospace,monospace; /* brand --mono */
47
47
  --shadow-lg: 0 1px 2px rgba(37,9,2,.05), 0 10px 30px rgba(37,9,2,.07); /* brand --shadow */
@@ -79,7 +79,7 @@
79
79
  --accent-gradient: linear-gradient(90deg, #860F09, #4E030F, #AE5B58); /* JUDGED: composed from the three locked palette crimsons — no new hue */
80
80
  --border-hairline: #322c24; /* brand --line */
81
81
  --border-strong: #3d362c; /* brand --line2 */
82
- --focus-ring: #860F09; /* brand --crimson */
82
+ --focus-ring: #e0736b; /* brand --crimson; dark takes the dark --text-accent, since crimson on the dark page is too faint to see a focus by */
83
83
  --font-body: 'Plus Jakarta Sans','Helvetica Neue',system-ui,sans-serif; /* brand --font */
84
84
  --font-mono: 'Fira Code',ui-monospace,monospace; /* brand --mono */
85
85
  --shadow-lg: 0 1px 2px rgba(0,0,0,.4),0 10px 30px rgba(0,0,0,.55); /* brand --shadow */
@@ -771,7 +771,7 @@ button.twisty:focus {
771
771
  }
772
772
 
773
773
  button.twisty:focus-visible {
774
- outline: 2px solid var(--accent);
774
+ outline: 2px solid var(--focus-ring);
775
775
  outline-offset: 1px;
776
776
  }
777
777
 
@@ -886,6 +886,17 @@ table.data td.nest-2 {
886
886
  @media (max-width: 560px) {
887
887
  .names-wrap { overflow-x: auto; position: relative; }
888
888
  }
889
+ /* THE EMPTY-LIST SENTENCE STAYS INSIDE THE FRAME. Its cell spans every column, so below 560px it is as
890
+ wide as the table's 860px floor, and the sentence ran past the wrapper's right edge: measured at 390 to
891
+ 400px it read "… Pick another company" until the reader dragged the table. It now wraps at the
892
+ wrapper's width (the container measured above) and holds the wrapper's left edge while the table
893
+ scrolls under it. At desktop widths the table fits its wrapper and neither rule moves anything. */
894
+ .names-wrap .list-empty {
895
+ display: block;
896
+ position: sticky;
897
+ left: 12px;
898
+ max-width: calc(100cqi - 24px);
899
+ }
889
900
  /* Eight pixels either side instead of twelve, on every column but the two narrow ones at the left: the
890
901
  actions column takes a quarter of the table, and the text columns keep their words on one line by
891
902
  giving up padding rather than width. The date and the actions give up a little more. */
@@ -1040,7 +1051,7 @@ button.row-open:hover {
1040
1051
  }
1041
1052
  button.row-open:focus-visible,
1042
1053
  button.row-menu-btn:focus-visible {
1043
- outline: 2px solid var(--accent);
1054
+ outline: 2px solid var(--focus-ring);
1044
1055
  outline-offset: 1px;
1045
1056
  }
1046
1057
  .row-menu {
@@ -1133,6 +1144,15 @@ button.row-menu-item {
1133
1144
  color: var(--text-muted);
1134
1145
  }
1135
1146
 
1147
+ /* The Clearances list's tags under a name: one small pill per kind of search behind it, on a line of their
1148
+ own so they never crowd the name, wrapping inside the Name cell at every width. */
1149
+ .level-tags {
1150
+ display: flex;
1151
+ flex-wrap: wrap;
1152
+ gap: 4px;
1153
+ margin-top: 5px;
1154
+ }
1155
+
1136
1156
  /* The larger pill, for a control that is a card's closing action rather than a label — and an anchor
1137
1157
  drawn as one, which is what opening a document in a new tab is. */
1138
1158
  .pill-lg {
@@ -1261,7 +1281,7 @@ input[type='checkbox'].pickbox {
1261
1281
  }
1262
1282
 
1263
1283
  input[type='checkbox'].pickbox:focus-visible {
1264
- outline: 2px solid var(--accent);
1284
+ outline: 2px solid var(--focus-ring);
1265
1285
  outline-offset: 2px;
1266
1286
  }
1267
1287
 
@@ -36,8 +36,8 @@
36
36
  chosen anywhere in the product holds everywhere in it.
37
37
  -->
38
38
  <script>(function(){try{var t=localStorage.getItem('cordillera-theme');if(t==='dark'||t==='light')document.documentElement.setAttribute('data-theme',t);}catch(e){}})();</script>
39
- <script type="module" crossorigin src="/portal/assets/index-CYaO2ygd.js"></script>
40
- <link rel="stylesheet" crossorigin href="/portal/assets/index-izLa9apq.css">
39
+ <script type="module" crossorigin src="/portal/assets/index-CtkllKJ2.js"></script>
40
+ <link rel="stylesheet" crossorigin href="/portal/assets/index-CxAkJXIT.css">
41
41
  </head>
42
42
  <body>
43
43
  <div id="root"></div>
@@ -2,7 +2,7 @@
2
2
  "name": "portal-ui",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "0.6.0",
5
+ "version": "0.7.0-beta.0",
6
6
  "license": "AGPL-3.0-only",
7
7
  "description": "The unified trademark portal UI. One address, one login: who you are decides what you see. Built as a static bundle, served by driver/portal-service.mjs — the browser never reaches profile-service or recipe-service.",
8
8
  "engines": {
@@ -22,8 +22,8 @@
22
22
  "devDependencies": {
23
23
  "@types/react": "^19.3.0",
24
24
  "@types/react-dom": "^19.3.0",
25
- "@vitejs/plugin-react": "^6.2.1",
25
+ "@vitejs/plugin-react": "^6.3.0",
26
26
  "typescript": "^7.0.2",
27
- "vite": "^8.3.6"
27
+ "vite": "^8.3.8"
28
28
  }
29
29
  }
@@ -33,6 +33,7 @@ import { appendFileSync, mkdirSync, statSync, openSync, readSync, closeSync, rea
33
33
  import { dirname, basename } from "node:path";
34
34
  import { createHash } from "node:crypto";
35
35
  import { ledgerPath, RUN_RECORD_LOG_FILE } from "./ledger-path.mjs";
36
+ import { normalizeRecordUri } from "./record-uri.mjs";
36
37
 
37
38
  export const CALL_LOG_PATH = ledgerPath("call");
38
39
  // Spec A1 (citation fidelity): every fetched record's BODY is persisted alongside the call ledger, so the
@@ -135,7 +136,7 @@ export function makeLedger(provider) {
135
136
  //
136
137
  // Run-scoped ledgers only. The box-wide fallback file holds many runs, and a record one run fetched is not
137
138
  // a record another run holds.
138
- const RUN_INDEXES = new Map(); // dest → { offset, byTarget: Map<key, { hash, refreshed, ts, start, len }>, byGuid: Map<guid, key> }
139
+ const RUN_INDEXES = new Map(); // dest → { offset, byTarget: Map<key, { hash, refreshed, ts, start, len }>, byGuid: Map<guid, key>, withBody: Map<record key, { start, len }> }
139
140
  const targetKey = (t) => String(t ?? "").toLowerCase(); // the key every reader of this file matches on
140
141
  const bodyHash = (b) => createHash("sha1").update(JSON.stringify(b ?? null)).digest("hex");
141
142
  // The record's own id: the last segment of `/mark/<office>/<id>`. The office segment is a hint that can
@@ -150,6 +151,9 @@ function indexRow(ix, line, start = null, len = null) {
150
151
  const key = targetKey(r?.target);
151
152
  ix.byTarget.set(key, { hash: bodyHash(r?.body), refreshed: r?.refreshed === true, ts: r?.ts ?? null, start, len });
152
153
  if (key) ix.byGuid.set(guidOf(key), key);
154
+ // THE LAST LINE THAT CARRIES A BODY, under the record key a lookup by record id uses (recordBodyFromLog). Kept
155
+ // apart from `byTarget`, whose rule is the last line of any kind: a later line with no body must not hide a body.
156
+ if (r?.body) ix.withBody.set(normalizeRecordUri(r.target) || key, { start, len });
153
157
  } catch { /* a torn or foreign line indexes nothing, and is left where it is */ }
154
158
  }
155
159
 
@@ -160,7 +164,7 @@ function indexOf(dest) {
160
164
  let ix = RUN_INDEXES.get(dest);
161
165
  // A replacement elsewhere renames a NEW file over this one: same path, different inode, and an offset
162
166
  // into the old file means nothing in the new one. Re-read from the start.
163
- if (!ix || size < ix.offset || ix.ino !== ino) { ix = { offset: 0, ino, byTarget: new Map(), byGuid: new Map() }; RUN_INDEXES.set(dest, ix); }
167
+ if (!ix || size < ix.offset || ix.ino !== ino) { ix = { offset: 0, ino, byTarget: new Map(), byGuid: new Map(), withBody: new Map() }; RUN_INDEXES.set(dest, ix); }
164
168
  if (size <= ix.offset) return ix;
165
169
  const fd = openSync(dest, "r");
166
170
  try {
@@ -219,6 +223,30 @@ export function heldRecordBodies(dest, ids) {
219
223
  return out;
220
224
  }
221
225
 
226
+ /**
227
+ * The body this run's record log holds for one record, or null: the last line naming it, by its record key, that
228
+ * carries a body. The same answer as reading the whole log and keeping the last such line, served from the index
229
+ * above, so a lookup costs the lines appended since the last one and one line's read, not a parse of the whole log.
230
+ * Measured on production's 0.4.x clearances before this existed: a whole-log lookup took a median 0.80 s and up to
231
+ * 147 s, inside serial stages whose model waited for each answer.
232
+ *
233
+ * A run-scoped log only, like `heldRecordBodies`. A line still being written is not yet in the index, as it is not
234
+ * yet a whole line. Anything that cannot be read is null, which the caller reports as not fetched yet.
235
+ */
236
+ export function recordBodyFromLog(dest, uri) {
237
+ if (typeof dest !== "string" || basename(dest) !== RUN_RECORD_LOG_FILE) return null;
238
+ const want = normalizeRecordUri(uri) || targetKey(uri);
239
+ let fd;
240
+ try {
241
+ const at = indexOf(dest).withBody.get(want);
242
+ if (!at || !Number.isInteger(at.start) || !Number.isInteger(at.len)) return null;
243
+ fd = openSync(dest, "r");
244
+ const buf = Buffer.alloc(at.len);
245
+ if (readSync(fd, buf, 0, at.len, at.start) !== at.len) return null;
246
+ return JSON.parse(buf.toString("utf8"))?.body || null;
247
+ } catch { return null; } finally { if (fd !== undefined) try { closeSync(fd); } catch { /* closed */ } }
248
+ }
249
+
222
250
  const sleepMs = (ms) => { try { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); } catch { /* no sleep available */ } };
223
251
 
224
252
  /** Run `fn` holding the ledger's lock; false (and `fn` not run) when the lock could not be had in time. */
@@ -0,0 +1,15 @@
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
+ // record-uri.mjs — the one key a register record is looked up by, wherever a reader stands. A leaf with no imports, so
5
+ // the run record log's index (`ledger.mjs`) and the driver's record joins (`driver/registry-fidelity.mjs`) key a
6
+ // record the same way: two readers of one log must not disagree about which row is the record's.
7
+
8
+ // WP-receipts W2 (the VENZY join defect): meter sources sometimes arrive as FULL provider URLs
9
+ // (https://tm.corsearch.com/mark/ae/229552) while the record set keys on /mark/ paths — without
10
+ // normalization a genuinely FETCHED record demotes to "assumed" at render, with a false integrity
11
+ // flag on top. Same broad id shape as pipeline.mjs CITED_URI_RE.
12
+ export function normalizeRecordUri(src) {
13
+ const m = String(src ?? "").trim().match(/\/mark\/[a-z]{2,6}\/[a-z0-9][a-z0-9_-]*/i);
14
+ return m ? m[0].toLowerCase() : "";
15
+ }
@@ -26,6 +26,17 @@ export const adapter = {
26
26
  return err ? { ok: false, cause: err.slice(0, 140) } : { ok: true };
27
27
  } catch (e) { return { ok: false, cause: `fetch threw: ${e.message}` }; }
28
28
  },
29
+ // One cited registration's logo, for the report: one image request, ledgered like every other call.
30
+ async markImage(uri, { agentId, sessionKey, recordLog = null }) {
31
+ if (!process.env.CLARIVATE_API_KEY) return { ok: false, cause: "CLARIVATE_API_KEY absent from driver env" };
32
+ let doMarkImage, DEFAULT_BASE;
33
+ try { ({ doMarkImage, DEFAULT_BASE } = await import("./core.js")); }
34
+ catch (e) { return { ok: false, cause: `plugin core unavailable: ${e.message}` }; }
35
+ const base = process.env.CLARIVATE_API_BASE || DEFAULT_BASE;
36
+ try {
37
+ return await doMarkImage(process.env.CLARIVATE_API_KEY, base, uri, { kind: "image", agentId, sessionKey, sessionId: null, recordLog });
38
+ } catch (e) { return { ok: false, cause: `fetch threw: ${e.message}` }; }
39
+ },
29
40
  // Depth 2's count, same contract as corsearch's (see above). A TRUE count-only call here: POST
30
41
  // /count fetches no records and works at any magnitude. regions[] is mandatory on this provider,
31
42
  // so a worldwide count is a disclosed capability gap rather than a number — register-count.mjs
@@ -1766,7 +1766,23 @@ export async function doImageFetch(apiKey, base, params, tctx) {
1766
1766
  return { type: "text", text: JSON.stringify({ test_mode: useTest, count: results.length, results }, null, 2) };
1767
1767
  }
1768
1768
 
1769
- // ── Filing date (per-register data freshness) ─────────────────────────────────────────────────────
1769
+ // ── One cited registration's logo, for the report ───────────────────────────────────────────────────────────────
1770
+ // The live image of one record: one image request, on the same `/image` call as the metadata fetch above and through
1771
+ // the same ledger. The answer's `image` field is a string; read here as base64, and the caller keeps the bytes only when
1772
+ // they open as a PNG, JPEG, GIF or WebP file, so a different encoding is reported rather than saved. `{ ok, bytes,
1773
+ // contentType }`, or `{ ok: false, cause }` for a call that did not land or held no image.
1774
+ export async function doMarkImage(apiKey, base, ref, tctx) {
1775
+ const guid = refToGuid(ref);
1776
+ const r = await clarivateFetch(apiKey, base, "/image", { body: { id: guid }, tctx: { ...tctx, target: guid } });
1777
+ if (!r.ok) return { ok: false, cause: `HTTP ${r.status}: ${String(errText(r)).slice(0, 120)}` };
1778
+ if (r.parseError) return { ok: false, cause: `unparseable body (HTTP ${r.status})` };
1779
+ const imgs = Array.isArray(r.body?.images) ? r.body.images : Array.isArray(r.body) ? r.body : null;
1780
+ const img = imgs?.find((i) => typeof i?.image === "string" && i.image.length > 0) ?? null;
1781
+ if (!img) return { ok: false, cause: imgs ? "the answer held no image" : `not an image response (HTTP ${r.status})` };
1782
+ return { ok: true, bytes: Buffer.from(img.image, "base64"), contentType: img.contentType ?? img.mimeType ?? null };
1783
+ }
1784
+
1785
+ // ── Filing date (per-register data freshness)─────────────────────────────────────────────────────
1770
1786
  // POST /filingdate — how CURRENT each register's data is (recordLastUpdated yyyyMMdd + the office's own
1771
1787
  // currency notes). A coverage claim is only as good as the freshness of the register behind it.
1772
1788
  export async function doFilingDate(apiKey, base, params, tctx) {
@@ -1,5 +1,9 @@
1
1
  # trademark-oauth-mcp-bridge
2
2
 
3
+ ## 0.7.0-beta.0
4
+
5
+ No changes in this release.
6
+
3
7
  ## 0.6.0
4
8
 
5
9
  No changes in this release.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trademark-oauth-mcp-bridge",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-beta.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": true,
6
6
  "description": "OAuth 2.1 MCP stdio bridge used by the engine's case-law gather stage (courtlistener / legaldatahunter).",
package/scripts/README.md CHANGED
@@ -19,7 +19,7 @@ The axis is *what the script assumes exists*, not where it happens to be run.
19
19
  | `clearances-render-check.mjs` | Checks the `/portal/clearances` columns hold together. Run by CI. |
20
20
  | `report-print-check.mjs` | Shows what the exported PDF actually renders under print media. Run by CI. |
21
21
  | `report-offline-render-check.mjs` | Opens every demo report, from disk and served under the portal's report policy, and every pool index, and fails on any request to another machine or an embedded font that did not load. Run by CI. |
22
- | `report-overflow-check.mjs` | Checks the same two kinds of report for sideways overflow on screen — the print check cannot see a width, because print sets the watermark to `display:none` and the watermark was the overflow. Run by CI. |
22
+ | `report-overflow-check.mjs` | Checks the same two kinds of report for sideways overflow on screen — the print check cannot see a width, because print sets the watermark to `display:none` and the watermark was the overflow. Kept outside this repository. |
23
23
  | `portal-lifecycle-check.mjs` | Asks whether the portal names a brand owner and whether a person can manage their searches. Run by CI. |
24
24
  | `portal-strings.mjs` | Reads every string the portal can show out of its source, as a reader meets it. `--check <approved list>` refuses a string on a screen that is neither approved nor in `portal-ui/strings-backlog.json`; `--backlog-shrinks --base <ref>` refuses a backlog line the base did not have. The approved list is kept with the designs, outside this repository. CI runs the backlog half. |
25
25
  | `validate-profiles.mjs` | Validates a customer-config store's profile bundles. Read-only. |
@@ -30,7 +30,7 @@ The axis is *what the script assumes exists*, not where it happens to be run.
30
30
  | `score.mjs` | Scores a completed run against a reference answer. |
31
31
  | `compare.mjs` | Lays the E2E product-comparison scenarios side by side — the depth dial, the config layers, fan-out, native language, the deep end. Reads files only, prints no verdict, always exits 0. |
32
32
  | `feedback-mint.mjs` | The one file in the feedback feature that touches the network. |
33
- | `publication-scan.mjs` | Reads every blob in a repository's history and asks whether all of it can be public: retired identities, operator identity, secrets, withheld paths, the licence. Portable, but it needs the private roster to say anything real — a check it could not run fails the scan rather than passing. |
33
+ | `publication-scan.mjs` | Reads every blob in a repository's history and asks whether all of it can be public: retired identities, operator identity, secrets, withheld paths, the licence. Portable, but it needs the private roster to say anything real — a check it could not run fails the scan rather than passing. Kept outside this repository. |
34
34
  | `mint-suite-census.mjs` | Re-stamps `driver/suite-census.json` — the persisted expectation that makes a DELETED, RENAMED or GUTTED test file visible. Dry-run by default;`--apply` writes it, and it prints removals and shrinkage first because a silently lowered ceiling is how a gutting gets laundered into a green suite. |
35
35
  | `merge-presence-check.mjs` | Re-states every merge in a window against the tree: did the merged content reach `main` and is it STILL there (proved by content, never by ancestry), and did the branch carry work the merge never took. Deliberately not a CI gate — it reads the forge. A branch that is simply gone makes the second question unanswerable, which is a non-zero exit, waived only by an explicit dated flag that is itself invalid once it covers nothing. |
36
36
 
@@ -88,7 +88,8 @@ or declared, with a reason, as one that cannot run in CI.
88
88
 
89
89
  **Three are declared**, and all three need something CI does not have: `live-surface-check.mjs` (a
90
90
  running deployment), `merge-presence-check.mjs` (a range that does not exist before the merge) and
91
- `deploy-drift-check.mjs` (a deployed host to compare against). Everything else runs.
91
+ `deploy-drift-check.mjs` (a deployed host to compare against; kept outside this repository). Everything
92
+ else runs.
92
93
 
93
94
  That includes `render-check.mjs`, which joined the blocking browser step, and `report-frame-check.mjs`.
94
95
  **This paragraph said the opposite until 2026-08-27** — it had them both on the declared list, left over
@@ -120,3 +121,146 @@ contributor tier, on machines where a `ulimit -v` makes Chrome dump core.
120
121
  these needs a path, it takes it as an argument or an environment variable and **refuses when it is
121
122
  absent**. Falling back to the production value means an unset variable — a fresh shell, a clone, a
122
123
  CI job — silently aims a real operation at live client matter.
124
+
125
+ ## Every script, by how it runs
126
+
127
+ One row for every file in this folder, so a CI guard can be told from a tool somebody runs and from a
128
+ one-off. What each does is in its own header. A test fails on a file this table does not list, and on a
129
+ row that names a file this folder does not hold.
130
+
131
+ - **CI**: a workflow runs it, directly or through an npm script.
132
+ - **by hand**: something in the repository names it, a document, a test or another script, and a person runs it.
133
+ - **one-off, named nowhere**: nothing in the repository refers to it. Ask whoever wrote it before retiring it.
134
+
135
+ | Script | Runs |
136
+ |---|---|
137
+ | `added-reference-check.mjs` | CI |
138
+ | `ai-page-render-check.mjs` | CI |
139
+ | `ask-ai-render-check.mjs` | CI |
140
+ | `authority-boundary-probe.mjs` | by hand, `npm run authority-probe` |
141
+ | `backfill-started-at.mjs` | by hand |
142
+ | `backup-recall-stores.mjs` | by hand |
143
+ | `band-shape-probe.mjs` | by hand |
144
+ | `bench-replay-request.mjs` | CI |
145
+ | `carry-through.mjs` | by hand |
146
+ | `census-merge-driver.mjs` | by hand |
147
+ | `changelog-plain-language.mjs` | by hand |
148
+ | `citation-anchor-report.mjs` | one-off, named nowhere |
149
+ | `citation-drift-report.mjs` | by hand |
150
+ | `citation-line-check.mjs` | CI |
151
+ | `clearances-render-check.mjs` | CI |
152
+ | `clone-recipe-check.mjs` | CI |
153
+ | `compare.mjs` | by hand |
154
+ | `composer-render-check.mjs` | CI |
155
+ | `contract-dictation-scan.mjs` | by hand, `npm run contract-dictation` |
156
+ | `count-manual-pins.mjs` | by hand |
157
+ | `dead-names.mjs` | by hand, `npm run retired-settings` |
158
+ | `demo-evidence.mjs` | CI |
159
+ | `deprecate-below.mjs` | CI |
160
+ | `doctrine-report.mjs` | by hand, `npm run doctrine-report` |
161
+ | `drain-preflight.mjs` | by hand, `npm run drain-preflight` |
162
+ | `drive-env-check.mjs` | CI |
163
+ | `e2e-first-time.mjs` | by hand |
164
+ | `e2e-scenario-ops.mjs` | by hand |
165
+ | `e2e-unread-terminals.mjs` | by hand |
166
+ | `e2e.mjs` | by hand |
167
+ | `engine-pins.mjs` | CI |
168
+ | `engine-probe.mjs` | by hand, `npm run engine-probe` |
169
+ | `env-audit.mjs` | by hand |
170
+ | `env-classify.mjs` | by hand |
171
+ | `feedback-mint.mjs` | by hand |
172
+ | `freeze-example-run.mjs` | by hand |
173
+ | `generated-files-are-current.mjs` | CI |
174
+ | `hand-off-exits-probe.mjs` | one-off, named nowhere |
175
+ | `head-arrived-gated.mjs` | one-off, named nowhere |
176
+ | `headless-page.mjs` | by hand |
177
+ | `home-render-check.mjs` | CI |
178
+ | `import-cycle-check.mjs` | CI |
179
+ | `live-surface-check.mjs` | by hand |
180
+ | `main-health.mjs` | by hand |
181
+ | `markdown-link-check.mjs` | CI |
182
+ | `mcp-registry-listing.mjs` | CI |
183
+ | `measure-test-durations.mjs` | by hand |
184
+ | `merge-presence-check.mjs` | by hand |
185
+ | `merge-shape-check.mjs` | by hand |
186
+ | `mint-names-in-force.mjs` | by hand |
187
+ | `mint-offered-territories.mjs` | by hand |
188
+ | `mint-plugin-folder.mjs` | by hand |
189
+ | `mint-public-residue.mjs` | by hand |
190
+ | `mint-reference-strip-backlog.mjs` | by hand |
191
+ | `mint-search-level-tags.mjs` | by hand |
192
+ | `mint-source-pin-census.mjs` | by hand |
193
+ | `mint-suite-census.mjs` | CI |
194
+ | `mint-writing-standard-backlog.mjs` | by hand |
195
+ | `nightly-notice.mjs` | by hand |
196
+ | `no-test-account-reaches-the-package.mjs` | CI |
197
+ | `pack-publishable.mjs` | by hand |
198
+ | `package-size-budget.mjs` | CI |
199
+ | `placement-diff.mjs` | by hand |
200
+ | `plain-language-rules.mjs` | by hand |
201
+ | `portal-lifecycle-check.mjs` | CI |
202
+ | `portal-strings.mjs` | CI |
203
+ | `preinstall-node-check.mjs` | CI |
204
+ | `purge-runs.mjs` | by hand |
205
+ | `queue-inflight.mjs` | by hand |
206
+ | `reconcile-runs.mjs` | by hand |
207
+ | `record-carry-probe.mjs` | by hand |
208
+ | `register-plan-shape.mjs` | by hand |
209
+ | `release-approve-parked.mjs` | CI |
210
+ | `release-artifact-seal.mjs` | CI |
211
+ | `release-await-cut.mjs` | CI |
212
+ | `release-bench-replay-check.mjs` | CI |
213
+ | `release-code-scanning-check.mjs` | CI |
214
+ | `release-completeness-check.mjs` | CI |
215
+ | `release-cut-decision.mjs` | CI |
216
+ | `release-dist-tag.mjs` | CI |
217
+ | `release-duplicate-notes.mjs` | CI |
218
+ | `release-entry-catch-up.mjs` | CI |
219
+ | `release-install-check.mjs` | CI |
220
+ | `release-note-required.mjs` | CI |
221
+ | `release-notes-for.mjs` | CI |
222
+ | `release-notes-lint.mjs` | CI |
223
+ | `release-pre-gate.mjs` | CI |
224
+ | `release-publish-guard.mjs` | CI |
225
+ | `release-rehearsal-version.mjs` | CI |
226
+ | `release-sbom.mjs` | CI |
227
+ | `release-version-pr-checks.mjs` | CI |
228
+ | `release-version.mjs` | CI |
229
+ | `release-visible-check.mjs` | CI |
230
+ | `render-brand-banner.mjs` | one-off, named nowhere |
231
+ | `render-check.mjs` | CI |
232
+ | `repo-writes.mjs` | by hand |
233
+ | `report-frame-check.mjs` | CI |
234
+ | `report-header-render-check.mjs` | CI |
235
+ | `report-offline-render-check.mjs` | CI |
236
+ | `report-print-check.mjs` | CI |
237
+ | `report-screenshot.mjs` | by hand |
238
+ | `report-sections-render-check.mjs` | CI |
239
+ | `report-theme-render-check.mjs` | CI |
240
+ | `retire-bare-refs.mjs` | by hand |
241
+ | `revisit-render-check.mjs` | CI |
242
+ | `score.mjs` | by hand |
243
+ | `seat-retry-report.mjs` | by hand, `npm run retry-report` |
244
+ | `secret-scanner-fetch.mjs` | CI |
245
+ | `settings-render-check.mjs` | CI |
246
+ | `spdx-headers.mjs` | CI |
247
+ | `strip-titles-and-attributions.mjs` | by hand |
248
+ | `strip-tracker-citations.mjs` | by hand |
249
+ | `sync-e2e-store.mjs` | by hand |
250
+ | `test-account-names.mjs` | by hand |
251
+ | `test-durations-reporter.mjs` | by hand |
252
+ | `test-durations.json` | by hand |
253
+ | `test-fast.mjs` | by hand, `npm run test` |
254
+ | `test-full.mjs` | CI |
255
+ | `test-run.mjs` | CI |
256
+ | `text-difference.mjs` | by hand |
257
+ | `third-party-notices.mjs` | CI |
258
+ | `travelling-predicates.mjs` | by hand |
259
+ | `undeclared-field-census.mjs` | by hand |
260
+ | `undeclared-key-census.mjs` | by hand |
261
+ | `unexecuted-asserts.mjs` | by hand, `npm run assert-census` |
262
+ | `validate-profiles.mjs` | by hand |
263
+ | `verify-publishable.mjs` | by hand |
264
+ | `write-build-info.mjs` | npm, before every pack |
265
+ | `write-up-form-census.mjs` | by hand |
266
+ | `writing-standard-check.mjs` | CI |
@@ -104,7 +104,7 @@ export const COUNTED_EVENTS = {
104
104
  // court-decisions file that arrived absent or empty from a stage that ended ok: this record is its only one.
105
105
  "degraded-parts": { kind: FAILED, when: (e) => (Array.isArray(e.parts) ? e.parts : [])
106
106
  .some((p) => p?.part === "court-decisions" && /is (absent|empty)$/.test(String(p?.cause ?? ""))) },
107
- "degraded-parts-failed": FAILED,
107
+ "degraded-parts-failed": FAILED, "logos-not-written": FAILED,
108
108
  // A store publishing found unreadable, or one delivery read and a republish found missing: its only record.
109
109
  "degraded-parts-at-publish": FAILED,
110
110
  // A part publishing could not write, and the report shipped without it. A clearance's workbook is counted by its
@@ -197,7 +197,7 @@ export const NOT_COUNTED_EVENTS = {
197
197
  "digest-coverage-form-brief", "digest-flush", "digest-queue-noop", "digest-queued", "digest-rulings-tail",
198
198
  "doctrine-write", "document-coverage-rendered", "document-growth-trip", "doubt-selection", "doubts", "draft-carry",
199
199
  "economics", "engine-build", "envelope-closed", "envelope-decision", "envelope-decision-early",
200
- "escalation-skipped", "experiment", "experiment-refused", "goods-held-whole-handed",
200
+ "escalation-skipped", "experiment", "experiment-refused", "goods-held-whole-handed", "logos",
201
201
  "form-neighbourhood-derived", "frame-diff",
202
202
  "frame-diff-source-directives-dropped", "frame-reopen-reconcile-not-needed", "frame-reopen-skipped", "frame-web-grid",
203
203
  "framework", "goods-evidence", "grid-ledger-saved", "grid-spec", "grid-split", "hit-list-minted",
@@ -233,7 +233,7 @@ export const NOT_COUNTED_EVENTS = {
233
233
  "scope-facts", "scope-frontmatter", "scope-ledger-derived", "scope-ledger-skipped", "screen-gate-clean", "screen-gate-evidence",
234
234
  "seam-reapplied", "search-policy", "searched-jurisdictions", "senior-rights", "skip",
235
235
  "stage-contract", "stage-limit-derived", "stage-stamps-reconciled", "start", "supplemental-fold", "token-rollup",
236
- "turnaround-reconciliation", "unit-band-seeded-empty", "verdict", "verdict-conditions-followed", "verdict-conditions-recorded", "verdict-floors-pass", "verdict-frontmatter",
236
+ "turnaround-reconciliation", "uncovered-market-rows", "unit-band-seeded-empty", "verdict", "verdict-conditions-followed", "verdict-conditions-recorded", "verdict-floors-pass", "verdict-frontmatter",
237
237
  "verdict-recomputed-steps-withdrawn", "whatif-settled-on-archive", "write-up-forms",
238
238
  ],
239
239
  "a note about the answer's content that changes nothing in the run; the quality read judges it": [
@@ -69,8 +69,8 @@ const FROZEN_FILES = [
69
69
  { path: "_driver/senior-rights.json", why: "publish/index.mjs:790 seniorRights" },
70
70
  { path: "_driver/verdict.json", why: "publish/index.mjs:811 verdictInfo" },
71
71
  { path: "_driver/framework.json", why: "publish/index.mjs, the frozen band vocabulary the run was rated under" },
72
- { path: "_driver/register-plan.json", why: "publish/index.mjs:919 scopeBasis" },
73
- { path: "_driver/instructed-scope.json", why: "publish/index.mjs:930 searchedJurisdictions, the fallback for register-plan" },
72
+ { path: "_driver/register-plan.json", why: "publish/index.mjs:914 scopeBasis" },
73
+ { path: "_driver/instructed-scope.json", why: "publish/index.mjs:915 searchedJurisdictions, the fallback for register-plan" },
74
74
  { path: "_driver/enforcer-signals.json", why: "`esPath` declared in index.mjs" },
75
75
  { path: "_driver/predelivery-lint.json", why: "publish/index.mjs:173 lintSink" },
76
76
  { path: "_driver/escalation-state.json", why: "publish/index.mjs:174 escSink" },
@@ -118,7 +118,7 @@ const KNOCKOUT_FILES = [
118
118
  // knockout report render empty (`buildKnockoutWorkbook` in publish/knockout.mjs). Named by `koPaths` in stages-knockout.mjs.
119
119
  { path: "_driver/register-counts.json", why: "buildKnockoutWorkbook in publish/knockout.mjs: counted figures + the Register column" },
120
120
  { path: "_driver/register-records.json", why: "koPaths in stages-knockout.mjs: the terms behind the close-variation axis" },
121
- { path: "_driver/instructed-scope.json", why: "publish/index.mjs:930 searchedJurisdictions, the fallback for register-plan" },
121
+ { path: "_driver/instructed-scope.json", why: "publish/index.mjs:915 searchedJurisdictions, the fallback for register-plan" },
122
122
  ];
123
123
 
124
124
  /** The allowlist for a template. One place, so a new template cannot half-exist. */
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
4
+ //
5
+ // mint-search-level-tags.mjs — write the short name of each search the product sells, from the registry.
6
+ //
7
+ // The Clearances list prints a tag under each name, one per kind of search behind it, and offers the same
8
+ // tags as a filter: "KO", "Prelim", "Multi", "Full". Each tag lives on its product's own row in
9
+ // driver/search-policy.mjs (`report.tag`, beside the `identity` the report's masthead prints), so a product
10
+ // cannot ship without naming its own. The browser cannot import the registry, so this writes the part it
11
+ // needs, in the registry's order, to shared/search-level-tags.json, which the page imports.
12
+ //
13
+ // The page never keeps a list of its own. The portal once held its own table from product to label, and it
14
+ // listed only the retired products, so every new run showed a blank label. A retired product has no tag
15
+ // and is left out here: its runs show no tag and appear only under All.
16
+ //
17
+ // node scripts/mint-search-level-tags.mjs write the file
18
+ // node scripts/mint-search-level-tags.mjs --check exit 1 if the committed file disagrees with the registry
19
+
20
+ import { readFileSync, writeFileSync } from "node:fs";
21
+ import { dirname, join } from "node:path";
22
+ import { fileURLToPath } from "node:url";
23
+
24
+ const REPO = dirname(dirname(fileURLToPath(import.meta.url)));
25
+ const OUT = join(REPO, "shared", "search-level-tags.json");
26
+
27
+ /** The file's content, derived fresh: one `{product, tag, name}` per orderable product, in the registry's order. */
28
+ export async function deriveSearchLevelTags() {
29
+ const { PRODUCT_POLICIES, ORDERABLE_PRODUCTS } = await import("../driver/search-policy.mjs");
30
+ const levels = ORDERABLE_PRODUCTS.map((product) => {
31
+ const report = PRODUCT_POLICIES[product]?.report ?? {};
32
+ // Refuse rather than write a blank: a product with no tag would show nothing under its names and have no
33
+ // button, which reads as "no searches of this kind" rather than as a missing name.
34
+ if (typeof report.tag !== "string" || !report.tag.trim()) throw new Error(`${product}: the registry gives it no report.tag`);
35
+ if (typeof report.identity !== "string" || !report.identity.trim()) throw new Error(`${product}: the registry gives it no report.identity`);
36
+ return { product, tag: report.tag, name: report.identity };
37
+ });
38
+ return {
39
+ _generated: "by scripts/mint-search-level-tags.mjs from driver/search-policy.mjs PRODUCT_POLICIES — do not edit; re-mint",
40
+ levels,
41
+ };
42
+ }
43
+
44
+ const render = (doc) => JSON.stringify(doc, null, 2) + "\n";
45
+
46
+ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
47
+ const next = render(await deriveSearchLevelTags());
48
+ if (process.argv.includes("--check")) {
49
+ let current;
50
+ try { current = readFileSync(OUT, "utf8"); }
51
+ catch { console.error(`mint-search-level-tags: ${OUT} is missing — run without --check to mint it.`); process.exit(1); }
52
+ if (current === next) {
53
+ console.log(`search-level-tags: current, ${JSON.parse(current).levels.length} level(s).`);
54
+ process.exit(0);
55
+ }
56
+ console.error("search-level-tags: the committed file disagrees with the registry — re-mint: node scripts/mint-search-level-tags.mjs");
57
+ process.exit(1);
58
+ }
59
+ writeFileSync(OUT, next);
60
+ console.log(`search-level-tags: wrote ${JSON.parse(next).levels.length} level(s) to ${OUT}`);
61
+ }
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
4
+ //
5
+ // RE-MINT THE SOURCE-PIN CENSUS — which test files pin product source text, and how many pins each holds. A floor.
6
+ //
7
+ // node scripts/mint-source-pin-census.mjs # report the delta, change nothing
8
+ // node scripts/mint-source-pin-census.mjs --check # ... and exit 1 if the file is out of date
9
+ // node scripts/mint-source-pin-census.mjs --apply # write it
10
+ //
11
+ // WHY A COUNT. A test that asserts on a product file's TEXT goes red when that text moves, reflows or is renamed, though
12
+ // no run behaves differently, and every carve of a long function has to repoint such pins before it can land. About one
13
+ // test file in five pinned source on 2026-11-18 and nothing counted them, so the number could only grow unseen. Each pin is
14
+ // retired by the change that makes its behaviour reachable by a test; this records where they are so that can be seen.
15
+ //
16
+ // WHAT THE MATCHER SEES, said rather than found later. Two shapes, per test file under `driver/test` and `mcp-server/test`:
17
+ // - a call to `driverSource(` (driver/test/driver-source.mjs), the house helper for reading the driver's text;
18
+ // - a `readFileSync(` whose own argument names a product file by a path literal: a `../…` path outside any `test/`
19
+ // folder, a path under `driver/`, `bin/`, `shared/`, `scripts/`, `mcp-server/`, `providers/` or `portal-ui/`, or a
20
+ // `join(…, "<folder>", …, "<file>.mjs")`.
21
+ // A test that reads source through a variable holding the path is not seen, so the true count is at least this floor.
22
+ // Measured on 2026-11-18: 299 files (151 call `driverSource`, 148 read a product file by a literal path), against the
23
+ // 317 an audit counted by hand.
24
+ //
25
+ // THE ONLY REASON TO RUN `--apply` IS THAT THE NUMBER WENT DOWN. The floor arm in
26
+ // driver/test/the-tests-that-pin-source-are-a-floor.test.mjs reads the committed file and refuses a file that pins more
27
+ // than it is recorded with, so minting upward records a regression rather than absorbing it.
28
+ import { readFileSync, writeFileSync } from "node:fs";
29
+ import { join, dirname } from "node:path";
30
+ import { fileURLToPath } from "node:url";
31
+ import { publishedOf, publishedReader } from "../shared/reference-guard-classes.mjs";
32
+ import { trackedFiles, skipReason } from "../shared/tracked-files.mjs";
33
+ import { isEntrypoint } from "../shared/is-entrypoint.mjs";
34
+
35
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
36
+ export const FIXTURE = join(ROOT, "driver/test/fixtures/source-pin-census.json");
37
+ const GUARD = "source-pin-census";
38
+
39
+ const PRODUCT_PATH = new RegExp([
40
+ String.raw`["'\x60](?:\.\.\/)+(?![\w-]*\/?test\/)[\w./-]+\.(?:mjs|js|ts|tsx|css)["'\x60]`,
41
+ String.raw`["'\x60](?:driver|bin|shared|scripts|mcp-server|providers|portal-ui)\/(?![\w./-]*\btest\/)[\w./-]+\.(?:mjs|js|ts|tsx|css)["'\x60]`,
42
+ String.raw`join\([^)]*["'](?:driver|bin|shared|scripts|mcp-server|providers|portal-ui)["'][^)]*["'][\w.-]+\.(?:mjs|js|ts|tsx|css)["']\)`,
43
+ ].join("|"));
44
+
45
+ /** [driverSource calls, literal source reads] in one test file's text. PURE. */
46
+ export function pinsIn(text) {
47
+ const s = String(text ?? "");
48
+ const calls = (s.match(/\bdriverSource\(/g) ?? []).length;
49
+ let reads = 0;
50
+ for (const m of s.matchAll(/readFileSync\(([^;\n]{0,240})/g)) if (PRODUCT_PATH.test(m[1])) reads++;
51
+ return [calls, reads];
52
+ }
53
+
54
+ /** The tree's census: { total: files that pin, files: { path: [calls, reads] } }, or null outside a checkout. */
55
+ export function mint(root = ROOT) {
56
+ const tracked = trackedFiles(GUARD, { root, pathspec: ["driver/test", "mcp-server/test"] });
57
+ if (tracked === null) return null;
58
+ const p = publishedOf(tracked.filter((f) => f.endsWith(".test.mjs")), root);
59
+ if (p.error) throw new Error(`mint-source-pin-census: ${p.error}`);
60
+ // Test files the index carries and HEAD does not are laid over this checkout, not published in it: said, and not counted.
61
+ if (p.laid) console.log(`mint-source-pin-census: ${p.laid} tracked test file(s) are not in HEAD — laid over this checkout and not counted`);
62
+ const read = publishedReader(root, (f) => readFileSync(join(root, f), "utf8"));
63
+ const files = {};
64
+ for (const f of [...p.files].sort()) {
65
+ const counts = pinsIn(read(f));
66
+ if (counts[0] || counts[1]) files[f] = counts;
67
+ }
68
+ return { total: Object.keys(files).length, files };
69
+ }
70
+
71
+ function main() {
72
+ const apply = process.argv.includes("--apply");
73
+ const check = process.argv.includes("--check");
74
+ let now;
75
+ try { now = mint(); } catch (e) { console.error(e.message); process.exit(2); }
76
+ if (now === null) { console.error(`mint-source-pin-census: ${skipReason(GUARD)}`); process.exit(2); }
77
+ let was = null;
78
+ try { was = JSON.parse(readFileSync(FIXTURE, "utf8")); } catch { /* first mint */ }
79
+ const calls = Object.values(now.files).filter(([c]) => c).length;
80
+ console.log(`source pins: ${now.total} test file(s), ${calls} calling driverSource, ${now.total - calls} reading a product file by path`);
81
+ const next = JSON.stringify(now, null, 2) + "\n";
82
+ if (was && JSON.stringify(was, null, 2) + "\n" === next) { console.log("the census is current"); return; }
83
+ if (was) console.log(`total ${was.total} → ${now.total}`);
84
+ if (apply) { writeFileSync(FIXTURE, next); console.log("written"); return; }
85
+ console.log("re-run with --apply to write it");
86
+ if (check) process.exit(1);
87
+ }
88
+
89
+ if (isEntrypoint(import.meta.url)) main();