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
@@ -11,15 +11,18 @@ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
11
11
  import { finishPoolRun, openPoolRun, refreshStaffPages } from './shell.mjs';
12
12
  import { plainDeferralReason, plainCause } from '../deferral-row.mjs'; import { knockoutStepFailures, PART_NAMES, RULED_WORDS, NOT_COMPLETED, linkNotOnRegisterSite } from '../degraded-parts.mjs'; import { ownersOwedACheck, composeOwnerQuery } from '../owner-use-check.mjs'; import { KNOCKOUT_WEB } from '../stages-knockout.mjs'; // — the reader's words for a search left open; and the parts that failed as a whole
13
13
  import { join } from 'node:path';
14
+ import { EMAIL_TIER } from '../../shared/brand.mjs';
14
15
  import { riskTier, TONE_TIER, regenIndex, regenSurfaces, auditRouteFor, markReportRouteFor, reportRouteFor } from './index.mjs';
15
16
  import { runKnockoutLint, deliveryFlagLines } from '../predelivery-lint.mjs';
16
17
  import { note } from '../log.mjs';
17
18
  import { addSheet } from './xlsx.mjs';
19
+ import { KNOCKOUT_EMAIL as KO, KNOCKOUT_WORKBOOK as KW } from './strings.mjs';
18
20
  import { COUNT_PREDICATES, COUNT_BASIS, countsForMark, countLine, countedMarks, variantFormsLine, disclosedFloor, moreThan, countNote } from '../register-count.mjs';
19
21
  import { noneCarriedForward, recordsForMark, recordsLine, normalizeRegisterRecordLinks } from '../register-records.mjs';
20
22
  import { reportIdentityFor, productCoverageNote, kebab } from '../search-policy.mjs';
21
23
  import { batchMarkName } from '../mark-name.mjs';
22
- import { renderKnockoutHtml, knockoutReportData } from './render-knockout.mjs';
24
+ import { renderKnockoutHtml, DEGRADED_NOTE } from './render-knockout.mjs';
25
+ import { knockoutReportData } from './report-data.mjs';
23
26
  import { readFrozenMethod, inputsLine, FROZEN_METHOD_FILE } from '../framework-method.mjs';
24
27
  import { resolveDemoData, demoBannerMd } from './demo-marking.mjs'; //
25
28
  import { engineCommit } from '../engine-build.mjs';
@@ -39,7 +42,7 @@ const esc = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').
39
42
  export function bandTier(framework, word) {
40
43
  const tone = framework?.bands?.find((b) => String(b.label).toLowerCase() === String(word ?? '').trim().toLowerCase())?.tone;
41
44
  if (tone && TONE_TIER[tone]) return { ...TONE_TIER[tone], label: String(word) };
42
- return riskTier(word) ?? { bg: '#bfbfbf', fg: '#000', txt: '#555', label: String(word ?? '—') };
45
+ return riskTier(word) ?? { ...EMAIL_TIER.unrated, label: String(word ?? '—') };
43
46
  }
44
47
  // The email body is inline-styled and self-contained by contract (docs/DELIVERY.md: the courier sends
45
48
  // `emailBodyHtml` verbatim), so it keeps a mail-safe font stack. The report does not — it has a stylesheet.
@@ -97,6 +100,24 @@ export const knockoutStatement = (framework, marks) =>
97
100
  // than "never asked for". 'Impact' goes with them: it was the second rating scale. What replaces them is
98
101
  // what the typed record actually carries. A `—` means the shape that produced the row never had the
99
102
  // field (an archived prose finding), which is a different fact from an empty cell.
103
+ /**
104
+ * WHAT A KNOCKOUT LEFT OPEN, from the run's own record (design's rule, approved by the owner 2026-11-18). PURE.
105
+ *
106
+ * A register step that failed is a row under the report's "Register" name: the listing that never came back is not
107
+ * searched, and a reading that stopped part-way is partly covered. A name whose automated research was unavailable is a
108
+ * row under its own name, not searched. The notes are the shipped lines, the deferral row's for a step and the page's
109
+ * own for a name, so nothing here is a new sentence and nothing comes from model prose. A refused listing is not a
110
+ * search that failed (the run never offered it), and a run with nothing left open returns no rows.
111
+ */
112
+ export function knockoutLeftOpen(steps, marks = []) {
113
+ return [
114
+ ...(steps?.listing ? [{ area: PART_NAMES.register, state: 'not-searched', note: plainDeferralReason(steps.listing.reason) }] : []),
115
+ ...(steps?.reading ? [{ area: PART_NAMES.register, state: 'coverage-limited', note: plainDeferralReason(steps.reading.reason) }] : []),
116
+ ...(Array.isArray(marks) ? marks : []).filter((m) => m?.degraded === true && String(m?.name ?? '').trim())
117
+ .map((m) => ({ area: String(m.name).trim(), state: 'not-searched', note: DEGRADED_NOTE })),
118
+ ];
119
+ }
120
+
100
121
  export async function buildKnockoutWorkbook(findings, receipts, outPath, registerCounts = null, qcFlags = [], framework = null, registerRecords = null, frameworkMethod = null, ownerChecks = [], degraded = {}) {
101
122
  const ExcelJS = (await import('exceljs')).default;
102
123
  const wb = new ExcelJS.Workbook();
@@ -116,7 +137,7 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
116
137
  });
117
138
  }
118
139
  for (const n of m.negatives ?? []) {
119
- negativeRows.push({ 'Mark': m.name, 'Search Term': n.term ?? '', 'Source / Context': n.source ?? '', 'Result': n.note ?? 'No results found', 'Notes': '' });
140
+ negativeRows.push({ 'Mark': m.name, 'Search Term': n.term ?? '', 'Source / Context': n.source ?? '', 'Result': n.note ?? KW.noResults, 'Notes': '' });
120
141
  }
