clearotron 0.7.0-beta.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/build-info.json +2 -2
- package/docs/architecture/04-configuration-reference.md +105 -8
- package/driver/CHANGELOG.md +38 -0
- package/driver/cancel.mjs +19 -0
- package/driver/contract-e3-backlog.mjs +40 -40
- package/driver/contract-vocabulary.mjs +1 -1
- package/driver/driver.config.mjs +1 -2
- 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 +10 -2
- package/driver/jx-units.mjs +3 -1
- package/driver/manuals-inline.mjs +98 -0
- package/driver/manuals-seen.mjs +4 -16
- package/driver/mark-logos.mjs +31 -1
- package/driver/owner-use-check.mjs +5 -1
- package/driver/package.json +1 -1
- package/driver/pipeline-knockout.mjs +19 -4
- package/driver/pipeline.mjs +36 -8
- package/driver/portal-report.mjs +2 -2
- package/driver/portal-runs.mjs +13 -7
- package/driver/predelivery-lint.mjs +7 -5
- package/driver/publish/email-conditions.mjs +20 -3
- package/driver/publish/index.mjs +218 -139
- package/driver/publish/knockout.mjs +252 -228
- package/driver/publish/pool-admin.mjs +2 -2
- package/driver/publish/regions.mjs +4 -0
- package/driver/publish/register-record-html.mjs +105 -0
- package/driver/publish/register-record.mjs +26 -11
- package/driver/publish/render-knockout.mjs +108 -33
- package/driver/publish/render.mjs +311 -149
- package/driver/publish/report-data.mjs +1 -1
- 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 +152 -4
- package/driver/publish/templates/clearance-print.css +23 -0
- package/driver/publish/templates/knockout.css +24 -0
- package/driver/publish/templates/report.css +40 -1
- package/driver/publish/xlsx.mjs +16 -20
- package/driver/register-count.mjs +5 -1
- package/driver/registry-fidelity.mjs +152 -29
- package/driver/repair-composers.mjs +2 -2
- package/driver/replay-archive.mjs +4 -3
- package/driver/run-delivered.mjs +8 -7
- package/driver/run-record.mjs +1 -0
- 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 +66 -40
- package/driver/steps/delivery.mjs +9 -5
- package/driver/steps/overview-and-cards.mjs +4 -1
- package/driver/steps/register-sweep.mjs +5 -4
- package/driver/steps/skeptic-and-follow-up.mjs +3 -2
- package/driver/steps/verdict-gate.mjs +2 -1
- package/driver/suite-census.json +224 -32
- package/driver/synthesis-record.mjs +4 -3
- package/driver/withdrawn-rating.mjs +72 -0
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/lib/brief.mjs +4 -1
- package/mcp-server/lib/evidence.mjs +66 -22
- package/mcp-server/lib/findings.mjs +19 -2
- package/mcp-server/lib/knockout.mjs +12 -3
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +19 -2
- package/package.json +1 -1
- package/portal-ui/dist/assets/{index-CtkllKJ2.js → index-BBlN4CYq.js} +13 -3
- package/portal-ui/dist/index.html +1 -1
- package/portal-ui/package.json +1 -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 +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/scripts/added-reference-check.mjs +35 -7
- package/scripts/e2e-first-time.mjs +1 -1
- package/scripts/env-audit.mjs +16 -9
- package/scripts/mint-public-residue.mjs +3 -3
- package/shared/brand.mjs +8 -1
- package/shared/names-in-force.mjs +0 -1
- package/shared/reference-guard-classes.mjs +43 -2
- package/shared/source-spans.mjs +91 -0
package/driver/publish/index.mjs
CHANGED
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
// This is deterministic Node — NOT an LLM turn — so it cannot hang/timeout. The driver calls it directly
|
|
9
9
|
// (not via runStage). Run identity (runId/codename) comes from the driver's ctx.run; do NOT regenerate it.
|
|
10
10
|
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, chmodSync } from 'node:fs';
|
|
11
|
-
import {
|
|
11
|
+
import { grpRead, publishRun } from './shell.mjs';
|
|
12
12
|
import { join, dirname } from 'node:path';
|
|
13
13
|
import { readFold } from '../record-fold.mjs'; import { parseReport, parseAudit, stripInternal, parseCaseLawProfiles, parseCaseLawPreamble, joinCaseLawProfiles } from './parse.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { renderClearanceDocument } from './render.mjs'; import { emailConditionsOf } from './email-conditions.mjs'; // the box's conditions, read the same way by the delivery check
|
|
15
15
|
import { buildAudit } from './xlsx.mjs'; import { readDegradedPartRows, degradedPartRows, degradedAtPublish, storeStates, readDeliveredStores, mergeDegradedRows } from '../degraded-parts.mjs'; import { readDeclinations } from '../declination-tool.mjs'; import { frameSetAsideRows } from '../web-grid.mjs'; // — what synthesis set aside, with its grounds; and the stores the matter frame set aside, with its reason
|
|
16
16
|
import { parseFindingsJson, parseFindingsJsonLenient, deriveDisplayVerdict, projectCoverageJudgment, COVERAGE_AREA_STATES } from '../findings-model.mjs';
|
|
17
17
|
import { recordsOfDeliveredPositions } from '../declination-duty.mjs'; import { findingUris } from '../record-carry.mjs'; // — a position a finding delivers is not listed as set aside
|
|
18
18
|
import { readStore, requiredAbsent, nonClosingAbsences } from './publish-inputs.mjs'; import { coverageFormStamp, readCoverageForm } from '../coverage-form-io.mjs'; import { readReleasedFamilies, readWithheldFamilies } from '../withheld-families.mjs'; import { unitLabel } from '../coverage-form.mjs'; import { coverageUnitLabel } from '../coverage-ledger.mjs'; import { recallReceiptForOwnCompany } from '../recall-receipt.mjs'; // — and why an absence did not close; whose recall checks an audit lists
|
|
19
|
-
import {
|
|
19
|
+
import { clearanceReportDocument, clearanceReportDataOf, clearanceRatingOf, clearanceWorkbookOf } from './report-document.mjs'; // the run's report as one document, and what it carries
|
|
20
20
|
import { searchDepthRecord, planTerritoriesOf, caseLawPassRecord } from './search-depth.mjs'; import { bandRecords } from '../named-band.mjs'; import { CASELAW_BRIDGES } from '../engine/mcp/gather-config.mjs'; // how much was read to reach the answer, as counts and tokens; and the case-law sources whose calls the court state reads
|
|
21
21
|
import { parseFrameworkManifest } from '../framework.mjs'; import { readFrozenMethod, FROZEN_METHOD_FILE } from '../framework-method.mjs';
|
|
22
22
|
import { rollupTokens, servedModels } from '../tokens.mjs';
|
|
23
23
|
import { reportIdentityFor, productCoverageNote, isRegisterOnly } from '../search-policy.mjs';
|
|
24
24
|
import { readRecordArtifacts, bindFindingsToRecords, joinEvidenceStatus } from '../registry-fidelity.mjs';
|
|
25
|
-
import {
|
|
25
|
+
import { deliveredFailure } from '../predelivery-lint.mjs';
|
|
26
26
|
import { unrenderableConditions, clientStatement, clientConditions } from '../terminal-clamp.mjs'; // — the conditions that reach no client surface; the cover note's
|
|
27
27
|
import { runLog } from '../log.mjs'; // — one line in the run record when one does
|
|
28
28
|
import { PROVIDERS, config } from '../driver.config.mjs';
|
|
@@ -142,7 +142,7 @@ export function evaluateClientGate({ coverage = [], lintFailingIds = [], escalat
|
|
|
142
142
|
// T3 (H3) — the machine-QC INPUT assembly. Mirrors publishReport's own reads exactly (the
|
|
143
143
|
// strict→lenient findings degrade + the _driver sinks) so an out-of-band evaluation (tests, tooling)
|
|
144
144
|
// judges with the same pair of eyes as publish. The pipeline preflight that used to call this is gone
|
|
145
|
-
// (one report
|
|
145
|
+
// (one report) — publishReport's in-publish evaluation is the single live caller.
|
|
146
146
|
export function assembleReleaseInputs(reportMdPath, findingsJsonPath) {
|
|
147
147
|
let coverage = [], quarantined = [], findingsError = null;
|
|
148
148
|
const base = dirname(reportMdPath);
|
|
@@ -233,7 +233,7 @@ function indexRows(runs, { reportFile, linkPrefix = '', showAudit = true, client
|
|
|
233
233
|
return runs.map(r => {
|
|
234
234
|
// Machine-QC state (meta.clientGate is the historical stamp name): a STAFF-surface pill pointing the
|
|
235
235
|
// reviewer at the audit workbook. It no longer decides anything — one report, always listed, always
|
|
236
|
-
// linked
|
|
236
|
+
// linked; the delivery-language "⛔ on hold" pill is retired with the split.
|
|
237
237
|
const qcFailed = !client && r.clientGate && r.clientGate.released === false;
|
|
238
238
|
// Demo anonymisation (inert on the client-facing per-customer index — no overlay there): the matter
|
|
239
239
|
// (slug) + project (title) are marks → blur; the report/audit links carry the slug in the runId → the
|
|
@@ -263,7 +263,7 @@ function indexRows(runs, { reportFile, linkPrefix = '', showAudit = true, client
|
|
|
263
263
|
}).join('\n');
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
// ONE report
|
|
266
|
+
// ONE report: the "Review & iteration version · internal" / "Clean final version ·
|
|
267
267
|
// client-facing" header pills are retired with the split they printed on the page. Both indexes link the
|
|
268
268
|
// same report.html; what still differs between them is audience presentation (staff nav/filter/audit
|
|
269
269
|
// column vs the customer page's date-only rows and explicit-light theme), not the document.
|
|
@@ -400,7 +400,7 @@ ${indexRows(archivedRuns, { reportFile: 'report.html', showAudit: true })}
|
|
|
400
400
|
|
|
401
401
|
// Rebuild the pool index from every run's meta.json (newest first): the STAFF all-runs index (links
|
|
402
402
|
// report.html + audit) AND, additively (D3), one per-customer index per account linking the SAME
|
|
403
|
-
// report.html — one report
|
|
403
|
+
// report.html — one report; the per-customer pages differ in chrome, not document.
|
|
404
404
|
export function regenIndex(poolDir) {
|
|
405
405
|
const runs = readdirSync(poolDir, { withFileTypes: true })
|
|
406
406
|
.filter(d => d.isDirectory() && d.name !== 'customer' && existsSync(join(poolDir, d.name, 'meta.json')))
|
|
@@ -461,7 +461,7 @@ export function regenIndex(poolDir) {
|
|
|
461
461
|
try { chmodSync(idx, 0o640); } catch { /* best-effort; group-read via set-gid pool */ }
|
|
462
462
|
|
|
463
463
|
// D3 — per-customer indexes at customer/<key>/index.html: only that account's runs, linking THE report
|
|
464
|
-
// (report.html — one report
|
|
464
|
+
// (report.html — one report) two levels up. The page is template-identical to the
|
|
465
465
|
// staff index minus the staff chrome. NO staff nav here — internal surfaces never reach a
|
|
466
466
|
// customer-facing page.
|
|
467
467
|
// Do NOT chmod the customer dirs: they inherit the set-gid pool group (an explicit dir chmod here was the
|
|
@@ -479,7 +479,7 @@ export function regenIndex(poolDir) {
|
|
|
479
479
|
const dir = join(poolDir, 'customer', key);
|
|
480
480
|
mkdirSync(dir, { recursive: true }); // inherits the set-gid group; never chmod the dir
|
|
481
481
|
const cidx = join(dir, 'index.html');
|
|
482
|
-
// ONE report
|
|
482
|
+
// ONE report: a run you have rights to is always listed and always linked. The
|
|
483
483
|
// old clientGate suppression (a held run vanished from this page) is gone — the machine checks live
|
|
484
484
|
// on the audit workbook now and decide nothing about who may read. The precedent is the knockout
|
|
485
485
|
// lane's own collapse note: two renderings of one run is how the wrong link gets sent.
|
|
@@ -695,7 +695,7 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
695
695
|
// input left NO trace anywhere: findings=[]/coverage=[]/findingsError=null is exactly what a search
|
|
696
696
|
// that ran and found nothing produces, so "we read nothing" and "we read everything and it was clean"
|
|
697
697
|
// were the same delivered artifact. Recording is the whole fix here — the gate withholds nothing
|
|
698
|
-
//
|
|
698
|
+
// and the report's own face is the frozen renderer's, not this file's.
|
|
699
699
|
const inputsAbsent = [];
|
|
700
700
|
// THE OVERALL ASSESSMENT NOT COMPLETED (driver/parts-not-completed.mjs). A stated state, read from the run's own
|
|
701
701
|
// record and never inferred from an absence: the report is built from what the run held, with no rating, no
|
|
@@ -745,8 +745,8 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
745
745
|
: [];
|
|
746
746
|
}
|
|
747
747
|
coverage = withoutRepeatedRows(coverage); // one recorded row, repeated, prints once (see withoutRepeatedRows)
|
|
748
|
-
//
|
|
749
|
-
// projected on the RENDER path
|
|
748
|
+
// The STRING PROJECTION for coverage_judgment stays. mark_assessment is NO LONGER
|
|
749
|
+
// projected on the RENDER path: render.mjs takes the structured object and shows
|
|
750
750
|
// the one-sentence `read` with the typed rows collapsed. projectAssessmentField/projectMarkAssessment
|
|
751
751
|
// remain the projection for the workbook, report-data's client text, the lint and legacy string runs.
|
|
752
752
|
const coverageJudgmentDisplay = projectCoverageJudgment(coverageJudgment);
|
|
@@ -757,7 +757,7 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
757
757
|
// (materialized by the lint-pass assembleRunRecords); absent ⇒ empty map ⇒ a NO-OP (back-compat: archived /
|
|
758
758
|
// replay runs with no record set keep the model's fields). The persisted findings.json copy above is the
|
|
759
759
|
// model's original (kept for forensics); the records are archived alongside in _records/.
|
|
760
|
-
const recordsByUri = runDir ? readRecordArtifacts(runDir) : new Map();
|
|
760
|
+
const recordsByUri = runDir ? readRecordArtifacts(runDir) : new Map(), logos = logosForReport(runDir), followUpKinds = followUpKindsOf(runDir); // and each cited registration's saved logo; none on a run that fetched none
|
|
761
761
|
// WP-receipts W2 — the run's fetch-receipt index (written by assembleRunRecords). Its `provider` names
|
|
762
762
|
// the register THIS run actually used — the link origin + label come from THAT provider's config, never
|
|
763
763
|
// the currently-configured one (a re-published archive keeps its own register). Legacy runs: null ⇒
|
|
@@ -956,6 +956,12 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
956
956
|
const r = readStore(runDir ?? dirname(reportMd), '_driver/scope-facts.json').value?.register_reach;
|
|
957
957
|
if (typeof r?.service === 'string' && r.service && Number.isInteger(r.offices) && r.offices > 0) registerReach = { service: r.service, offices: r.offices };
|
|
958
958
|
}
|
|
959
|
+
// WHAT THE ORDER COVERED, for the register rows' head: 'worldwide', or 'named' for an order that names its
|
|
960
|
+
// countries, so the head does not call that search worldwide. Read from the same plan and instructed scope as the
|
|
961
|
+
// searched set above; null when the run's record cannot say.
|
|
962
|
+
const registerScope = scopeBasis === 'worldwide' ? 'worldwide'
|
|
963
|
+
: searchedJurisdictions.length && searchedJurisdictions.every((j) => !/^(worldwide|world|ww|global)$/i.test(String(j).trim())) ? 'named'
|
|
964
|
+
: null;
|
|
959
965
|
// T7 (E5) — the case-law layer joins DETERMINISTICALLY (was: a prompt fished in the md and
|
|
960
966
|
// hit 2 of 3 copper-spire cards): parse the grounded profiles, join by ordinal (fresh runs dictate
|
|
961
967
|
// "- ord:") falling back to mark/owner (archived runs) — every matched card gets its strand.
|
|
@@ -966,7 +972,7 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
966
972
|
if (existsSync(clPath)) {
|
|
967
973
|
const clMd = readFileSync(clPath, 'utf8');
|
|
968
974
|
caseLawByOrdinal = joinCaseLawProfiles(parseCaseLawProfiles(clMd), findings, readFold(runDir ?? dirname(reportMd))?.map?.modelToFolded ?? null);
|
|
969
|
-
caseLawNotice = parseCaseLawPreamble(clMd); // session-wide outage notice —
|
|
975
|
+
caseLawNotice = parseCaseLawPreamble(clMd); // session-wide outage notice — kept in the report document; no page prints it
|
|
970
976
|
}
|
|
971
977
|
} catch { /* no case-law layer this run */ }
|
|
972
978
|
// T7 (E6) — the Corsearch enforcement telemetry (onomaticsAggression/oppositions, extracted
|
|
@@ -1037,7 +1043,7 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
1037
1043
|
};
|
|
1038
1044
|
|
|
1039
1045
|
// Machine QC (the evaluateClientGate checks — arithmetic, record fidelity, stale corrections). The
|
|
1040
|
-
// checks SURVIVE; what they decide is gone: one report
|
|
1046
|
+
// checks SURVIVE; what they decide is gone: one report, so they no longer choose
|
|
1041
1047
|
// who may read anything. Evaluated HERE — before the audit workbook build — because the workbook is
|
|
1042
1048
|
// where their result lands (a plain internal QC row) alongside the run telemetry; failures also stamp
|
|
1043
1049
|
// meta.json for the staff index's ⚠ QC pill. The rendered report carries no banner either way, and a
|
|
@@ -1142,7 +1148,7 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
1142
1148
|
// The NAME is still never stored: the sidecar holds the product ID, and the string comes off
|
|
1143
1149
|
// today's registry row on every render — which is what lets a renamed product re-render honestly.
|
|
1144
1150
|
productName = reportIdentityFor(pol).identity ?? undefined;
|
|
1145
|
-
//
|
|
1151
|
+
// The masthead names what this depth covers and what it omits (2026-07-30),
|
|
1146
1152
|
// from the run's OWN frozen components. No sidecar ⇒ undefined ⇒ no strip (archived byte-identity).
|
|
1147
1153
|
depthNote = productCoverageNote(pol) ?? undefined;
|
|
1148
1154
|
} catch { stageLabel = undefined; depthNote = undefined; productName = undefined; }
|
|
@@ -1233,7 +1239,7 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
1233
1239
|
bridges: CASELAW_BRIDGES,
|
|
1234
1240
|
});
|
|
1235
1241
|
})(),
|
|
1236
|
-
registerPlan: rdJson(paths(runBase).registerPlan),
|
|
1242
|
+
registerPlan: rdJson(paths(runBase).registerPlan), planExecution: readStore(runBase, '_driver/plan-execution.json').value ?? null,
|
|
1237
1243
|
laneDepthVerdicts,
|
|
1238
1244
|
noMarketplacesPicked,
|
|
1239
1245
|
});
|
|
@@ -1265,7 +1271,7 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
1265
1271
|
// same reason: the fact exists on the way IN and was lost on the way out.
|
|
1266
1272
|
//
|
|
1267
1273
|
// The composer has a project picker, portal-service stamps `projectKey` onto the job, and freezeProfile
|
|
1268
|
-
// records the key AND the resolved name in _driver/profile.json
|
|
1274
|
+
// records the key AND the resolved name in _driver/profile.json. The sidecar does not travel
|
|
1269
1275
|
// with a pool dir, so once a run was delivered nothing could say which matter it belonged to — not the
|
|
1270
1276
|
// run list, not Clearances, not a report. "What was I working on" had no answer anywhere in the portal.
|
|
1271
1277
|
//
|
|
@@ -1285,9 +1291,9 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
1285
1291
|
return {
|
|
1286
1292
|
parsed, fm, deliv, dates, issued, asOf, demoData, demoMd, inputsAbsent, findings, coverage, contextNotes,
|
|
1287
1293
|
quarantined, findingsError, coverageJudgment, markAssessment, actionsRegister, askAnswers, correctionsDoc,
|
|
1288
|
-
fourAnswers, findingsSchemaVersion, findingsKept, assessmentNotCompleted, coverageJudgmentDisplay, recordsByUri,
|
|
1294
|
+
fourAnswers, findingsSchemaVersion, findingsKept, assessmentNotCompleted, coverageJudgmentDisplay, recordsByUri, logos, followUpKinds,
|
|
1289
1295
|
runProviderConf, recordOrigin, providerLabel, runOrigins, seniorRights, verdictInfo, droppedConditions,
|
|
1290
|
-
undispatchedProbes, withheldFamilies, setAside, framework, frameworkMethod, scopeBasis, searchedJurisdictions, registerReach,
|
|
1296
|
+
undispatchedProbes, withheldFamilies, setAside, framework, frameworkMethod, scopeBasis, searchedJurisdictions, registerReach, registerScope,
|
|
1291
1297
|
planTerritories, caseLawByOrdinal, caseLawNotice, enforcerSignals, officeLinks, reviewReceipts, clientGate,
|
|
1292
1298
|
fetchState, searchPolicy, registerOnly, noMarketplacesPicked, jurisdiction, commonLawJoinedTerms, stageLabel,
|
|
1293
1299
|
depthNote, productName, publishParts, auditParsed, degradedRows, releasedFamilies, served, searchDepth, issuedAt,
|
|
@@ -1308,8 +1314,9 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
1308
1314
|
// The headline caption as the front matter states it, empty as null. The email, the data file, meta.json and the run
|
|
1309
1315
|
// record take it; the page takes the report's Summary instead (render.mjs).
|
|
1310
1316
|
caption: fm.overall_caption || null,
|
|
1311
|
-
// The
|
|
1312
|
-
|
|
1317
|
+
// The verdict record as written, which the cover email reads. `verdictInfo` above is the record as the page reads it:
|
|
1318
|
+
// the two differ on a record older than the derived display fields, and where the assessment was not completed.
|
|
1319
|
+
verdictWritten: (() => { try { return readJson(paths(runDir ?? dirname(reportMd)).verdict); } catch { return null; } })(),
|
|
1313
1320
|
};
|
|
1314
1321
|
}
|
|
1315
1322
|
|
|
@@ -1326,85 +1333,98 @@ export async function readClearanceDocument({ runId, reportMd, auditMd, findings
|
|
|
1326
1333
|
*/
|
|
1327
1334
|
// skipRegen — do NOT re-render index.html + the staff pages at the end. The batch backfill passes this and does
|
|
1328
1335
|
// ONE regen after the whole loop instead of N redundant ones (per-run publish leaves it false, as before).
|
|
1329
|
-
// (skipClient is retired with report.client.html — one report
|
|
1330
|
-
export async function publishReport(
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1336
|
+
// (skipClient is retired with report.client.html — one report.)
|
|
1337
|
+
export async function publishReport(input) {
|
|
1338
|
+
return publishRun(CLEARANCE_SHAPE, input);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// The clearance's parts of the publishing order (shell.mjs publishRun).
|
|
1342
|
+
const CLEARANCE_SHAPE = {
|
|
1343
|
+
regenIndex, regenSurfaces,
|
|
1344
|
+
read: async ({ runId, reportMd, auditMd, findingsJson, poolRoot, poolUrl, customerKey, delivery, runDir, codename }) => ({
|
|
1345
|
+
doc: await readClearanceDocument({ runId, reportMd, auditMd, findingsJson, poolRoot, poolUrl, customerKey, delivery, runDir }),
|
|
1346
|
+
runId, codename, customerKey, reportMd, auditMd,
|
|
1347
|
+
}),
|
|
1348
|
+
keep({ writeRO, copyRO, copyPart }, { doc: { demoMd, findingsKept }, reportMd, auditMd }) {
|
|
1349
|
+
// The pool's copy of report.md, marked as demo data where the document says it is (the answer and its argument are
|
|
1350
|
+
// with `demoData` in readClearanceDocument).
|
|
1351
|
+
writeRO('report.md', (demoMd ? `${demoMd}\n` : '') + stripInternal(readFileSync(reportMd, 'utf8'), { client: false }));
|
|
1352
|
+
// The findings.json the document read, kept beside the report for forensics. A copy that fails leaves the report in
|
|
1353
|
+
// place and is recorded, as a data file is (shell.mjs).
|
|
1354
|
+
if (findingsKept) copyPart(findingsKept, 'findings.json');
|
|
1355
|
+
if (auditMd && existsSync(auditMd)) copyRO(auditMd, 'audit.md'); // durable source (kept even if the xlsx fails)
|
|
1356
|
+
},
|
|
1357
|
+
document: ({ doc, runId, codename, customerKey }) => clearanceReportDocument({ ...doc, runId }, { codename, customerKey }),
|
|
1358
|
+
warn: (what, e) => console.warn(`[report-document] ${what}: ${e?.message ?? e}`),
|
|
1359
|
+
async workbook({ buildWorkbook }, reportDocument, { doc: { findings, auditParsed, assessmentNotCompleted }, runId }) {
|
|
1360
|
+
// In the state the workbook is built even with no finding and no search log: it carries the part that was not
|
|
1361
|
+
// completed, and the coverage the run did record.
|
|
1362
|
+
if (!(findings.length || auditParsed || assessmentNotCompleted)) return { auditFile: null, auditError: null, built: null };
|
|
1363
|
+
return buildWorkbook(`${runId}-audit.xlsx`, async (at) => {
|
|
1354
1364
|
// A10 — the failing predelivery checks ride into the workbook and are ENUMERATED on its Summary
|
|
1355
|
-
// sheet (with the cover note, the delivery surfaces that reach the reviewing lawyer)
|
|
1356
|
-
//
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
// the same cover note that reaches a client principal, so it is a delivery surface under exactly
|
|
1360
|
-
// the same rule (the workbook's own BANNED gate had already started firing on the raw detail —
|
|
1361
|
-
// advisory, so CI stayed green). reviewReceipts.lint keeps its raw detail for the internal
|
|
1362
|
-
// readers above (fetchState reads registry-record-coverage's URIs out of it).
|
|
1363
|
-
const built = await buildAudit({ degradedParts: degradedRows, droppedConditions, undispatchedProbes, withheldFamilies, releasedFamilies, setAside, findings, frameworkMethod, coverage, contextNotes, coverageJudgment, markAssessment, corrections: correctionsDoc, fetchState, verdict: verdictInfo, jurisdiction, commonLawJoinedTerms, registerOnly, clientGate, lintFailures: deliveryFlagLines(reviewReceipts.lint), productName, registerPublishesRecordPages: runOrigins == null ? null : runOrigins.length > 0, recordLinks: officeLinks?.byUri ?? null, assessmentNotCompleted, registerReach }, auditParsed, at, fm.title, fm);
|
|
1365
|
+
// sheet (with the cover note, the delivery surfaces that reach the reviewing lawyer), as their delivery
|
|
1366
|
+
// lines (clearanceWorkbookOf).
|
|
1367
|
+
const w = clearanceWorkbookOf(reportDocument);
|
|
1368
|
+
const built = await buildAudit(w.contract, w.audit, at, w.title, w.frontMatter);
|
|
1364
1369
|
if (built?.gateViolations?.length) console.warn(`[audit-workbook] advisory: ${built.gateViolations.join(' | ')}`);
|
|
1365
1370
|
return built;
|
|
1366
|
-
})
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1371
|
+
}); // a REAL exception only — the report ships without the workbook, and nothing names it
|
|
1372
|
+
},
|
|
1373
|
+
surfaces({ writeRO, writeDataFile }, reportDocument, { doc: { searchDepth, recordsByUri, logos, deliv, demoData } }) {
|
|
1374
|
+
// THE report. The render receives no QC flags — the report a lawyer signs carries no
|
|
1375
|
+
// caveat banner (H1/H2); the receipts live on audit.xlsx. The machine QC above decides nothing
|
|
1376
|
+
// about this write.
|
|
1377
|
+
// homeHref — the floating "← All reports" pill returns to the listing (the staff index one level up).
|
|
1378
|
+
// NO SITE NAV IS BUILT FOR A REPORT. One was, from a walk of the pool on every publish, and handed to a
|
|
1379
|
+
// renderer that never read it; reports published before that carry one, and the portal still strips it.
|
|
1380
|
+
// How much was read to reach the answer, written where the document holds it (an additive record: a publish never
|
|
1381
|
+
// fails for want of it).
|
|
1382
|
+
if (searchDepth) { try { writeRO('search-depth.json', JSON.stringify(searchDepth, null, 2)); } catch { /* additive */ } }
|
|
1383
|
+
|
|
1384
|
+
writeRO('report.html', renderClearanceDocument(pageDocument(reportDocument), { recordsByUri, logos, homeHref: '../index.html', chromeHref: '../assets/chrome.css', delivery: deliv, demoData })); // the page reads the report document, with its surface beside it
|
|
1385
|
+
// ONE report: report.client.html is no longer written. The knockout lane's own
|
|
1386
|
+
// collapse note is the precedent: "two renderings of one run is how the wrong link gets sent". The
|
|
1387
|
+
// client host serves the same report.html through the portal's readReport() (cleaning built in) — its
|
|
1388
|
+
// repoint deployed before this change merged.
|
|
1389
|
+
//
|
|
1390
|
+
// The four-answers panel was once passed to BOTH renders. There is one render now, so `fourAnswers`
|
|
1391
|
+
// rides the one call — the panel reaches the client through the same cleaning path as every other
|
|
1392
|
+
// reader-facing block.
|
|
1393
|
+
// The clearance run as data: the client-cut projection the assistant drafts mail from, built from the
|
|
1394
|
+
// document (clearanceReportDataOf). BEST-EFFORT with a hard receipt rule: meta.reportSchema is stamped ONLY when the
|
|
1395
|
+
// file actually wrote, so a meta never names a data file that is not there. A producer throw never blocks the
|
|
1396
|
+
// report (the baked HTML above is already on disk).
|
|
1397
|
+
const reportSchema = writeDataFile('report-data.json', () => clearanceReportDataOf(reportDocument)) ? 'report-data/clearance-1' : null;
|
|
1398
|
+
return { reportSchema, template: deliv?.template ?? 'standard' };
|
|
1399
|
+
},
|
|
1400
|
+
// The run's record, from the document. A document that could not be built fails the publish here, after the page
|
|
1401
|
+
// and before the record, as a throw in the record always has.
|
|
1402
|
+
meta: (reportDocument, { template, reportSchema }) => clearanceMetaOf(reportDocument, { template, reportSchema }),
|
|
1403
|
+
result: ({ read: { doc: { reportRoute, findingsError, clientGate, caption }, runId, customerKey }, pool: { poolRunDir }, workbook: { auditFile, auditError, built: counts }, total }) => ({
|
|
1404
|
+
// THE PORTAL ROUTE, not the pool's directory layout. This was
|
|
1405
|
+
// `<origin>/<runId>/report.html` — where the documents sit on disk, which is not an application route.
|
|
1406
|
+
// Composed rather than spelled here so the report link is built the same way the audit link always was.
|
|
1407
|
+
runId, auditFile, counts, total, url: reportRoute, poolRunDir, auditError, findingsError, customerKey: customerKey || 'generic', clientGate,
|
|
1408
|
+
caption, // the report's own conclusion, for the run record's short surfaces
|
|
1409
|
+
}),
|
|
1410
|
+
};
|
|
1369
1411
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
//
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
// P5 rebase note: this package was written against the pre-collapse tree, where the four-answers panel
|
|
1387
|
-
// had to be passed to BOTH renders. There is one render now, so `fourAnswers` rides the one call — the
|
|
1388
|
-
// panel reaches the client through the same cleaning path as every other reader-facing block.
|
|
1389
|
-
// PR-9 — the clearance run as data (publish/report-data.mjs): the client-cut projection the assistant
|
|
1390
|
-
// drafts mail from. BEST-EFFORT with a hard receipt rule: meta.reportSchema is stamped ONLY when the file
|
|
1391
|
-
// actually wrote, so a meta never names a data file that is not there. A producer throw never blocks the
|
|
1392
|
-
// report (the baked HTML above is already on disk).
|
|
1393
|
-
const reportSchema = writeDataFile('report-data.json', () => clearanceReportData({
|
|
1394
|
-
runId, codename, matter: fm.matter, markName, title: fm.title, customerKey: customerKey || 'generic',
|
|
1395
|
-
issued, url: reportRoute,
|
|
1396
|
-
// stageLabel REGISTRY-FIRST ( residual, audit item 4): `stageLabel` is reportIdentityFor's
|
|
1397
|
-
// read-time derivation — the same label report.html renders — so a republished pre-renumber run
|
|
1398
|
-
// cannot mint report.html "Depth 2" beside report-data.json "Stage 0.5". The frozen sidecar label
|
|
1399
|
-
// is the LAST resort (a level today's registry no longer knows). meta.json below keeps the frozen
|
|
1400
|
-
// stamp BY DESIGN — its readers re-derive.
|
|
1401
|
-
auditFile, searchLevel: searchPolicy?.level ?? null, stageLabel: stageLabel ?? frozenStageLabel ?? null,
|
|
1402
|
-
engineCommit: doc.engineCommit, servedModels: served,
|
|
1403
|
-
framework, verdictInfo, findings, coverage, contextNotes, markAssessment, fourAnswers, askAnswers,
|
|
1404
|
-
actions: actionsRegister, jurisdiction, searchedJurisdictions, scopeBasis, caption,
|
|
1405
|
-
assessmentNotCompleted,
|
|
1406
|
-
})) ? 'report-data/clearance-1' : null;
|
|
1407
|
-
const total = finishPoolRun({ writeRO, poolRoot, skipRegen, regenIndex, meta: {
|
|
1412
|
+
/**
|
|
1413
|
+
* The run's record in the pool (meta.json), from the report document. `template`, the delivery's named variant, and
|
|
1414
|
+
* `reportSchema`, whether the data file wrote, are publishing's own facts and not the run's.
|
|
1415
|
+
*/
|
|
1416
|
+
function clearanceMetaOf(document, { template, reportSchema }) {
|
|
1417
|
+
if (!document) throw new Error('the report document could not be built, so the run record cannot be written');
|
|
1418
|
+
const { run, verdict, client, reviewer, staff, build } = document;
|
|
1419
|
+
const fm = document.prose.frontMatter;
|
|
1420
|
+
const { runId, codename, markName, project, organisation, customerKey, issuedAt, auditFile } = run;
|
|
1421
|
+
const { renderedAt } = build;
|
|
1422
|
+
const served = client.servedModels, framework = document.framework.manifest, clientGate = reviewer.clientGate;
|
|
1423
|
+
const verdictInfo = verdict.record, assessmentNotCompleted = verdict.assessmentNotCompleted;
|
|
1424
|
+
// The rating word and its badge as the page states them (clearanceRatingOf). The headline caption, empty as null.
|
|
1425
|
+
const { word: ratingWord, badge: ratingBadge } = clearanceRatingOf(document);
|
|
1426
|
+
const caption = fm.overall_caption || null;
|
|
1427
|
+
return {
|
|
1408
1428
|
runId, codename: codename || '', matter: fm.matter, title: fm.title, client: fm.client,
|
|
1409
1429
|
// The mark as typed — see above. Distinct from `title`, which is the report's own headline.
|
|
1410
1430
|
markName: markName ?? undefined,
|
|
@@ -1420,34 +1440,34 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1420
1440
|
issuedAt,
|
|
1421
1441
|
renderedAt,
|
|
1422
1442
|
// WHICH BUILD produced this. null off a git checkout — a provenance stamp never fails a publish.
|
|
1423
|
-
engineCommit:
|
|
1443
|
+
engineCommit: build.engineCommit,
|
|
1424
1444
|
// The models that served the run, named as a client may read them (tokens.mjs servedModels). Absent when
|
|
1425
1445
|
// nothing was read, so a meta from before the record keeps its shape; [] when turns ran and named none a client may read.
|
|
1426
1446
|
servedModels: served ?? undefined,
|
|
1427
|
-
kind: 'clearance', recordLinks:
|
|
1428
|
-
searchLevel:
|
|
1447
|
+
kind: 'clearance', recordLinks: client.recordLinks?.tally ?? undefined, // per office: linked, or cited by number and why; only where the register has no record pages
|
|
1448
|
+
searchLevel: run.product.level ?? undefined,
|
|
1429
1449
|
// Display-only face of the level ("Depth 4"), frozen alongside it so the list can show which reads
|
|
1430
1450
|
// have run on a name without the browser having to know the level registry.
|
|
1431
|
-
stageLabel: frozenStageLabel ?? undefined,
|
|
1432
|
-
recipe:
|
|
1433
|
-
enqueuedVia:
|
|
1434
|
-
enqueuedBy:
|
|
1435
|
-
parentRunId:
|
|
1436
|
-
tokens: (() => { const t =
|
|
1451
|
+
stageLabel: run.product.frozenStageLabel ?? undefined,
|
|
1452
|
+
recipe: run.provenance.recipe ?? undefined,
|
|
1453
|
+
enqueuedVia: run.provenance.enqueuedVia ?? undefined,
|
|
1454
|
+
enqueuedBy: run.provenance.enqueuedBy ?? undefined,
|
|
1455
|
+
parentRunId: run.provenance.parentRunId ?? undefined,
|
|
1456
|
+
tokens: (() => { const t = build.tokens; return t && (t.input || t.output || t.cacheRead || t.cacheWrite) ? t : undefined; })(),
|
|
1437
1457
|
// delivery.template: the named deliverable-template variant this run used. Default "standard"
|
|
1438
1458
|
// (today's render). Recorded here so the choice is observable + a live consumer of the profile field
|
|
1439
1459
|
// (not a dead knob); the registry currently holds one variant, ready to grow when a 2nd format ships.
|
|
1440
|
-
template
|
|
1460
|
+
template,
|
|
1441
1461
|
// T2 (H5): the derived display verdict is THE authority when the sidecar exists; the
|
|
1442
1462
|
// model-authored fm fields are the pre-A2 legacy fallback only.
|
|
1443
1463
|
// No rating at all in the state where the assessment was not completed, whatever a report's front matter says.
|
|
1444
1464
|
overall: ratingWord,
|
|
1445
1465
|
badge: ratingBadge, run: fm.run, date: dateOf(fm.run), auditFile,
|
|
1446
1466
|
// WHY THERE IS NO WORKBOOK, when the build threw. Absent when it built, so such a meta is unchanged.
|
|
1447
|
-
auditError: auditError ?? undefined,
|
|
1467
|
+
auditError: staff.auditError ?? undefined,
|
|
1448
1468
|
// THE PARTS PUBLISHING FOUND DEGRADED, with their raw causes, which no cell carries. Absent when none.
|
|
1449
|
-
degradedAtPublish: publishParts.length ? publishParts.map((d) => ({ part: d.part, name: d.name, cause: d.cause })) : undefined,
|
|
1450
|
-
//
|
|
1469
|
+
degradedAtPublish: staff.publishParts.length ? staff.publishParts.map((d) => ({ part: d.part, name: d.name, cause: d.cause })) : undefined,
|
|
1470
|
+
// THE one risk statement (band + stance in one sentence, composed once by the sidecar
|
|
1451
1471
|
// writer). Absent on legacy runs — regenIndex re-reads every historical meta.json, so consumers
|
|
1452
1472
|
// null-guard and old rows render byte-identically.
|
|
1453
1473
|
statement: verdictInfo?.statement ?? undefined,
|
|
@@ -1471,18 +1491,11 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1471
1491
|
clientGate: { released: clientGate.released, reasons: clientGate.reasons,
|
|
1472
1492
|
inputsAbsent: clientGate.inputsAbsent?.length ? clientGate.inputsAbsent : undefined, notClosing: clientGate.notClosing?.length ? clientGate.notClosing : undefined,
|
|
1473
1493
|
evaluationError: clientGate.evaluationError ?? undefined },
|
|
1474
|
-
//
|
|
1494
|
+
// Present ⇒ report-data.json is beside the report, in the shape the string names
|
|
1475
1495
|
// (`report-data/clearance-1`; a Knockout stamps `report-data/knockout-1`). undefined on a producer
|
|
1476
1496
|
// miss, so the meta never advertises a file that is not there.
|
|
1477
1497
|
reportSchema: reportSchema ?? undefined,
|
|
1478
|
-
}
|
|
1479
|
-
await refreshStaffPages({ regenSurfaces, poolRoot, skipRegen, runDir });
|
|
1480
|
-
// THE PORTAL ROUTE, not the pool's directory layout. This was
|
|
1481
|
-
// `<origin>/<runId>/report.html` — where the documents sit on disk, which is not an application route.
|
|
1482
|
-
// Composed rather than spelled here so the report link is built the same way the audit link always was.
|
|
1483
|
-
const url = reportRoute;
|
|
1484
|
-
return { runId, auditFile, counts, total, url, poolRunDir, auditError, findingsError, customerKey: customerKey || 'generic', clientGate,
|
|
1485
|
-
caption }; // the report's own conclusion, for the run record's short surfaces
|
|
1498
|
+
};
|
|
1486
1499
|
}
|
|
1487
1500
|
|
|
1488
1501
|
// Compose the notification email body — MARKDOWN (the mail tool renders markdown→HTML; raw HTML gets escaped).
|
|
@@ -1710,11 +1723,11 @@ const FONT = "font-family:Calibri,'Segoe UI',Arial,sans-serif";
|
|
|
1710
1723
|
// fill like yellow/red is unreadable as text). Order matters: VERY HIGH before HIGH.
|
|
1711
1724
|
const tier = (t, label) => ({ bg: t.bg, fg: t.fg, label, txt: t.txt });
|
|
1712
1725
|
export const RISK_TIERS = [
|
|
1713
|
-
[/VERY[\s-]?HIGH/, tier(EMAIL_TIER.veryHigh,
|
|
1714
|
-
[/HIGH/, tier(EMAIL_TIER.high,
|
|
1715
|
-
[/MEDIUM/, tier(EMAIL_TIER.medium,
|
|
1716
|
-
[/MANAGEABLE/, tier(EMAIL_TIER.manageable,
|
|
1717
|
-
[/LOW/, tier(EMAIL_TIER.low,
|
|
1726
|
+
[/VERY[\s-]?HIGH/, tier(EMAIL_TIER.veryHigh, EMAIL.tiers.veryHigh)],
|
|
1727
|
+
[/HIGH/, tier(EMAIL_TIER.high, EMAIL.tiers.high)],
|
|
1728
|
+
[/MEDIUM/, tier(EMAIL_TIER.medium, EMAIL.tiers.medium)],
|
|
1729
|
+
[/MANAGEABLE/, tier(EMAIL_TIER.manageable, EMAIL.tiers.manageable)],
|
|
1730
|
+
[/LOW/, tier(EMAIL_TIER.low, EMAIL.tiers.low)],
|
|
1718
1731
|
];
|
|
1719
1732
|
// doc 50 — the run's band LADDER (from opts.bands / meta.framework.bands): per-run vocabulary with the
|
|
1720
1733
|
// same template palette keyed by TONE, so "Moderate" (house) and "Medium" (a customer ladder) both colour correctly
|
|
@@ -1791,23 +1804,70 @@ function mdBlock(block) {
|
|
|
1791
1804
|
/**
|
|
1792
1805
|
* THE EMAIL'S OPTIONS, read from the run's frozen files: the product's name off the frozen search policy, the verdict
|
|
1793
1806
|
* record's sign-off word, conditions, rating and statement as the record wrote them, and the band ladder of the frozen
|
|
1794
|
-
* framework. The
|
|
1795
|
-
*
|
|
1796
|
-
*
|
|
1807
|
+
* framework. The cover email reads them for a run published before the report document existed (coverNoteInputs). The
|
|
1808
|
+
* statement is the record's own, which the run's status keeps; the report's surfaces print the client form. Never throws: a
|
|
1809
|
+
* file it cannot read leaves its options out.
|
|
1797
1810
|
*/
|
|
1798
1811
|
export function coverNoteOptions(runDir) {
|
|
1799
1812
|
const frozen = (key, parse = JSON.parse) => { try { return parse(readFileSync(paths(runDir)[key], 'utf8')); } catch { return null; } };
|
|
1800
1813
|
const opts = { productName: reportIdentityFor(frozen('searchPolicy')).identity ?? undefined };
|
|
1814
|
+
// The run's own record that its assessment did not complete decides, as it does for the page: then no verdict saved
|
|
1815
|
+
// by that assessment supplies a rating, and the rating stays unknown.
|
|
1816
|
+
if (readStore(runDir, '_driver/not-completed/assessment.json').state !== 'absent') return Object.assign(opts, frameworkBands(frozen), { assessmentNotCompleted: true, rating: null });
|
|
1801
1817
|
const v = frozen('verdict');
|
|
1802
1818
|
if (v) Object.assign(opts, { verdict: v.verdict, conditions: clientConditions(v), tier: v.tier, statement: v.statement ?? null });
|
|
1819
|
+
return Object.assign(opts, frameworkBands(frozen));
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
/** The run's band ladder for the email, from its frozen framework; nothing where it has none. */
|
|
1823
|
+
function frameworkBands(frozen) {
|
|
1803
1824
|
const framework = frozen('framework', parseFrameworkManifest);
|
|
1825
|
+
return framework ? { bands: framework.bands.map((b) => ({ label: b.label, tone: b.tone })) } : {};
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
export function composeEmailHtml(reportMdPath, url, auditFile, names = [], delivery = NEUTRAL_DELIVERY, opts = {}) {
|
|
1829
|
+
return composeEmailHtmlFrom(parseReport(reportMdPath), url, auditFile, names, delivery, opts);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
/**
|
|
1833
|
+
* The cover email for a run, as the delivery sends it, from what coverNoteInputs read. `productName` is the name the
|
|
1834
|
+
* subject takes, which the caller resolves.
|
|
1835
|
+
*/
|
|
1836
|
+
export function composeCoverNote({ report, opts }, { url, auditFile, names = [], delivery = NEUTRAL_DELIVERY, productName } = {}) {
|
|
1837
|
+
return composeEmailHtmlFrom(report, url, auditFile, names, delivery, { ...opts, productName });
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* What the cover email reads: the report's front matter and sections, and its options. From the run's report document
|
|
1842
|
+
* where it has one, and from the run's own files where it has none (a run published before the document existed).
|
|
1843
|
+
*/
|
|
1844
|
+
export function coverNoteInputs(runDir) {
|
|
1845
|
+
let document = null;
|
|
1846
|
+
try { document = readJson(paths(runDir).reportDocument); } catch { /* a run published before the document */ }
|
|
1847
|
+
// A document written before it carried the verdict record as written is read from the files too.
|
|
1848
|
+
if (!document || !('written' in (document.verdict ?? {}))) return { report: parseReport(join(runDir, 'report.md')), opts: coverNoteOptions(runDir) };
|
|
1849
|
+
return { report: { fm: document.prose.frontMatter, secs: document.prose.sections }, opts: coverNoteOptionsOf(document) };
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* coverNoteOptions, read from the document: the verdict record and the rating as the page reads them, and the run's band
|
|
1854
|
+
* ladder. An older record gains its derived rating, as on the page, and a run whose assessment was not completed has no
|
|
1855
|
+
* record, so a verdict saved from that assessment raises neither a rating nor the close-box, and leaves the run's status no
|
|
1856
|
+
* statement. Where there is a record, the statement is the record's as written, which the run's status keeps.
|
|
1857
|
+
*/
|
|
1858
|
+
function coverNoteOptionsOf(document) {
|
|
1859
|
+
const opts = { productName: document.run.product.name ?? undefined };
|
|
1860
|
+
if (document.verdict.assessmentNotCompleted === true) opts.assessmentNotCompleted = true;
|
|
1861
|
+
const v = document.verdict.record;
|
|
1862
|
+
if (v) Object.assign(opts, { verdict: v.verdict, conditions: clientConditions(v), tier: v.tier, statement: document.verdict.written?.statement ?? null });
|
|
1863
|
+
opts.rating = clearanceRatingOf(document).word ?? null;
|
|
1864
|
+
const framework = document.framework.manifest;
|
|
1804
1865
|
if (framework) opts.bands = framework.bands.map((b) => ({ label: b.label, tone: b.tone }));
|
|
1805
1866
|
return opts;
|
|
1806
1867
|
}
|
|
1807
1868
|
|
|
1808
|
-
|
|
1869
|
+
function composeEmailHtmlFrom({ fm, secs }, url, auditFile, names = [], delivery = NEUTRAL_DELIVERY, opts = {}) {
|
|
1809
1870
|
EMAIL_BANDS = Array.isArray(opts?.bands) && opts.bands.length ? opts.bands : null; // doc 50 — per-run vocabulary
|
|
1810
|
-
const { fm, secs } = parseReport(reportMdPath);
|
|
1811
1871
|
const auditUrl = auditUrlFor(url, auditFile);
|
|
1812
1872
|
|
|
1813
1873
|
// 1) internal review headline — short: the bottom line, and nothing of the reviewer's own notes.
|
|
@@ -1839,7 +1899,7 @@ export function composeEmailHtml(reportMdPath, url, auditFile, names = [], deliv
|
|
|
1839
1899
|
const flagBanner =
|
|
1840
1900
|
(fm.envelope_note ? `<p style="margin:0 0 6px"><b>${EMAIL.scopeLabel}</b> ${EMAIL.scopeOpen}</p>` : '');
|
|
1841
1901
|
|
|
1842
|
-
// ONE report
|
|
1902
|
+
// ONE report: the "Not client-ready — for your review only" block is deleted with
|
|
1843
1903
|
// the two-bit delivery it narrated. The cover note is a cover note — verdict, one-line summary, link —
|
|
1844
1904
|
// plus, since A10 (below), the surviving machine-check failures in the projection's own words. The
|
|
1845
1905
|
// "machine-QC lives on the workbook, never the email" rule that used to stand here was written when a
|
|
@@ -1894,17 +1954,26 @@ export function composeEmailHtml(reportMdPath, url, auditFile, names = [], deliv
|
|
|
1894
1954
|
// A BLOCKING RESULT KEEPS THE REPORT'S ITEMS TOO (ruled 2026-10-27). The box showed only on a CONDITIONAL result, so
|
|
1895
1955
|
// a blocking one lost the client's own actions the report lists. It shows them under the report's heading in the
|
|
1896
1956
|
// report's words, and only where the report names any: no empty box, no fallback line.
|
|
1897
|
-
|
|
1957
|
+
// AN ASSESSMENT THAT DID NOT COMPLETE HAS NO RESULT TO CONDITION (2026-11-19). Its box lists what the report lists under
|
|
1958
|
+
// "Before you can rely on this result", under that heading, in the report's order, and is left out where the report
|
|
1959
|
+
// names nothing there: a heading saying only the client can close these would claim more than the run knows.
|
|
1960
|
+
const notCompleted = opts?.assessmentNotCompleted === true;
|
|
1961
|
+
const emailConditions = emailConditionsOf(secs['Actions'], opts?.verdict, { assessmentNotCompleted: notCompleted });
|
|
1898
1962
|
// THE REPORT IS THE MASTER (ruled 2026-09-22). The banner used to print a second summary composed
|
|
1899
1963
|
// beside the report — "On hold — …" on a run the report called conditional, although nothing is ever
|
|
1900
1964
|
// held — and before that the delivery gate's word. It now quotes the report: the rating, then the
|
|
1901
1965
|
// report's own conclusion (below), and where the report names what only the client can close, those
|
|
1902
1966
|
// items under the report's own heading. Nothing here composes a sentence of its own.
|
|
1903
|
-
const closeBox = (items) => `<p style="margin:0 0 8px;padding:8px 10px;background:${EC.closeBoxFill};border:1px solid ${EC.closeBoxLine};color:${EC.closeBoxText}"><b>${
|
|
1904
|
-
const verdictBound =
|
|
1905
|
-
?
|
|
1906
|
-
: opts?.verdict === '
|
|
1907
|
-
|
|
1967
|
+
const closeBox = (items, head = EMAIL.onlyYouCanClose) => `<p style="margin:0 0 8px;padding:8px 10px;background:${EC.closeBoxFill};border:1px solid ${EC.closeBoxLine};color:${EC.closeBoxText}"><b>${head}</b><br>${items.map((r) => `• ${cell(String(r))}`).join('<br>')}</p>`;
|
|
1968
|
+
const verdictBound = notCompleted
|
|
1969
|
+
? (emailConditions.length ? closeBox(emailConditions, EMAIL.beforeYouCanRely) : '')
|
|
1970
|
+
: opts?.verdict === 'CONDITIONAL'
|
|
1971
|
+
? closeBox(emailConditions.length ? emailConditions : [EMAIL.onlyYouCanCloseDefault])
|
|
1972
|
+
: opts?.verdict === 'BLOCKING' && emailConditions.length ? closeBox(emailConditions) : '';
|
|
1973
|
+
|
|
1974
|
+
// The rating as the page states it where the options carry it (from the report document); otherwise the record's, then
|
|
1975
|
+
// the front matter's, as a run published before the document reads.
|
|
1976
|
+
const rating = opts && 'rating' in opts ? opts.rating : (opts?.tier ?? fm.overall_label);
|
|
1908
1977
|
const reviewHeadline = `<div style="${FONT};font-size:11pt;color:${EC.headline};margin:0 0 14px">`
|
|
1909
1978
|
+ flagBanner
|
|
1910
1979
|
+ verdictBound
|
|
@@ -1912,8 +1981,8 @@ export function composeEmailHtml(reportMdPath, url, auditFile, names = [], deliv
|
|
|
1912
1981
|
// T2 (H5): the derived tier (verdict sidecar, passed by the driver) outranks the
|
|
1913
1982
|
// model-authored fm label — one authority on every surface. The rating leads, then the report's own
|
|
1914
1983
|
// conclusion verbatim (ruling 244); with no rating recorded, the conclusion stands alone.
|
|
1915
|
-
+ (
|
|
1916
|
-
? `<p style="margin:0 0 6px"><b>${EMAIL.overallRisk} ${esc(
|
|
1984
|
+
+ (rating
|
|
1985
|
+
? `<p style="margin:0 0 6px"><b>${EMAIL.overallRisk} ${esc(rating)}.</b> ${cell(fm.overall_caption || '')}</p>`
|
|
1917
1986
|
: (fm.overall_caption ? `<p style="margin:0 0 6px">${cell(fm.overall_caption)}</p>` : ''))
|
|
1918
1987
|
+ reportLink
|
|
1919
1988
|
+ (fm.handling_note ? `<p style="margin:0 0 8px;color:${EC.warning}"><b>${EMAIL.handlingNote}</b> ${cell(fm.handling_note)}</p>` : '')
|
|
@@ -1963,6 +2032,8 @@ export function composeEmailHtml(reportMdPath, url, auditFile, names = [], deliv
|
|
|
1963
2032
|
import { recordLinksFor } from './office-record-links.mjs';
|
|
1964
2033
|
import { reportDates, zurichStamp } from './report-dates.mjs'; // the dates a report prints, from its record
|
|
1965
2034
|
import { driverDir, paths, readJson } from "../run-record.mjs";
|
|
2035
|
+
import { logosForReport } from "../mark-logos.mjs"; // the saved logo of each cited registration, embedded in the report
|
|
2036
|
+
import { followUpKindsOf } from "../follow-up-twins.mjs"; // the search each deferred directive recorded
|
|
1966
2037
|
function officeLinksFor(findings, recordsByUri, runOrigins) {
|
|
1967
2038
|
const links = recordLinksFor(findings, recordsByUri, runOrigins);
|
|
1968
2039
|
if (links) console.log(`[record-links] ${links.summary}`);
|
|
@@ -2065,3 +2136,11 @@ export function withoutRepeatedRows(rows) {
|
|
|
2065
2136
|
return true;
|
|
2066
2137
|
});
|
|
2067
2138
|
}
|
|
2139
|
+
|
|
2140
|
+
// THE PAGE READS THE RUN'S REPORT DOCUMENT AS WRITTEN: the JSON the run keeps, parsed back, so the page can read nothing
|
|
2141
|
+
// the file does not hold. A document that could not be built leaves the page nothing to read, and the publish stops
|
|
2142
|
+
// there rather than print a page from another source.
|
|
2143
|
+
function pageDocument(doc) {
|
|
2144
|
+
if (!doc) throw new Error('[report-document] not built, so report.html has nothing to read');
|
|
2145
|
+
return JSON.parse(JSON.stringify(doc));
|
|
2146
|
+
}
|