clearotron 0.5.1 → 0.6.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/.env.example +7 -7
- package/INSTALL.md +10 -10
- package/QUICKSTART.md +6 -6
- package/README.md +2 -2
- package/THIRD-PARTY-NOTICES.md +4 -4
- package/bin/README.md +2 -2
- package/bin/clearotron.mjs +1 -1
- package/bin/connect.mjs +1 -1
- package/bin/disconnect.mjs +1 -1
- package/bin/example.mjs +2 -2
- package/bin/grant.mjs +1 -1
- package/bin/onboard.mjs +78 -23
- package/bin/start.mjs +49 -18
- package/bin/update.mjs +13 -3
- package/build-info.json +2 -2
- package/docs/DELIVERY.md +1 -1
- package/docs/PORTAL.md +1 -1
- package/docs/RELEASES.md +1 -1
- package/docs/architecture/02-architecture.md +10 -2
- package/docs/architecture/03-run-lifecycle.md +6 -2
- package/docs/architecture/04-configuration-reference.md +3 -3
- package/docs/architecture/05-config-governance.md +5 -4
- package/docs/architecture/08-development-guide.md +4 -4
- package/docs/architecture/09-security-and-data.md +1 -1
- package/{driver/skills/clearance-search/SKILL.md → docs/architecture/retired-manuals/clearance-search-spine.md} +17 -30
- package/{driver/skills/clearance-search/templates/email/generic.md → docs/architecture/retired-manuals/email-generic.md} +1 -1
- package/{driver/skills/clearance-search → docs/architecture/retired-manuals}/template-formatting.md +3 -4
- package/docs/configuration.md +1 -1
- package/docs/decisions/0002-no-dark-functionality.md +5 -0
- package/driver/CHANGELOG.md +60 -0
- package/driver/README.md +11 -1
- package/driver/accepted-order.mjs +13 -5
- package/driver/attempt-rows.mjs +64 -0
- package/driver/attributed-span.mjs +1 -1
- package/driver/authority-trees.mjs +1 -1
- package/driver/best-draft.mjs +3 -3
- package/driver/blind-frame-record.mjs +2 -2
- package/driver/cancel.mjs +3 -2
- package/driver/carry-through.mjs +2 -2
- package/driver/citation-census.json +3 -3
- package/driver/clearance-variants-record.mjs +4 -10
- package/driver/common-law-coverage-status.mjs +3 -3
- package/driver/common-law-receipts.mjs +2 -2
- package/driver/compare.mjs +1 -1
- package/driver/config-inventory.mjs +6 -79
- package/driver/consumption-ledger.mjs +2 -1
- package/driver/contract-dictation-registry.mjs +5 -0
- package/driver/contract-e3-backlog.mjs +45 -66
- package/driver/contract-e3-baseline.json +16 -16
- package/driver/contract-vocabulary.mjs +8 -6
- package/driver/corrections-feedforward.mjs +3 -1
- package/driver/coverage-form-io.mjs +7 -8
- package/driver/coverage-tool.mjs +1 -1
- package/driver/declination-tool.mjs +2 -2
- package/driver/degraded-parts.mjs +9 -9
- package/driver/demo-container.mjs +5 -4
- package/driver/deploy-live-run-guard.mjs +19 -7
- package/driver/derived-state.mjs +2 -2
- package/driver/dev-portal.mjs +2 -1
- package/driver/dispatch-record.mjs +1 -1
- package/driver/disposition-tool.mjs +2 -1
- package/driver/doubt-closure-tool.mjs +2 -2
- package/driver/driver.config.mjs +35 -724
- package/driver/e2e-rounds.mjs +3 -4
- package/driver/engine/CONTRACT.md +3 -0
- package/driver/engine/README.md +2 -0
- package/driver/engine/anthropic-agent.mjs +8 -37
- package/driver/engine/auth.mjs +74 -0
- package/driver/engine/child-record.mjs +1 -1
- package/driver/engine/deny-authority-write.mjs +2 -2
- package/driver/engine/jx-turn.mjs +10 -2
- package/driver/engine/mcp/README.md +1 -1
- package/driver/engine/mcp/band-server.mjs +6 -6
- package/driver/engine/mcp/codex-config.mjs +1 -1
- package/driver/engine/mcp/declination-server.mjs +2 -3
- package/driver/engine/mcp/dispositions-server.mjs +3 -3
- package/driver/engine/mcp/gather-config.mjs +24 -19
- package/driver/engine/mcp/grid-provenance.mjs +1 -1
- package/driver/engine/mcp/held-answers.mjs +5 -5
- package/driver/engine/mcp/perplexity-server.mjs +16 -7
- package/driver/engine/mcp/recording-server.mjs +7 -6
- package/driver/engine/mcp/register-server.mjs +29 -0
- package/driver/engine/mcp/stdio-server.mjs +5 -5
- package/driver/engine/mcp/supplemental.mjs +9 -9
- package/driver/engine/openai-agent.mjs +5 -2
- package/driver/engine/registry.mjs +103 -0
- package/driver/engine/run-choices.mjs +162 -0
- package/driver/engine/stamps.mjs +35 -0
- package/driver/enqueue-schema.mjs +4 -4
- package/driver/envelope-settle.mjs +3 -2
- package/driver/feedback-issues.mjs +1 -1
- package/driver/feedback-mint.mjs +3 -2
- package/driver/feedback-store.mjs +3 -2
- package/driver/findings-model.mjs +1 -1
- package/driver/flag-snapshot.mjs +5 -4
- package/driver/floor-duty.mjs +3 -3
- package/driver/foreign-record-links.mjs +1 -1
- package/driver/frame-diff-record.mjs +2 -8
- package/driver/framework.mjs +1 -1
- package/driver/gate-metrics.mjs +10 -11
- package/driver/gateway.mjs +220 -839
- package/driver/goods-evidence.mjs +10 -6
- package/driver/jx-lanes.mjs +3 -3
- package/driver/jx-units.mjs +31 -37
- package/driver/jx.mjs +44 -59
- package/driver/knockout-assess-record.mjs +3 -3
- package/driver/knockout-caveats.mjs +21 -0
- package/driver/knockout-correction-record.mjs +58 -28
- package/driver/knockout-frame-record.mjs +2 -2
- package/driver/knockout-register-read.mjs +38 -21
- package/driver/knockout-register-record.mjs +5 -6
- package/driver/knockout-review-record.mjs +12 -11
- package/driver/ladder/model-gauge.mjs +88 -0
- package/driver/ladder/next-rung.mjs +296 -0
- package/driver/ladder/rescue.mjs +146 -0
- package/driver/ladder/stage-tools.mjs +57 -0
- package/driver/ladder/turn-failure.mjs +166 -0
- package/driver/log.mjs +2 -2
- package/driver/matter-frame-record.mjs +4 -4
- package/driver/methodology-witness.mjs +2 -2
- package/driver/narrative-refutation-record.mjs +145 -42
- package/driver/one-build-per-run.mjs +62 -0
- package/driver/outbox-backoff.mjs +4 -4
- package/driver/owner-screen.mjs +0 -10
- package/driver/owner-use-check.mjs +2 -28
- package/driver/package.json +1 -1
- package/driver/partial-payload-baseline.json +1 -1
- package/driver/parts-not-completed.mjs +1 -1
- package/driver/pipeline-knockout.mjs +1015 -1001
- package/driver/pipeline.mjs +511 -9265
- package/driver/placement-decisions.mjs +2 -2
- package/driver/placement-form-io.mjs +7 -9
- package/driver/placement-union.mjs +0 -6
- package/driver/plan-stability.mjs +7 -10
- package/driver/portal-acks.mjs +3 -2
- package/driver/portal-confirmation.mjs +48 -0
- package/driver/portal-families.mjs +3 -2
- package/driver/portal-local-auth.mjs +1 -2
- package/driver/portal-routes/README.md +24 -0
- package/driver/portal-routes/admin.mjs +425 -0
- package/driver/portal-routes/compose.mjs +66 -0
- package/driver/portal-routes/config.mjs +118 -0
- package/driver/portal-routes/connect.mjs +283 -0
- package/driver/portal-routes/feedback.mjs +178 -0
- package/driver/portal-routes/me.mjs +165 -0
- package/driver/portal-routes/queue.mjs +64 -0
- package/driver/portal-routes/report.mjs +106 -0
- package/driver/portal-routes/run.mjs +508 -0
- package/driver/portal-routes/runs.mjs +127 -0
- package/driver/portal-routes/usage.mjs +82 -0
- package/driver/portal-runs.mjs +588 -0
- package/driver/portal-service.mjs +78 -2592
- package/driver/portal-static.mjs +3 -1
- package/driver/predelivery-lint.mjs +92 -9
- package/driver/production-pool-guard.mjs +1 -1
- package/driver/profiles.mjs +5 -4
- package/driver/progress.mjs +29 -24
- package/driver/publish/README.md +10 -5
- package/driver/publish/archive-tags.mjs +3 -2
- package/driver/publish/demo-marking.mjs +2 -2
- package/driver/publish/index.mjs +215 -140
- package/driver/publish/knockout.mjs +153 -107
- package/driver/publish/office-record-links.mjs +22 -0
- package/driver/publish/parse.mjs +20 -5
- package/driver/publish/pool-admin.mjs +9 -3
- package/driver/publish/render.mjs +11 -3
- package/driver/publish/report-dates.mjs +3 -4
- package/driver/publish/report-registry.mjs +7 -10
- package/driver/publish/seed-pool.mjs +3 -2
- package/driver/publish/shell.mjs +106 -0
- package/driver/publish/templates/report.css +3 -1
- package/driver/queue-order.mjs +4 -3
- package/driver/record-carry.mjs +0 -9
- package/driver/record-discard.mjs +1 -4
- package/driver/record-fold.mjs +3 -3
- package/driver/record-goods.mjs +5 -5
- package/driver/reference-score.mjs +2 -3
- package/driver/register-capabilities.mjs +0 -6
- package/driver/register-count.mjs +3 -2
- package/driver/register-digest-record.mjs +7 -7
- package/driver/register-fixture-marker.mjs +3 -3
- package/driver/register-plan.mjs +2 -2
- package/driver/register-records.mjs +2 -2
- package/driver/register-taint.mjs +3 -3
- package/driver/register-unit-record.mjs +48 -9
- package/driver/register-unreachable.mjs +4 -3
- package/driver/registry-fidelity.mjs +79 -34
- package/driver/repair-composers.mjs +14 -9
- package/driver/repair-digest.mjs +4 -6
- package/driver/repair-scope.mjs +3 -3
- package/driver/repair-targets.mjs +24 -9
- package/driver/repairs.mjs +44 -58
- package/driver/replay-archive.mjs +7 -7
- package/driver/report-card-record.mjs +3 -3
- package/driver/report-overview-record.mjs +4 -4
- package/driver/research-answers.mjs +38 -6
- package/driver/research-checks.mjs +4 -4
- package/driver/result-noun-fields.mjs +28 -11
- package/driver/review-addresses.mjs +163 -0
- package/driver/rule-shape.mjs +1 -1
- package/driver/run-delivered.mjs +340 -0
- package/driver/run-economics.mjs +8 -26
- package/driver/run-failed.mjs +545 -0
- package/driver/run-integrity.mjs +1 -1
- package/driver/run-outcome.mjs +314 -0
- package/driver/run-park.mjs +23 -0
- package/driver/run-quote.mjs +32 -0
- package/driver/run-record.mjs +352 -0
- package/driver/run-requirements.mjs +22 -0
- package/driver/run-shell.mjs +55 -0
- package/driver/runner.mjs +71 -33
- package/driver/saved-register-pages.mjs +4 -4
- package/driver/score-redaction.mjs +2 -2
- package/driver/search-policy.mjs +12 -13
- package/driver/settle-stamp.mjs +4 -3
- package/driver/skeptic-record.mjs +2 -2
- package/driver/skeptic-search.mjs +1 -1
- package/driver/skills/README.md +7 -7
- package/driver/skills/blind-frame/SKILL.md +1 -2
- package/driver/skills/case-law-citation/SKILL.md +9 -37
- package/driver/skills/case-law-citation/sources/courtlistener.md +1 -3
- package/driver/skills/case-law-citation/sources/eurlex.md +8 -11
- package/driver/skills/case-law-citation/sources/legaldatahunter.md +1 -1
- package/driver/skills/clearance-common-law/SKILL.md +45 -111
- package/driver/skills/clearance-common-law/perplexity-prompts.md +7 -79
- package/driver/skills/clearance-register/SKILL.md +15 -33
- package/driver/skills/clearance-register/digest.md +31 -92
- package/driver/skills/clearance-register/providers/clarivate.md +2 -2
- package/driver/skills/clearance-register/providers/corsearch.md +5 -5
- package/driver/skills/clearance-register/providers/euipo.md +1 -2
- package/driver/skills/clearance-register/providers/free-tier.md +0 -19
- package/driver/skills/clearance-register/providers/signa.md +6 -25
- package/driver/skills/clearance-register/providers/uspto-local.md +0 -24
- package/driver/skills/clearance-register/register-recipes.md +8 -15
- package/driver/skills/clearance-register/status-rules.md +6 -24
- package/driver/skills/clearance-register/unit.md +11 -20
- package/driver/skills/clearance-search/delivery-contract.md +24 -120
- package/driver/skills/clearance-search/field-doctrine-pharma.md +1 -5
- package/driver/skills/clearance-search/firm-wide-reasoning.md +24 -43
- package/driver/skills/clearance-search/phase2-execution.md +29 -77
- package/driver/skills/clearance-search/report-prose.md +3 -4
- package/driver/skills/clearance-search/risk-framework-demo.md +1 -1
- package/driver/skills/clearance-search/risk-framework-triage.manifest.json +3 -3
- package/driver/skills/clearance-search/risk-framework-triage.md +7 -9
- package/driver/skills/clearance-search/risk-framework.manifest.json +1 -1
- package/driver/skills/clearance-search/risk-framework.md +1 -1
- package/driver/skills/clearance-search/synthesis-rules.md +30 -107
- package/driver/skills/clearance-search/worked-examples.md +5 -5
- package/driver/skills/clearance-variants/SKILL.md +46 -45
- package/driver/skills/clearance-variants/transliteration-scripts.md +4 -4
- package/driver/skills/frame-diff/SKILL.md +1 -1
- package/driver/skills/knockout-assess/SKILL.md +6 -14
- package/driver/skills/knockout-frame/SKILL.md +1 -1
- package/driver/skills/matter-frame/SKILL.md +7 -12
- package/driver/skills/matter-frame/watchlist-reference.md +1 -4
- package/driver/skills/narrative-refutation/SKILL.md +20 -30
- package/driver/skills/placement-inquiry/SKILL.md +8 -18
- package/driver/skills-store-provenance.mjs +1 -1
- package/driver/stage-context.mjs +32 -35
- package/driver/stage-freshness.mjs +127 -11
- package/driver/stages-knockout.mjs +49 -22
- package/driver/stages.mjs +88 -283
- package/driver/status-snapshot.mjs +2 -1
- package/driver/steps/correction-cycle.mjs +311 -0
- package/driver/steps/corrections.mjs +644 -0
- package/driver/steps/delivery.mjs +1287 -0
- package/driver/steps/frame-comparison.mjs +922 -0
- package/driver/steps/intake.mjs +84 -0
- package/driver/steps/open-run.mjs +419 -0
- package/driver/steps/overview-and-cards.mjs +899 -0
- package/driver/steps/placement-and-digest.mjs +23 -0
- package/driver/steps/register-sweep.mjs +1563 -0
- package/driver/steps/skeptic-and-follow-up.mjs +831 -0
- package/driver/steps/synthesis.mjs +261 -0
- package/driver/steps/verdict-gate.mjs +968 -0
- package/driver/suite-census.json +403 -91
- package/driver/surface-exit-verdict.mjs +0 -8
- package/driver/synthesis-record.mjs +72 -6
- package/driver/terminal-clamp.mjs +10 -0
- package/driver/tokens.mjs +8 -62
- package/driver/tool-calls.mjs +2 -2
- package/driver/unit-state-verdict.mjs +1 -1
- package/driver/usage-ledger.mjs +2 -1
- package/driver/verify-knockout.mjs +20 -35
- package/driver/verify.mjs +47 -36
- package/driver/web-grid.mjs +3 -4
- package/driver/whatif-memo-run.mjs +2 -2
- package/driver/whatif-queue.mjs +4 -3
- package/driver/withheld-families.mjs +14 -15
- package/driver/worker-heartbeat.mjs +3 -2
- package/driver/write-up-form.mjs +0 -3
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/http-server.mjs +1 -1
- package/mcp-server/lib/brief.mjs +22 -4
- package/mcp-server/lib/events.mjs +2 -2
- package/mcp-server/lib/evidence.mjs +3 -2
- package/mcp-server/lib/findings.mjs +2 -1
- package/mcp-server/lib/knockout.mjs +9 -10
- package/mcp-server/lib/ops.mjs +9 -9
- package/mcp-server/lib/runs.mjs +9 -10
- package/mcp-server/lib/trace.mjs +1 -1
- package/mcp-server/lib/whatif.mjs +2 -3
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +5 -5
- package/package.json +2 -1
- package/portal-ui/dist/assets/{index-fPqAU0sx.js → index-D5rkCjDc.js} +26 -14
- package/portal-ui/dist/index.html +1 -1
- package/portal-ui/package.json +3 -3
- package/providers/README.md +1 -1
- package/providers/_shared/answer-memory.mjs +4 -5
- package/providers/_shared/execute-plan.mjs +48 -1
- package/providers/_shared/records-from-search.mjs +46 -0
- package/providers/clarivate/README.md +2 -2
- package/providers/clarivate/src/adapter.js +147 -0
- package/providers/clarivate/src/core.js +1 -14
- package/{driver/engine/mcp/clarivate-server.mjs → providers/clarivate/src/mount.js} +5 -10
- package/providers/corsearch/README.md +3 -3
- package/providers/corsearch/src/adapter.js +80 -0
- package/providers/corsearch/src/core.js +14 -11
- package/{driver/engine/mcp/corsearch-server.mjs → providers/corsearch/src/mount.js} +5 -10
- package/providers/euipo/README.md +2 -2
- package/providers/euipo/src/adapter.js +85 -0
- package/providers/euipo/src/core.js +1 -1
- package/providers/euipo/src/euipo-client.js +1 -2
- package/{driver/engine/mcp/euipo-server.mjs → providers/euipo/src/mount.js} +5 -10
- package/providers/free-tier/README.md +2 -2
- package/providers/free-tier/src/adapter.js +127 -0
- package/{driver/engine/mcp/free-tier-server.mjs → providers/free-tier/src/mount.js} +5 -10
- package/providers/jx-subclass/coverage.mjs +1 -6
- package/providers/jx-subclass/score-truth.mjs +2 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/perplexity/src/core.js +2 -2
- package/providers/signa/README.md +2 -2
- package/providers/signa/src/adapter.js +157 -0
- package/providers/signa/src/capabilities.js +0 -3
- package/providers/signa/src/core.js +2 -2
- package/{driver/engine/mcp/signa-server.mjs → providers/signa/src/mount.js} +7 -12
- package/providers/signa/src/offices.generated.js +17 -15
- package/providers/uspto-local/README.md +1 -1
- package/providers/uspto-local/bin/verify-index.mjs +1 -1
- package/providers/uspto-local/src/adapter.js +75 -0
- package/{driver/engine/mcp/uspto-local-server.mjs → providers/uspto-local/src/mount.js} +5 -10
- package/scripts/band-shape-probe.mjs +2 -2
- package/scripts/citation-line-check.mjs +7 -7
- package/scripts/compare.mjs +1 -1
- package/scripts/dead-names.mjs +2 -2
- package/scripts/e2e-first-time.mjs +19 -7
- package/scripts/e2e.mjs +13 -13
- package/scripts/engine-probe.mjs +1 -1
- package/scripts/env-audit.mjs +7 -4
- package/scripts/env-classify.mjs +5 -1
- package/scripts/feedback-mint.mjs +1 -1
- package/scripts/freeze-example-run.mjs +7 -7
- package/scripts/mint-suite-census.mjs +2 -2
- package/scripts/nightly-notice.mjs +1 -1
- package/scripts/release-cut-decision.mjs +7 -2
- package/scripts/release-note-required.mjs +26 -9
- package/scripts/release-notes-lint.mjs +3 -2
- package/scripts/release-version-pr-checks.mjs +1 -1
- package/scripts/settings-render-check.mjs +23 -3
- package/scripts/test-run.mjs +5 -5
- package/scripts/travelling-predicates.mjs +1 -1
- package/scripts/undeclared-field-census.mjs +1 -1
- package/scripts/unexecuted-asserts.mjs +1 -1
- package/scripts/verify-publishable.mjs +1 -1
- package/shared/client-door.mjs +1 -1
- package/shared/connect-clients.mjs +1 -1
- package/shared/connector-signin-probe.mjs +1 -1
- package/shared/env-aliases.mjs +1 -1
- package/shared/invocation.mjs +14 -2
- package/shared/names-in-force.mjs +2 -0
- package/shared/register-selection.mjs +2 -2
- package/shared/store-in-repo.mjs +3 -3
- package/shared/summary-blocks.mjs +0 -3
- package/shared/trigger-lane.mjs +1 -1
- package/shared/vacuous-pass.mjs +2 -2
- package/shared/verb-shim.mjs +4 -2
- package/node_modules/exceljs/README.md +0 -3023
package/driver/publish/index.mjs
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
//
|
|
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
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync,
|
|
10
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, chmodSync } from 'node:fs';
|
|
11
|
+
import { finishPoolRun, grpRead, openPoolRun, refreshStaffPages } from './shell.mjs';
|
|
11
12
|
import { join, dirname } from 'node:path';
|
|
12
|
-
import {
|
|
13
|
-
import { parseReport, parseAudit, parseSections, parseBlocks, stripInternal, parseCaseLawProfiles, parseCaseLawPreamble, joinCaseLawProfiles } from './parse.mjs';
|
|
13
|
+
import { readFold } from '../record-fold.mjs'; import { parseReport, parseAudit, stripInternal, parseCaseLawProfiles, parseCaseLawPreamble, joinCaseLawProfiles } from './parse.mjs';
|
|
14
14
|
import { renderHtml } 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
|
-
import { parseFindingsJson, parseFindingsJsonLenient, deriveDisplayVerdict,
|
|
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
19
|
import { clearanceReportData } from './report-data.mjs';
|
|
@@ -23,7 +23,7 @@ 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
25
|
import { deliveryFlagLines, deliveredFailure } from '../predelivery-lint.mjs';
|
|
26
|
-
import { unrenderableConditions, clientStatement } from '../terminal-clamp.mjs'; // — the conditions that reach no client surface
|
|
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';
|
|
29
29
|
import { declaredRecordOrigins } from '../record-origins.mjs';
|
|
@@ -407,7 +407,7 @@ export function regenIndex(poolDir) {
|
|
|
407
407
|
// Normalize customerKey ONCE at the read boundary so every consumer (rows' data-client, byCustomer,
|
|
408
408
|
// clientList, siteNav) sees the same canonical key — historical metas predate the field and used to
|
|
409
409
|
// land as data-client="" rows no filter option could ever match.
|
|
410
|
-
.map(d => { const m =
|
|
410
|
+
.map(d => { const m = readJson(join(poolDir, d.name, 'meta.json')); m.customerKey = m.customerKey || 'generic'; return m; })
|
|
411
411
|
.sort(runOrder);
|
|
412
412
|
|
|
413
413
|
// Staff all-runs index — every run, links report.html + audit (employees keep full access).
|
|
@@ -497,7 +497,6 @@ export function regenIndex(poolDir) {
|
|
|
497
497
|
}
|
|
498
498
|
|
|
499
499
|
// Make a just-written path group-readable (Caddy serves via the caddy group; the pool dir is set-gid).
|
|
500
|
-
const grpRead = (p, mode) => { try { chmodSync(p, mode); } catch { /* best-effort */ } };
|
|
501
500
|
|
|
502
501
|
// D — the shared chrome stylesheet: the nav + toggle + floating-fab CSS written ONCE to <pool>/assets/chrome.css
|
|
503
502
|
// so the INTERNAL report.html can <link> it (chromeHref) instead of inlining. A cosmetic nav/theme tweak then
|
|
@@ -636,20 +635,14 @@ export function normalizeRecordLinks(findings, origins) {
|
|
|
636
635
|
}
|
|
637
636
|
|
|
638
637
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* @param {string} a.poolRoot - config.poolRoot (no default since; the deployment's CLEAROTRON_REPORTS_DIR)
|
|
646
|
-
* @param {string} [a.poolUrl] - config.poolUrl (https://trademark.example.com) for the returned link
|
|
647
|
-
* @returns {Promise<{runId,auditFile,counts,total,url,poolRunDir}>}
|
|
638
|
+
* THE REPORT DOCUMENT FOR A CLEARANCE: every fact the run's surfaces print, read from the run once.
|
|
639
|
+
*
|
|
640
|
+
* It is read before anything is written to the pool, and each surface prints from it: the pool's `report.md`, the
|
|
641
|
+
* workbook, the page, the data file and `meta.json`. Where two surfaces state one fact two ways today, each way is its
|
|
642
|
+
* own field, so every surface prints what it printed before; which way is right is not this function's to decide. It
|
|
643
|
+
* writes nothing to the pool. It does append to the run's own log what the read found dropped or missing, as before.
|
|
648
644
|
*/
|
|
649
|
-
|
|
650
|
-
// ONE regen after the whole loop instead of N redundant ones (per-run publish leaves it false, as before).
|
|
651
|
-
// (skipClient is retired with report.client.html — one report, spec 2026-07-30 §5.)
|
|
652
|
-
export async function publishReport({ runId, codename, reportMd, auditMd, findingsJson, poolRoot, poolUrl, customerKey, delivery, runDir, skipRegen = false }) {
|
|
645
|
+
export async function readClearanceDocument({ runId, reportMd, auditMd, findingsJson, poolRoot, poolUrl, customerKey, delivery, runDir }) {
|
|
653
646
|
const parsed = parseReport(reportMd);
|
|
654
647
|
const { fm } = parsed;
|
|
655
648
|
const deliv = delivery || NEUTRAL_DELIVERY;
|
|
@@ -667,16 +660,6 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
667
660
|
const dates = reportDates({ runDir: runDir ?? dirname(reportMd), poolRunDir: join(poolRoot, runId) });
|
|
668
661
|
const issued = zurichStamp(dates.issuedAt, { zone: true });
|
|
669
662
|
const asOf = new Date().toISOString(); // C2 — publish-time clock for the priority-window flag (render stays pure)
|
|
670
|
-
const poolRunDir = join(poolRoot, runId);
|
|
671
|
-
mkdirSync(poolRunDir, { recursive: true, mode: RUN_DIR_MODE }); // owner and group only; mkdir keeps the pool root's set-GID
|
|
672
|
-
// The run dir inherits the web-server group + the set-GID bit AUTOMATICALLY from the set-GID pool root
|
|
673
|
-
// (mode 2750, web-server group) — so files written inside take that group and the web server (Caddy in
|
|
674
|
-
// the reference deployment, mode 0640) can read them. Do NOT chmod this dir: the service account is not
|
|
675
|
-
// a member of the web-server group, and POSIX silently strips S_ISGID when a non-member sets it, leaving
|
|
676
|
-
// the dir 0750 → new files fall back to the service account's primary group → every report 403s. (An explicit
|
|
677
|
-
// `grpRead(poolRunDir, 0o2750)` here, added 2026-06-02, WAS that 403 bug; removed 2026-06-08.)
|
|
678
|
-
const writeRO = (name, data) => { const p = join(poolRunDir, name); writeFileSync(p, data); grpRead(p, 0o640); };
|
|
679
|
-
const copyRO = (src, name) => { const p = join(poolRunDir, name); copyFileSync(src, p); grpRead(p, 0o640); };
|
|
680
663
|
|
|
681
664
|
// T6 (H7): the POOL copy of report.md is written through the stripInternal choke point —
|
|
682
665
|
// markers consumed, internal tails labelled "[internal]" — so no raw ::p:: token ever reaches a
|
|
@@ -698,7 +681,6 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
698
681
|
// cannot be written before the question is asked.
|
|
699
682
|
const demoData = resolveDemoData({ runDir, customerKey });
|
|
700
683
|
const demoMd = demoBannerMd(demoData);
|
|
701
|
-
writeRO('report.md', (demoMd ? `${demoMd}\n` : '') + stripInternal(readFileSync(reportMd, 'utf8'), { client: false }));
|
|
702
684
|
|
|
703
685
|
// The per-finding machine contract drives the data-driven report + Excel. BEST-EFFORT — a bad or
|
|
704
686
|
// absent findings.json never blocks the report (the render degrades to a structured-light report); the
|
|
@@ -726,6 +708,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
726
708
|
: readStore(dirname(reportMd), 'findings.json',
|
|
727
709
|
{ path: (findingsJson && existsSync(findingsJson)) ? findingsJson : null });
|
|
728
710
|
const fjPath = fj.path;
|
|
711
|
+
let findingsKept = null; // the findings.json the pool keeps beside the report, when it was read
|
|
729
712
|
if (fj.state === 'absent') {
|
|
730
713
|
inputsAbsent.push('findings.json');
|
|
731
714
|
} else if (fj.raw == null) {
|
|
@@ -735,7 +718,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
735
718
|
findingsError = fj.error;
|
|
736
719
|
} else {
|
|
737
720
|
const raw = fj.raw;
|
|
738
|
-
try { const v = parseFindingsJson(raw); findings = v.findings; coverage = v.coverage; contextNotes = v.contextNotes || []; coverageJudgment = v.coverageJudgment || null; markAssessment = v.markAssessment || null; actionsRegister = v.actions || null; askAnswers = v.askAnswers || null; correctionsDoc = v.corrections || null; fourAnswers = v.fourAnswers || null; findingsSchemaVersion = v.schemaVersion ?? null;
|
|
721
|
+
try { const v = parseFindingsJson(raw); findings = v.findings; coverage = v.coverage; contextNotes = v.contextNotes || []; coverageJudgment = v.coverageJudgment || null; markAssessment = v.markAssessment || null; actionsRegister = v.actions || null; askAnswers = v.askAnswers || null; correctionsDoc = v.corrections || null; fourAnswers = v.fourAnswers || null; findingsSchemaVersion = v.schemaVersion ?? null; findingsKept = fjPath; }
|
|
739
722
|
catch (e) {
|
|
740
723
|
// A3 — strict parse failed: fall back to the lenient parse so ONE malformed finding degrades to "the rest
|
|
741
724
|
// delivers + a loud banner + client export blocked" instead of dropping ALL structured findings. A top-level
|
|
@@ -747,7 +730,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
747
730
|
// — deliberately NOT set on the quarantine path. This document already failed the strict
|
|
748
731
|
// contract; grouping its negatives by grounds the parser never verified would dress a
|
|
749
732
|
// half-validated record as a fully-reasoned one.
|
|
750
|
-
|
|
733
|
+
findingsKept = fjPath; // keep the ORIGINAL findings.json (with the bad finding) for forensics
|
|
751
734
|
} else { findingsError = e.message; }
|
|
752
735
|
} catch { findingsError = e.message; }
|
|
753
736
|
}
|
|
@@ -761,6 +744,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
761
744
|
? rows.filter((r) => r && typeof r.area === 'string' && r.area.trim() && COVERAGE_AREA_STATES.includes(r.state))
|
|
762
745
|
: [];
|
|
763
746
|
}
|
|
747
|
+
coverage = withoutRepeatedRows(coverage); // one recorded row, repeated, prints once (see withoutRepeatedRows)
|
|
764
748
|
// PR-9 (E9) — the STRING PROJECTION for coverage_judgment stays. mark_assessment is NO LONGER
|
|
765
749
|
// projected on the RENDER path (spec 2026-07-30 §3): render.mjs takes the structured object and shows
|
|
766
750
|
// the one-sentence `read` with the typed rows collapsed. projectAssessmentField/projectMarkAssessment
|
|
@@ -779,7 +763,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
779
763
|
// the currently-configured one (a re-published archive keeps its own register). Legacy runs: null ⇒
|
|
780
764
|
// render keeps the resolved_link inference and prints no receipt lines (byte-identical output).
|
|
781
765
|
let fetchReceipts = null;
|
|
782
|
-
try { const rj =
|
|
766
|
+
try { const rj = readJson(paths(runDir).receipts); if (Array.isArray(rj?.receipts) && rj.receipts.length) fetchReceipts = rj.receipts; } catch { /* legacy run */ }
|
|
783
767
|
const runProviderConf = fetchReceipts ? PROVIDERS[String(fetchReceipts[0]?.provider ?? '').toLowerCase()] : null;
|
|
784
768
|
const recordOrigin = runProviderConf?.hasPublicRecordUrl ? (runProviderConf.publicRecordOrigin ?? null) : null;
|
|
785
769
|
const providerLabel = runProviderConf?.label ?? null;
|
|
@@ -805,12 +789,12 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
805
789
|
// WP-receipts W3/W4 — the senior-right sidecar: the render code-adds the plain-English open item on
|
|
806
790
|
// any verdict-driving card whose senior right went unverified. Absent on legacy runs → no lines.
|
|
807
791
|
let seniorRights = null;
|
|
808
|
-
if (!assessmentNotCompleted) try { const sr =
|
|
792
|
+
if (!assessmentNotCompleted) try { const sr = readJson(paths(runDir).seniorRights); if (Array.isArray(sr?.rows)) seniorRights = sr.rows; } catch { /* legacy run */ }
|
|
809
793
|
// D1 — the code-carried verdict + clamp reasons/kinds (A2 sidecar): the report bound line
|
|
810
794
|
// distinguishes a machinery/coverage-clamped CONDITIONAL from a genuine legal read (which lives in
|
|
811
795
|
// the narrative, never in a status line). Best-effort; legacy runs have no sidecar.
|
|
812
796
|
let verdictInfo = null;
|
|
813
|
-
if (!assessmentNotCompleted) try { verdictInfo =
|
|
797
|
+
if (!assessmentNotCompleted) try { verdictInfo = readJson(paths(runDir).verdict); } catch { /* legacy */ }
|
|
814
798
|
// Every surface below reads the statement from here, so its count of further conditions is made true here, to
|
|
815
799
|
// the list the client reads (terminal-clamp.mjs clientStatement). The stored record is not touched.
|
|
816
800
|
if (typeof verdictInfo?.statement === 'string') verdictInfo = { ...verdictInfo, statement: clientStatement(verdictInfo) };
|
|
@@ -910,7 +894,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
910
894
|
// doc 50 — the run's FROZEN framework manifest (band vocabulary). Present on band-doctrine runs;
|
|
911
895
|
// absent on every archived run (they render byte-identically on the legacy paths).
|
|
912
896
|
let framework = null, frameworkMethod = null; // + the frozen method, where the framework states one (framework-method.mjs): the card and workbook show its inputs
|
|
913
|
-
try { framework = parseFrameworkManifest(readFileSync(
|
|
897
|
+
try { framework = parseFrameworkManifest(readFileSync(paths(runDir).framework, 'utf8')); frameworkMethod = readFrozenMethod(driverDir(runDir, FROZEN_METHOD_FILE), framework).method ?? null; } catch { /* legacy run */ }
|
|
914
898
|
// T2 (H5): a pre-49 sidecar ({verdict,reasons,kinds} — copper-spire's shape) gains the derived
|
|
915
899
|
// display fields HERE, so a re-published archived run joins the same single authority as a fresh one.
|
|
916
900
|
// No sidecar at all (pre-A2 runs) ⇒ legacy fm rendering, byte-stable.
|
|
@@ -947,7 +931,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
947
931
|
// cannot say — an archived or legacy run — and it must not be confused with a plan that named nothing.
|
|
948
932
|
let planTerritories = null;
|
|
949
933
|
try {
|
|
950
|
-
const plan =
|
|
934
|
+
const plan = readJson(paths(runDir ?? dirname(reportMd)).registerPlan);
|
|
951
935
|
if (plan?.scope_basis === 'worldwide') scopeBasis = 'worldwide';
|
|
952
936
|
searchedJurisdictions = [...new Set((plan?.entries ?? []).flatMap((e) => Array.isArray(e.regions) ? e.regions : []))];
|
|
953
937
|
if (!searchedJurisdictions.length && Array.isArray(plan?.regions)) searchedJurisdictions = [...new Set(plan.regions)];
|
|
@@ -957,7 +941,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
957
941
|
} catch { /* no plan sidecar — try the instructed scope */ }
|
|
958
942
|
if (!searchedJurisdictions.length) {
|
|
959
943
|
try {
|
|
960
|
-
const scope =
|
|
944
|
+
const scope = readJson(paths(runDir ?? dirname(reportMd)).instructedScope);
|
|
961
945
|
if (Array.isArray(scope?.jurisdictions)) searchedJurisdictions = scope.jurisdictions;
|
|
962
946
|
else if (typeof scope?.jurisdictions === 'string') searchedJurisdictions = scope.jurisdictions.split(/[,·;\s]+/).filter(Boolean);
|
|
963
947
|
} catch { /* legacy run — render falls back */ }
|
|
@@ -979,7 +963,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
979
963
|
const clPath = join(dirname(reportMd), 'case-law-findings.md');
|
|
980
964
|
if (existsSync(clPath)) {
|
|
981
965
|
const clMd = readFileSync(clPath, 'utf8');
|
|
982
|
-
caseLawByOrdinal = joinCaseLawProfiles(parseCaseLawProfiles(clMd), findings);
|
|
966
|
+
caseLawByOrdinal = joinCaseLawProfiles(parseCaseLawProfiles(clMd), findings, readFold(runDir ?? dirname(reportMd))?.map?.modelToFolded ?? null);
|
|
983
967
|
caseLawNotice = parseCaseLawPreamble(clMd); // session-wide outage notice — rendered once in §04
|
|
984
968
|
}
|
|
985
969
|
} catch { /* no case-law layer this run */ }
|
|
@@ -988,8 +972,8 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
988
972
|
// extension point. Presentation-only — a provider-recorded fact beside the meter, never a restamp.
|
|
989
973
|
let enforcerSignals = [];
|
|
990
974
|
try {
|
|
991
|
-
const esPath =
|
|
992
|
-
if (existsSync(esPath)) { const es =
|
|
975
|
+
const esPath = paths(runDir ?? dirname(reportMd)).enforcerSignals;
|
|
976
|
+
if (existsSync(esPath)) { const es = readJson(esPath); if (Array.isArray(es)) enforcerSignals = es; }
|
|
993
977
|
} catch { /* absent — no telemetry lines */ }
|
|
994
978
|
const officeLinks = officeLinksFor(findings, recordsByUri, runOrigins); bindFindingsToRecords(findings, recordsByUri);
|
|
995
979
|
// 404-card caveat (2026-07-22): the V4-2 closure pass persisted every cited record its targeted
|
|
@@ -999,7 +983,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
999
983
|
// (archived/legacy runs) means no stamp, byte-identical legacy render.
|
|
1000
984
|
let recordFetchFailures = null;
|
|
1001
985
|
try {
|
|
1002
|
-
const sink =
|
|
986
|
+
const sink = readJson(paths(dirname(reportMd)).predeliveryLint);
|
|
1003
987
|
if (Array.isArray(sink?.artifactSet?.recordFetchFailures)) recordFetchFailures = sink.artifactSet.recordFetchFailures;
|
|
1004
988
|
} catch { /* legacy run — no failure list */ }
|
|
1005
989
|
// A4 — derive per-meter evidence status by machine join (verified needs a receipt; a
|
|
@@ -1047,7 +1031,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1047
1031
|
evidenceDemotions: evidenceFlags.map(String),
|
|
1048
1032
|
findingsStale,
|
|
1049
1033
|
escalationFailed: Array.isArray(escSink?.failed) ? escSink.failed : [],
|
|
1050
|
-
machineLedgerNote: (() => { try { return
|
|
1034
|
+
machineLedgerNote: (() => { try { return readJson(join(runDir ?? dirname(reportMd), 'status.json'))?.machineLedgerNote ?? null; } catch { return null; } })(),
|
|
1051
1035
|
};
|
|
1052
1036
|
|
|
1053
1037
|
// Machine QC (the evaluateClientGate checks — arithmetic, record fidelity, stale corrections). The
|
|
@@ -1089,7 +1073,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1089
1073
|
// The frozen product shape. Read HERE rather than at the meta.json write below, because the Summary's
|
|
1090
1074
|
// jurisdiction line is composed before that point and must not claim a surface this run never touched.
|
|
1091
1075
|
let searchPolicy = null;
|
|
1092
|
-
try { searchPolicy = runDir ?
|
|
1076
|
+
try { searchPolicy = runDir ? readJson(paths(runDir).searchPolicy) : null; } catch { /* legacy run */ }
|
|
1093
1077
|
// A run whose frozen policy predates the component reads as grid-ran — archived reports never change.
|
|
1094
1078
|
// THE ENGINE'S PREDICATE, not a copy of it. This line used to re-implement isRegisterOnly by
|
|
1095
1079
|
// hand without importing it, so the predicate whose own doc comment calls it "the ONE predicate every
|
|
@@ -1103,7 +1087,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1103
1087
|
// the frozen profile, which is the list the run actually searched; absent (a legacy run) reads as picked.
|
|
1104
1088
|
let noMarketplacesPicked = false;
|
|
1105
1089
|
try {
|
|
1106
|
-
const frozenProfile = runDir ?
|
|
1090
|
+
const frozenProfile = runDir ? readJson(paths(runDir).profile) : null;
|
|
1107
1091
|
noMarketplacesPicked = Array.isArray(frozenProfile?.platforms) && frozenProfile.platforms.length === 0;
|
|
1108
1092
|
} catch { /* no frozen profile — a legacy run keeps its wording */ }
|
|
1109
1093
|
|
|
@@ -1120,7 +1104,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1120
1104
|
// grid ⇒ the workbook falls back to the pure token-join. Never a guessed finding number.
|
|
1121
1105
|
let commonLawJoinedTerms = null;
|
|
1122
1106
|
try {
|
|
1123
|
-
const grid =
|
|
1107
|
+
const grid = readJson(join(runDir ?? dirname(reportMd), 'common-law-grid.json'));
|
|
1124
1108
|
const links = new Set(findings.map(f => f.source?.resolved_link).filter(Boolean));
|
|
1125
1109
|
commonLawJoinedTerms = new Set();
|
|
1126
1110
|
for (const c of (grid.cells || [])) for (const cand of (c.candidates || [])) if (cand?.url && links.has(cand.url)) commonLawJoinedTerms.add(String(c.term).toUpperCase());
|
|
@@ -1138,7 +1122,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1138
1122
|
// byte-identically to before — which is the proof obligation for touching the frozen renderer at all.
|
|
1139
1123
|
let stageLabel, depthNote, productName;
|
|
1140
1124
|
try {
|
|
1141
|
-
const pol =
|
|
1125
|
+
const pol = readJson(paths(runDir).searchPolicy);
|
|
1142
1126
|
stageLabel = reportIdentityFor(pol).stageLabel ?? undefined;
|
|
1143
1127
|
// — THE PRODUCT NAME THE DOCUMENT PRINTS. `.identity`, never `.banner`: banner leads with
|
|
1144
1128
|
// `stageLabel`, which on a retired row is "Depth 4" and on a level the registry has forgotten is
|
|
@@ -1165,7 +1149,6 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1165
1149
|
// to sit under it. A `let` read above its declaration is a temporal-dead-zone throw, and the one
|
|
1166
1150
|
// test that exercises publishReport has no findings — so buildAudit was skipped and the suite went
|
|
1167
1151
|
// green on a publish path that would have thrown on every run that actually has a workbook.
|
|
1168
|
-
let auditFile = null, counts = null, auditError = null;
|
|
1169
1152
|
// THE PARTS ONLY PUBLISHING SEES (degraded-parts.mjs degradedAtPublish): a store present and unreadable
|
|
1170
1153
|
// now, or one delivery read and a republish finds missing. Their rows follow delivery's, one per name,
|
|
1171
1154
|
// and they are recorded in meta.json and the run log beside them; delivery's own record is never
|
|
@@ -1176,42 +1159,9 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1176
1159
|
catch { /* the workbook row is the record that matters; this line is the second copy */ }
|
|
1177
1160
|
}
|
|
1178
1161
|
const auditParsed = (auditMd && existsSync(auditMd)) ? parseAudit(auditMd) : null;
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
if (findings.length || auditParsed || assessmentNotCompleted) {
|
|
1183
|
-
try {
|
|
1184
|
-
auditFile = `${runId}-audit.xlsx`;
|
|
1185
|
-
// A10 — the failing predelivery checks ride into the workbook and are ENUMERATED on its Summary
|
|
1186
|
-
// sheet (with the cover note, the delivery surfaces that reach the reviewing lawyer). The
|
|
1187
|
-
// reviewReceipts assembly above claimed for two releases that these "land on the audit workbook's
|
|
1188
|
-
// Review-receipts sheet"; nothing ever threaded them through — the sink was a flag nobody read.
|
|
1189
|
-
// The workbook is handed the PROJECTED lines, never the checks: the audit download link rides in
|
|
1190
|
-
// the same cover note that reaches a client principal, so it is a delivery surface under exactly
|
|
1191
|
-
// the same rule (the workbook's own BANNED gate had already started firing on the raw detail —
|
|
1192
|
-
// advisory, so CI stayed green). reviewReceipts.lint keeps its raw detail for the internal
|
|
1193
|
-
// readers above (fetchState reads registry-record-coverage's URIs out of it).
|
|
1194
|
-
counts = await buildAudit({ degradedParts: mergeDegradedRows(runDir ? readDegradedPartRows(runDir) : [], degradedPartRows(publishParts)), droppedConditions, undispatchedProbes, withheldFamilies, releasedFamilies: releasedFamilyRows(runDir ?? dirname(reportMd)), 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 }, auditParsed, join(poolRunDir, auditFile), fm.title, fm);
|
|
1195
|
-
grpRead(join(poolRunDir, auditFile), 0o640);
|
|
1196
|
-
if (counts?.gateViolations?.length) console.warn(`[audit-workbook] advisory: ${counts.gateViolations.join(' | ')}`);
|
|
1197
|
-
} catch (e) {
|
|
1198
|
-
auditFile = null; auditError = e.message; // a REAL exception only — report ships without the workbook
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
// THE report. T4: the render receives no QC flags — the report a lawyer signs carries no
|
|
1204
|
-
// caveat banner (H1/H2); the receipts live on audit.xlsx. The machine QC above decides nothing
|
|
1205
|
-
// about this write.
|
|
1206
|
-
// homeHref — the floating "← All reports" pill returns to the listing (the staff index one level up).
|
|
1207
|
-
// The floating cross-page nav on the INTERNAL report too (jump to Archive/Status from a report).
|
|
1208
|
-
// '../' prefix — a report lives one level down at <pool>/<runId>/report.html; existence-gating stays poolRoot-
|
|
1209
|
-
// absolute. portal-report.mjs strips the nav at serve time (it lists every customer key).
|
|
1210
|
-
// anon:false — the demo-privacy toggle is a STAFF-INDEX feature (its __ANON__ config + overlay JS are
|
|
1211
|
-
// injected there only); on a report page the button rendered "Privacy ON" while doing nothing. Omit it
|
|
1212
|
-
// rather than wire the overlay in: client names saturate privileged report prose — a partial blur is a
|
|
1213
|
-
// worse demo than no toggle.
|
|
1214
|
-
const reportNav = siteNav(poolRoot, 'report', null, '../', { anon: false });
|
|
1162
|
+
// The workbook's two further reads, made here with the rest. Neither throws.
|
|
1163
|
+
const degradedRows = mergeDegradedRows(runDir ? readDegradedPartRows(runDir) : [], degradedPartRows(publishParts));
|
|
1164
|
+
const releasedFamilies = releasedFamilyRows(runDir ?? dirname(reportMd));
|
|
1215
1165
|
// The models that served this run, named as a client may read them (tokens.mjs servedModels). The closing
|
|
1216
1166
|
// line of the report's scope section, the data file and the meta below all take this one read; a read
|
|
1217
1167
|
// that throws records nothing rather than failing the publish.
|
|
@@ -1230,12 +1180,12 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1230
1180
|
// machinery at all. No sidecar means the component never ran, which the fold reports as not-in-scope.
|
|
1231
1181
|
let laneDepthVerdicts = null;
|
|
1232
1182
|
try {
|
|
1233
|
-
const jxSidecar =
|
|
1183
|
+
const jxSidecar = paths(runDir ?? dirname(reportMd)).jxLanes;
|
|
1234
1184
|
if (existsSync(jxSidecar)) {
|
|
1235
|
-
const sidecar =
|
|
1185
|
+
const sidecar = readJson(jxSidecar);
|
|
1236
1186
|
const { laneDepthOfRun } = await import('../jx.mjs');
|
|
1237
1187
|
let units = null;
|
|
1238
|
-
try { units =
|
|
1188
|
+
try { units = readJson(paths(runDir ?? dirname(reportMd)).jxUnits); } catch { /* the statement handles an absent units file */ }
|
|
1239
1189
|
// THE RUN ALREADY ANSWERED THIS, AND THE STAMPED ANSWER IS THE ONE THAT COUNTS.
|
|
1240
1190
|
//
|
|
1241
1191
|
// `deriveJxSliceStatement` writes `fold.depth` at delivery, from the run's OWN environment, for the
|
|
@@ -1257,7 +1207,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1257
1207
|
const runBase = runDir ?? dirname(reportMd);
|
|
1258
1208
|
const recDir = join(runBase, '_records');
|
|
1259
1209
|
const rdText = (p2) => { try { return readFileSync(p2, 'utf8'); } catch { return ''; } };
|
|
1260
|
-
const rdJson = (p2) => { try { return
|
|
1210
|
+
const rdJson = (p2) => { try { return readJson(p2); } catch { return null; } };
|
|
1261
1211
|
searchDepth = searchDepthRecord({
|
|
1262
1212
|
auditMd: (auditMd && existsSync(auditMd)) ? rdText(auditMd) : '',
|
|
1263
1213
|
recordIndex: recordsByUri ?? {},
|
|
@@ -1275,28 +1225,17 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1275
1225
|
caseLawRecord: (() => {
|
|
1276
1226
|
const ledger = readStore(runBase, 'case-law-citations.json');
|
|
1277
1227
|
return caseLawPassRecord({
|
|
1278
|
-
attemptsJsonl: rdText(
|
|
1228
|
+
attemptsJsonl: rdText(paths(runBase).caseLawRecord) || null,
|
|
1279
1229
|
ledgerRaw: ledger.state === 'absent' ? null : (ledger.raw ?? ''),
|
|
1280
|
-
readingLogJsonl: rdText(
|
|
1230
|
+
readingLogJsonl: rdText(paths(runBase).readingLog) || null,
|
|
1281
1231
|
bridges: CASELAW_BRIDGES,
|
|
1282
1232
|
});
|
|
1283
1233
|
})(),
|
|
1284
|
-
registerPlan: rdJson(
|
|
1234
|
+
registerPlan: rdJson(paths(runBase).registerPlan),
|
|
1285
1235
|
laneDepthVerdicts,
|
|
1286
1236
|
noMarketplacesPicked,
|
|
1287
1237
|
});
|
|
1288
|
-
writeRO('search-depth.json', JSON.stringify(searchDepth, null, 2));
|
|
1289
1238
|
} catch { /* the depth record is additive — a publish never fails for want of it */ }
|
|
1290
|
-
|
|
1291
|
-
writeRO('report.html', renderHtml(parsed, findings, coverage, { demoData, frameworkMethod, servedModels: served, productName, depthNote, scopeBasis, auditFile: auditFile || undefined, runId, delivery: deliv, recordsByUri, contextNotes, coverageJudgment: coverageJudgmentDisplay, markAssessment, fourAnswers, homeHref: '../index.html', nav: reportNav, chromeHref: '../assets/chrome.css', issued, asOf, verdictInfo, framework, searchedJurisdictions, planTerritories, caseLawByOrdinal, caseLawNotice, enforcerSignals, recordOrigin, recordOrigins: runOrigins, recordCitation: runProviderConf?.recordCitation ?? null, recordLinks: officeLinks?.byUri ?? null, providerLabel, seniorRights, findingsSchemaVersion, searchDepth, assessmentNotCompleted }));
|
|
1292
|
-
// ONE report (spec 2026-07-30 §5): report.client.html is no longer written. The knockout lane's own
|
|
1293
|
-
// collapse note is the precedent: "two renderings of one run is how the wrong link gets sent". The
|
|
1294
|
-
// client host serves the same report.html through the portal's readReport() (cleaning built in) — its
|
|
1295
|
-
// repoint deploys BEFORE this change merges (charter ruling 2a).
|
|
1296
|
-
//
|
|
1297
|
-
// P5 rebase note: this package was written against the pre-collapse tree, where the four-answers panel
|
|
1298
|
-
// had to be passed to BOTH renders. There is one render now, so `fourAnswers` rides the one call — the
|
|
1299
|
-
// panel reaches the client through the same cleaning path as every other reader-facing block.
|
|
1300
1239
|
// Write-once publish timestamp: the index sorts same-day runs by it, and a republish (same runId) keeps the FIRST
|
|
1301
1240
|
// issue time so re-rendering an old run never bumps it to the top. The render's own time is `renderedAt`.
|
|
1302
1241
|
const { issuedAt, renderedAt } = dates;
|
|
@@ -1319,7 +1258,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1319
1258
|
// one name" possible for delivered runs at all. Legacy runs published before this get it on republish
|
|
1320
1259
|
// (pool-admin doRepublish sources the same workspace), and until then consumers fall back to title.
|
|
1321
1260
|
let markName = null;
|
|
1322
|
-
try { markName = runDir ? (
|
|
1261
|
+
try { markName = runDir ? (readJson(join(runDir, 'status.json')).markName ?? null) : null; } catch { /* no status sidecar */ }
|
|
1323
1262
|
// WHICH PROJECT THIS RAN UNDER, carried into the pool — the same move as markName above, and for the
|
|
1324
1263
|
// same reason: the fact exists on the way IN and was lost on the way out.
|
|
1325
1264
|
//
|
|
@@ -1335,39 +1274,142 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1335
1274
|
let project = null;
|
|
1336
1275
|
let organisation = null;
|
|
1337
1276
|
try {
|
|
1338
|
-
const frozen = runDir ?
|
|
1277
|
+
const frozen = runDir ? readJson(paths(runDir).profile) : null;
|
|
1339
1278
|
if (frozen?.projectKey) project = { key: String(frozen.projectKey), name: String(frozen.projectName ?? frozen.projectKey) };
|
|
1340
1279
|
if (typeof frozen?.organisation === 'string' && frozen.organisation) organisation = frozen.organisation;
|
|
1341
1280
|
} catch { /* no frozen profile — pre-WS-B run, or a republish with no workspace */ }
|
|
1342
1281
|
let tokenRollup;
|
|
1343
1282
|
try { tokenRollup = runDir ? rollupTokens(runDir) : undefined; } catch { tokenRollup = undefined; }
|
|
1283
|
+
return {
|
|
1284
|
+
parsed, fm, deliv, dates, issued, asOf, demoData, demoMd, inputsAbsent, findings, coverage, contextNotes,
|
|
1285
|
+
quarantined, findingsError, coverageJudgment, markAssessment, actionsRegister, askAnswers, correctionsDoc,
|
|
1286
|
+
fourAnswers, findingsSchemaVersion, findingsKept, assessmentNotCompleted, coverageJudgmentDisplay, recordsByUri,
|
|
1287
|
+
runProviderConf, recordOrigin, providerLabel, runOrigins, seniorRights, verdictInfo, droppedConditions,
|
|
1288
|
+
undispatchedProbes, withheldFamilies, setAside, framework, frameworkMethod, scopeBasis, searchedJurisdictions,
|
|
1289
|
+
planTerritories, caseLawByOrdinal, caseLawNotice, enforcerSignals, officeLinks, reviewReceipts, clientGate,
|
|
1290
|
+
fetchState, searchPolicy, registerOnly, noMarketplacesPicked, jurisdiction, commonLawJoinedTerms, stageLabel,
|
|
1291
|
+
depthNote, productName, publishParts, auditParsed, degradedRows, releasedFamilies, served, searchDepth, issuedAt,
|
|
1292
|
+
renderedAt, markName, project, organisation, tokenRollup,
|
|
1293
|
+
// WHICH BUILD produced this, read once for every surface that records it. null off a git checkout.
|
|
1294
|
+
engineCommit: engineCommit(),
|
|
1295
|
+
// THE REPORT'S LINK, ONE WAY: the portal route the email, the run record and the data file all name. The data file
|
|
1296
|
+
// used to name the pool path, which production serves as "not found" (see reportRouteFor).
|
|
1297
|
+
reportRoute: reportRouteFor(poolUrl, runId),
|
|
1298
|
+
|
|
1299
|
+
// The product's stage label as frozen with the run, which meta.json keeps; `stageLabel` above is today's registry's.
|
|
1300
|
+
frozenStageLabel: searchPolicy?.stageLabel,
|
|
1301
|
+
// The rating word and its badge for meta.json, falling back to the report's front matter on a run older than the
|
|
1302
|
+
// verdict record, as the page does; the data file takes the verdict record's alone. None where the assessment was not
|
|
1303
|
+
// completed.
|
|
1304
|
+
ratingWord: assessmentNotCompleted ? undefined : (verdictInfo?.tier ?? fm.overall_label),
|
|
1305
|
+
ratingBadge: assessmentNotCompleted ? undefined : (verdictInfo?.badge ?? fm.overall_badge),
|
|
1306
|
+
// The headline caption as the front matter states it, empty as null. The email, the data file, meta.json and the run
|
|
1307
|
+
// record take it; the page takes the report's Summary instead (render.mjs).
|
|
1308
|
+
caption: fm.overall_caption || null,
|
|
1309
|
+
// The email's options (coverNoteOptions): the delivery composes the email after publishing, from the same function.
|
|
1310
|
+
cover: coverNoteOptions(runDir ?? dirname(reportMd)),
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* Publish a finished run to the pool.
|
|
1316
|
+
* @param {object} a
|
|
1317
|
+
* @param {string} a.runId - driver run identity, e.g. "tmp2201-novapulse-2026-06-01-teal-spire"
|
|
1318
|
+
* @param {string} a.codename - driver codename (display only), e.g. "teal-spire"
|
|
1319
|
+
* @param {string} a.reportMd - absolute path to report.md (from report-synthesis stage)
|
|
1320
|
+
* @param {string} [a.auditMd] - absolute path to audit.md (from audit-emit stage); optional
|
|
1321
|
+
* @param {string} a.poolRoot - config.poolRoot (no default since; the deployment's CLEAROTRON_REPORTS_DIR)
|
|
1322
|
+
* @param {string} [a.poolUrl] - config.poolUrl (https://trademark.example.com) for the returned link
|
|
1323
|
+
* @returns {Promise<{runId,auditFile,counts,total,url,poolRunDir}>}
|
|
1324
|
+
*/
|
|
1325
|
+
// skipRegen — do NOT re-render index.html + the staff pages at the end. The batch backfill passes this and does
|
|
1326
|
+
// ONE regen after the whole loop instead of N redundant ones (per-run publish leaves it false, as before).
|
|
1327
|
+
// (skipClient is retired with report.client.html — one report, spec 2026-07-30 §5.)
|
|
1328
|
+
export async function publishReport({ runId, codename, reportMd, auditMd, findingsJson, poolRoot, poolUrl, customerKey, delivery, runDir, skipRegen = false }) {
|
|
1329
|
+
const doc = await readClearanceDocument({ runId, reportMd, auditMd, findingsJson, poolRoot, poolUrl, customerKey, delivery, runDir });
|
|
1330
|
+
const { parsed, fm, deliv, issued, asOf, demoData, demoMd, findings, coverage, contextNotes, findingsError,
|
|
1331
|
+
coverageJudgment, markAssessment, actionsRegister, askAnswers, correctionsDoc, fourAnswers, findingsSchemaVersion,
|
|
1332
|
+
findingsKept, assessmentNotCompleted, coverageJudgmentDisplay, recordsByUri, runProviderConf, recordOrigin, providerLabel,
|
|
1333
|
+
runOrigins, seniorRights, verdictInfo, droppedConditions, undispatchedProbes, withheldFamilies, setAside, framework,
|
|
1334
|
+
frameworkMethod, scopeBasis, searchedJurisdictions, planTerritories, caseLawByOrdinal, caseLawNotice, enforcerSignals,
|
|
1335
|
+
officeLinks, reviewReceipts, clientGate, fetchState, searchPolicy, registerOnly, jurisdiction, commonLawJoinedTerms,
|
|
1336
|
+
stageLabel, depthNote, productName, publishParts, auditParsed, degradedRows, releasedFamilies, served, searchDepth,
|
|
1337
|
+
issuedAt, renderedAt, markName, project, organisation, tokenRollup, reportRoute, frozenStageLabel, ratingWord,
|
|
1338
|
+
ratingBadge, caption } = doc;
|
|
1339
|
+
const { poolRunDir, writeRO, copyRO, copyPart, buildWorkbook, writeDataFile } = openPoolRun(poolRoot, runId, { runDir });
|
|
1340
|
+
// The pool's copy of report.md, marked as demo data where the document says it is (the answer and its argument are
|
|
1341
|
+
// with `demoData` in readClearanceDocument).
|
|
1342
|
+
writeRO('report.md', (demoMd ? `${demoMd}\n` : '') + stripInternal(readFileSync(reportMd, 'utf8'), { client: false }));
|
|
1343
|
+
// The findings.json the document read, kept beside the report for forensics. A copy that fails leaves the report in
|
|
1344
|
+
// place and is recorded, as a data file is (shell.mjs).
|
|
1345
|
+
if (findingsKept) copyPart(findingsKept, 'findings.json');
|
|
1346
|
+
if (auditMd && existsSync(auditMd)) copyRO(auditMd, 'audit.md'); // durable source (kept even if the xlsx fails)
|
|
1347
|
+
let auditFile = null, counts = null, auditError = null;
|
|
1348
|
+
// In the state the workbook is built even with no finding and no search log: it carries the part that was not
|
|
1349
|
+
// completed, and the coverage the run did record.
|
|
1350
|
+
if (findings.length || auditParsed || assessmentNotCompleted) {
|
|
1351
|
+
({ auditFile, auditError, built: counts } = await buildWorkbook(`${runId}-audit.xlsx`, async (at) => {
|
|
1352
|
+
// A10 — the failing predelivery checks ride into the workbook and are ENUMERATED on its Summary
|
|
1353
|
+
// sheet (with the cover note, the delivery surfaces that reach the reviewing lawyer). The
|
|
1354
|
+
// reviewReceipts assembly above claimed for two releases that these "land on the audit workbook's
|
|
1355
|
+
// Review-receipts sheet"; nothing ever threaded them through — the sink was a flag nobody read.
|
|
1356
|
+
// The workbook is handed the PROJECTED lines, never the checks: the audit download link rides in
|
|
1357
|
+
// the same cover note that reaches a client principal, so it is a delivery surface under exactly
|
|
1358
|
+
// the same rule (the workbook's own BANNED gate had already started firing on the raw detail —
|
|
1359
|
+
// advisory, so CI stayed green). reviewReceipts.lint keeps its raw detail for the internal
|
|
1360
|
+
// readers above (fetchState reads registry-record-coverage's URIs out of it).
|
|
1361
|
+
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 }, auditParsed, at, fm.title, fm);
|
|
1362
|
+
if (built?.gateViolations?.length) console.warn(`[audit-workbook] advisory: ${built.gateViolations.join(' | ')}`);
|
|
1363
|
+
return built;
|
|
1364
|
+
})); // a REAL exception only — the report ships without the workbook, and nothing names it
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
|
|
1368
|
+
// THE report. T4: the render receives no QC flags — the report a lawyer signs carries no
|
|
1369
|
+
// caveat banner (H1/H2); the receipts live on audit.xlsx. The machine QC above decides nothing
|
|
1370
|
+
// about this write.
|
|
1371
|
+
// homeHref — the floating "← All reports" pill returns to the listing (the staff index one level up).
|
|
1372
|
+
// The floating cross-page nav on the INTERNAL report too (jump to Archive/Status from a report).
|
|
1373
|
+
// '../' prefix — a report lives one level down at <pool>/<runId>/report.html; existence-gating stays poolRoot-
|
|
1374
|
+
// absolute. portal-report.mjs strips the nav at serve time (it lists every customer key).
|
|
1375
|
+
// anon:false — the demo-privacy toggle is a STAFF-INDEX feature (its __ANON__ config + overlay JS are
|
|
1376
|
+
// injected there only); on a report page the button rendered "Privacy ON" while doing nothing. Omit it
|
|
1377
|
+
// rather than wire the overlay in: client names saturate privileged report prose — a partial blur is a
|
|
1378
|
+
// worse demo than no toggle.
|
|
1379
|
+
const reportNav = siteNav(poolRoot, 'report', null, '../', { anon: false });
|
|
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', renderHtml(parsed, findings, coverage, { demoData, frameworkMethod, servedModels: served, productName, depthNote, scopeBasis, auditFile: auditFile || undefined, runId, delivery: deliv, recordsByUri, contextNotes, coverageJudgment: coverageJudgmentDisplay, markAssessment, fourAnswers, homeHref: '../index.html', nav: reportNav, chromeHref: '../assets/chrome.css', issued, asOf, verdictInfo, framework, searchedJurisdictions, planTerritories, caseLawByOrdinal, caseLawNotice, enforcerSignals, recordOrigin, recordOrigins: runOrigins, recordCitation: runProviderConf?.recordCitation ?? null, recordLinks: officeLinks?.byUri ?? null, providerLabel, seniorRights, findingsSchemaVersion, searchDepth, assessmentNotCompleted }));
|
|
1385
|
+
// ONE report (spec 2026-07-30 §5): 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 deploys BEFORE this change merges (charter ruling 2a).
|
|
1389
|
+
//
|
|
1390
|
+
// P5 rebase note: this package was written against the pre-collapse tree, where the four-answers panel
|
|
1391
|
+
// had to be passed to BOTH renders. There is one render now, so `fourAnswers` rides the one call — the
|
|
1392
|
+
// panel reaches the client through the same cleaning path as every other reader-facing block.
|
|
1344
1393
|
// PR-9 — the clearance run as data (publish/report-data.mjs): the client-cut projection the assistant
|
|
1345
1394
|
// drafts mail from and the portal's native-render path reads. BEST-EFFORT with a hard receipt rule:
|
|
1346
1395
|
// meta.reportSchema is stamped ONLY when the file actually wrote — a run whose meta advertises a data
|
|
1347
1396
|
// file that is not there would break the portal's presence branch. A producer throw never blocks the
|
|
1348
1397
|
// report (the baked HTML above is already on disk).
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
});
|
|
1365
|
-
writeRO('report-data.json', JSON.stringify(data, null, 2));
|
|
1366
|
-
reportSchema = 'report-data/1';
|
|
1367
|
-
} catch (e) {
|
|
1368
|
-
console.warn(`[report-data] producer failed (report ships without the data file): ${String(e?.message ?? e).slice(0, 140)}`);
|
|
1369
|
-
}
|
|
1370
|
-
writeRO('meta.json', JSON.stringify({
|
|
1398
|
+
const reportSchema = writeDataFile('report-data.json', () => clearanceReportData({
|
|
1399
|
+
runId, codename, matter: fm.matter, markName, title: fm.title, customerKey: customerKey || 'generic',
|
|
1400
|
+
issued, url: reportRoute,
|
|
1401
|
+
// stageLabel REGISTRY-FIRST ( residual, audit item 4): `stageLabel` is reportIdentityFor's
|
|
1402
|
+
// read-time derivation — the same label report.html renders — so a republished pre-renumber run
|
|
1403
|
+
// cannot mint report.html "Depth 2" beside report-data.json "Stage 0.5". The frozen sidecar label
|
|
1404
|
+
// is the LAST resort (a level today's registry no longer knows). meta.json below keeps the frozen
|
|
1405
|
+
// stamp BY DESIGN — its readers re-derive.
|
|
1406
|
+
auditFile, searchLevel: searchPolicy?.level ?? null, stageLabel: stageLabel ?? frozenStageLabel ?? null,
|
|
1407
|
+
engineCommit: doc.engineCommit, servedModels: served,
|
|
1408
|
+
framework, verdictInfo, findings, coverage, contextNotes, markAssessment, fourAnswers, askAnswers,
|
|
1409
|
+
actions: actionsRegister, jurisdiction, searchedJurisdictions, scopeBasis, caption,
|
|
1410
|
+
assessmentNotCompleted,
|
|
1411
|
+
})) ? 'report-data/1' : null;
|
|
1412
|
+
const total = finishPoolRun({ writeRO, poolRoot, skipRegen, regenIndex, meta: {
|
|
1371
1413
|
runId, codename: codename || '', matter: fm.matter, title: fm.title, client: fm.client,
|
|
1372
1414
|
// The mark as typed — see above. Distinct from `title`, which is the report's own headline.
|
|
1373
1415
|
markName: markName ?? undefined,
|
|
@@ -1383,7 +1425,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1383
1425
|
issuedAt,
|
|
1384
1426
|
renderedAt,
|
|
1385
1427
|
// WHICH BUILD produced this. null off a git checkout — a provenance stamp never fails a publish.
|
|
1386
|
-
engineCommit: engineCommit
|
|
1428
|
+
engineCommit: doc.engineCommit,
|
|
1387
1429
|
// The models that served the run, named as a client may read them (tokens.mjs servedModels). Absent when
|
|
1388
1430
|
// nothing was read, so a meta from before the record keeps its shape; [] when turns ran and named none a client may read.
|
|
1389
1431
|
servedModels: served ?? undefined,
|
|
@@ -1391,7 +1433,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1391
1433
|
searchLevel: searchPolicy?.level ?? undefined,
|
|
1392
1434
|
// Display-only face of the level ("Depth 4"), frozen alongside it so the list can show which reads
|
|
1393
1435
|
// have run on a name without the browser having to know the level registry.
|
|
1394
|
-
stageLabel:
|
|
1436
|
+
stageLabel: frozenStageLabel ?? undefined,
|
|
1395
1437
|
recipe: searchPolicy?.recipe ?? undefined,
|
|
1396
1438
|
enqueuedVia: searchPolicy?.enqueuedVia ?? undefined,
|
|
1397
1439
|
enqueuedBy: searchPolicy?.enqueuedBy ?? undefined,
|
|
@@ -1404,8 +1446,8 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1404
1446
|
// T2 (H5): the derived display verdict is THE authority when the sidecar exists; the
|
|
1405
1447
|
// model-authored fm fields are the pre-A2 legacy fallback only.
|
|
1406
1448
|
// No rating at all in the state where the assessment was not completed, whatever a report's front matter says.
|
|
1407
|
-
overall:
|
|
1408
|
-
badge:
|
|
1449
|
+
overall: ratingWord,
|
|
1450
|
+
badge: ratingBadge, run: fm.run, date: dateOf(fm.run), auditFile,
|
|
1409
1451
|
// WHY THERE IS NO WORKBOOK, when the build threw. Absent when it built, so such a meta is unchanged.
|
|
1410
1452
|
auditError: auditError ?? undefined,
|
|
1411
1453
|
// THE PARTS PUBLISHING FOUND DEGRADED, with their raw causes, which no cell carries. Absent when none.
|
|
@@ -1414,7 +1456,7 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1414
1456
|
// writer). Absent on legacy runs — regenIndex re-reads every historical meta.json, so consumers
|
|
1415
1457
|
// null-guard and old rows render byte-identically.
|
|
1416
1458
|
statement: verdictInfo?.statement ?? undefined,
|
|
1417
|
-
caption:
|
|
1459
|
+
caption: caption ?? undefined, // the report's own conclusion, which the run list quotes
|
|
1418
1460
|
// The run's overall assessment could not be completed, so it carries no rating: a stated state, for every reader
|
|
1419
1461
|
// of the pool that has no run directory. Absent on every other run, so its meta is unchanged.
|
|
1420
1462
|
assessment: assessmentNotCompleted ? 'not-completed' : undefined,
|
|
@@ -1438,16 +1480,14 @@ export async function publishReport({ runId, codename, reportMd, auditMd, findin
|
|
|
1438
1480
|
// same stamp the knockout lane writes; the consumer branch had readers before it had a writer).
|
|
1439
1481
|
// undefined on a producer miss, so the meta never advertises a file that is not there.
|
|
1440
1482
|
reportSchema: reportSchema ?? undefined,
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
const total = skipRegen ? null : regenIndex(poolRoot);
|
|
1444
|
-
if (!skipRegen) await regenSurfaces(poolRoot);
|
|
1483
|
+
} });
|
|
1484
|
+
await refreshStaffPages({ regenSurfaces, poolRoot, skipRegen, runDir });
|
|
1445
1485
|
// THE PORTAL ROUTE, not the pool's directory layout. This was
|
|
1446
1486
|
// `<origin>/<runId>/report.html` — where the documents sit on disk, which is not an application route.
|
|
1447
1487
|
// Composed rather than spelled here so the report link is built the same way the audit link always was.
|
|
1448
|
-
const url =
|
|
1488
|
+
const url = reportRoute;
|
|
1449
1489
|
return { runId, auditFile, counts, total, url, poolRunDir, auditError, findingsError, customerKey: customerKey || 'generic', clientGate,
|
|
1450
|
-
caption
|
|
1490
|
+
caption }; // the report's own conclusion, for the run record's short surfaces
|
|
1451
1491
|
}
|
|
1452
1492
|
|
|
1453
1493
|
// Compose the notification email body — MARKDOWN (the mail tool renders markdown→HTML; raw HTML gets escaped).
|
|
@@ -1734,6 +1774,23 @@ function mdBlock(block) {
|
|
|
1734
1774
|
// opts.tier, else the report front-matter, and the conditions from the report's own `# Actions`), and
|
|
1735
1775
|
// the note that used to stand here claiming the parameter was "retained because client-summary.md is
|
|
1736
1776
|
// still a first-class artifact" outlived its own truth: the stage is retired and nothing writes the file.
|
|
1777
|
+
/**
|
|
1778
|
+
* THE EMAIL'S OPTIONS, read from the run's frozen files: the product's name off the frozen search policy, the verdict
|
|
1779
|
+
* record's sign-off word, conditions, rating and statement as the record wrote them, and the band ladder of the frozen
|
|
1780
|
+
* framework. The report document carries them as `cover`, and the delivery passes them to composeEmailHtml, on a fresh
|
|
1781
|
+
* publish and on a resume that finds the run already published. The statement is the record's own, which the run's status
|
|
1782
|
+
* keeps; the report's surfaces print the client form. Never throws: a file it cannot read leaves its options out.
|
|
1783
|
+
*/
|
|
1784
|
+
export function coverNoteOptions(runDir) {
|
|
1785
|
+
const frozen = (key, parse = JSON.parse) => { try { return parse(readFileSync(paths(runDir)[key], 'utf8')); } catch { return null; } };
|
|
1786
|
+
const opts = { productName: reportIdentityFor(frozen('searchPolicy')).identity ?? undefined };
|
|
1787
|
+
const v = frozen('verdict');
|
|
1788
|
+
if (v) Object.assign(opts, { verdict: v.verdict, conditions: clientConditions(v), tier: v.tier, statement: v.statement ?? null });
|
|
1789
|
+
const framework = frozen('framework', parseFrameworkManifest);
|
|
1790
|
+
if (framework) opts.bands = framework.bands.map((b) => ({ label: b.label, tone: b.tone }));
|
|
1791
|
+
return opts;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1737
1794
|
export function composeEmailHtml(reportMdPath, url, auditFile, names = [], delivery = NEUTRAL_DELIVERY, opts = {}) {
|
|
1738
1795
|
EMAIL_BANDS = Array.isArray(opts?.bands) && opts.bands.length ? opts.bands : null; // doc 50 — per-run vocabulary
|
|
1739
1796
|
const { fm, secs } = parseReport(reportMdPath);
|
|
@@ -1891,6 +1948,7 @@ export function composeEmailHtml(reportMdPath, url, auditFile, names = [], deliv
|
|
|
1891
1948
|
// of the tree cites by number.
|
|
1892
1949
|
import { recordLinksFor } from './office-record-links.mjs';
|
|
1893
1950
|
import { reportDates, zurichStamp } from './report-dates.mjs'; // the dates a report prints, from its record
|
|
1951
|
+
import { driverDir, paths, readJson } from "../run-record.mjs";
|
|
1894
1952
|
function officeLinksFor(findings, recordsByUri, runOrigins) {
|
|
1895
1953
|
const links = recordLinksFor(findings, recordsByUri, runOrigins);
|
|
1896
1954
|
if (links) console.log(`[record-links] ${links.summary}`);
|
|
@@ -1932,7 +1990,7 @@ export function releasedFamilyRows(runDir) {
|
|
|
1932
1990
|
try {
|
|
1933
1991
|
const released = readReleasedFamilies(runDir);
|
|
1934
1992
|
let entries = [];
|
|
1935
|
-
try { entries =
|
|
1993
|
+
try { entries = readJson(paths(runDir).registerPlan)?.entries ?? []; } catch { /* no frozen plan */ }
|
|
1936
1994
|
const byQid = new Map((Array.isArray(entries) ? entries : []).map((e) => [e?.qid, e]));
|
|
1937
1995
|
return Object.entries(released).map(([qid, r]) => ({ area: coverageUnitLabel(unitLabel(r.axis, byQid.get(qid))), state: 'note', note: String(r.reason), done: String(r.reason), left: '' }));
|
|
1938
1996
|
} catch { return []; }
|
|
@@ -1954,7 +2012,7 @@ export function setAsideRows(runDir, { findings = null } = {}) {
|
|
|
1954
2012
|
try {
|
|
1955
2013
|
const d = readDeclinations(runDir);
|
|
1956
2014
|
if (!d.present) return [];
|
|
1957
|
-
const read = (f) => { try { return
|
|
2015
|
+
const read = (f) => { try { return readJson(driverDir(runDir, f)); } catch { return null; } };
|
|
1958
2016
|
let delivered = findings;
|
|
1959
2017
|
if (!Array.isArray(delivered)) {
|
|
1960
2018
|
try { delivered = parseFindingsJsonLenient(readFileSync(join(runDir, 'findings.json'), 'utf8')).findings ?? []; } catch { delivered = []; }
|
|
@@ -1976,3 +2034,20 @@ export function setAsideRows(runDir, { findings = null } = {}) {
|
|
|
1976
2034
|
*/
|
|
1977
2035
|
export const gateCouldNotEvaluate = (e, inputsAbsent = []) => ({ released: false, reasons: [], reasonCodes: ["gate-evaluation-error"],
|
|
1978
2036
|
inputsAbsent, evaluationError: String(e?.message ?? e).slice(0, 80) });
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* THE SAME RECORDED COVERAGE ROW, TWICE, IS ONE ROW. A run's record can carry one row repeated, its area, state and
|
|
2040
|
+
* note all equal (measured on the full country demo, 2026-11-11: one Japanese spelling's row, twice), and the report,
|
|
2041
|
+
* the data file and the workbook each printed it twice. Only an exact repeat goes, the first one kept in place: rows
|
|
2042
|
+
* that differ in area, state or note stand, however alike they read (design's ruling, 2026-11-11). PURE.
|
|
2043
|
+
*/
|
|
2044
|
+
export function withoutRepeatedRows(rows) {
|
|
2045
|
+
if (!Array.isArray(rows)) return rows;
|
|
2046
|
+
const seen = new Set();
|
|
2047
|
+
return rows.filter((r) => {
|
|
2048
|
+
const key = JSON.stringify([r?.area ?? null, r?.state ?? null, r?.note ?? null]);
|
|
2049
|
+
if (seen.has(key)) return false;
|
|
2050
|
+
seen.add(key);
|
|
2051
|
+
return true;
|
|
2052
|
+
});
|
|
2053
|
+
}
|