121
142
  }
122
143
  // EACH CELL'S QUERY, not just its spelling. Since the knockout's cells search the spelling followed by
@@ -134,10 +155,9 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
134
155
  // was searched on. An archived run's rows print as they were delivered: the mark as the term, and on
135
156
  // its second web question the kinds of use it asked about, in the frame's words.
136
157
  'Mark': r.mark, 'Search Term': searchedTerms(r),
137
- 'Source / Context': `${r.executor ?? 'perplexity'} (${r.preset ?? ''})${Array.isArray(r.places) && r.places.length ? ` — ${r.places.join(', ')}` : r.question && r.inUseAs ? ` — in use as ${r.inUseAs}` : ''}`,
138
- 'Result Summary': r.ok ? `ok — ${r.bytes ?? 0} bytes` : `FAILED — ${plainCause(r.cause)}`,
158
+ 'Source / Context': `${r.executor ?? 'perplexity'} (${r.preset ?? ''})${Array.isArray(r.places) && r.places.length ? ` — ${r.places.join(', ')}` : r.question && r.inUseAs ? KW.inUseAs(r.inUseAs) : ''}`,
159
+ 'Result Summary': r.ok ? KW.callOk(r.bytes ?? 0) : KW.failed(plainCause(r.cause)),
139
160
  'Finding Reference': r.ok && refByMark.has(r.mark) ? refByMark.get(r.mark) : '',
140
- 'Sweep Call #': r.callNo ?? '', 'Wall-time (s)': r.took_ms != null ? Math.round(r.took_ms / 1000) : '', 'OK/Degraded': r.ok ? 'OK' : 'Degraded',
141
161
  }));
142
162
  // AN OWNER LOOKUP THAT GOT NO ANSWER (ruling 498): the card still prints its use-check line, so the
143
163
  // failure is recorded here, in the trail's own columns and words, beside the web searches. Only a failed
@@ -147,15 +167,15 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
147
167
  if (!c || c.ok) continue;
148
168
  trailRows.push({
149
169
  'Mark': c.mark, 'Search Term': c.query ?? '', 'Source / Context': `perplexity (${c.preset ?? ''})`,
150
- 'Result Summary': `FAILED — ${plainCause(c.cause)}`,
151
- 'Finding Reference': '', 'Sweep Call #': '', 'Wall-time (s)': c.took_ms != null ? Math.round(c.took_ms / 1000) : '', 'OK/Degraded': 'Degraded',
170
+ 'Result Summary': KW.failed(plainCause(c.cause)),
171
+ 'Finding Reference': '',
152
172
  });
153
173
  }
154
174
  // THE PARTS THAT FAILED AS A WHOLE (ruled 2026-09-25, 537 and 539), in the trail's own columns: the
155
175
  // part's name where a search would be named, the reader's line for a part left open, and every other
156
176
  // cell `—`. A run with none of them builds the workbook it built before.
157
177
  const partRow = (name, reason) => ({ 'Mark': '—', 'Search Term': '—', 'Source / Context': name,
158
- 'Result Summary': `FAILED — ${plainDeferralReason(reason)}`, 'Finding Reference': '—', 'Sweep Call #': '—', 'Wall-time (s)': '—', 'OK/Degraded': 'Degraded' });
178
+ 'Result Summary': KW.failed(plainDeferralReason(reason)), 'Finding Reference': '—' });
159
179
  if (degraded.reading) trailRows.push(partRow(PART_NAMES.register, degraded.reading.reason));
160
180
  if (degraded.review) trailRows.push(partRow(RULED_WORDS.plainLanguageReview, degraded.review.reason));
161
181
  if (degraded.machineChecks) trailRows.push(partRow(PART_NAMES.machineChecks, degraded.machineChecks.reason));
@@ -164,7 +184,7 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
164
184
  // says the record was not kept, and never that the search failed.
165
185
  for (const r of degraded.recordsNotKept ?? []) {
166
186
  trailRows.push({ 'Mark': r.mark, 'Search Term': '—', 'Source / Context': `perplexity (${r.preset ?? ''})`,
167
- 'Result Summary': RULED_WORDS.recordNotKept, 'Finding Reference': '—', 'Sweep Call #': '—', 'Wall-time (s)': '—', 'OK/Degraded': 'Degraded' });
187
+ 'Result Summary': RULED_WORDS.recordNotKept, 'Finding Reference': '—' });
168
188
  }
169
189
  // WHAT THE SEARCH RETURNED AND THE RATING DID NOT CARRY, each with the ground the rater wrote (ruled
170
190
  // 2026-09-26). Set-aside reasons live in the audit workbook and never in the report, so this sheet is
@@ -192,14 +212,16 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
192
212
  // A row with no url has nothing to name and nothing to look up, so it is the one shape that
193
213
  // cannot be printed at all.
194
214
  if (!url) continue;
195
- trailRows.push({ 'Mark': m.name, 'Search Term': `Set aside: ${url}`, 'Source / Context': '—',
215
+ trailRows.push({ 'Mark': m.name, 'Search Term': KW.setAside(url), 'Source / Context': '—',
196
216
  'Result Summary': ground,
197
- 'Finding Reference': '—', 'Sweep Call #': '—', 'Wall-time (s)': '—', 'OK/Degraded': ground ? 'OK' : 'Degraded' });
217
+ 'Finding Reference': '—' });
198
218
  }
199
219
  }
200
220
  addSheet(wb, 'Findings', ['Mark', 'Finding Reference', 'Finding Name', 'Owner', 'Band', 'Type', 'Net', 'Basis', 'Evidence'], findingRows);
201
221
  addSheet(wb, 'Negative Results', ['Mark', 'Search Term', 'Source / Context', 'Result', 'Notes'], negativeRows);
