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.
- 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/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 +39 -0
- package/driver/connotation-search.mjs +1 -1
- package/driver/contract-e3-backlog.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 +4 -3
- 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/gateway.mjs +67 -10
- package/driver/jx.mjs +13 -5
- package/driver/manuals-seen.mjs +146 -0
- package/driver/mark-logos.mjs +144 -0
- package/driver/methodology-witness.mjs +2 -1
- package/driver/owner-use-check.mjs +3 -3
- package/driver/package.json +1 -1
- package/driver/pipeline-knockout.mjs +4 -0
- package/driver/pipeline.mjs +92 -7
- package/driver/portal-local-auth.mjs +6 -2
- package/driver/portal-report.mjs +43 -12
- package/driver/portal-routes/me.mjs +4 -1
- package/driver/portal-runs.mjs +6 -9
- package/driver/profiles.mjs +4 -4
- package/driver/publish/README.md +9 -7
- package/driver/publish/email-conditions.mjs +2 -2
- package/driver/publish/evidence-words.mjs +21 -0
- package/driver/publish/index.mjs +104 -90
- package/driver/publish/knockout.mjs +75 -49
- package/driver/publish/office-record-links.mjs +11 -9
- package/driver/publish/page-shell.mjs +98 -0
- package/driver/publish/publish-inputs.mjs +4 -0
- package/driver/publish/regions.mjs +24 -3
- package/driver/publish/register-record.mjs +150 -0
- package/driver/publish/render-knockout.mjs +195 -642
- package/driver/publish/render.mjs +270 -363
- package/driver/publish/report-data.mjs +225 -12
- package/driver/publish/strings.mjs +662 -0
- package/driver/publish/templates/knockout.css +200 -0
- package/driver/publish/templates/report.css +72 -52
- package/driver/publish/xlsx.mjs +148 -125
- package/driver/record-goods.mjs +42 -0
- package/driver/reference-score.mjs +4 -1
- package/driver/register-reach.mjs +39 -0
- package/driver/registry-fidelity.mjs +3 -8
- package/driver/repair-composers.mjs +6 -2
- package/driver/repair-targets.mjs +4 -1
- package/driver/run-delivered.mjs +6 -1
- package/driver/runner.mjs +73 -29
- package/driver/scope-facts.mjs +27 -6
- package/driver/search-policy.mjs +9 -4
- package/driver/stages.mjs +3 -3
- package/driver/steps/overview-and-cards.mjs +50 -14
- package/driver/steps/verdict-gate.mjs +33 -13
- package/driver/suite-census.json +368 -68
- package/driver/terminal-clamp.mjs +6 -1
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/lib/audit-view.mjs +5 -2
- package/mcp-server/lib/brief.mjs +2 -1
- package/mcp-server/lib/evidence.mjs +31 -4
- package/mcp-server/lib/knockout.mjs +1 -1
- package/mcp-server/lib/scrub.mjs +1 -1
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +5 -3
- package/package.json +4 -1
- package/portal-ui/dist/assets/{index-CYaO2ygd.js → index-CtkllKJ2.js} +225 -77
- 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/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/scripts/README.md +147 -3
- package/scripts/e2e-first-time.mjs +3 -3
- package/scripts/freeze-example-run.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 +85 -5
- package/shared/inline-markdown.mjs +53 -0
- package/shared/portal-tokens.mjs +2 -1
- package/shared/register-selection.mjs +8 -3
- package/shared/search-level-tags.json +25 -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
|
|
|
@@ -51,7 +58,8 @@ const A10_UNPROJECTED = 'A machine check on the report did not pass.';
|
|
|
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' ? 'not checked' : '');
|
|
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.
|
|
@@ -198,10 +212,10 @@ function findingRows(findings, fetchState, recordLinks = null, method = null) {
|
|
|
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 } = {}) {
|
|
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,11 @@ 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. A run that recorded none, a service that
|
|
312
|
+
// declares no office list or a run from before the record, keeps the head it always had.
|
|
313
|
+
const head = registerReach ? W.registerSectionReach(registerReach.service, registerReach.offices) : W.registerSection;
|
|
314
|
+
push({ 'Search term / variant': head, Scope: '', Result: '', Outcome: '', Note: '', _section: true });
|
|
297
315
|
for (const n of reg) {
|
|
298
316
|
const note = plainNote(n.notes);
|
|
299
317
|
push({
|
|
@@ -335,7 +353,7 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
335
353
|
const results = [...g.results];
|
|
336
354
|
const anyHit = results.some(r => (HITY.test(r) || GRID_HIT.test(String(r).trim())) && !/^no /i.test(r));
|
|
337
355
|
const n = g.plats.size;
|
|
338
|
-
const scope = n ?
|
|
356
|
+
const scope = n ? W.surfaces(n) : '';
|
|
339
357
|
// the deduped row lost its per-surface detail (that lives in the run's own grid); the Note states the
|
|
340
358
|
// honest aggregate — how wide the sweep ran and where any hit went — never one cherry-picked surface
|
|
341
359
|
// receipt (which, on a hit term, would read as "nothing found" beside a "found" result).
|
|
@@ -352,31 +370,26 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
352
370
|
// a content-policy refusal will refuse again, a query that never ran may simply run.
|
|
353
371
|
const said = gaps.map((s) => [s, g.gapReasons.get(s)]).filter(([, r]) => r);
|
|
354
372
|
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')
|
|
373
|
+
const firstFour = (list) => `${list.slice(0, 4).join(', ')}${list.length > 4 ? ', …' : ''}`;
|
|
374
|
+
const reasonNote = said.length ? W.reasonsGiven(said.length, said.map(([s, r]) => `${s} — ${r}`).join('; ')) : '';
|
|
375
|
+
const silentNote = silent.length && said.length ? W.someGaveNoReason(silent.length, firstFour(silent))
|
|
376
|
+
: silent.length ? W.noneGaveAReason : '';
|
|
377
|
+
const gapNote = gaps.length ? `${W.notClosedAcross(gaps.length, firstFour(gaps))}${reasonNote}${silentNote}` : '';
|
|
378
|
+
const outcome = anyHit ? (joined ? W.outcome.findings : W.outcome.reviewed)
|
|
363
379
|
: gaps.length && !ran ? NOT_SEARCHED_OUTCOME // nothing ran at all: never a closure claim
|
|
364
|
-
: gaps.length ?
|
|
365
|
-
:
|
|
380
|
+
: gaps.length ? W.outcome.partial // some ran clean, some never ran: say both
|
|
381
|
+
: W.outcome.noConflict;
|
|
382
|
+
const across = ran ? `~${ran}` : 'the';
|
|
366
383
|
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;
|
|
384
|
+
? (joined ? W.checkedJoined(across) : W.checkedReviewed(across))
|
|
385
|
+
: ran ? W.checkedClean(ran) : W.checkedNowhere) + gapNote;
|
|
373
386
|
push({
|
|
374
387
|
'Search term / variant': plainNote(term), Scope: scope,
|
|
375
388
|
// The all-clean row is unchanged — a workbook that annotates every clean line teaches the reader to
|
|
376
389
|
// ignore the annotation. It says "of N" only when some surface did NOT run.
|
|
377
|
-
Result: anyHit ?
|
|
390
|
+
Result: anyHit ? W.similarFound
|
|
378
391
|
: !ran ? NOT_SEARCHED_RESULT
|
|
379
|
-
: gaps.length ?
|
|
392
|
+
: gaps.length ? W.cleanOn(ran, n) : W.clean,
|
|
380
393
|
Outcome: outcome, Note: note,
|
|
381
394
|
});
|
|
382
395
|
}
|
|
@@ -391,9 +404,9 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
391
404
|
// about what ran — only what this run's own search log does and does not hold.
|
|
392
405
|
push({ 'Search term / variant': COMMON_LAW_SECTION, Scope: '', Result: '', Outcome: '', Note: '', _section: true });
|
|
393
406
|
push({
|
|
394
|
-
'Search term / variant':
|
|
395
|
-
Scope: '', Result:
|
|
396
|
-
Note:
|
|
407
|
+
'Search term / variant': W.unlogged.term,
|
|
408
|
+
Scope: '', Result: W.unlogged.result, Outcome: W.unlogged.outcome,
|
|
409
|
+
Note: W.unlogged.note,
|
|
397
410
|
_commonLawUnlogged: true,
|
|
398
411
|
});
|
|
399
412
|
}
|
|
@@ -402,17 +415,17 @@ export function searchRows(auditParsed, { findings = [], joinedTerms = null, reg
|
|
|
402
415
|
|
|
403
416
|
// ── Coverage & gaps ─────────────────────────────────────────────────────────────────────────────────────
|
|
404
417
|
const COVERAGE_COLS = ['Area', 'State', 'What was done', "What's left"];
|
|
405
|
-
const STATE_WORD = { 'confirmed-clean':
|
|
418
|
+
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
419
|
// A coverage row is open where this tab shows it Open or Limited. The Summary's count and its caveat read the same
|
|
407
420
|
// 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] ===
|
|
421
|
+
const isOpenCoverage = (c) => STATE_WORD[c?.state] === W.state.open || STATE_WORD[c?.state] === W.state.limited;
|
|
409
422
|
|
|
410
423
|
// split a coverage note into "what was done" / "what's left" at its natural prose seam. Open/limited areas
|
|
411
424
|
// describe the residual after a "; " or " — "; a clean area is all done and has nothing left.
|
|
412
425
|
function splitCoverageNote(note, state) {
|
|
413
426
|
const n = plainNote(note);
|
|
414
427
|
if (!n) return { done: '', left: '' };
|
|
415
|
-
if (state ===
|
|
428
|
+
if (state === W.state.clean) return { done: n, left: '—' };
|
|
416
429
|
const seam = n.search(/\s—\s|;\s/);
|
|
417
430
|
if (seam > 0) {
|
|
418
431
|
const done = n.slice(0, seam).trim();
|
|
@@ -420,18 +433,19 @@ function splitCoverageNote(note, state) {
|
|
|
420
433
|
return { done, left: left || '—' };
|
|
421
434
|
}
|
|
422
435
|
// no clean seam — a residual-describing note reads as "what's left"; a clean note reads as "what was done".
|
|
423
|
-
return state ===
|
|
436
|
+
return state === W.state.open || state === W.state.limited ? { done: '', left: n } : { done: n, left: '—' };
|
|
424
437
|
}
|
|
425
438
|
|
|
426
439
|
function coverageRows(coverage) {
|
|
427
440
|
return (coverage || []).map(c => {
|
|
428
|
-
const state = STATE_WORD[c.state] ||
|
|
441
|
+
const state = STATE_WORD[c.state] || W.state.note;
|
|
429
442
|
// A row that says which cell its words belong in is not split: a reading turn's reason is one sentence,
|
|
430
443
|
// and cut at its first `;` it read as half done and half left.
|
|
431
444
|
const { done, left } = ('done' in c || 'left' in c)
|
|
432
445
|
? { done: plainNote(c.done ?? ''), left: plainNote(c.left ?? '') || '—' }
|
|
433
446
|
: splitCoverageNote(c.note, state);
|
|
434
|
-
|
|
447
|
+
// An area the engine named by its axis reads the reader's label, as the Summary's slices do.
|
|
448
|
+
return { Area: plainNote(coverageUnitLabel(c.area)), State: state, 'What was done': done, "What's left": left };
|
|
435
449
|
});
|
|
436
450
|
}
|
|
437
451
|
|
|
@@ -445,6 +459,8 @@ function coverageOpen({ coverage = [], coverageJudgment = null, verdict = null,
|
|
|
445
459
|
return openState || judgeUnsure || verdictCoverage;
|
|
446
460
|
}
|
|
447
461
|
|
|
462
|
+
// A label under one of the Summary's headings is indented, as a spreadsheet has no other way to nest it.
|
|
463
|
+
const IND = ' ';
|
|
448
464
|
export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, verdict, jurisdiction, registerOnly = false, commonLawUnlogged = false, clientGate = null, lintFailures = [], productName = null, degradedParts = [], assessmentNotCompleted = false } = {}) {
|
|
449
465
|
const disp = d => findings.filter(f => f.disposition === d && !f.isContextNote).length;
|
|
450
466
|
const rated = findings.filter(f => !f.isContextNote);
|
|
@@ -460,7 +476,7 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
460
476
|
const caveat = (notCompletedRow && plainNote(notCompletedRow.note)) || plainNote(coverageJudgment?.reason) ||
|
|
461
477
|
(coverage || []).find(isOpenCoverage)?.note ||
|
|
462
478
|
(degradedParts || [])[0]?.note ||
|
|
463
|
-
|
|
479
|
+
W.summary.nothingOpen;
|
|
464
480
|
|
|
465
481
|
const rows = [
|
|
466
482
|
// — THE WORKBOOK NAMES THE SAME PRODUCT ITS REPORT DOES. This title was the literal
|
|
@@ -468,29 +484,29 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
468
484
|
// search's workbook carried one name between them, and neither matched the masthead of the report
|
|
469
485
|
// they were downloaded from. The workbook is a delivery surface: its link rides the same cover note
|
|
470
486
|
// that reaches a client principal. Null ⇒ the neutral title, never a product the run did not run.
|
|
471
|
-
{ Field: productName ?
|
|
487
|
+
{ Field: productName ? W.summary.title(productName) : W.summary.titleWithoutProduct, Value: W.summary.subtitle, _title: true },
|
|
472
488
|
{ Field: '', Value: '' },
|
|
473
|
-
{ Field:
|
|
474
|
-
{ Field:
|
|
475
|
-
{ Field:
|
|
489
|
+
{ Field: W.summary.mark, Value: mark || fm.title || '' },
|
|
490
|
+
{ Field: W.summary.matter, Value: fm.matter || '' },
|
|
491
|
+
{ Field: W.summary.classes, Value: fm.classes || '' },
|
|
476
492
|
// compute-don't-author (PR-4, review issue 2): the driver-computed per-class register-coverage
|
|
477
493
|
// line (scope-facts.mjs → `coverage_line:` front-matter) renders here so the workbook's headline
|
|
478
494
|
// carries the honest per-class proportion ("Class 30: 76 of 99 slices fully searched — the
|
|
479
495
|
// remaining 23 are non-Latin script forms", the spec-B4 plain form) beside the bare class
|
|
480
496
|
// numbers. Conditional on the fm key: a republished ARCHIVED workbook (whose front-matter never
|
|
481
497
|
// carried coverage_line) must not grow rows.
|
|
482
|
-
...(fm.coverage_line ? [{ Field:
|
|
483
|
-
{ Field:
|
|
484
|
-
{ Field:
|
|
498
|
+
...(fm.coverage_line ? [{ Field: W.summary.registerCoverage, Value: fm.coverage_line }] : []),
|
|
499
|
+
{ Field: W.summary.jurisdiction, Value: jurisdiction || '' },
|
|
500
|
+
{ Field: W.summary.searched, Value: fm.searched || fm.run || '' },
|
|
485
501
|
// spec 64 — the old single row printed the severity TIER under the label "Verdict" (a reader saw
|
|
486
502
|
// "Verdict: High" — vocabulary conflation). With a composed statement the summary carries two
|
|
487
503
|
// labelled rows: the band word and THE one risk statement. A legacy run (no statement) keeps its
|
|
488
504
|
// single original row byte-identically — a republished archived workbook must not grow rows.
|
|
489
505
|
...(assessmentNotCompleted ? []
|
|
490
506
|
: verdict && verdict.statement
|
|
491
|
-
? [{ Field:
|
|
492
|
-
: [{ Field:
|
|
493
|
-
{ Field:
|
|
507
|
+
? [{ Field: W.summary.riskBand, Value: verdictWord }, { Field: W.summary.verdict, Value: verdict.statement, _verdict: true }]
|
|
508
|
+
: [{ Field: W.summary.verdict, Value: verdictWord, _verdict: true }]),
|
|
509
|
+
{ Field: W.summary.checkFirst, Value: caveat, _caveat: true },
|
|
494
510
|
// The gap "What was searched" had to DECLARE rather than list, said again where the reader starts.
|
|
495
511
|
// It is set when that sheet found no per-term common-law rows on a run nothing records as
|
|
496
512
|
// register-only, and it exists because the only signal for this used to be an advisory line on
|
|
@@ -505,7 +521,7 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
505
521
|
// exist, because the same defect threw before writeFile, or it silently read as a complete
|
|
506
522
|
// register-only search. Reproducing that byte-for-byte would be reproducing the defect.
|
|
507
523
|
...(commonLawUnlogged
|
|
508
|
-
? [{ Field:
|
|
524
|
+
? [{ Field: W.summary.commonLaw, Value: W.summary.commonLawUnlogged, _caveat: true }]
|
|
509
525
|
: []),
|
|
510
526
|
// ONE report (spec 2026-07-30 §5): the machine-QC checks enumerate their failures HERE — the
|
|
511
527
|
// workbook is where they live now, and they decide nothing about who may read the report. The old
|
|
@@ -513,7 +529,7 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
513
529
|
// are the checks' own plain-language lines (no internal vocabulary); plainNote() folds any
|
|
514
530
|
// engineering residue. No failed checks ⇒ no row, byte-identical workbook (archived republish safe).
|
|
515
531
|
...(clientGate && clientGate.released === false
|
|
516
|
-
? [{ Field:
|
|
532
|
+
? [{ 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
533
|
: []),
|
|
518
534
|
// A10 (addendum 2026-07-30) — the failing predelivery machine checks, ENUMERATED, whether or not
|
|
519
535
|
// the gate closed: the workbook is the QC record the reviewing lawyer keeps, and a defect that
|
|
@@ -525,34 +541,34 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
525
541
|
// principal — so the raw `detail` may not arrive here at all, and a caller that passes a check
|
|
526
542
|
// object gets a neutral row rather than that object's prose. validateAudit holds the same line.
|
|
527
543
|
...(Array.isArray(lintFailures) && lintFailures.length
|
|
528
|
-
? [{ Field:
|
|
529
|
-
...lintFailures.map((f, i) => ({ Field:
|
|
544
|
+
? [{ Field: W.summary.checksFlagged, Value: W.summary.checksFlaggedCount(lintFailures.length), _caveat: true },
|
|
545
|
+
...lintFailures.map((f, i) => ({ Field: `${IND}${W.summary.check} ${i + 1}`, Value: plainNote(typeof f === 'string' ? f : A10_UNPROJECTED), _caveat: true }))]
|
|
530
546
|
: []),
|
|
531
547
|
{ Field: '', Value: '' },
|
|
532
|
-
{ Field:
|
|
548
|
+
{ Field: W.summary.byTheNumbers, Value: '', _head: true },
|
|
533
549
|
...(assessmentNotCompleted ? [] : [
|
|
534
|
-
{ Field:
|
|
535
|
-
{ Field:
|
|
536
|
-
{ Field:
|
|
537
|
-
{ Field:
|
|
550
|
+
{ Field: `${IND}${W.summary.findingsRated}`, Value: String(rated.length) },
|
|
551
|
+
{ Field: `${IND}${W.summary.onField}`, Value: String(disp('adversarial')) },
|
|
552
|
+
{ Field: `${IND}${W.summary.distinguished}`, Value: String(disp('distinguished')) },
|
|
553
|
+
{ Field: `${IND}${W.summary.offField}`, Value: String(disp('off-field')) },
|
|
538
554
|
]),
|
|
539
|
-
{ Field:
|
|
540
|
-
{ Field:
|
|
555
|
+
{ Field: `${IND}${W.summary.areasAssessed}`, Value: String((coverage || []).length) },
|
|
556
|
+
{ Field: `${IND}${W.summary.openOrLimited}`, Value: String(openCount) },
|
|
541
557
|
{ Field: '', Value: '' },
|
|
542
|
-
{ Field:
|
|
558
|
+
{ Field: W.summary.howToRead, Value: '', _head: true },
|
|
543
559
|
...(assessmentNotCompleted ? []
|
|
544
|
-
: [{ Field:
|
|
560
|
+
: [{ Field: `${IND}${W.summary.findingsTab}`, Value: W.summary.findingsTabIs }]),
|
|
545
561
|
// the third form is not cosmetic. "every search we ran — register and common-law — so you can see
|
|
546
562
|
// we looked everywhere" is a claim ABOUT THIS SHEET, and on a run whose common-law sweep never
|
|
547
563
|
// reached the search log the sheet does not carry it, so the sentence was simply false.
|
|
548
|
-
{ Field:
|
|
549
|
-
?
|
|
564
|
+
{ Field: `${IND}${W.summary.searchedTab}`, Value: registerOnly
|
|
565
|
+
? W.summary.searchedTabIsRegisterOnly
|
|
550
566
|
: commonLawUnlogged
|
|
551
|
-
?
|
|
552
|
-
:
|
|
553
|
-
{ Field:
|
|
554
|
-
{ Field:
|
|
555
|
-
{ Field:
|
|
567
|
+
? W.summary.searchedTabIsRegisterTerms
|
|
568
|
+
: W.summary.searchedTabIsEverything },
|
|
569
|
+
{ Field: `${IND}${W.summary.coverageTab}`, Value: W.summary.coverageTabIs },
|
|
570
|
+
{ Field: `${IND}${W.summary.evidenceTags}`, Value: W.summary.evidenceTagsAre },
|
|
571
|
+
{ Field: `${IND}${W.summary.recordRetrieved}`, Value: W.summary.recordRetrievedIs },
|
|
556
572
|
];
|
|
557
573
|
return rows;
|
|
558
574
|
}
|
|
@@ -566,32 +582,32 @@ export function summaryRows(findings, coverage, fm, { mark, coverageJudgment, ve
|
|
|
566
582
|
function assessmentSummaryRows(ma) {
|
|
567
583
|
if (!ma || (typeof ma.distinctiveness !== 'object' || ma.distinctiveness === null)
|
|
568
584
|
&& (typeof ma.connotation !== 'object' || ma.connotation === null)) return [];
|
|
569
|
-
const rows = [{ Field: '', Value: '' }, { Field:
|
|
585
|
+
const rows = [{ Field: '', Value: '' }, { Field: W.markItself, Value: '', _head: true }];
|
|
570
586
|
const field = (label, v) => {
|
|
571
587
|
if (v == null) return;
|
|
572
588
|
rows.push({ Field: ` ${label}`, Value: plainNote(projectAssessmentField(v)) });
|
|
573
589
|
if (typeof v !== 'object') return;
|
|
574
590
|
for (const r of (Array.isArray(v.per_class) ? v.per_class : []))
|
|
575
|
-
rows.push({ Field: `
|
|
591
|
+
rows.push({ Field: ` ${W.perClass(String(r.class).trim())}`, Value: plainNote(r.note) });
|
|
576
592
|
for (const r of (Array.isArray(v.per_market) ? v.per_market : []))
|
|
577
593
|
rows.push({ Field: ` ${plainNote(r.market)}`, Value: plainNote(r.note) });
|
|
578
594
|
for (const r of (Array.isArray(v.counter_registrations) ? v.counter_registrations : []))
|
|
579
|
-
rows.push({ Field:
|
|
595
|
+
rows.push({ Field: ` ${W.coexistingRegistration}`, Value: plainNote([r.mark, r.uri, r.owner, r.note].filter(Boolean).join(' — ')) });
|
|
580
596
|
};
|
|
581
|
-
field(
|
|
582
|
-
field(
|
|
597
|
+
field(W.distinctiveness, ma.distinctiveness);
|
|
598
|
+
field(W.connotation, ma.connotation);
|
|
583
599
|
return rows.length > 2 ? rows : [];
|
|
584
600
|
}
|
|
585
601
|
function coverageJudgmentSummaryRows(cj) {
|
|
586
602
|
const rows = Array.isArray(cj?.rows) ? cj.rows : [];
|
|
587
603
|
if (!rows.length) return [];
|
|
588
|
-
return [{ Field: '', Value: '' }, { Field:
|
|
604
|
+
return [{ Field: '', Value: '' }, { Field: W.howCoverageWasJudged, Value: '', _head: true },
|
|
589
605
|
...rows.map((r) => ({ Field: ` ${plainNote(r.areaLabel || r.area)}`, Value: plainNote(r.note) }))];
|
|
590
606
|
}
|
|
591
607
|
function correctionsSummaryRows(c) {
|
|
592
608
|
const entries = Array.isArray(c?.entries) ? c.entries : [];
|
|
593
609
|
if (!entries.length) return [];
|
|
594
|
-
return [{ Field: '', Value: '' }, { Field:
|
|
610
|
+
return [{ Field: '', Value: '' }, { Field: W.correctionsApplied, Value: '', _head: true },
|
|
595
611
|
...entries.map((r) => ({ Field: ` ${plainNote(r.entity)}`, Value: plainNote([r.disposition, r.note].filter(Boolean).join(' — ')) }))];
|
|
596
612
|
}
|
|
597
613
|
|
|
@@ -635,7 +651,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
635
651
|
const registerOnly = contract?.registerOnly === true;
|
|
636
652
|
const joinedTerms = contract?.commonLawJoinedTerms instanceof Set ? contract.commonLawJoinedTerms
|
|
637
653
|
: Array.isArray(contract?.commonLawJoinedTerms) ? new Set(contract.commonLawJoinedTerms.map(s => String(s).toUpperCase())) : null;
|
|
638
|
-
const searched = searchRows(auditParsed, { findings: contract?.findings || [], joinedTerms, registerOnly });
|
|
654
|
+
const searched = searchRows(auditParsed, { findings: contract?.findings || [], joinedTerms, registerOnly, registerReach: contract?.registerReach ?? null });
|
|
639
655
|
const commonLawUnlogged = searched.some(r => r._commonLawUnlogged);
|
|
640
656
|
|
|
641
657
|
// 1 · Summary
|
|
@@ -654,7 +670,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
654
670
|
if (kept.has('Link')) {
|
|
655
671
|
const link = row.getCell('Link');
|
|
656
672
|
const url = String(link.value || '').trim();
|
|
657
|
-
if (/^https?:\/\//i.test(url)) { link.value = { text:
|
|
673
|
+
if (/^https?:\/\//i.test(url)) { link.value = { text: W.view, hyperlink: url }; link.font = { color: { argb: WB.link }, underline: true }; }
|
|
658
674
|
}
|
|
659
675
|
if (kept.has('Risk band')) {
|
|
660
676
|
const band = row.getCell('Risk band');
|
|
@@ -666,7 +682,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
666
682
|
// are identified by the flag the row already carries, not re-derived from three of its cells: the
|
|
667
683
|
// re-derivation needed Scope and Result to exist, which on a sparse run they do not.
|
|
668
684
|
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:
|
|
685
|
+
if (data?._section) row.eachCell(c => { c.font = { bold: true }; c.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: WB.sectionFill } }; });
|
|
670
686
|
});
|
|
671
687
|
|
|
672
688
|
// 4 · Coverage & gaps — the honest completeness ledger, state coloured.
|
|
@@ -690,7 +706,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
690
706
|
addSheet(wb, 'Coverage & gaps', COVERAGE_COLS,
|
|
691
707
|
[...coverageRows(coverage), ...coverageRows(degradedParts), ...coverageRows(contract?.droppedConditions || []),
|
|
692
708
|
...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) => {
|
|
709
|
+
...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
710
|
if (!kept.has('State')) return;
|
|
695
711
|
const st = row.getCell('State'); const f = STATE_FILL[String(st.value).trim()];
|
|
696
712
|
if (f) { st.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF' + f } }; st.font = { bold: true }; }
|
|
@@ -708,7 +724,7 @@ export async function buildAudit(contract, auditParsed, outPath, mark = '', fm =
|
|
|
708
724
|
sheets: wb.worksheets.map(w => w.name),
|
|
709
725
|
findings: findings.length,
|
|
710
726
|
coverage: coverage.length,
|
|
711
|
-
searched: wb.getWorksheet('What was searched')?.rowCount - 1 || 0,
|
|
727
|
+
searched: wb.getWorksheet(LABELS.sheets['What was searched'])?.rowCount - 1 || 0,
|
|
712
728
|
gateViolations: gate.violations,
|
|
713
729
|
};
|
|
714
730
|
}
|
|
@@ -755,7 +771,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
755
771
|
const sheets = wb.worksheets.map(w => w.name);
|
|
756
772
|
|
|
757
773
|
// 1 — exactly four tabs, the four plain names, none saying "receipts".
|
|
758
|
-
const EXPECT = ['Summary', 'Findings', 'What was searched', 'Coverage & gaps'];
|
|
774
|
+
const EXPECT = ['Summary', 'Findings', 'What was searched', 'Coverage & gaps'].map((n) => LABELS.sheets[n]);
|
|
759
775
|
if (sheets.length !== 4) v.push(`expected 4 tabs, got ${sheets.length} (${sheets.join(', ')})`);
|
|
760
776
|
for (const name of EXPECT) if (!sheets.includes(name)) v.push(`missing tab "${name}"`);
|
|
761
777
|
|
|
@@ -784,7 +800,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
784
800
|
// green while `HTTP 404 for uri=/mark/ch/06198` shipped in Summary r12. These rows are held to the
|
|
785
801
|
// delivery house rules (predelivery-lint's list) AND to BANNED, and a hit is reported as a
|
|
786
802
|
// violation the A10 tests assert to be empty.
|
|
787
|
-
const summaryWs = wb.getWorksheet('Summary');
|
|
803
|
+
const summaryWs = wb.getWorksheet(LABELS.sheets['Summary']);
|
|
788
804
|
if (summaryWs) {
|
|
789
805
|
summaryWs.eachRow((row, rn) => {
|
|
790
806
|
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 +826,8 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
810
826
|
}
|
|
811
827
|
}
|
|
812
828
|
|
|
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; };
|
|
829
|
+
const findWs = wb.getWorksheet(LABELS.sheets['Findings']);
|
|
830
|
+
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
831
|
// A column addSheet DROPPED has no index here — col() returns 0, and exceljs refuses column 0 as hard
|
|
816
832
|
// as it refuses column 16385, so the gate threw on exactly the workbooks it exists to judge. Reading a
|
|
817
833
|
// dropped column as an EMPTY cell is not a softening: every check below already treats "" as the
|
|
@@ -893,11 +909,18 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
893
909
|
if (/not retrieved/i.test(ret) && !/unverified/i.test(ret) && !/n\/a/i.test(ret) && !/read/i.test(ret)) {
|
|
894
910
|
// "Not individually retrieved" is allowed; only a fetch-FAILURE must carry "unverified"
|
|
895
911
|
}
|
|
896
|
-
// 5 — rated findings:
|
|
912
|
+
// 5 — rated findings: each driver says how its value is evidenced in the report's words, as the page does
|
|
913
|
+
// (context notes exempt). Similarity carries no evidence word; Use carries only "inferred" or "not checked"; the
|
|
914
|
+
// other two carry one of the four words or none; an unknown value nobody checked reads "not checked".
|
|
897
915
|
if (!isCtx) {
|
|
916
|
+
const WORDS = { 'mark similarity': null, 'goods proximity': /^(?:verified|not yet verified|inferred|not checked)$/i,
|
|
917
|
+
use: /^(?:inferred|not checked)$/i, enforcer: /^(?:verified|not yet verified|inferred|not checked)$/i };
|
|
898
918
|
for (const [cc, label] of [[cMs, 'mark similarity'], [cGp, 'goods proximity'], [cUse, 'use'], [cEnf, 'enforcer']]) {
|
|
899
919
|
const t = cellText(cc);
|
|
900
|
-
|
|
920
|
+
const word = t.includes(' · ') ? t.slice(t.lastIndexOf(' · ') + 3) : '';
|
|
921
|
+
if (label === 'mark similarity') { if (word) v.push(`Findings "${mark}": the similarity driver carries an evidence word the report does not print (got "${t}")`); }
|
|
922
|
+
else if (/^unknown\b/i.test(t) && !word) v.push(`Findings "${mark}": ${label} driver is unknown but says nothing about its evidence (got "${t}")`);
|
|
923
|
+
else if (word && !WORDS[label].test(word)) v.push(`Findings "${mark}": ${label} driver's evidence word is not the report's (got "${t}")`);
|
|
901
924
|
}
|
|
902
925
|
}
|
|
903
926
|
}
|
|
@@ -920,7 +943,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
920
943
|
// gate is EXPORTED and a caller can hand it a workbook this builder did not assemble — a missing
|
|
921
944
|
// block is still the right thing to say about such a workbook. Do not read its absence from the
|
|
922
945
|
// build path as the check having been retired.
|
|
923
|
-
const searchWs = wb.getWorksheet('What was searched');
|
|
946
|
+
const searchWs = wb.getWorksheet(LABELS.sheets['What was searched']);
|
|
924
947
|
if (searchWs) {
|
|
925
948
|
const cTerm = col(searchWs, 'Search term / variant') || 2;
|
|
926
949
|
let inCommon = false, sawCommon = false, commonTerms = 0;
|
|
@@ -937,7 +960,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
937
960
|
}
|
|
938
961
|
|
|
939
962
|
// 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');
|
|
963
|
+
const sumWs = wb.getWorksheet(LABELS.sheets['Summary']);
|
|
941
964
|
if (sumWs) {
|
|
942
965
|
let hasVerdict = false, hasCaveat = false;
|
|
943
966
|
sumWs.eachRow(row => {
|
|
@@ -949,7 +972,7 @@ export function validateAudit(wb, { findings = [], coverage = [], coverageJudgme
|
|
|
949
972
|
if (!hasVerdict && !assessmentNotCompleted) v.push('Summary: no Verdict row');
|
|
950
973
|
if (coverageOpen({ coverage, coverageJudgment, verdict, degradedParts })) {
|
|
951
974
|
if (!hasCaveat) v.push('Summary: coverage is open but no caveat row (headline-honesty)');
|
|
952
|
-
const covWs = wb.getWorksheet('Coverage & gaps');
|
|
975
|
+
const covWs = wb.getWorksheet(LABELS.sheets['Coverage & gaps']);
|
|
953
976
|
let openRow = false;
|
|
954
977
|
// by header, not by position: a dropped column shifts the second column to a different question,
|
|
955
978
|
// and this check must read the State word or read nothing (and then say the caveat is missing).
|