clearotron 0.6.0 → 0.7.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALL.md +7 -4
- package/QUICKSTART.md +1 -0
- package/README.md +5 -2
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/bin/clearotron.mjs +4 -2
- package/bin/onboard.mjs +158 -29
- package/build-info.json +2 -2
- package/docs/CLIENT-MCP.md +3 -1
- package/docs/DELIVERY.md +6 -3
- package/docs/architecture/02-architecture.md +1 -1
- package/docs/architecture/04-configuration-reference.md +105 -8
- package/docs/branding.md +4 -4
- package/docs/report-data/clearance-1.schema.json +320 -0
- package/docs/report-data/knockout-1.schema.json +268 -0
- package/driver/CHANGELOG.md +77 -0
- package/driver/cancel.mjs +19 -0
- package/driver/connotation-search.mjs +1 -1
- package/driver/contract-e3-backlog.mjs +41 -41
- package/driver/contract-vocabulary.mjs +1 -1
- package/driver/coverage-ledger.mjs +18 -2
- package/driver/deferral-row.mjs +1 -1
- package/driver/degraded-parts.mjs +1 -0
- package/driver/driver.config.mjs +5 -5
- package/driver/effective-scope.mjs +3 -1
- package/driver/engagement-receipt.mjs +3 -3
- package/driver/engine/anthropic-agent.mjs +15 -1
- package/driver/engine/common.mjs +7 -0
- package/driver/engine/mcp/band-server.mjs +7 -16
- package/driver/engine/mcp/codex-config.mjs +3 -0
- package/driver/engine/mcp/recording-server.mjs +45 -34
- package/driver/engine/openai-agent.mjs +74 -7
- package/driver/engine/session-record.mjs +44 -2
- package/driver/findings-model.mjs +14 -2
- package/driver/follow-up-twins.mjs +86 -0
- package/driver/gateway.mjs +77 -12
- package/driver/jx-units.mjs +3 -1
- package/driver/jx.mjs +13 -5
- package/driver/manuals-inline.mjs +98 -0
- package/driver/manuals-seen.mjs +134 -0
- package/driver/mark-logos.mjs +174 -0
- package/driver/methodology-witness.mjs +2 -1
- package/driver/owner-use-check.mjs +8 -4
- package/driver/package.json +1 -1
- package/driver/pipeline-knockout.mjs +23 -4
- package/driver/pipeline.mjs +128 -15
- package/driver/portal-local-auth.mjs +6 -2
- package/driver/portal-report.mjs +45 -14
- package/driver/portal-routes/me.mjs +4 -1
- package/driver/portal-runs.mjs +19 -16
- package/driver/predelivery-lint.mjs +7 -5
- package/driver/profiles.mjs +4 -4
- package/driver/publish/README.md +9 -7
- package/driver/publish/email-conditions.mjs +22 -5
- package/driver/publish/evidence-words.mjs +21 -0
- package/driver/publish/index.mjs +304 -211
- package/driver/publish/knockout.mjs +297 -247
- package/driver/publish/office-record-links.mjs +11 -9
- package/driver/publish/page-shell.mjs +98 -0
- package/driver/publish/pool-admin.mjs +2 -2
- package/driver/publish/publish-inputs.mjs +4 -0
- package/driver/publish/regions.mjs +28 -3
- package/driver/publish/register-record-html.mjs +105 -0
- package/driver/publish/register-record.mjs +165 -0
- package/driver/publish/render-knockout.mjs +299 -671
- package/driver/publish/render.mjs +561 -492
- package/driver/publish/report-data.mjs +226 -13
- package/driver/publish/report-document.mjs +353 -0
- package/driver/publish/search-depth.mjs +88 -7
- package/driver/publish/shell.mjs +41 -1
- package/driver/publish/strings.mjs +810 -0
- package/driver/publish/templates/clearance-print.css +23 -0
- package/driver/publish/templates/knockout.css +224 -0
- package/driver/publish/templates/report.css +112 -53
- package/driver/publish/xlsx.mjs +158 -139
- package/driver/record-goods.mjs +42 -0
- package/driver/reference-score.mjs +4 -1
- package/driver/register-count.mjs +5 -1
- package/driver/register-reach.mjs +39 -0
- package/driver/registry-fidelity.mjs +155 -37
- package/driver/repair-composers.mjs +7 -3
- package/driver/repair-targets.mjs +4 -1
- package/driver/replay-archive.mjs +4 -3
- package/driver/run-delivered.mjs +14 -8
- package/driver/run-record.mjs +1 -0
- package/driver/runner.mjs +73 -29
- package/driver/scope-facts.mjs +27 -6
- package/driver/search-policy.mjs +9 -4
- package/driver/skills/clearance-search/report-prose.md +3 -0
- package/driver/skills/knockout-assess/SKILL.md +8 -0
- package/driver/stage-freshness.mjs +8 -5
- package/driver/stages.mjs +69 -43
- package/driver/steps/delivery.mjs +9 -5
- package/driver/steps/overview-and-cards.mjs +54 -15
- package/driver/steps/register-sweep.mjs +5 -4
- package/driver/steps/skeptic-and-follow-up.mjs +3 -2
- package/driver/steps/verdict-gate.mjs +35 -14
- package/driver/suite-census.json +579 -87
- package/driver/synthesis-record.mjs +4 -3
- package/driver/terminal-clamp.mjs +6 -1
- package/driver/withdrawn-rating.mjs +72 -0
- package/mcp-server/CHANGELOG.md +8 -0
- package/mcp-server/lib/audit-view.mjs +5 -2
- package/mcp-server/lib/brief.mjs +6 -2
- package/mcp-server/lib/evidence.mjs +94 -23
- package/mcp-server/lib/findings.mjs +19 -2
- package/mcp-server/lib/knockout.mjs +13 -4
- package/mcp-server/lib/scrub.mjs +1 -1
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +22 -3
- package/package.json +4 -1
- package/portal-ui/dist/assets/{index-CYaO2ygd.js → index-BBlN4CYq.js} +238 -80
- package/portal-ui/dist/assets/{index-izLa9apq.css → index-CxAkJXIT.css} +25 -5
- package/portal-ui/dist/index.html +2 -2
- package/portal-ui/package.json +3 -3
- package/providers/_shared/ledger.mjs +30 -2
- package/providers/_shared/record-uri.mjs +15 -0
- package/providers/clarivate/src/adapter.js +11 -0
- package/providers/clarivate/src/core.js +17 -1
- package/providers/jx/src/core.js +4 -4
- package/providers/jx/src/judge.js +1 -3
- package/providers/jx/src/nativeread.js +1 -3
- package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/scripts/README.md +147 -3
- package/scripts/added-reference-check.mjs +35 -7
- package/scripts/e2e-first-time.mjs +4 -4
- package/scripts/env-audit.mjs +16 -9
- package/scripts/freeze-example-run.mjs +3 -3
- package/scripts/mint-public-residue.mjs +3 -3
- package/scripts/mint-search-level-tags.mjs +61 -0
- package/scripts/mint-source-pin-census.mjs +89 -0
- package/scripts/release-note-required.mjs +65 -6
- package/scripts/test-durations-reporter.mjs +25 -0
- package/scripts/test-full.mjs +72 -18
- package/scripts/test-run.mjs +18 -1
- package/shared/brand.mjs +93 -6
- package/shared/inline-markdown.mjs +53 -0
- package/shared/names-in-force.mjs +0 -1
- package/shared/portal-tokens.mjs +2 -1
- package/shared/reference-guard-classes.mjs +43 -2
- package/shared/register-selection.mjs +8 -3
- package/shared/search-level-tags.json +25 -0
- package/shared/source-spans.mjs +91 -0
- package/shared/tools/derive-band-pairs.mjs +10 -0
- package/driver/own-rights.mjs +0 -83
- package/driver/use-check.mjs +0 -85
package/driver/publish/xlsx.mjs
CHANGED
|
@@ -17,14 +17,17 @@
|
|
|
17
17
|
// vocabulary reaching a lawyer-visible cell) for the driver to log — it never suppresses the deliverable.
|
|
18
18
|
// exceljs is loaded lazily so this delivery-only dep can never break the driver's import.
|
|
19
19
|
|
|
20
|
-
import { BRAND } from '../../shared/brand.mjs';
|
|
20
|
+
import { BRAND, WORKBOOK_COLOURS as WB } from '../../shared/brand.mjs';
|
|
21
|
+
import { meterEvidence } from './evidence-words.mjs';
|
|
22
|
+
import { WORKBOOK as W, WORKBOOK_LABELS as LABELS } from './strings.mjs';
|
|
21
23
|
import { projectAssessmentField } from '../findings-model.mjs';
|
|
22
24
|
import { inputsLine } from '../framework-method.mjs';
|
|
23
25
|
import { deliveryVocabViolations } from '../predelivery-lint.mjs';
|
|
26
|
+
import { coverageUnitLabel } from '../coverage-ledger.mjs';
|
|
24
27
|
|
|
25
|
-
const HEAD_FILL =
|
|
28
|
+
const HEAD_FILL = WB.headerFill;
|
|
26
29
|
// plain-English coverage-state fills (the state words are relabelled for the reader; the fills key off them).
|
|
27
|
-
const STATE_FILL = {
|
|
30
|
+
const STATE_FILL = { [W.state.clean]: WB.stateClean, [W.state.limited]: WB.stateLimited, [W.state.open]: WB.stateOpen, [W.state.note]: WB.stateNote };
|
|
28
31
|
const WIDE = {
|
|
29
32
|
// Summary
|
|
30
33
|
'Field': 26, 'Value': 96,
|
|
@@ -36,6 +39,10 @@ const WIDE = {
|
|
|
36
39
|
'Search term / variant': 40, 'Scope': 20, 'Result': 24, 'Outcome': 24, 'Note': 60,
|
|
37
40
|
// Coverage & gaps
|
|
38
41
|
'Area': 40, 'State': 12, 'What was done': 60, "What's left": 60,
|
|
42
|
+
// The Knockout's sheets (knockout.mjs), whose long text wrapped in the 16-wide default: Findings, Negative Results,
|
|
43
|
+
// Audit Trail and Working Notes. One table for both workbooks, so a header means one width wherever it appears.
|
|
44
|
+
'Finding Name': 40, 'Type': 40, 'Net': 60, 'Basis': 60, 'Evidence': 60,
|
|
45
|
+
'Search Term': 40, 'Source / Context': 40, 'Notes': 60, 'Result Summary': 60,
|
|
39
46
|
};
|
|
40
47
|
const width = h => WIDE[h] || 16;
|
|
41
48
|
|
|
@@ -47,11 +54,12 @@ export const BANNED = /\b(receipts?|lint|tripwires?|composite|quadrants?|scatter
|
|
|
47
54
|
|
|
48
55
|
// A10 rows are composed by predelivery-lint's projection table. If a caller hands this module a check
|
|
49
56
|
// object instead of a projected line, the row says nothing rather than saying the engine's words.
|
|
50
|
-
const A10_UNPROJECTED =
|
|
57
|
+
const A10_UNPROJECTED = W.checkNotPassed;
|
|
51
58
|
// The Summary rows A10 owns. validateAudit holds these to a HARD standard (see there) — the general
|
|
52
59
|
// BANNED scan over every cell stays advisory, because archived model-authored prose legitimately trips
|
|
53
60
|
// it and a republish must not lose its workbook over a word in a finding.
|
|
54
|
-
const
|
|
61
|
+
const reEscape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
62
|
+
const A10_FIELD_RE = new RegExp(`^(?:${reEscape(W.summary.checksFlagged)}|\\s+${reEscape(W.summary.check)} \\d+)$`);
|
|
55
63
|
|
|
56
64
|
// plainNote: fold the raw spine/model prose that reaches a reader cell down to plain English — strip markdown
|
|
57
65
|
// emphasis and rewrite the few engineering phrases that leak through the search log ("has_more:false"). The
|
|
@@ -62,9 +70,17 @@ function plainNote(s) {
|
|
|
62
70
|
.replace(/has_more\s*:?\s*false/gi, 'completion')
|
|
63
71
|
.replace(/\bhas_more\b/gi, 'enumeration')
|
|
64
72
|
.replace(/\s+/g, ' ')
|
|
65
|
-
.trim()
|
|
73
|
+
.trim()
|
|
74
|
+
// A note that opens with the ledger's state word opens with the report's instead (2026-11-18).
|
|
75
|
+
.replace(/^coverage-limited — /, 'Partially covered — ')
|
|
76
|
+
.replace(/^deferred — /, 'Not searched — ');
|
|
66
77
|
}
|
|
67
78
|
|
|
79
|
+
// A run stores its slice labels in the words of the build that wrote them, and both workbooks copy them into
|
|
80
|
+
// cells. Every cell says "main register search", as the workbook's own words do (2026-11-18). Lower case
|
|
81
|
+
// only, as readerWords: a capitalised word is a name and stays as written.
|
|
82
|
+
const inCellWords = (v) => (typeof v === 'string' ? v.replace(/\bmain register sweep\b/g, 'main register search') : v);
|
|
83
|
+
|
|
68
84
|
// a column is "empty" only when NO data row fills it. Dropping such a column honours the spec's
|
|
69
85
|
// "no dead schema" by construction (a common-law-only run simply omits Class / Registration(s) rather
|
|
70
86
|
// than shipping them blank) AND means the workbook never carries an empty column to trip a gate on.
|
|
@@ -83,20 +99,21 @@ const nonEmptyColumns = (columns, rows) =>
|
|
|
83
99
|
columns.filter(h => rows.some(r => !cellEmpty(r[h])));
|
|
84
100
|
|
|
85
101
|
export function addSheet(wb, name, columns, rows, styleRow) {
|
|
86
|
-
|
|
102
|
+
// The tab and its headers read as the catalogue says; the code builds the rows on the keys.
|
|
103
|
+
const ws = wb.addWorksheet(LABELS.sheets[name] ?? name, { views: [{ state: 'frozen', ySplit: 1 }] });
|
|
87
104
|
const cols = nonEmptyColumns(columns, rows);
|
|
88
105
|
columns = cols.length ? cols : columns; // never drop EVERY column (empty sheet keeps its headers)
|
|
89
|
-
ws.columns = columns.map(h => ({ header: h, key: h, width: width(h) }));
|
|
106
|
+
ws.columns = columns.map(h => ({ header: LABELS.columns[h] ?? h, key: h, width: width(h) }));
|
|
90
107
|
const kept = new Set(columns); // what SURVIVED the drop — the set every styler is held to
|
|
91
108
|
const hr = ws.getRow(1);
|
|
92
109
|
hr.eachCell(c => {
|
|
93
|
-
c.font = { bold: true, color: { argb:
|
|
110
|
+
c.font = { bold: true, color: { argb: WB.headerText } };
|
|
94
111
|
c.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF' + HEAD_FILL } };
|
|
95
112
|
c.alignment = { vertical: 'middle', wrapText: true };
|
|
96
113
|
});
|
|
97
114
|
hr.height = 26;
|
|
98
115
|
for (const r of rows) {
|
|
99
|
-
const row = ws.addRow(r);
|
|
116
|
+
const row = ws.addRow(Object.fromEntries(Object.entries(r).map(([k, v]) => [k, inCellWords(v)])));
|
|
100
117
|
row.alignment = { vertical: 'top', wrapText: true };
|
|
101
118
|
// a styler gets the written row, its SOURCE data, and the surviving columns. Each states its own
|
|
102
119
|
// precondition against `kept`, so a dropped column makes that one rule a no-op and leaves every
|
|
@@ -111,54 +128,51 @@ export function addSheet(wb, name, columns, rows, styleRow) {
|
|
|
111
128
|
|
|
112
129
|
// source_type -> the plain word a lawyer reads. A register finding never wears a common-law label and back.
|
|
113
130
|
const sourceWord = st => /^register/.test(st) ? 'Register'
|
|
114
|
-
: /^case-law/.test(st) ?
|
|
115
|
-
: /marketplace/.test(st) ?
|
|
116
|
-
: /^common-law/.test(st) ?
|
|
117
|
-
: st ?
|
|
131
|
+
: /^case-law/.test(st) ? W.sourceLayer.caseLaw
|
|
132
|
+
: /marketplace/.test(st) ? W.sourceLayer.marketplace
|
|
133
|
+
: /^common-law/.test(st) ? W.sourceLayer.web
|
|
134
|
+
: st ? W.sourceLayer.web : '';
|
|
118
135
|
|
|
119
136
|
// /mark/ca/1693383 -> country "CA", number "1693383", "CA 1693383". Absent/odd shapes fall back gracefully.
|
|
120
137
|
const uriCountry = uri => (String(uri || '').match(/\/mark\/([a-z]{2})\//i)?.[1] || '').toUpperCase();
|
|
121
138
|
const uriNumber = uri => String(uri || '').match(/\/mark\/[a-z]{2,6}\/(.+)$/i)?.[1] || String(uri || '');
|
|
122
139
|
const regLabel = uri => { const c = uriCountry(uri); const n = uriNumber(uri); return c ? `${c} ${n}` : n; };
|
|
123
140
|
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
141
|
+
// THE CELL SAYS WHAT THE PAGE SAYS: the token, and the meter's evidence in the report's own words
|
|
142
|
+
// (evidence-words.mjs). An unknown value nobody checked reads "not checked" where the page has no word for it.
|
|
143
|
+
export const meterCell = (m, driver) => {
|
|
144
|
+
if (!m || !m.token) return '';
|
|
145
|
+
const word = meterEvidence(driver, m) || (m.token === 'unknown' && driver !== 'mark_similarity' ? W.notChecked : '');
|
|
146
|
+
return `${m.token}${word ? ` · ${word}` : ''}`;
|
|
147
|
+
};
|
|
129
148
|
|
|
130
149
|
// disposition -> the plain "how we treated it" sentence.
|
|
131
|
-
const TREATMENT =
|
|
132
|
-
adversarial: 'On-field — stress-tested as the closest conflict',
|
|
133
|
-
'coexistence-partner': 'Coexistence partner — living alongside, kept manageable',
|
|
134
|
-
distinguished: 'Distinguished — weak shared element, kept manageable',
|
|
135
|
-
'off-field': 'Off-field — outside the risk zone',
|
|
136
|
-
};
|
|
150
|
+
const TREATMENT = W.treatment;
|
|
137
151
|
const treatmentCell = f => f?.disposition === 'withdrawn'
|
|
138
|
-
?
|
|
139
|
-
: (f?.isContextNote ?
|
|
152
|
+
? W.withdrawn(plainNote(f.withdrawn_reason) || W.noReasonRecorded)
|
|
153
|
+
: (f?.isContextNote ? W.contextNote : (TREATMENT[f?.disposition] || ''));
|
|
140
154
|
|
|
141
155
|
// Record retrieved? — the plain-English state of the register-record fetch for a finding, from the per-URI
|
|
142
156
|
// fetch-state map ({retrieved | failed | not-attempted}). A common-law finding (no registrations) is
|
|
143
157
|
// "n/a — live listing"; a failed fetch is VISIBLY unverified, never presented as confirmed.
|
|
144
158
|
export function retrievedCell(f, fetchState) { // @internal — driven by its test
|
|
145
159
|
const regs = f?.owner?.registrations || [];
|
|
146
|
-
if (!regs.length) return
|
|
160
|
+
if (!regs.length) return W.liveListing;
|
|
147
161
|
const st = uri => (fetchState && fetchState[String(uri || '').toLowerCase()]) || 'not-attempted';
|
|
148
162
|
const states = regs.map(r => st(r.uri));
|
|
149
|
-
if (states.every(s => s === 'retrieved')) return
|
|
163
|
+
if (states.every(s => s === 'retrieved')) return W.retrieved;
|
|
150
164
|
const anyRead = states.some(s => s === 'retrieved');
|
|
151
165
|
const anyFailed = states.some(s => s === 'failed');
|
|
152
166
|
// no leg read: a fetch that FAILED (a 404) makes the registry values unverified — say so visibly; a leg
|
|
153
167
|
// simply never pulled (off-field context) is the softer "not individually retrieved".
|
|
154
|
-
if (!anyRead) return anyFailed ?
|
|
168
|
+
if (!anyRead) return anyFailed ? W.notRetrievedUnverified : W.notIndividuallyRetrieved;
|
|
155
169
|
// mixed — spell out which country legs were retrieved and which were not ("CA retrieved; US/AU not retrieved").
|
|
156
170
|
const read = regs.filter(r => st(r.uri) === 'retrieved').map(r => uriCountry(r.uri)).filter(Boolean);
|
|
157
171
|
const missing = regs.filter(r => st(r.uri) !== 'retrieved').map(r => uriCountry(r.uri)).filter(Boolean);
|
|
158
172
|
const parts = [];
|
|
159
|
-
if (read.length) parts.push(
|
|
160
|
-
if (missing.length) parts.push(
|
|
161
|
-
return parts.join('; ') ||
|
|
173
|
+
if (read.length) parts.push(W.countriesRetrieved(read.join('/')));
|
|
174
|
+
if (missing.length) parts.push(W.countriesNotRetrieved(missing.join('/')));
|
|
175
|
+
return parts.join('; ') || W.notIndividuallyRetrieved;
|
|
162
176
|
}
|
|
163
177
|
|
|
164
178
|
// Status & key dates — a single representative line from the first registration whose record was read.
|
|
@@ -191,17 +205,17 @@ function findingRows(findings, fetchState, recordLinks = null, method = null) {
|
|
|
191
205
|
'Country': f.owner?.country || '',
|
|
192
206
|
'Source': sourceWord(f.source?.source_type || ''),
|
|
193
207
|
'Class': classCell(f),
|
|
194
|
-
'Registration(s)': regs.length ? regs.map(r => recordLinks?.get(String(r.uri || '').toLowerCase())?.label || regLabel(r.uri)).join('; ') : (ctx ? '—' :
|
|
208
|
+
'Registration(s)': regs.length ? regs.map(r => recordLinks?.get(String(r.uri || '').toLowerCase())?.label || regLabel(r.uri)).join('; ') : (ctx ? '—' : W.commonLawRegistration),
|
|
195
209
|
'Status & key dates': statusDatesCell(f),
|
|
196
|
-
'Record retrieved?': ctx ?
|
|
210
|
+
'Record retrieved?': ctx ? W.notedOnly : retrievedCell(f, fetchState),
|
|
197
211
|
// where the framework states a method, its inputs ride beside the band, as on the report card
|
|
198
212
|
'Risk band': f.band ? [f.band, inputsLine(method, f.inputs)].filter(Boolean).join(' · ') : '—',
|
|
199
213
|
'How we treated it': treatmentCell(f),
|
|
200
214
|
// context notes are NOT rated conflicts — the four drivers read n/a and the four-drivers gate skips them.
|
|
201
|
-
'Mark similarity': ctx ? 'n/a' : meterCell(f.meters?.mark_similarity),
|
|
202
|
-
'Goods proximity': ctx ? 'n/a' : meterCell(f.meters?.goods_proximity),
|
|
203
|
-
'Use': ctx ? 'n/a' : meterCell(f.meters?.use),
|
|
204
|
-
'Enforcer': ctx ? 'n/a' : meterCell(f.meters?.enforcer),
|
|
215
|
+
'Mark similarity': ctx ? 'n/a' : meterCell(f.meters?.mark_similarity, 'mark_similarity'),
|
|
216
|
+
'Goods proximity': ctx ? 'n/a' : meterCell(f.meters?.goods_proximity, 'goods_proximity'),
|
|
217
|
+
'Use': ctx ? 'n/a' : meterCell(f.meters?.use, 'use'),
|
|
218
|
+
'Enforcer': ctx ? 'n/a' : meterCell(f.meters?.enforcer, 'enforcer'),
|
|
205
219
|
'Link': f.source?.resolved_link || linkCellFor(regs, recordLinks), // the office's own page, or why there is none
|
|
206
220
|
};
|
|
207
221
|
});
|
|
@@ -227,8 +241,8 @@ const EXCL = /excluded|dropped|off-field|out of scope|distribution-partner|relev
|
|
|
227
241
|
// SAME WORKBOOK already shows a client on its Coverage & gaps tab: STATE_WORD maps the typed
|
|
228
242
|
// `not-searched` coverage state to "Open". Reusing it keeps one vocabulary in front of the reader instead
|
|
229
243
|
// of inventing a second for the same fact.
|
|
230
|
-
const NOT_SEARCHED_OUTCOME =
|
|
231
|
-
const NOT_SEARCHED_RESULT =
|
|
244
|
+
const NOT_SEARCHED_OUTCOME = W.outcome.notSearched;
|
|
245
|
+
const NOT_SEARCHED_RESULT = W.couldNotBeSearched;
|
|
232
246
|
|
|
233
247
|
// A row is not-searched when it SAYS SO IN A FIELD, not when its prose happens to match a pattern.
|
|
234
248
|
// audit-from-spine.mjs stamps `searched:false` on every gaps[] row, because that function already knows
|
|
@@ -247,13 +261,13 @@ const outcomeFor = (result, note, row = null) => {
|
|
|
247
261
|
const t = `${result} ${note}`;
|
|
248
262
|
// Ahead of everything: a query that never ran cannot be a hit, an exclusion, or a clean sweep.
|
|
249
263
|
if (notSearched(row, result, note)) return NOT_SEARCHED_OUTCOME;
|
|
250
|
-
if (HITY.test(t) && !/no (similar|active|products|results|relevant)/i.test(result)) return
|
|
251
|
-
if (EXCL.test(t)) return
|
|
264
|
+
if (HITY.test(t) && !/no (similar|active|products|results|relevant)/i.test(result)) return W.outcome.findings;
|
|
265
|
+
if (EXCL.test(t)) return W.outcome.excluded;
|
|
252
266
|
// NO CATCH-ALL. `return 'No conflict'` as a fall-through was the defect: an unknown shape resolved to
|
|
253
267
|
// the most reassuring answer available, so any Result this file has never seen became a closure claim.
|
|
254
268
|
// An unrecognised row now says it is unrecognised, and a human reads the Result column beside it.
|
|
255
|
-
if (!String(result ?? '').trim()) return
|
|
256
|
-
return /^(0|no |none\b|nothing\b|clean\b)/i.test(String(result).trim()) ?
|
|
269
|
+
if (!String(result ?? '').trim()) return W.outcome.noConflict;
|
|
270
|
+
return /^(0|no |none\b|nothing\b|clean\b)/i.test(String(result).trim()) ? W.outcome.noConflict : W.outcome.recorded;
|
|
257
271
|
};
|
|
258
272
|
|
|
259
273
|
// term -> did it become a surviving finding? A PROVABLE join, never a guessed number: the term shares a
|
|
@@ -276,14 +290,14 @@ function joinsFinding(term, findings, joinedTerms) {
|
|
|
276
290
|
return false;
|
|
277
291
|
}
|
|
278
292
|
|
|
279
|
-
const COMMON_LAW_SECTION =
|
|
293
|
+
const COMMON_LAW_SECTION = W.commonLawSection;
|
|
280
294
|
|
|
281
295
|
// register negatives are already one row per term in the spine; common-law negatives arrive per-platform and
|
|
282
296
|
// collapse to one row per term with a distinct-surface count (the spec's dedup). The full per-surface grid
|
|
283
297
|
// is the run's own artifact; this is the reader's deduped view, not a claim the surfaces went unrecorded.
|
|
284
298
|
// Exported for test: the three-state logic is the deliverable's own claim about what was
|
|
285
299
|
// searched, and it is worth asserting directly rather than only through a rendered xlsx.
|
|
286
|
-
export function searchRows(auditParsed, { findings = [], joinedTerms = null, registerOnly = false } = {}) {
|
|
300
|
+
export function searchRows(auditParsed, { findings = [], joinedTerms = null, registerOnly = false, registerReach = null, registerScope = null } = {}) {
|
|
287
301
|
const negs = (auditParsed?.negatives || []).filter(n => (n.search_term || '').trim() && (n.search_term || '').trim() !== '—');
|
|
288
302
|
const reg = negs.filter(n => n.source_layer !== 'Common-law');
|
|
289
303
|
const cl = negs.filter(n => n.source_layer === 'Common-law');
|
|
@@ -293,7 +307,13 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
293
307
|
const push = r => rows.push({ '#': ++i, ...r, Result: readerWords(r.Result), Note: readerWords(r.Note) }); // plain words, after each branch below has classified its row from the engine's own
|
|
294
308
|
|
|
295
309
|
if (reg.length) {
|
|
296
|
-
|
|
310
|
+
// THE REGISTER'S HEAD STATES THE SERVICE'S REACH, from the answer the run recorded beside its coverage line
|
|
311
|
+
// (`register_reach` in the scope facts), so the two cannot disagree. An order that names its countries reads
|
|
312
|
+
// "REGISTER" alone, and its rows say where (owner, 2026-11-19). A worldwide run that recorded no reach, or a
|
|
313
|
+
// run whose record cannot say, keeps the head it always had.
|
|
314
|
+
const head = registerReach ? W.registerSectionReach(registerReach.service, registerReach.offices)
|
|
315
|
+
: registerScope === 'named' ? W.registerSectionNamed : W.registerSection;
|
|
316
|
+
push({ 'Search term / variant': head, Scope: '', Result: '', Outcome: '', Note: '', _section: true });
|
|
297
317
|
for (const n of reg) {
|
|
298
318
|
const note = plainNote(n.notes);
|
|
299
319
|
push({
|
|
@@ -335,7 +355,7 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
335
355
|
const results = [...g.results];
|
|
336
356
|
const anyHit = results.some(r => (HITY.test(r) || GRID_HIT.test(String(r).trim())) && !/^no /i.test(r));
|
|
337
357
|
const n = g.plats.size;
|
|
338
|
-
const scope = n ?
|
|
358
|
+
const scope = n ? W.surfaces(n) : '';
|
|
339
359
|
// the deduped row lost its per-surface detail (that lives in the run's own grid); the Note states the
|
|
340
360
|
// honest aggregate — how wide the sweep ran and where any hit went — never one cherry-picked surface
|
|
341
361
|
// receipt (which, on a hit term, would read as "nothing found" beside a "found" result).
|
|
@@ -352,31 +372,26 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
352
372
|
// a content-policy refusal will refuse again, a query that never ran may simply run.
|
|
353
373
|
const said = gaps.map((s) => [s, g.gapReasons.get(s)]).filter(([, r]) => r);
|
|
354
374
|
const silent = gaps.filter((s) => !g.gapReasons.has(s));
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
const gapNote = gaps.length ? ` ${gaps.length} surface${gaps.length === 1 ? '' : 's'} could not be searched (${gaps.slice(0, 4).join(', ')}${gaps.length > 4 ? ', …' : ''}) — this term is NOT closed across them.${reasonNote}${silentNote}` : '';
|
|
362
|
-
const outcome = anyHit ? (joined ? '→ Findings' : 'Reviewed — not carried as a conflict')
|
|
375
|
+
const firstFour = (list) => `${list.slice(0, 4).join(', ')}${list.length > 4 ? ', …' : ''}`;
|
|
376
|
+
const reasonNote = said.length ? W.reasonsGiven(said.length, said.map(([s, r]) => `${s} — ${r}`).join('; ')) : '';
|
|
377
|
+
const silentNote = silent.length && said.length ? W.someGaveNoReason(silent.length, firstFour(silent))
|
|
378
|
+
: silent.length ? W.noneGaveAReason : '';
|
|
379
|
+
const gapNote = gaps.length ? `${W.notClosedAcross(gaps.length, firstFour(gaps))}${reasonNote}${silentNote}` : '';
|
|
380
|
+
const outcome = anyHit ? (joined ? W.outcome.findings : W.outcome.reviewed)
|
|
363
381
|
: gaps.length && !ran ? NOT_SEARCHED_OUTCOME // nothing ran at all: never a closure claim
|
|
364
|
-
: gaps.length ?
|
|
365
|
-
:
|
|
382
|
+
: gaps.length ? W.outcome.partial // some ran clean, some never ran: say both
|
|
383
|
+
: W.outcome.noConflict;
|
|
384
|
+
const across = ran ? `~${ran}` : 'the';
|
|
366
385
|
const note = (anyHit
|
|
367
|
-
? (joined
|
|
368
|
-
|
|
369
|
-
: `Checked across ${ran ? `~${ran}` : 'the'} surfaces; listing(s) reviewed, none carried as a separate conflict`)
|
|
370
|
-
: ran
|
|
371
|
-
? `Checked across ~${ran} surface${ran === 1 ? '' : 's'}; no listing found`
|
|
372
|
-
: `Not checked on any recorded surface`) + gapNote;
|
|
386
|
+
? (joined ? W.checkedJoined(across) : W.checkedReviewed(across))
|
|
387
|
+
: ran ? W.checkedClean(ran) : W.checkedNowhere) + gapNote;
|
|
373
388
|
push({
|
|
374
389
|
'Search term / variant': plainNote(term), Scope: scope,
|
|
375
390
|
// The all-clean row is unchanged — a workbook that annotates every clean line teaches the reader to
|
|
376
391
|
// ignore the annotation. It says "of N" only when some surface did NOT run.
|
|
377
|
-
Result: anyHit ?
|
|
392
|
+
Result: anyHit ? W.similarFound
|
|
378
393
|
: !ran ? NOT_SEARCHED_RESULT
|
|
379
|
-
: gaps.length ?
|
|
394
|
+
: gaps.length ? W.cleanOn(ran, n) : W.clean,
|
|
380
395
|
Outcome: outcome, Note: note,
|
|
381
396
|
});
|
|
382
397
|
}
|
|
@@ -391,9 +406,9 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
391
406
|
// about what ran — only what this run's own search log does and does not hold.
|
|
392
407
|
push({ 'Search term / variant': COMMON_LAW_SECTION, Scope: '', Result: '', Outcome: '', Note: '', _section: true });
|
|
393
408
|
push({
|
|
394
|
-
'Search term / variant':
|
|
395
|
-
Scope: '', Result:
|
|
396
|
-
Note:
|
|
409
|
+
'Search term / variant': W.unlogged.term,
|
|
410
|
+
Scope: '', Result: W.unlogged.result, Outcome: W.unlogged.outcome,
|
|
411
|
+
Note: W.unlogged.note,
|
|
397
412
|
_commonLawUnlogged: true,
|
|
398
413
|
});
|
|
399
414
|
}
|
|
@@ -402,17 +417,17 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
402
417
|
|
|
403
418
|
// ── Coverage & gaps ─────────────────────────────────────────────────────────────────────────────────────
|
|
404
419
|
const COVERAGE_COLS = ['Area', 'State', 'What was done', "What's left"];
|
|
405
|
-
const STATE_WORD = { 'confirmed-clean':
|
|
420
|
+
const STATE_WORD = { 'confirmed-clean': W.state.clean, 'coverage-limited': W.state.limited, open: W.state.open, 'not-searched': W.state.open, note: W.state.note };
|
|
406
421
|
// A coverage row is open where this tab shows it Open or Limited. The Summary's count and its caveat read the same
|
|
407
422
|
// rule, so a not-searched row, shown Open here, is never left out of the count the Summary leads with.
|
|
408
|
-
const isOpenCoverage = (c) => STATE_WORD[c?.state] ===
|
|
423
|
+
const isOpenCoverage = (c) => STATE_WORD[c?.state] === W.state.open || STATE_WORD[c?.state] === W.state.limited;
|
|
409
424
|
|
|
410
425
|
// split a coverage note into "what was done" / "what's left" at its natural prose seam. Open/limited areas
|
|
411
426
|
// describe the residual after a "; " or " — "; a clean area is all done and has nothing left.
|
|
412
427
|
function splitCoverageNote(note, state) {
|
|
413
428
|
const n = plainNote(note);
|
|
414
429
|
if (!n) return { done: '', left: '' };
|
|
415
|
-
if (state ===
|
|
430
|
+
if (state === W.state.clean) return { done: n, left: '—' };
|
|
416
431
|
const seam = n.search(/\s—\s|;\s/);
|
|
417
432
|
if (seam > 0) {
|
|
418
433
|
const done = n.slice(0, seam).trim();
|
|
@@ -420,18 +435,19 @@ function splitCoverageNote(note, state) {
|
|
|
420
435
|
return { done, left: left || '—' };
|
|
421
436
|
}
|
|
422
437
|
// no clean seam — a residual-describing note reads as "what's left"; a clean note reads as "what was done".
|
|
423
|
-
return state ===
|
|
438
|
+
return state === W.state.open || state === W.state.limited ? { done: '', left: n } : { done: n, left: '—' };
|
|
424
439
|
}
|
|
425
440
|
|
|
426
441
|
function coverageRows(coverage) {
|
|
427
442
|
return (coverage || []).map(c => {
|
|
428
|
-
const state = STATE_WORD[c.state] ||
|
|
443
|
+
const state = STATE_WORD[c.state] || W.state.note;
|
|
429
444
|
// A row that says which cell its words belong in is not split: a reading turn's reason is one sentence,
|
|
430
445
|
// and cut at its first `;` it read as half done and half left.
|
|
431
446
|
const { done, left } = ('done' in c || 'left' in c)
|
|
432
447
|
? { done: plainNote(c.done ?? ''), left: plainNote(c.left ?? '') || '—' }
|
|
433
448
|
: splitCoverageNote(c.note, state);
|
|
434
|
-
|
|
449
|
+
// An area the engine named by its axis reads the reader's label, as the Summary's slices do.
|
|
450
|
+
return { Area: plainNote(coverageUnitLabel(c.area)), State: state, 'What was done': done, "What's left": left };
|
|
435
451
|
});
|
|
436
452
|
}
|
|
437
453
|
|
|
@@ -445,6 +461,8 @@ function coverageOpen({ coverage = [], coverageJudgment = null, verdict = null,
|
|
|
445
461
|
return openState || judgeUnsure || verdictCoverage;
|
|
446
462
|
}
|
|
447
463
|
|
|
464
|
+
// A label under one of the Summary's headings is indented, as a spreadsheet has no other way to nest it.
|
|
465
|
+
const IND = ' ';
|
|
448
466
|
export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, verdict, jurisdiction, registerOnly = false, commonLawUnlogged = false, clientGate = null, lintFailures = [], productName = null, degradedParts = [], assessmentNotCompleted = false } = {}) {
|
|
449
467
|
const disp = d => findings.filter(f => f.disposition === d && !f.isContextNote).length;
|
|
450
468
|
const rated = findings.filter(f => !f.isContextNote);
|
|
@@ -460,7 +478,7 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
460
478
|
const caveat = (notCompletedRow && plainNote(notCompletedRow.note)) || plainNote(coverageJudgment?.reason) ||
|
|
461
479
|
(coverage || []).find(isOpenCoverage)?.note ||
|
|
462
480
|
(degradedParts || [])[0]?.note ||
|
|
463
|
-
|
|
481
|
+
W.summary.nothingOpen;
|
|
464
482
|
|
|
465
483
|
const rows = [
|
|
466
484
|
// — THE WORKBOOK NAMES THE SAME PRODUCT ITS REPORT DOES. This title was the literal
|
|
@@ -468,29 +486,29 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
468
486
|
// search's workbook carried one name between them, and neither matched the masthead of the report
|
|
469
487
|
// they were downloaded from. The workbook is a delivery surface: its link rides the same cover note
|
|
470
488
|
// that reaches a client principal. Null ⇒ the neutral title, never a product the run did not run.
|
|
471
|
-
{ Field: productName ?
|
|
489
|
+
{ Field: productName ? W.summary.title(productName) : W.summary.titleWithoutProduct, Value: W.summary.subtitle, _title: true },
|
|
472
490
|
{ Field: '', Value: '' },
|
|
473
|
-
{ Field:
|
|
474
|
-
{ Field:
|
|
475
|
-
{ Field:
|
|
491
|
+
{ Field: W.summary.mark, Value: mark || fm.title || '' },
|
|
492
|
+
{ Field: W.summary.matter, Value: fm.matter || '' },
|
|
493
|
+
{ Field: W.summary.classes, Value: fm.classes || '' },
|
|
476
494
|
// compute-don't-author (PR-4, review issue 2): the driver-computed per-class register-coverage
|
|
477
495
|
// line (scope-facts.mjs → `coverage_line:` front-matter) renders here so the workbook's headline
|
|
478
496
|
// carries the honest per-class proportion ("Class 30: 76 of 99 slices fully searched — the
|
|
479
497
|
// remaining 23 are non-Latin script forms", the spec-B4 plain form) beside the bare class
|
|
480
498
|
// numbers. Conditional on the fm key: a republished ARCHIVED workbook (whose front-matter never
|
|
481
499
|
// carried coverage_line) must not grow rows.
|
|
482
|
-
...(fm.coverage_line ? [{ Field:
|
|
483
|
-
{ Field:
|
|
484
|
-
{ Field:
|
|
485
|
-
//
|
|
500
|
+
...(fm.coverage_line ? [{ Field: W.summary.registerCoverage, Value: fm.coverage_line }] : []),
|
|
501
|
+
{ Field: W.summary.jurisdiction, Value: jurisdiction || '' },
|
|
502
|
+
{ Field: W.summary.searched, Value: fm.searched || fm.run || '' },
|
|
503
|
+
// The old single row printed the severity TIER under the label "Verdict" (a reader saw
|
|
486
504
|
// "Verdict: High" — vocabulary conflation). With a composed statement the summary carries two
|
|
487
505
|
// labelled rows: the band word and THE one risk statement. A legacy run (no statement) keeps its
|
|
488
506
|
// single original row byte-identically — a republished archived workbook must not grow rows.
|
|
489
507
|
...(assessmentNotCompleted ? []
|
|
490
508
|
: verdict && verdict.statement
|
|
491
|
-
? [{ Field:
|
|
492
|
-
: [{ Field:
|
|
493
|
-
{ Field:
|
|
509
|
+
? [{ Field: W.summary.riskBand, Value: verdictWord }, { Field: W.summary.verdict, Value: verdict.statement, _verdict: true }]
|
|
510
|
+
: [{ Field: W.summary.verdict, Value: verdictWord, _verdict: true }]),
|
|
511
|
+
{ Field: W.summary.checkFirst, Value: caveat, _caveat: true },
|
|
494
512
|
// The gap "What was searched" had to DECLARE rather than list, said again where the reader starts.
|
|
495
513
|
// It is set when that sheet found no per-term common-law rows on a run nothing records as
|
|
496
514
|
// register-only, and it exists because the only signal for this used to be an advisory line on
|
|
@@ -505,15 +523,15 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
505
523
|
// exist, because the same defect threw before writeFile, or it silently read as a complete
|
|
506
524
|
// register-only search. Reproducing that byte-for-byte would be reproducing the defect.
|
|
507
525
|
...(commonLawUnlogged
|
|
508
|
-
? [{ Field:
|
|
526
|
+
? [{ Field: W.summary.commonLaw, Value: W.summary.commonLawUnlogged, _caveat: true }]
|
|
509
527
|
: []),
|
|
510
|
-
// ONE report
|
|
528
|
+
// ONE report: the machine-QC checks enumerate their failures HERE — the
|
|
511
529
|
// workbook is where they live now, and they decide nothing about who may read the report. The old
|
|
512
530
|
// "⛔ Not released to the client" delivery language is retired with the split it narrated. Reasons
|
|
513
531
|
// are the checks' own plain-language lines (no internal vocabulary); plainNote() folds any
|
|
514
532
|
// engineering residue. No failed checks ⇒ no row, byte-identical workbook (archived republish safe).
|
|
515
533
|
...(clientGate && clientGate.released === false
|
|
516
|
-
? [{ Field:
|
|
534
|
+
? [{ Field: W.summary.machineQc, Value: W.summary.machineQcFailed((clientGate.reasons ?? []).length || W.summary.someChecks, ((clientGate.reasons ?? []).map(r => plainNote(r)).join(' · ')) || W.summary.checksNotEvaluated), _caveat: true }]
|
|
517
535
|
: []),
|
|
518
536
|
// A10 (addendum 2026-07-30) — the failing predelivery machine checks, ENUMERATED, whether or not
|
|
519
537
|
// the gate closed: the workbook is the QC record the reviewing lawyer keeps, and a defect that
|
|
@@ -525,39 +543,39 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
525
543
|
// principal — so the raw `detail` may not arrive here at all, and a caller that passes a check
|
|
526
544
|
// object gets a neutral row rather than that object's prose. validateAudit holds the same line.
|
|
527
545
|
...(Array.isArray(lintFailures) && lintFailures.length
|
|
528
|
-
? [{ Field:
|
|
529
|
-
...lintFailures.map((f, i) => ({ Field:
|
|
546
|
+
? [{ Field: W.summary.checksFlagged, Value: W.summary.checksFlaggedCount(lintFailures.length), _caveat: true },
|
|
547
|
+
...lintFailures.map((f, i) => ({ Field: `${IND}${W.summary.check} ${i + 1}`, Value: plainNote(typeof f === 'string' ? f : A10_UNPROJECTED), _caveat: true }))]
|
|
530
548
|
: []),
|
|
531
549
|
{ Field: '', Value: '' },
|
|
532
|
-
{ Field:
|
|
550
|
+
{ Field: W.summary.byTheNumbers, Value: '', _head: true },
|
|
533
551
|
...(assessmentNotCompleted ? [] : [
|
|
534
|
-
{ Field:
|
|
535
|
-
{ Field:
|
|
536
|
-
{ Field:
|
|
537
|
-
{ Field:
|
|
552
|
+
{ Field: `${IND}${W.summary.findingsRated}`, Value: String(rated.length) },
|
|
553
|
+
{ Field: `${IND}${W.summary.onField}`, Value: String(disp('adversarial')) },
|
|
554
|
+
{ Field: `${IND}${W.summary.distinguished}`, Value: String(disp('distinguished')) },
|
|
555
|
+
{ Field: `${IND}${W.summary.offField}`, Value: String(disp('off-field')) },
|
|
538
556
|
]),
|
|
539
|
-
{ Field:
|
|
540
|
-
{ Field:
|
|
557
|
+
{ Field: `${IND}${W.summary.areasAssessed}`, Value: String((coverage || []).length) },
|
|
558
|
+
{ Field: `${IND}${W.summary.openOrLimited}`, Value: String(openCount) },
|
|
541
559
|
{ Field: '', Value: '' },
|
|
542
|
-
{ Field:
|
|
560
|
+
{ Field: W.summary.howToRead, Value: '', _head: true },
|
|
543
561
|
...(assessmentNotCompleted ? []
|
|
544
|
-
: [{ Field:
|
|
562
|
+
: [{ Field: `${IND}${W.summary.findingsTab}`, Value: W.summary.findingsTabIs }]),
|
|
545
563
|
// the third form is not cosmetic. "every search we ran — register and common-law — so you can see
|
|
546
564
|
// we looked everywhere" is a claim ABOUT THIS SHEET, and on a run whose common-law sweep never
|
|
547
565
|
// reached the search log the sheet does not carry it, so the sentence was simply false.
|
|
548
|
-
{ Field:
|
|
549
|
-
?
|
|
566
|
+
{ Field: `${IND}${W.summary.searchedTab}`, Value: registerOnly
|
|
567
|
+
? W.summary.searchedTabIsRegisterOnly
|
|
550
568
|
: commonLawUnlogged
|
|
551
|
-
?
|
|
552
|
-
:
|
|
553
|
-
{ Field:
|
|
554
|
-
{ Field:
|
|
555
|
-
{ Field:
|
|
569
|
+
? W.summary.searchedTabIsRegisterTerms
|
|
570
|
+
: W.summary.searchedTabIsEverything },
|
|
571
|
+
{ Field: `${IND}${W.summary.coverageTab}`, Value: W.summary.coverageTabIs },
|
|
572
|
+
{ Field: `${IND}${W.summary.evidenceTags}`, Value: W.summary.evidenceTagsAre },
|
|
573
|
+
{ Field: `${IND}${W.summary.recordRetrieved}`, Value: W.summary.recordRetrievedIs },
|
|
556
574
|
];
|
|
557
575
|
return rows;
|
|
558
576
|
}
|
|
559
577
|
|
|
560
|
-
// ──
|
|
578
|
+
// ── The STRUCTURED v5 rows, rendered as rows ────────────────────────────────────────────────────────────
|
|
561
579
|
// The report (frozen renderer) receives the deterministic string projection; the WORKBOOK is the surface
|
|
562
580
|
// that renders the typed rows themselves — per-class, per-market, the counter-registration list, the
|
|
563
581
|
// coverage-judgment slices and the corrections attestation. All three helpers are ADDITIVE AND
|
|
@@ -566,32 +584,32 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
566
584
|
function assessmentSummaryRows(ma) {
|
|
567
585
|
if (!ma || (typeof ma.distinctiveness !== 'object' || ma.distinctiveness === null)
|
|
568
586
|
&& (typeof ma.connotation !== 'object' || ma.connotation === null)) return [];
|
|
569
|
-
const rows = [{ Field: '', Value: '' }, { Field:
|
|
587
|
+
const rows = [{ Field: '', Value: '' }, { Field: W.markItself, Value: '', _head: true }];
|
|
570
588
|
const field = (label, v) => {
|
|
571
589
|
if (v == null) return;
|
|
572
590
|
rows.push({ Field: ` ${label}`, Value: plainNote(projectAssessmentField(v)) });
|
|
573
591
|
if (typeof v !== 'object') return;
|
|
574
592
|
for (const r of (Array.isArray(v.per_class) ? v.per_class : []))
|
|
575
|
-
rows.push({ Field: `
|
|
593
|
+
rows.push({ Field: ` ${W.perClass(String(r.class).trim())}`, Value: plainNote(r.note) });
|
|
576
594
|
for (const r of (Array.isArray(v.per_market) ? v.per_market : []))
|
|
577
595
|
rows.push({ Field: ` ${plainNote(r.market)}`, Value: plainNote(r.note) });
|
|
578
596
|
for (const r of (Array.isArray(v.counter_registrations) ? v.counter_registrations : []))
|
|
579
|
-
rows.push({ Field:
|
|
597
|
+
rows.push({ Field: ` ${W.coexistingRegistration}`, Value: plainNote([r.mark, r.uri, r.owner, r.note].filter(Boolean).join(' — ')) });
|
|
580
598
|
};
|
|
581
|
-
field(
|
|
582
|
-
field(
|
|
599
|
+
field(W.distinctiveness, ma.distinctiveness);
|
|
600
|
+
field(W.connotation, ma.connotation);
|
|
583
601
|
return rows.length > 2 ? rows : [];
|
|
584
602
|
}
|
|
585
603
|
function coverageJudgmentSummaryRows(cj) {
|
|
586
604
|
const rows = Array.isArray(cj?.rows) ? cj.rows : [];
|
|
587
605
|
if (!rows.length) return [];
|
|
588
|
-
return [{ Field: '', Value: '' }, { Field:
|
|
606
|
+
return [{ Field: '', Value: '' }, { Field: W.howCoverageWasJudged, Value: '', _head: true },
|
|
589
607
|
...rows.map((r) => ({ Field: ` ${plainNote(r.areaLabel || r.area)}`, Value: plainNote(r.note) }))];
|
|
590
608
|
}
|
|
591
609
|
function correctionsSummaryRows(c) {
|
|
592
610
|
const entries = Array.isArray(c?.entries) ? c.entries : [];
|
|
593
611
|
if (!entries.length) return [];
|
|
594
|
-
return [{ Field: '', Value: '' }, { Field:
|
|
612
|
+
return [{ Field: '', Value: '' }, { Field: W.correctionsApplied, Value: '', _head: true },
|
|
595
613
|
...entries.map((r) => ({ Field: ` ${plainNote(r.entity)}`, Value: plainNote([r.disposition, r.note].filter(Boolean).join(' — ')) }))];
|
|
596
614
|
}
|
|
597
615
|
|
|
@@ -635,13 +653,13 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
635
653
|
const registerOnly = contract?.registerOnly === true;
|
|
636
654
|
const joinedTerms = contract?.commonLawJoinedTerms instanceof Set ? contract.commonLawJoinedTerms
|
|
637
655
|
: Array.isArray(contract?.commonLawJoinedTerms) ? new Set(contract.commonLawJoinedTerms.map(s => String(s).toUpperCase())) : null;
|
|
638
|
-
const searched = searchRows(auditParsed, { findings: contract?.findings || [], joinedTerms, registerOnly });
|
|
656
|
+
const searched = searchRows(auditParsed, { findings: contract?.findings || [], joinedTerms, registerOnly, registerReach: contract?.registerReach ?? null, registerScope: contract?.registerScope ?? null });
|
|
639
657
|
const commonLawUnlogged = searched.some(r => r._commonLawUnlogged);
|
|
640
658
|
|
|
641
659
|
// 1 · Summary
|
|
642
660
|
addSheet(wb, 'Summary', ['Field', 'Value'],
|
|
643
661
|
[...summaryRows(findings, coverage, fm, { mark, coverageJudgment, verdict, jurisdiction, registerOnly, commonLawUnlogged, clientGate: contract?.clientGate ?? null, lintFailures: contract?.lintFailures ?? [], productName: contract?.productName ?? null, degradedParts, assessmentNotCompleted: contract?.assessmentNotCompleted === true }),
|
|
644
|
-
//
|
|
662
|
+
// The structured v5 rows (mark assessment / coverage-judgment slices / corrections
|
|
645
663
|
// attestation) render as ROWS here; the report carries only their string projection. All three
|
|
646
664
|
// are empty on legacy records, so a republished archived workbook never grows rows.
|
|
647
665
|
...assessmentSummaryRows(contract?.markAssessment ?? null),
|
|
@@ -654,7 +672,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
654
672
|
if (kept.has('Link')) {
|
|
655
673
|
const link = row.getCell('Link');
|
|
656
674
|
const url = String(link.value || '').trim();
|
|
657
|
-
if (/^https?:\/\//i.test(url)) { link.value = { text:
|
|
675
|
+
if (/^https?:\/\//i.test(url)) { link.value = { text: W.view, hyperlink: url }; link.font = { color: { argb: WB.link }, underline: true }; }
|
|
658
676
|
}
|
|
659
677
|
if (kept.has('Risk band')) {
|
|
660
678
|
const band = row.getCell('Risk band');
|
|
@@ -666,7 +684,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
666
684
|
// are identified by the flag the row already carries, not re-derived from three of its cells: the
|
|
667
685
|
// re-derivation needed Scope and Result to exist, which on a sparse run they do not.
|
|
668
686
|
addSheet(wb, 'What was searched', SEARCH_COLS, searched, (row, data) => {
|
|
669
|
-
if (data?._section) row.eachCell(c => { c.font = { bold: true }; c.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb:
|
|
687
|
+
if (data?._section) row.eachCell(c => { c.font = { bold: true }; c.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: WB.sectionFill } }; });
|
|
670
688
|
});
|
|
671
689
|
|
|
672
690
|
// 4 · Coverage & gaps — the honest completeness ledger, state coloured.
|
|
@@ -690,7 +708,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
690
708
|
addSheet(wb, 'Coverage & gaps', COVERAGE_COLS,
|
|
691
709
|
[...coverageRows(coverage), ...coverageRows(degradedParts), ...coverageRows(contract?.droppedConditions || []),
|
|
692
710
|
...coverageRows(contract?.undispatchedProbes || []), ...coverageRows(contract?.withheldFamilies || []),
|
|
693
|
-
...coverageRows(contract?.releasedFamilies || []), ...(contract?.setAside || []).map((s) => ({ Area: plainNote(s.area), State: 'Note', 'What was done': plainNote(s.note) || '—', "What's left": '—' }))], (row, _d, kept) => {
|
|
711
|
+
...coverageRows(contract?.releasedFamilies || []), ...(contract?.setAside || []).map((s) => ({ Area: plainNote(coverageUnitLabel(s.area)), State: 'Note', 'What was done': plainNote(s.note) || '—', "What's left": '—' }))], (row, _d, kept) => {
|
|
694
712
|
if (!kept.has('State')) return;
|
|
695
713
|
const st = row.getCell('State'); const f = STATE_FILL[String(st.value).trim()];
|
|
696
714
|
if (f) { st.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF' + f } }; st.font = { bold: true }; }
|
|
@@ -708,7 +726,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
708
726
|
sheets: wb.worksheets.map(w => w.name),
|
|
709
727
|
findings: findings.length,
|
|
710
728
|
coverage: coverage.length,
|
|
711
|
-
searched: wb.getWorksheet('What was searched')?.rowCount - 1 || 0,
|
|
729
|
+
searched: wb.getWorksheet(LABELS.sheets['What was searched'])?.rowCount - 1 || 0,
|
|
712
730
|
gateViolations: gate.violations,
|
|
713
731
|
};
|
|
714
732
|
}
|
|
@@ -726,13 +744,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
726
744
|
// name. A web address loses its scheme in any case and keeps its host and path. has_more is plainNote's.
|
|
727
745
|
//
|
|
728
746
|
// Kept down here, below every line the rest of the tree cites in this file by number.
|
|
729
|
-
export const READER_WORDS =
|
|
730
|
-
receipt: 'record', receipts: 'records',
|
|
731
|
-
lint: 'check', tripwire: 'check', tripwires: 'checks',
|
|
732
|
-
composite: 'combined', scatter: 'chart', cache: 'stored copy',
|
|
733
|
-
quadrant: 'position', quadrants: 'positions', coordinate: 'position', coordinates: 'positions',
|
|
734
|
-
meter: 'measure', meters: 'measures',
|
|
735
|
-
});
|
|
747
|
+
export const READER_WORDS = W.readerWords;
|
|
736
748
|
const READER_WORD = new RegExp(`\\b(?:${Object.keys(READER_WORDS).join('|')})\\b`, 'gi');
|
|
737
749
|
|
|
738
750
|
function readerWords(s) {
|
|
@@ -755,7 +767,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
755
767
|
const sheets = wb.worksheets.map(w => w.name);
|
|
756
768
|
|
|
757
769
|
// 1 — exactly four tabs, the four plain names, none saying "receipts".
|
|
758
|
-
const EXPECT = ['Summary', 'Findings', 'What was searched', 'Coverage & gaps'];
|
|
770
|
+
const EXPECT = ['Summary', 'Findings', 'What was searched', 'Coverage & gaps'].map((n) => LABELS.sheets[n]);
|
|
759
771
|
if (sheets.length !== 4) v.push(`expected 4 tabs, got ${sheets.length} (${sheets.join(', ')})`);
|
|
760
772
|
for (const name of EXPECT) if (!sheets.includes(name)) v.push(`missing tab "${name}"`);
|
|
761
773
|
|
|
@@ -784,7 +796,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
784
796
|
// green while `HTTP 404 for uri=/mark/ch/06198` shipped in Summary r12. These rows are held to the
|
|
785
797
|
// delivery house rules (predelivery-lint's list) AND to BANNED, and a hit is reported as a
|
|
786
798
|
// violation the A10 tests assert to be empty.
|
|
787
|
-
const summaryWs = wb.getWorksheet('Summary');
|
|
799
|
+
const summaryWs = wb.getWorksheet(LABELS.sheets['Summary']);
|
|
788
800
|
if (summaryWs) {
|
|
789
801
|
summaryWs.eachRow((row, rn) => {
|
|
790
802
|
const cellText = (c) => { const val = c.value; return val && typeof val === 'object' ? (val.text ?? val.hyperlink ?? (val.richText || []).map(r => r.text).join('')) : val; };
|
|
@@ -810,8 +822,8 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
810
822
|
}
|
|
811
823
|
}
|
|
812
824
|
|
|
813
|
-
const findWs = wb.getWorksheet('Findings');
|
|
814
|
-
const col = (ws, name) => { let idx = 0; ws.getRow(1).eachCell((c, i) => { if (c.value === name) idx = i; }); return idx; };
|
|
825
|
+
const findWs = wb.getWorksheet(LABELS.sheets['Findings']);
|
|
826
|
+
const col = (ws, name) => { let idx = 0; ws.getRow(1).eachCell((c, i) => { if (c.value === (LABELS.columns[name] ?? name)) idx = i; }); return idx; };
|
|
815
827
|
// A column addSheet DROPPED has no index here — col() returns 0, and exceljs refuses column 0 as hard
|
|
816
828
|
// as it refuses column 16385, so the gate threw on exactly the workbooks it exists to judge. Reading a
|
|
817
829
|
// dropped column as an EMPTY cell is not a softening: every check below already treats "" as the
|
|
@@ -893,11 +905,18 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
893
905
|
if (/not retrieved/i.test(ret) && !/unverified/i.test(ret) && !/n\/a/i.test(ret) && !/read/i.test(ret)) {
|
|
894
906
|
// "Not individually retrieved" is allowed; only a fetch-FAILURE must carry "unverified"
|
|
895
907
|
}
|
|
896
|
-
// 5 — rated findings:
|
|
908
|
+
// 5 — rated findings: each driver says how its value is evidenced in the report's words, as the page does
|
|
909
|
+
// (context notes exempt). Similarity carries no evidence word; Use carries only "inferred" or "not checked"; the
|
|
910
|
+
// other two carry one of the four words or none; an unknown value nobody checked reads "not checked".
|
|
897
911
|
if (!isCtx) {
|
|
912
|
+
const WORDS = { 'mark similarity': null, 'goods proximity': /^(?:verified|not yet verified|inferred|not checked)$/i,
|
|
913
|
+
use: /^(?:inferred|not checked)$/i, enforcer: /^(?:verified|not yet verified|inferred|not checked)$/i };
|
|
898
914
|
for (const [cc, label] of [[cMs, 'mark similarity'], [cGp, 'goods proximity'], [cUse, 'use'], [cEnf, 'enforcer']]) {
|
|
899
915
|
const t = cellText(cc);
|
|
900
|
-
|
|
916
|
+
const word = t.includes(' · ') ? t.slice(t.lastIndexOf(' · ') + 3) : '';
|
|
917
|
+
if (label === 'mark similarity') { if (word) v.push(`Findings "${mark}": the similarity driver carries an evidence word the report does not print (got "${t}")`); }
|
|
918
|
+
else if (/^unknown\b/i.test(t) && !word) v.push(`Findings "${mark}": ${label} driver is unknown but says nothing about its evidence (got "${t}")`);
|
|
919
|
+
else if (word && !WORDS[label].test(word)) v.push(`Findings "${mark}": ${label} driver's evidence word is not the report's (got "${t}")`);
|
|
901
920
|
}
|
|
902
921
|
}
|
|
903
922
|
}
|
|
@@ -920,7 +939,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
920
939
|
// gate is EXPORTED and a caller can hand it a workbook this builder did not assemble — a missing
|
|
921
940
|
// block is still the right thing to say about such a workbook. Do not read its absence from the
|
|
922
941
|
// build path as the check having been retired.
|
|
923
|
-
const searchWs = wb.getWorksheet('What was searched');
|
|
942
|
+
const searchWs = wb.getWorksheet(LABELS.sheets['What was searched']);
|
|
924
943
|
if (searchWs) {
|
|
925
944
|
const cTerm = col(searchWs, 'Search term / variant') || 2;
|
|
926
945
|
let inCommon = false, sawCommon = false, commonTerms = 0;
|
|
@@ -937,7 +956,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
937
956
|
}
|
|
938
957
|
|
|
939
958
|
// 8/9 — Summary leads with verdict + caveat; and the headline is never clean while a unit did not finish.
|
|
940
|
-
const sumWs = wb.getWorksheet('Summary');
|
|
959
|
+
const sumWs = wb.getWorksheet(LABELS.sheets['Summary']);
|
|
941
960
|
if (sumWs) {
|
|
942
961
|
let hasVerdict = false, hasCaveat = false;
|
|
943
962
|
sumWs.eachRow(row => {
|
|
@@ -949,7 +968,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
949
968
|
if (!hasVerdict && !assessmentNotCompleted) v.push('Summary: no Verdict row');
|
|
950
969
|
if (coverageOpen({ coverage, coverageJudgment, verdict, degradedParts })) {
|
|
951
970
|
if (!hasCaveat) v.push('Summary: coverage is open but no caveat row (headline-honesty)');
|
|
952
|
-
const covWs = wb.getWorksheet('Coverage & gaps');
|
|
971
|
+
const covWs = wb.getWorksheet(LABELS.sheets['Coverage & gaps']);
|
|
953
972
|
let openRow = false;
|
|
954
973
|
// by header, not by position: a dropped column shifts the second column to a different question,
|
|
955
974
|
// and this check must read the State word or read nothing (and then say the caveat is missing).
|