202
- addSheet(wb, 'Audit Trail', ['Mark', 'Search Term', 'Source / Context', 'Result Summary', 'Finding Reference', 'Sweep Call #', 'Wall-time (s)', 'OK/Degraded'], trailRows);
222
+ // The sweep's call number, its wall time and OK/Degraded are the engine's, not the lawyer's: they stay in the run
223
+ // record and leave this sheet (2026-11-18).
224
+ addSheet(wb, 'Audit Trail', ['Mark', 'Search Term', 'Source / Context', 'Result Summary', 'Finding Reference'], trailRows);
203
225
  // ── Depth 2: an EXTRA sheet, only when counts were taken ────────────────────────────────────────
204
226
  // Additive by design: the three sheets above are the interactive skill's exact contract and a
205
227
  // knockout without counts produces a byte-identical workbook. A count that could not be taken says
@@ -213,37 +235,37 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
213
235
  const noteRows = [];
214
236
  // WHAT THE LOOK AT THE CORRECTED RECORD STILL FOUND, for the reviewing lawyer, in its own words. Not on the client's report.
215
237
  // Where the run could not close it, the note says why, so the lawyer can tell a repair that failed from a look that did not run.
216
- const OPEN_BECAUSE = { 'not-corrected': 'Not corrected in this run: ', 'not-rechecked': 'Corrected, but not read again: ', 'not-answered': 'Not answered: ' };
217
- for (const p of degraded.openPoints ?? []) noteRows.push({ 'Mark': p.mark, 'Type': 'Internal note', 'Note': `${OPEN_BECAUSE[p.state] ?? ''}${p.problem}` });
238
+ const OPEN_BECAUSE = KW.openBecause;
239
+ for (const p of degraded.openPoints ?? []) noteRows.push({ 'Mark': p.mark, 'Type': KW.internalNote, 'Note': `${OPEN_BECAUSE[p.state] ?? ''}${p.problem}` });
218
240
  for (const m of findings.marks ?? []) {
219
- for (const n of m.purpleNotes ?? []) noteRows.push({ 'Mark': m.name, 'Type': 'Internal note', 'Note': n });
220
- if (m.registerEstimate) noteRows.push({ 'Mark': m.name, 'Type': 'Register estimate (model)', 'Note': m.registerEstimate });
241
+ for (const n of m.purpleNotes ?? []) noteRows.push({ 'Mark': m.name, 'Type': KW.internalNote, 'Note': n });
242
+ if (m.registerEstimate) noteRows.push({ 'Mark': m.name, 'Type': KW.registerEstimate, 'Note': m.registerEstimate });
221
243
  }
222
244
  if (noteRows.length) addSheet(wb, 'Working Notes', ['Mark', 'Type', 'Note'], noteRows);
223
245
 
224
246
  if (registerCounts?.marks?.length) {
225
247
  // A floor the register disclosed is its own figure, printed as the report prints it.
226
- const cell = (c) => (Number.isFinite(c?.total) ? c.total : disclosedFloor(c) !== null ? moreThan(disclosedFloor(c)) : 'not available');
248
+ const cell = (c) => (Number.isFinite(c?.total) ? c.total : disclosedFloor(c) !== null ? moreThan(disclosedFloor(c)) : KW.notAvailable);
227
249
  const countRows = (findings.marks ?? []).map((m) => {
228
250
  const e = countsForMark(registerCounts, m.name);
229
251
  const row = {
230
252
  'Mark': m.name,
231
- 'Classes counted': (e?.classes ?? []).join(', ') || 'all classes',
232
- 'Territories': (registerCounts.scope?.regions ?? []).join(', ') || 'worldwide',
253
+ 'Classes counted': (e?.classes ?? []).join(', ') || KW.allClasses,
254
+ 'Territories': (registerCounts.scope?.regions ?? []).join(', ') || KW.worldwide,
233
255
  };
234
256
  for (const p of COUNT_PREDICATES) row[p.column] = cell(e?.counts?.[p.key]);
235
257
  // WHICH FORMS the close column was counted over. Without it the aggregate is a number nobody can
236
258
  // check: two runs of the same mark under different rule tables produce different figures and the
237
259
  // sheet would show no reason why. An archived schema-1 row (no expansion cell) says so in words
238
260
  // rather than showing a blank, which on this sheet reads as "none".
239
- row['Close variation forms'] = variantFormsLine(e) ?? 'not recorded — this run predates the close-variation column';
261
+ row['Close variation forms'] = variantFormsLine(e) ?? KW.formsNotRecorded;
240
262
  row['Register'] = registerCounts.providerLabel ?? registerCounts.provider ?? '';
241
263
  row['Basis'] = COUNT_BASIS;
242
264
  // The reader's line for anything missing. The provider's own reason, or an exception's message, stays
243
265
  // in the counts record where it was written (register-count.mjs, countNote).
244
266
  row['Notes'] = COUNT_PREDICATES
245
267
  .filter((p) => !Number.isFinite(e?.counts?.[p.key]?.total) && disclosedFloor(e?.counts?.[p.key]) === null)
246
- .map((p) => `${p.label}: ${countNote(e?.counts?.[p.key]) ?? 'no count recorded'}`)
268
+ .map((p) => `${p.label}: ${countNote(e?.counts?.[p.key]) ?? KW.noCountRecorded}`)
247
269
  .join(' · ');
248
270
  return row;
249
271
  });
@@ -271,15 +293,15 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
271
293
  const recordRows = [];
272
294
  // The cell says which question found the filing: `default` is the register's containing search. An owner search is no
273
295
  // question about the name, so it gets no word here. An archived listing names no predicate, so it reads as it did.
274
- const basisCell = (basis, predicate) => (predicate === 'default' ? 'containing search' : predicate === 'phonetic' ? 'sound-alike search'
275
- : predicate === 'owner' ? '—' : basis === 'close' ? 'close variation' : 'identical');
296
+ const basisCell = (basis, predicate) => (predicate === 'default' ? KW.containingSearch : predicate === 'phonetic' ? KW.soundAlikeSearch
297
+ : predicate === 'owner' ? '—' : basis === 'close' ? KW.closeVariation : KW.identical);
276
298
  for (const m of findings.marks ?? []) {
277
299
  const e = recordsForMark(registerRecords, m.name);
278
300
  if (!e) {
279
301
  recordRows.push({
280
- 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': 'not listed',
302
+ 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': KW.notListed,
281
303
  'Owner': '—', 'Status': '—', 'Classes': '—', 'Territory': '—', 'Filed': '—', 'Registered': '—',
282
- 'Record': '—', 'Note': registerRecords.unavailable ?? 'no listing was recorded for this mark',
304
+ 'Record': '—', 'Note': registerRecords.unavailable ?? KW.noListingRecorded,
283
305
  });
284
306
  continue;
285
307
  }
@@ -305,30 +327,30 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
305
327
  if (t.ok) continue;
306
328
  recordRows.push({
307
329
  'Mark': m.name, 'Matched form': t.term, 'Basis': basisCell(t.basis, t.predicate),
308
- 'Trademark': 'not available', 'Owner': '—', 'Status': '—', 'Classes': '—', 'Territory': '—',
330
+ 'Trademark': KW.notAvailable, 'Owner': '—', 'Status': '—', 'Classes': '—', 'Territory': '—',
309
331
  'Filed': '—', 'Registered': '—', 'Record': '—',
310
- 'Note': !t.reason ? 'the search did not run' : t.notAsked ? t.reason : plainCause(t.reason),
332
+ 'Note': !t.reason ? KW.searchDidNotRun : t.notAsked ? t.reason : plainCause(t.reason),
311
333
  });
312
334
  }
313
335
  // An added class's question that has no answer is on the sheet as what it is, with the reason where one was given.
314
336
  for (const t of e.terms ?? []) {
315
337
  if (!t.unresolved) continue;
316
338
  recordRows.push({
317
- 'Mark': m.name, 'Matched form': t.term, 'Basis': 'identical', 'Trademark': 'not available', 'Owner': '—', 'Status': '—', 'Classes': (t.classes ?? []).join(', ') || '—', 'Territory': '—',
318
- 'Filed': '—', 'Registered': '—', 'Record': '—', 'Note': t.reason ?? 'the search did not run',
339
+ 'Mark': m.name, 'Matched form': t.term, 'Basis': KW.identical, 'Trademark': KW.notAvailable, 'Owner': '—', 'Status': '—', 'Classes': (t.classes ?? []).join(', ') || '—', 'Territory': '—',
340
+ 'Filed': '—', 'Registered': '—', 'Record': '—', 'Note': t.reason ?? KW.searchDidNotRun,
319
341
  });
320
342
  }
321
343
  if (!(e.records ?? []).length && (e.terms ?? []).every((t) => t.ok)) {
322
344
  // A count above zero that nothing read is not none: the register holds filings under it.
323
345
  recordRows.push({
324
- 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': noneCarriedForward(e) ? 'none carried forward' : (e.terms ?? []).some((t) => t.setAside) ? 'not available' : 'none found',
346
+ 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': noneCarriedForward(e) ? KW.noneCarriedForward : (e.terms ?? []).some((t) => t.setAside) ? KW.notAvailable : KW.noneFound,
325
347
  'Owner': '—', 'Status': '—', 'Classes': '—', 'Territory': '—', 'Filed': '—', 'Registered': '—',
326
348
  'Record': '—', 'Note': recordsLine(e) ?? '',
327
349
  });
328
350
  }
329
351
  if (e.capped) {
330
352
  recordRows.push({
331
- 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': `capped at ${e.cap}`,
353
+ 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': KW.cappedAt(e.cap),
332
354
  'Owner': '—', 'Status': '—', 'Classes': '—', 'Territory': '—', 'Filed': '—', 'Registered': '—',
333
355
  'Record': '—', 'Note': recordsLine(e) ?? '',
334
356
  });
@@ -343,7 +365,7 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
343
365
  addSheet(wb, 'Register Filings',
344
366
  ['Mark', 'Matched form', 'Basis', 'Trademark', 'Owner', 'Status', 'Classes', 'Territory', 'Filed', 'Registered', 'Record', 'Note'],
345
367
  (findings.marks ?? []).map((m) => ({
346
- 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': 'not available', 'Owner': '—', 'Status': '—',
368
+ 'Mark': m.name, 'Matched form': '—', 'Basis': '—', 'Trademark': KW.notAvailable, 'Owner': '—', 'Status': '—',
347
369
  'Classes': '—', 'Territory': '—', 'Filed': '—', 'Registered': '—', 'Record': '—', 'Note': plainDeferralReason(degraded.listing.reason),
348
370
  })));
349
371
  }
@@ -358,8 +380,8 @@ export async function buildKnockoutWorkbook(findings, receipts, outPath, registe
358
380
  const qcLines = (Array.isArray(qcFlags) ? qcFlags : []).filter((l) => typeof l === 'string' && l.trim());
359
381
  if (qcLines.length) {
360
382
  addSheet(wb, 'Machine Checks', ['Check', 'What it found'], [
361
- { 'Check': 'Machine checks flagged', 'What it found': `${qcLines.length} — enumerated below; the report was delivered as usual.` },
362
- ...qcLines.map((l, i) => ({ 'Check': `Check ${i + 1}`, 'What it found': l })),
383
+ { 'Check': KW.checksFlagged, 'What it found': KW.checksFlaggedCount(qcLines.length) },
384
+ ...qcLines.map((l, i) => ({ 'Check': KW.check(i + 1), 'What it found': l })),
363
385
  ]);
364
386
  }
365
387
  await wb.xlsx.writeFile(outPath);
@@ -401,24 +423,24 @@ export function composeKnockoutEmail({ findings, framework, overall, reports = [
401
423
  const only = n === 1 ? urlByMark.get((findings.marks ?? [])[0]?.name) ?? null : null;
402
424
  // The product's name and the reference, each where there is one: a part left out leaves no dash or colon behind it.
403
425
  const lead = [productName, job?.ref].filter(Boolean).map((p) => esc(p)).join(' — ');
404
- const head = `<p style="${FONT}">${lead ? `${lead}: ` : ''}<b>${n} mark${n === 1 ? '' : 's'}</b>, ${n === 1 ? 'rating' : 'highest rating'} <b style="color:${t.txt}">${esc(overall ?? '')}</b>.`
405
- + (only ? ` <a href="${esc(only)}">Open the full report</a>${auditUrl ? ` · <a href="${esc(auditUrl)}">audit workbook</a>` : ''}.` : '')
406
- + (!only && n > 1 ? ` One report per name below${auditUrl ? `, and one <a href="${esc(auditUrl)}">audit workbook</a> for the batch` : ''}.` : '') + `</p>`;
426
+ const head = `<p style="${FONT}">${lead ? `${lead}: ` : ''}<b>${KO.marks(n)}</b>, ${n === 1 ? KO.rating : KO.highestRating} <b style="color:${t.txt}">${esc(overall ?? '')}</b>.`
427
+ + (only ? ` <a href="${esc(only)}">${KO.openReport}</a>${auditUrl ? ` · <a href="${esc(auditUrl)}">${KO.auditWorkbook}</a>` : ''}.` : '')
428
+ + (!only && n > 1 ? ` ${KO.onePerName}${auditUrl ? KO.batchWorkbook(`<a href="${esc(auditUrl)}">${KO.auditWorkbook}</a>`) : ''}.` : '') + `</p>`;
407
429
  // — THE FIRST NON-BLANK, never element 0. `?? fallback` catches null and undefined
408
430
  // and not "", so an array whose first entry was an empty string put an empty italic line at the top of
409
431
  // the requester's email. That array shape reaches here now that the lint no longer refuses it, and the
410
432
  // fallback exists precisely so this line is never blank.
411
433
  const firstCaveat = (findings.batch?.standardCaveats ?? []).map((c) => String(c ?? "").trim()).find(Boolean);
412
- const caveat = `<p style="${FONT}"><i>${esc(firstCaveat || 'Ratings reflect our common law assessment. Register analysis may adjust ratings in either direction.')}</i></p>`;
434
+ const caveat = `<p style="${FONT}"><i>${esc(firstCaveat || KO.defaultCaveat)}</i></p>`;
413
435
  // One band and the classes behind it, or where the evidence divides them, each group's band and classes.
414
- const oneBand = (band, qualifier, classes) => `<b style="color:${bandTier(framework, band).txt ?? 'black'}">${esc(band)}${qualifier ? ` (${esc(qualifier)})` : ''}</b>${classes?.length ? ` — Classes ${esc(classes.join(', '))}` : ''}`;
436
+ const oneBand = (band, qualifier, classes) => `<b style="color:${bandTier(framework, band).txt ?? 'black'}">${esc(band)}${qualifier ? ` (${esc(qualifier)})` : ''}</b>${classes?.length ? ` — ${KO.classes} ${esc(classes.join(', '))}` : ''}`;
415
437
  const bandLine = (m) => (Array.isArray(m.classGroups) && m.classGroups.length
416
438
  ? m.classGroups.map((g) => oneBand(g.band, g.ratingQualifier, g.classes)).join('; ')
417
439
  : oneBand(m.rating, m.ratingQualifier, m.classesDriving));
418
440
  const lines = (findings.marks ?? []).map((m) => {
419
441
  const counted = registerCounts ? countLine(countsForMark(registerCounts, m.name)) : null;
420
442
  const href = n > 1 ? urlByMark.get(m.name) ?? null : null;
421
- return `<li><b>${esc(m.name)}</b>: ${bandLine(m)}${counted ? ` — ${esc(counted)}` : ''}${m.degraded ? ' — <i>manual verification recommended (automated research unavailable)</i>' : ''}${href ? ` — <a href="${esc(href)}">open this report</a>` : ''}</li>`;
443
+ return `<li><b>${esc(m.name)}</b>: ${bandLine(m)}${counted ? ` — ${esc(counted)}` : ''}${m.degraded ? ` — <i>${KO.manualCheck}</i>` : ''}${href ? ` — <a href="${esc(href)}">${KO.openThisReport}</a>` : ''}</li>`;
422
444
  }).join('');
423
445
  // A10, extended to this lane 2026-07-31 — the surviving machine-check flags reach the reviewing
424
446
  // lawyer WITH the report, in the projection's own words, or they reach nobody. The gate stays a gate:
@@ -801,6 +823,12 @@ export async function publishKnockout({ runId, codename, runDir, findings, plan,
801
823
  const markBand = single ? overall : worstBand(framework, [m]);
802
824
  writeRO(file, renderKnockoutHtml(one, framework, {
803
825
  runId, overall: markBand, issued, searched, auditFile, probeRan, registerCounts, registerRecords, ownerChecks, instructedScope, identity, matter: runId,
826
+ // The page's workbook control links the portal's audit route, the one the cover note links: the pool path to the
827
+ // file reaches no handler. Null when the workbook could not be written, and then no control is drawn.
828
+ auditHref: auditFile ? auditRouteFor(origin, runId) : null,
829
+ // The searches this run did not complete, for this page's names: the Knockout's own Left open grid.
830
+ // A listing failure counts only where no filings came back, as the workbook's own part rows read it.
831
+ leftOpen: knockoutLeftOpen({ listing: registerRecords ? null : steps.listing, reading: steps.reading }, one.marks),
804
832
  // Carried as its own value rather than folded into `registerRecords`, because three sites PRINT
805
833
  // `registerRecords.unavailable` and a marker invented here would become client-facing wording.
806
834
  registerRecordsUnreadable,
@@ -817,11 +845,10 @@ export async function publishKnockout({ runId, codename, runDir, findings, plan,
817
845
  servedModels: served,
818
846
  frameworkMethod,
819
847
  }));
820
- // The run as data — what the assistant drafts client-facing mail from, and the shape the portal's
821
- // native-render path has been reading for since before anything wrote it. One per report, so the
822
- // native render of a per-mark document is that mark's data and not the batch's. A data file that
823
- // cannot be written leaves this name's report in place and the other names publishing; `dataFile`
824
- // is null for it, so nothing points at a file that is not there.
848
+ // The run as data — what the assistant drafts client-facing mail from. One per report, so a per-mark
849
+ // document's data is that mark's and not the batch's. A data file that cannot be written leaves this
850
+ // name's report in place and the other names publishing; `dataFile` is null for it, so nothing points
851
+ // at a file that is not there.
825
852
  const dataFile = writeDataFile(single ? 'report-data.json' : `report-data-${slug}.json`, () => knockoutReportData(one, framework, {
826
853
  runId, codename, overall: markBand, issued, registerCounts, registerRecords, ownerChecks, auditFile, customerKey, matter: runId, servedModels: served,
827
854
  identity: { ...identity, level: searchPolicy?.level ?? null },
@@ -899,10 +926,9 @@ export async function publishKnockout({ runId, codename, runDir, findings, plan,
899
926
  // WHY THERE IS NO WORKBOOK, when the build threw. Absent when it built, so such a meta is unchanged.
900
927
  auditError: auditError ?? undefined,
901
928
  framework: framework ? { key: framework.framework_key, title: framework.title, custom: framework.framework_key !== 'house-triage', bands: framework.bands.map((b) => ({ label: b.label, tone: b.tone })) } : undefined,
902
- // Present ⇒ this run has a report-data.json beside its report. The portal reads this to tell a run it
903
- // could render natively from a legacy one; the field had readers long before it had a writer.
929
+ // Present ⇒ this run has a report-data.json beside each name's report, in the Knockout's shape.
904
930
  // Stamped only when every name's data file wrote, as the clearance stamps it only when its one file wrote.
905
- reportSchema: reports.every((r) => r.dataFile) ? 'report-data/1' : undefined,
931
+ reportSchema: reports.every((r) => r.dataFile) ? 'report-data/knockout-1' : undefined,
906
932
  // WHICH DOCUMENTS THIS RUN PUBLISHED, and for which name. Every reader that has to open,
907
933
  // serve or link a knockout's reports takes the list from here rather than deriving a filename: the
908
934
  // naming rule (one mark ⇒ `report.html`, several ⇒ `report-<slug>.html`) is written ONCE, above, and
@@ -22,6 +22,8 @@
22
22
  //
23
23
  // Each address was checked on 2026-09-10 against a real record, and each row says how.
24
24
 
25
+ import { RECORD_LINKS as L } from "./strings.mjs";
26
+
25
27
  const pad = (s, n) => String(s).padStart(n, "0");
26
28
  const clean = (v) => (v == null ? "" : String(v).trim());
27
29
 
@@ -244,33 +246,33 @@ export function officeReasonSentences(byUri) {
244
246
  const each = [...keys].sort().map((k) => {
245
247
  const [office, reason] = k.split(" ");
246
248
  const name = nameOf(office);
247
- if (reason === "no-page") return `${name}: the register publishes no page for a single record, so its registrations are cited by number.`;
248
- return `${name}: registrations whose numbers are not in the form the register's page address takes are cited by number, not linked.`;
249
+ if (reason === "no-page") return L.noPage(name);
250
+ return L.numberForm(name);
249
251
  });
250
252
  const codes = [...unknown].sort().map(nameOf);
251
- if (codes.length === 1) each.push(`${codes[0]}: we hold no page address for this register, so its registrations are cited by number.`);
252
- else if (codes.length > 1) each.push(`${codes.join(", ")}: we hold no page address for these registers, so their registrations are cited by number.`);
253
+ if (codes.length === 1) each.push(L.noAddress(codes[0]));
254
+ else if (codes.length > 1) each.push(L.noAddresses(codes.join(", ")));
253
255
  return each;
254
256
  }
255
257
 
256
258
  /**
257
259
  * What a linked registration number opens, when one is linked, then the reasons per office, as the
258
260
  * knockout says them under its listed filings. They are the sentences the clearance says in Scope; its
259
- * renderer is frozen (render-frozen.test.mjs) and keeps its own copy of the first.
261
+ * renderer was hash-frozen when this was written (render-frozen.test.mjs) and keeps its own copy of the first.
260
262
  */
261
263
  export function officeLinkSentences(byUri) {
262
264
  if (!(byUri instanceof Map)) return [];
263
265
  const linked = [...byUri.values()].some((l) => l?.href);
264
- return [...(linked ? ["A registration number shown as a link opens the office’s own page for that record."] : []),
266
+ return [...(linked ? [L.opensOfficePage] : []),
265
267
  ...officeReasonSentences(byUri)];
266
268
  }
267
269
 
268
270
  /** Why a registration is cited by number rather than linked, in the workbook's words. */
269
271
  export function reasonCellFor(link) {
270
272
  const name = nameOf(link.office);
271
- if (link.reason === "no-page") return `No page for a single record at this register (${name}); cited by number`;
272
- if (link.reason === "unknown-office") return `No page address held for this register (${name}); cited by number`;
273
- return `Number not in the form this register's page address takes (${name}); cited by number`;
273
+ if (link.reason === "no-page") return L.cell.noPage(name);
274
+ if (link.reason === "unknown-office") return L.cell.noAddress(name);
275
+ return L.cell.numberForm(name);
274
276
  }
275
277
 
276
278
  /** The workbook's Link cell for a finding: its first linked registration, else the first stated reason. */
@@ -0,0 +1,98 @@
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
+ // publish/page-shell.mjs — the document both report renderers wrap their page in.
4
+ //
5
+ // The clearance report (render.mjs) and the Knockout (render-knockout.mjs) built this shell each on its own: the same
6
+ // head, title, typefaces, favicon, theme script and style block, written twice, with the report's base sheet and the
7
+ // print rule defined in both files. A change a skin needs, to the head, the fonts, the theme or print, had to be made
8
+ // twice, and the two copies had already drifted on the chrome sheet.
9
+ //
10
+ // WHAT DIFFERS BETWEEN THE TWO PAGES IS AN INPUT, NEVER A SWITCH. Each renderer passes its own title, its own sheet and,
11
+ // when the pool serves one, the address of the shared chrome sheet. The clearance inlines the chrome only when it is
12
+ // given no address, and the Knockout always inlines it; each decides that in what it passes as `css`, so the shell
13
+ // emits each page's bytes exactly as its renderer wrote them before. Converging the two would change a page a reader
14
+ // sees, and is not this module's to do.
15
+ import { readFileSync } from 'node:fs';
16
+ import { join, dirname } from 'node:path';
17
+ import { fileURLToPath } from 'node:url';
18
+ import { REPORT_ROOT, REPORT_ROOT_DARK_EXPLICIT, THEME_INIT_EXPLICIT, FAVICON_LINK, BRAND } from '../../shared/brand.mjs';
19
+ import { REPORT_FONT_STYLE } from '../../shared/brand-fonts.mjs'; // the typefaces travel inside the report; it fetches nothing to draw its text
20
+
21
+ const HERE = dirname(fileURLToPath(import.meta.url));
22
+ const escHtml = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
23
+
24
+ // Brand :root tokens are sourced from shared/brand.mjs (REPORT_ROOT) and prepended to the report stylesheet, so
25
+ // report.css carries only rules — the palette lives in ONE place across surfaces.
26
+ export const REPORT_BASE = REPORT_ROOT + '\n' + readFileSync(join(HERE, 'templates', 'report.css'), 'utf8');
27
+ // Print always renders light: re-assert the REPORT_ROOT light tokens under [data-theme=dark] inside @media
28
+ // print (a dark-toggled report must never print on near-black — ink/banding + legal-document convention).
29
+ const PRINT_LIGHT = '\n@media print{' + REPORT_ROOT.replace(':root{', ':root[data-theme="dark"]{color-scheme:light;') + '}';
30
+
31
+ // Dark theme rides at EMIT time — the module-level sheets stay untouched (their light half must render
32
+ // byte-identically). The toggle arrives via the nav.
33
+ //
34
+ // EXPLICIT ONLY. A report is the product's most client-facing artefact — it is opened in front of a client, and the
35
+ // portal frames it for one — and a client surface must never follow the OS colour preference. The clearance report
36
+ // once emitted the automatic pair and went dark on a dark-mode laptop, as a delivered legal document, on the
37
+ // standalone file AND framed in the portal, because the portal's shell does not strip the rule. The Knockout already
38
+ // took the explicit pair. Dark is still fully reachable, by the toggle and by a choice carried from any other
39
+ // surface; only the automatic part is gone.
40
+
41
+ /**
42
+ * A stylesheet without its comments, for a page a client receives. The source files keep every comment: they carry
43
+ * the reasoning (a stylesheet's notes are for whoever edits it), and a client who views the source of a forwarded
44
+ * report would read internal process notes. A comment opener inside a quoted string or an unquoted url() is text, not
45
+ * a comment, and is kept as it is; a comment between two word characters leaves a space, so no two tokens merge.
46
+ * PURE.
47
+ */
48
+ export function stripCssComments(css) {
49
+ const src = String(css ?? '');
50
+ let out = '';
51
+ for (let i = 0; i < src.length;) {
52
+ const ch = src[i];
53
+ if (ch === '"' || ch === "'") { // a quoted string, copied whole, escapes included
54
+ let j = i + 1;
55
+ while (j < src.length && src[j] !== ch) j += src[j] === '\\' ? 2 : 1;
56
+ out += src.slice(i, j + 1); i = j + 1; continue;
57
+ }
58
+ if (/^url\(/i.test(src.slice(i, i + 4)) && !/[\w-]/.test(src[i - 1] ?? '')) { // url( … ), quoted or not
59
+ let j = i + 4, quote = null;
60
+ for (; j < src.length; j++) {
61
+ if (quote) { if (src[j] === '\\') j++; else if (src[j] === quote) quote = null; }
62
+ else if (src[j] === '"' || src[j] === "'") quote = src[j];
63
+ else if (src[j] === ')') break;
64
+ }
65
+ out += src.slice(i, j + 1); i = j + 1; continue;
66
+ }
67
+ if (ch === '/' && src[i + 1] === '*') {
68
+ const end = src.indexOf('*/', i + 2);
69
+ const next = end < 0 ? src.length : end + 2;
70
+ if (/[\w-]$/.test(out) && /^[\w-]/.test(src.slice(next, next + 1))) out += ' ';
71
+ i = next; continue;
72
+ }
73
+ out += ch; i++;
74
+ }
75
+ return out;
76
+ }
77
+
78
+ // THE PAGE'S OWN CHROME CARRIES ONE ATTRIBUTE, data-report-chrome: the sticky header (the bar, the export menu, the
79
+ // section strip) on both reports, and the Knockout's theme button. The portal frames a report and removes that chrome,
80
+ // and it found it by class names a re-skin could rename without a sound. An element carrying the attribute is the
81
+ // renderer saying "this is mine, not the report's". No stylesheet selects on it, so it changes nothing a reader sees.
82
+
83
+ /**
84
+ * One report page. `title` is the page's own title as HTML, already escaped by its renderer; the shell adds the
85
+ * product's name after it. `css` is the renderer's sheet, placed after the base sheet and before the dark and print
86
+ * rules. `chromeHref`, when given, links the pool's shared chrome sheet after the inline style, so the chrome stays
87
+ * last in the cascade. `body` is everything inside <body>.
88
+ */
89
+ export function pageShell({ title, css, chromeHref, body }) {
90
+ const chromeLinkTag = chromeHref ? `<link rel="stylesheet" href="${escHtml(chromeHref)}">` : '';
91
+ return `<!DOCTYPE html>
92
+ <html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
93
+ <title>${title} · ${escHtml(BRAND.name)}</title>
94
+ ${REPORT_FONT_STYLE}${FAVICON_LINK}${THEME_INIT_EXPLICIT}
95
+ <style>${stripCssComments(`${REPORT_BASE}\n${css}${REPORT_ROOT_DARK_EXPLICIT}${PRINT_LIGHT}`)}</style>${chromeLinkTag}</head><body class="has-glow">
96
+ ${body}
97
+ </body></html>`;
98
+ }
@@ -75,6 +75,10 @@ export const PUBLISH_INPUTS = {
75
75
  "register-named-band.json": "optional",
76
76
  // The instructed scope, read only as the register plan's fallback for the searched-jurisdiction set.
77
77
  "_driver/instructed-scope.json": "optional",
78
+ // The scope facts, read only for the register service's reach the run recorded beside its coverage line: the head
79
+ // of the workbook's register rows states it. Optional: a run from before the record, and every run whose service
80
+ // declares no office list, has no reach, and the head keeps its earlier words.
81
+ "_driver/scope-facts.json": "optional",
78
82
  // The frozen local-language lane decision, and the units the fold wrote. Read to derive how deep that
79
83
  // investigation went against what the matter configured — through the engine's own asked-versus-ran
80
84
  // reader, not by re-deciding it here. Optional and genuinely so: a plain clearance never runs the
@@ -6,7 +6,7 @@
6
6
  // The common-law sentinel is 'C/L', never 'CL' — to a trademark lawyer CL is Chile (ISO 3166), and an
7
7
  // actual Chilean registration must not collide with the common-law bucket (the latent bug a reviewing
8
8
  // lawyer hit on a live matter). Every ISO-3166 alpha-2 key in REGION_NAMES must therefore carry its
9
- // country meaning; only non-ISO keys ('C/L', 'WO', 'BX', 'EU') may carry a non-country meaning —
9
+ // country meaning; only non-ISO keys ('C/L', 'WO', 'BX', 'EU', 'XS') may carry a non-country meaning —
10
10
  // regions.test.mjs guards this.
11
11
  //
12
12
  // PURE (no node imports) so tests run offline and any surface (render, email, xlsx) can import it.
@@ -22,6 +22,9 @@ export const REGION_NAMES = {
22
22
  MX: 'Mexico', TW: 'Taiwan', HK: 'Hong Kong', SA: 'Saudi Arabia', AE: 'United Arab Emirates',
23
23
  DK: 'Denmark', FI: 'Finland', PL: 'Poland', PT: 'Portugal', AT: 'Austria', BE: 'Belgium',
24
24
  IE: 'Ireland', GR: 'Greece', IL: 'Israel', TK: 'Tokelau',
25
+ // XS is no country: it is the code the US state registers are filed under beside the federal one, read as they are
26
+ // named (owner, 2026-11-18). It printed as "XS".
27
+ XS: 'US state registers',
25
28
  CL: 'Chile', [COMMON_LAW]: 'Common-law',
26
29
  };
27
30
 
@@ -34,5 +37,23 @@ export const REGION_ALIAS = { GB: 'UK', EM: 'EU', EUTM: 'EU', EUIPO: 'EU', INT:
34
37
 
35
38
  export const normRegion = (c) => { const u = String(c || '').toUpperCase(); return REGION_ALIAS[u] || u; };
36
39
 
37
- // Unknown code ⇒ the raw code doubles as the name, so a new register surfaces without a change here.
38
- export const regionName = (code) => REGION_NAMES[code] || code;
40
+ // THE NAME A READER SEES. The table above wins; a two-letter country code it lacks takes the name the runtime's own
41
+ // region names give it (Intl.DisplayNames, a global, so this file stays import-free); anything else is printed as
42
+ // the code itself, so a new register still surfaces without a change here. 128 of 320 country rows on delivered
43
+ // reports printed a bare code (AR, CO, CZ) because the table is hand-kept.
44
+ //
45
+ // ONLY A REAL COUNTRY CODE IS ASKED. ZZ reads "Unknown Region" and a numeric code "world", and neither may reach a
46
+ // page, so the question is put only for two capital letters outside ZZ and the private-use ranges (AA, QM to QZ,
47
+ // XA to XZ), and a name that comes back as the code itself (EM) is no name. The runtime's names come from its ICU
48
+ // data, so a newer Node can spell one differently; the table is where a spelling is pinned (TR stays Turkey).
49
+ const PRIVATE_USE = /^(?:AA|ZZ|Q[M-Z]|X[A-Z])$/;
50
+ let displayNames;
51
+ function runtimeRegionName(code) {
52
+ if (!/^[A-Z]{2}$/.test(code) || PRIVATE_USE.test(code) || typeof Intl?.DisplayNames !== 'function') return null;
53
+ try {
54
+ displayNames ??= new Intl.DisplayNames(['en'], { type: 'region' });
55
+ const name = displayNames.of(code);
56
+ return name && name !== code ? name : null;
57
+ } catch { return null; }
58
+ }
59
+ export const regionName = (code) => REGION_NAMES[code] || runtimeRegionName(code) || code;