clearotron 0.5.1 → 0.6.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/.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 +88 -33
- 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 +69 -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/band-shape.mjs +21 -3
- 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/commonlaw-carry-floor.json +3 -3
- package/driver/compare.mjs +1 -1
- package/driver/config-inventory.mjs +6 -79
- package/driver/consumption-ledger.mjs +2 -1
- package/driver/contract-arm2-baseline.json +2 -3
- 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/demo-posture.mjs +17 -0
- 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 +13 -42
- 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 +20 -13
- 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 +26 -14
- 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/named-band.mjs +60 -3
- 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 +714 -9351
- 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 +82 -2593
- package/driver/portal-static.mjs +3 -1
- package/driver/predelivery-lint.mjs +101 -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 +9 -7
- 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 +79 -23
- 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 +35 -96
- 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 +10 -20
- 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 +89 -288
- 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 +927 -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 +836 -0
- package/driver/steps/synthesis.mjs +261 -0
- package/driver/steps/verdict-gate.mjs +968 -0
- package/driver/suite-census.json +456 -96
- 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/unexecuted-asserts.json +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 +8 -0
- package/mcp-server/http-server.mjs +11 -12
- 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/node_modules/buffers/package.json +1 -1
- package/package.json +2 -1
- package/portal-ui/dist/assets/{index-fPqAU0sx.js → index-CYaO2ygd.js} +26 -14
- package/portal-ui/dist/assets/{index-AtB9ZpDH.css → index-izLa9apq.css} +2 -2
- package/portal-ui/dist/index.html +4 -4
- 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 +8 -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/render-check.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 +3 -3
- 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/customer-store.mjs +3 -2
- 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/vendor/buffers/package.json +1 -1
- package/node_modules/exceljs/README.md +0 -3023
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
3
|
+
//
|
|
4
|
+
// steps/verdict-gate.mjs — the verdict's floors and terminal guards, and the label and sidecar they write.
|
|
5
|
+
//
|
|
6
|
+
// One phase of a run, moved out of pipelineInner unchanged. `helpers` are functions still held in pipeline.mjs, handed in
|
|
7
|
+
// because this module must not import that one back; each moves here when the other phases that share it have moved.
|
|
8
|
+
import { paths } from "../run-record.mjs";
|
|
9
|
+
import { runRecordLogPath } from "../../providers/_shared/ledger-path.mjs";
|
|
10
|
+
import { decideRegisterGap } from "../coverage-ledger.mjs";
|
|
11
|
+
import { plainDirective } from "../deferral-row.mjs";
|
|
12
|
+
import { UNREACHABLE_SENIOR_POLICY } from "../driver.config.mjs";
|
|
13
|
+
import { deriveActionConditions, deriveDisplayVerdict, parseFindingsJsonLenient, quarantinedConditionRows, riskStatement, verdictStance } from "../findings-model.mjs";
|
|
14
|
+
import { floorDutyArmed, floorDutyBlock, floorDutyClosed } from "../floor-duty.mjs";
|
|
15
|
+
import { note, runLog } from "../log.mjs";
|
|
16
|
+
import { signoffPatch, writeRunStatus } from "../progress.mjs";
|
|
17
|
+
import { readActiveTaintAxes } from "../register-taint.mjs";
|
|
18
|
+
import { assembleRunRecords } from "../registry-fidelity.mjs";
|
|
19
|
+
import { postRepairRecordPath } from "../repair-scope.mjs";
|
|
20
|
+
import { createRepairLedger } from "../repairs.mjs";
|
|
21
|
+
import { isRegisterOnly } from "../search-policy.mjs";
|
|
22
|
+
import { rankClusterLegs, verdictDrivingFindings } from "../senior-rights.mjs";
|
|
23
|
+
import { lines } from "../stages.mjs";
|
|
24
|
+
import { synthesisDutyForRun } from "../synthesis-record.mjs";
|
|
25
|
+
import { clauseForDefect, gapPositivelyClosed, jointUnaccounted, orderClausesForLede, terminalClampDecision, verdictWhenTheStepsAreWithdrawn, verdictWithConditionsStanding, verdictWithoutTheClosedGap } from "../terminal-clamp.mjs";
|
|
26
|
+
import { countCitedDefects, parseCorrections, parseVerdict } from "../verify.mjs";
|
|
27
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
28
|
+
|
|
29
|
+
export async function runVerdictGate({ P, agent, applyVerdictFrontMatter, correctiveCycleSettled, correctiveEntryVerdict, correctiveRecheckOk, coverageJudgment, ctx, opts, run, runState }, helpers) {
|
|
30
|
+
const { StageFailure, actionsRegisterListed, conditionsFollowingTheRecord, defaultRecordFetcher, enrichFindingDeadlines, lateRecordsUnaddressed, loadCoverageLedger, loadScreenGateUnresolved, owedUrisFor, planAuditExtra, refusedRecordsLeftOut, registerGapConditions, safeReadJson, saveWithRetries, stage, withdrawByToken } = helpers;
|
|
31
|
+
// U1 — coverage-honesty floor (Appendix A tripwire #2). The reviewer verdict is empirically noisy
|
|
32
|
+
// (it flips on byte-identical input), so the honest-status signal is derived from the coverage
|
|
33
|
+
// LEDGER alone, never from the verdict. A run can be only as CLEAR as the layers it actually ran:
|
|
34
|
+
// if a layer MATERIAL to this matter is coverage-limited / deferred (saturation-probe excluded by
|
|
35
|
+
// contract — count-only ⇒ limited by definition), the run cannot ship CLEAR. We only ever RAISE
|
|
36
|
+
// CLEAR→CONDITIONAL — never lower, never manufacture BLOCKING — and we do it AFTER the reviewer's
|
|
37
|
+
// corrective ladder has settled, so it forces an honest delivered status without firing an empty
|
|
38
|
+
// corrective re-synthesis (the gap is a search-execution reality, not a narrative the model can fix).
|
|
39
|
+
// This is the deterministic backstop under the reviewer's LLM-level coverage-overclaim rule.
|
|
40
|
+
// judgment-relocation (revised 2026-06-24): the deliver-conditional verdict floor. The funnel's old
|
|
41
|
+
// search-shape coverage-honesty clamp (findFloorShapeGaps, deleted) is gone — sufficiency is the lawyer's
|
|
42
|
+
// call, not a re-parse of the prose ledger. Three honest, NON-WITHHOLDING reasons can clamp a clean run
|
|
43
|
+
// CLEAR→CONDITIONAL (deliver the report, carry the gap in the status — never command a re-loop, never halt):
|
|
44
|
+
// • coverageInsufficient — the lawyer (synthesis coverage_judgment.sufficient:false) judged a MATERIAL
|
|
45
|
+
// register slice not fully cleared. This is the deliver-conditional realisation of "command or halt":
|
|
46
|
+
// we neither re-search nor stop — we ship a CONDITIONAL with the lawyer's reason. Safe because the
|
|
47
|
+
// dangerous named band was enumerated to completeness (fan-in band gate); the conditional covers a
|
|
48
|
+
// genuine residual, not a hidden miss.
|
|
49
|
+
// • frameResidual — a STRUCTURAL omission the blind frame-diff found and the reopen could not close.
|
|
50
|
+
// • screenGateGap — an in-scope-live mark whose record could not be retrieved (could-not-examine).
|
|
51
|
+
// A GENUINE open judgment (the search IS complete; the legal/commercial call is genuinely arguable) is NOT a
|
|
52
|
+
// clamp — it ships as reasoning in the report (the lawyer's product), never as a status caveat.
|
|
53
|
+
// ── WP-receipts W3 — the senior-right closure ("verify the right that matters", senior lawyer 2026-07-05).
|
|
54
|
+
// For the handful of findings that DRIVE the delivered verdict, the verified basis must be the
|
|
55
|
+
// cluster's SENIOR live right, never an arbitrary leg (VENZY: the report read "verified" off the
|
|
56
|
+
// junior AE 2015 leg while the senior TR 2009 registration was never pulled). Seniority is ranked
|
|
57
|
+
// in CODE from artifacts the run already holds (fetched records → register-index screen facts);
|
|
58
|
+
// when the senior leg is absent from the record set, ONE targeted driver fetch closes it — the
|
|
59
|
+
// same code-fetch seam as the screen-gate/V4-2 closures. Zero new provider calls to IDENTIFY the
|
|
60
|
+
// senior leg; worst case one redirect-fetch per verdict-driving finding, steady-state zero once
|
|
61
|
+
// the digest prompt redirect lands the senior leg first. Single-leg clusters are trivially
|
|
62
|
+
// satisfied (their one fetched leg IS the senior right) — the guarantee targets multi-leg owners.
|
|
63
|
+
ctx.seniorRights = null;
|
|
64
|
+
// D1 fail-closed — record whether the live arm below OWES the receipt: the arming condition
|
|
65
|
+
// (frozen framework + v4 findings) is flagged the moment it is established, so a closure that
|
|
66
|
+
// throws AFTER arming still surfaces in predelivery-lint as expected-but-absent (before D1 a
|
|
67
|
+
// crashed closure left no rows and the lint's presence-gated check silently passed). The
|
|
68
|
+
// replay harness never sets the flag — archived runs never grow the failure.
|
|
69
|
+
ctx.seniorRightsExpected = false;
|
|
70
|
+
if (ctx.framework) {
|
|
71
|
+
try {
|
|
72
|
+
const srDoc = existsSync(P.findings) ? parseFindingsJsonLenient(readFileSync(P.findings, "utf8")) : null;
|
|
73
|
+
if (srDoc && (srDoc.schemaVersion ?? 1) >= 4 && srDoc.findings?.length) {
|
|
74
|
+
ctx.seniorRightsExpected = true;
|
|
75
|
+
const driving = verdictDrivingFindings(srDoc.findings, ctx.framework);
|
|
76
|
+
const indexByUri = new Map();
|
|
77
|
+
try {
|
|
78
|
+
const band = JSON.parse(readFileSync(P.registerNamedBand, "utf8"));
|
|
79
|
+
for (const r of band?.enumerated ?? []) {
|
|
80
|
+
const uri = String(r?.record_id ?? "").toLowerCase();
|
|
81
|
+
if (uri) indexByUri.set(uri, { applicationDate: r?.screen?.applicationDate, registrationDate: r?.screen?.registrationDate,
|
|
82
|
+
status: r?.screen?.status ?? r?.status, live_status: r?.screen?.live_status });
|
|
83
|
+
}
|
|
84
|
+
} catch { /* no merged band (legacy run) — fetched-record facts alone rank */ }
|
|
85
|
+
const srPrefix = `clearance-${run.slug}-${run.codename}-`;
|
|
86
|
+
let srRecords = assembleRunRecords(run.runDir, srPrefix).records;
|
|
87
|
+
const srFetcher = opts.recordFetcher ?? defaultRecordFetcher;
|
|
88
|
+
const srLedger = ctx.repairLedger ?? (ctx.repairLedger = createRepairLedger(run.runDir, { log: (o) => runLog(run.runDir, o) }));
|
|
89
|
+
const rows = [];
|
|
90
|
+
for (const f of driving) {
|
|
91
|
+
const regs = f?.owner?.registrations ?? [];
|
|
92
|
+
if (regs.length < 2) { rows.push({ ordinal: f.ordinal, mark: f.mark, applicable: false, reason: regs.length ? "single leg — seniority trivial" : "no register legs (use/marketplace evidence path)" }); continue; }
|
|
93
|
+
const { senior, unrankable, excluded } = rankClusterLegs(regs, indexByUri, srRecords);
|
|
94
|
+
if (!senior) { rows.push({ ordinal: f.ordinal, mark: f.mark, applicable: true, seniorUri: null, verified: false, unrankable, excludedDead: excluded.length }); continue; }
|
|
95
|
+
let verified = srRecords.has(senior.uri);
|
|
96
|
+
let fetchFailureCause = null;
|
|
97
|
+
// — ONE ceiling, named once and read by BOTH ends. A literal repeated at the record site is a
|
|
98
|
+
// second statement of the same rule, and two ends stating the same rule is how they drift apart.
|
|
99
|
+
const seniorFetchMax = 1;
|
|
100
|
+
if (!verified && srLedger.canAttempt("senior-right-fetch", senior.uri, { max: seniorFetchMax })) {
|
|
101
|
+
note(`senior-right closure: fetching the SENIOR leg ${senior.uri} for "${f.mark}" (the verified basis must be the senior right, never an arbitrary leg)`);
|
|
102
|
+
let outcome = "failed";
|
|
103
|
+
try {
|
|
104
|
+
const rf = await srFetcher(senior.uri, { agentId: agent, sessionKey: `${srPrefix}senior-right`, recordLog: runRecordLogPath(run.runDir) });
|
|
105
|
+
outcome = rf?.ok ? "ok" : `failed: ${String(rf?.cause ?? "unknown").slice(0, 140)}`;
|
|
106
|
+
if (!rf?.ok) fetchFailureCause = String(rf?.cause ?? "unreachable").slice(0, 200);
|
|
107
|
+
} catch (err) { outcome = `threw: ${String(err?.message ?? err).slice(0, 140)}`; fetchFailureCause = String(err?.message ?? err).slice(0, 200); }
|
|
108
|
+
srLedger.record("senior-right-fetch", senior.uri, outcome, { max: seniorFetchMax });
|
|
109
|
+
srRecords = assembleRunRecords(run.runDir, srPrefix).records;
|
|
110
|
+
verified = srRecords.has(senior.uri);
|
|
111
|
+
} else if (!verified) {
|
|
112
|
+
fetchFailureCause = "fetch budget exhausted on a prior attempt";
|
|
113
|
+
}
|
|
114
|
+
rows.push({ ordinal: f.ordinal, mark: f.mark, applicable: true, seniorUri: senior.uri, rankedFrom: senior.source, verified, ...(fetchFailureCause ? { fetchFailureCause } : {}), excludedDead: excluded.length });
|
|
115
|
+
}
|
|
116
|
+
ctx.seniorRights = { schema_version: 1, policy: UNREACHABLE_SENIOR_POLICY, rows };
|
|
117
|
+
writeFileSync(paths(run.runDir).seniorRights, JSON.stringify(ctx.seniorRights, null, 2) + "\n");
|
|
118
|
+
runLog(run.runDir, { event: "senior-rights", driving: driving.length, applicable: rows.filter((r) => r.applicable).length,
|
|
119
|
+
verified: rows.filter((r) => r.verified).length, open: rows.filter((r) => r.applicable && !r.verified).length });
|
|
120
|
+
}
|
|
121
|
+
} catch (e) {
|
|
122
|
+
note(`senior-right closure skipped (${String(e?.message ?? e).slice(0, 100)}) — the render/lint surfaces stay code-owned either way`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// The register's own opposition windows reach the findings BEFORE any deadline judgment (the bands
|
|
127
|
+
// are settled by now; the corrective ladder above re-emitted findings last).
|
|
128
|
+
enrichFindingDeadlines(P, run.runDir, note);
|
|
129
|
+
|
|
130
|
+
// ── P2-A pre-verdict floor: the reconciliation's hard discrepancy list ─────────────────────────
|
|
131
|
+
// screened-live dominant-element candidates ∖ endings is read here as it always was, and it no longer THROWS:
|
|
132
|
+
// the owner's ruling of 2026-10-19 that a run is never held replaces the Round-2 rule that this one class never
|
|
133
|
+
// ships. The run first recovers what it can in-run (the digest seam's followups; placement assessing late
|
|
134
|
+
// evidence before the writer); whatever is still unended ships NAMED, through the terminal guards' deliver-and-clamp
|
|
135
|
+
// (`clampOnTheRecallGate`, beside the floor duty's clamp below), never as a run that delivers nothing.
|
|
136
|
+
|
|
137
|
+
// ── — THE TERMINAL GUARDS DELIVER AND CLAMP; THEY DO NOT WITHHOLD ───────────
|
|
138
|
+
//
|
|
139
|
+
// Ruling, 2026-08-27, verbatim intent: **reports always ship**. When a terminal guard finds
|
|
140
|
+
// the report incomplete at delivery, the engine sends it with the gap patched conservatively and
|
|
141
|
+
// the defect named in the run record. It never withholds.
|
|
142
|
+
//
|
|
143
|
+
// The two checks below USED TO THROW. Both were right about the defect and wrong about the remedy:
|
|
144
|
+
// a guard that stops a report marks where a fix is missing, it is not itself the fix. The cost was
|
|
145
|
+
// measured rather than argued — a live clearance run died at delivery after 5.55 hours because the
|
|
146
|
+
// floor duty found ONE undischarged record, and the client received nothing at all instead of a
|
|
147
|
+
// report naming one gap.
|
|
148
|
+
//
|
|
149
|
+
// NOTHING NEW IS BUILT HERE. `clampReasons`/`clampClauses`/`clampKinds` and the CLEAR→CONDITIONAL
|
|
150
|
+
// clamp already run twenty lines below this point for the coverage floor; these declarations simply
|
|
151
|
+
// move ABOVE the two checks so both can reach them. The conversion is a routing change.
|
|
152
|
+
runState.clampReasons = []; // A2/D1 — persisted below
|
|
153
|
+
let clampClauses = [];
|
|
154
|
+
let clampKinds = {};
|
|
155
|
+
// — which clause texts came from a TERMINAL GUARD. The lede question: a guard's
|
|
156
|
+
// disclosure must not silently outrank the opinion's own condition clauses just because the guards
|
|
157
|
+
// run earlier in this function. The sidecar write sorts guard clauses AFTER the opinion's, stated
|
|
158
|
+
// there; this set is how it tells them apart without a parallel index to keep aligned.
|
|
159
|
+
const guardClauses = new Set();
|
|
160
|
+
// THE ACCEPTED ASSESSMENT: the result the review reached, before any guard or floor clamped it. It moves with the
|
|
161
|
+
// review alone (the degenerate re-ask, a late review that is harsher), and a gap a guard judged again finds closed is
|
|
162
|
+
// withdrawn against it (ruled 2026-10-19).
|
|
163
|
+
runState.assessed = runState.verdict;
|
|
164
|
+
runState.restoredClear = false; // a closed gap took this run back to CLEAR, so a later writer's judgment meets the floor again
|
|
165
|
+
// THE REASONS THE RECORD'S OWN ACTIONS PUT IN THE LIST, by the floor's legal-actions arm, so the list can follow the
|
|
166
|
+
// record when a repair in the delivery check rewrites, withdraws or adds a step (conditionsFollowingTheRecord).
|
|
167
|
+
let recordConditionReasons = new Set();
|
|
168
|
+
// WHAT A WITHDRAWAL OF THOSE STEPS NEEDS TO GIVE THE REVIEW'S CLEAR BACK (verdictWhenTheStepsAreWithdrawn): that the
|
|
169
|
+
// steps raised the result, that none was ever dropped as unreadable, when a readable record last held none of them,
|
|
170
|
+
// and when a correction in the delivery check was last rejected.
|
|
171
|
+
let stepsRaisedTheResult = false;
|
|
172
|
+
let stepsUnreadable = false;
|
|
173
|
+
let stepsWithdrawnAt = null;
|
|
174
|
+
runState.correctionRejectedAt = null;
|
|
175
|
+
const DROPPED_CONDITIONS_REASON = "a forward legal step this opinion named could not be recorded, so the conditions listed here are incomplete";
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Deliver, clamp conservatively, and name the defect in the run record.
|
|
179
|
+
*
|
|
180
|
+
* CONSERVATIVE means one direction only: CLEAR becomes CONDITIONAL. A verdict already at
|
|
181
|
+
* CONDITIONAL or BLOCKING is never relaxed — a clamp may add caution and may never remove it.
|
|
182
|
+
*
|
|
183
|
+
* The defect goes to the RUN RECORD (`runLog`) as well as the reader-facing note, because the R2
|
|
184
|
+
* scorer keys on the run record and this is what preserves its reads: what used to be a terminal
|
|
185
|
+
* failure event is now a delivered-with-defect event, and both are visible to the same consumer.
|
|
186
|
+
*/
|
|
187
|
+
// THE DECISION IS `terminalClampDecision`, CALLED NOT COPIED — it lives in terminal-clamp.mjs so
|
|
188
|
+
// the arms can drive it, for the reason floor-duty.mjs states about its own predicate: inline, it
|
|
189
|
+
// could only be pinned by source text, and a source-text pin cannot tell an armed check from one
|
|
190
|
+
// somebody disarmed while leaving its words in place. This closure is the wiring: run record, note,
|
|
191
|
+
// clamp lists, status. The judgement is all in the module.
|
|
192
|
+
const deliverAndClamp = ({ event, defect, reason, clause, detail = {}, again = false, statedElsewhere = false }) => {
|
|
193
|
+
// A GUARD JUDGED AGAIN in this run says nothing new when its judgment is unchanged, and otherwise replaces its
|
|
194
|
+
// earlier clause of the same kind, so a record is never counted twice and no count stands from an earlier pass.
|
|
195
|
+
if (again && runState.clampReasons.includes(String(reason ?? "").trim())) return;
|
|
196
|
+
if (again) replaceClauses(String(defect ?? "").split(":")[0]);
|
|
197
|
+
// — reason and clause are SEPARATE inputs now: the run record and the ops note keep
|
|
198
|
+
// the token sentence; the clause list (which riskStatement renders into the client's Verdict row)
|
|
199
|
+
// receives only the reader's sentence. terminalClampDecision refuses a fused clause by shape.
|
|
200
|
+
const d = terminalClampDecision({ verdict: runState.verdict, defect, reason, clause, detail });
|
|
201
|
+
runLog(run.runDir, { event, ...d.record });
|
|
202
|
+
note(d.reason);
|
|
203
|
+
// A gap stated in another entry's sentence keeps its reason for the run record, and its clause is that sentence's.
|
|
204
|
+
const stored = statedElsewhere ? null : d.clause;
|
|
205
|
+
if (!runState.clampReasons.includes(d.reason)) { clampClauses.push(stored); runState.clampReasons.push(d.reason); guardClauses.add(stored); }
|
|
206
|
+
if (d.clamped) {
|
|
207
|
+
runLog(run.runDir, { event: "terminal-guard-clamp", defect: d.record.defect, from: runState.verdict, to: d.verdict });
|
|
208
|
+
runState.verdict = d.verdict;
|
|
209
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// A CLAUSE JUDGED AGAIN REPLACES THE ONE IT REPEATS. A guard judged a second time in this run, after a repeat or a
|
|
214
|
+
// re-run, withdraws its earlier clause of the same kind before it states the current one, so a record is never
|
|
215
|
+
// counted twice and a count never stands from an earlier judgment. Returns how many entries it withdrew.
|
|
216
|
+
const replaceClauses = (token, { event = "guard-clause-replaced" } = {}) => {
|
|
217
|
+
const w = withdrawByToken(runState.clampReasons, clampClauses, guardClauses, token);
|
|
218
|
+
if (!w.withdrawn) return 0;
|
|
219
|
+
runState.clampReasons = w.reasons;
|
|
220
|
+
clampClauses = w.clauses;
|
|
221
|
+
runLog(run.runDir, { event, token, withdrawn: w.withdrawn });
|
|
222
|
+
return w.withdrawn;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// A GAP JUDGED AGAIN AND POSITIVELY CLOSED takes its own clause with it, and the result is recomputed from the
|
|
226
|
+
// accepted assessment and the conditions still standing (ruled 2026-10-19). Only a CONDITIONAL that this run's
|
|
227
|
+
// guards alone made goes back to CLEAR, and that CLEAR then meets the same deliver-conditional floor any CLEAR meets.
|
|
228
|
+
// A gap whose account is absent, unreadable or not computable is not closed: its clause stands.
|
|
229
|
+
const withdrawClosedGap = (token) => {
|
|
230
|
+
if (!replaceClauses(token, { event: "guard-gap-closed" })) return;
|
|
231
|
+
const now = verdictWithoutTheClosedGap({ verdict: runState.verdict, assessed: runState.assessed, reasons: runState.clampReasons });
|
|
232
|
+
if (now === runState.verdict) return;
|
|
233
|
+
runLog(run.runDir, { event: "verdict-recomputed-gap-closed", token, from: runState.verdict, to: now });
|
|
234
|
+
note(`the ${token.split("_")[0]} gap this run named is closed, and nothing else conditions the result — ${runState.verdict} goes back to ${now}, the result the review reached`);
|
|
235
|
+
runState.verdict = now;
|
|
236
|
+
runState.restoredClear = now === "CLEAR";
|
|
237
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
238
|
+
applyCoverageFloor(); // the floor any CLEAR meets: the opinion's forward actions, the coverage gaps
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// THE RECALL GATE, DELIVERED AND CLAMPED (the owner's ruling of 2026-10-19: a run is never held). A retrieved record still
|
|
242
|
+
// ending nowhere a reader can see after the run's recovery ships named, in the approved sentence for the same state,
|
|
243
|
+
// counted in records out of the records the gate weighed. A record another clause already names (the writer's duty,
|
|
244
|
+
// the floor) is left to it, so no record is counted twice. Returns the count it clamped on, or 0.
|
|
245
|
+
// THE RECALL GATE'S GAP AS IT STANDS, judged and not yet clamped, so the writer's duty can be stated with it.
|
|
246
|
+
const recallGapNow = (duty = null) => {
|
|
247
|
+
const rec = safeReadJson(P.recallReconciliation);
|
|
248
|
+
const computable = rec?.computable === true;
|
|
249
|
+
// A record the writer's duty or the floor's clamp already names is left to that clause: one record, one sentence.
|
|
250
|
+
// The floor's rows count only where its clamp fires, so a record is never left unnamed by both.
|
|
251
|
+
const floorNames = floorDutyBlock(safeReadJson(P.floorDuty), { armed: floorDutyArmed(run.runDir) })
|
|
252
|
+
? (safeReadJson(P.floorDuty)?.rows ?? []).filter((r) => r?.disposition !== "accounted").map((r) => String(r?.record_id ?? "").toLowerCase())
|
|
253
|
+
: [];
|
|
254
|
+
const alreadyNamed = new Set([...(duty?.computable === true ? duty.unaccounted : []).map((u) => String(u?.uri ?? "").toLowerCase()), ...floorNames]);
|
|
255
|
+
// A RECORD A REFUSED MERGE LEFT OUT IS UNREAD, and it is counted here, in the same sentence, out of a total that
|
|
256
|
+
// includes it: the band could not take it without passing the size its readers can be dispatched over.
|
|
257
|
+
const left = refusedRecordsLeftOut(P);
|
|
258
|
+
// A RECORD NO PLACEMENT PASS READ, and that the report does not address, is counted in the same sentence: the band
|
|
259
|
+
// gained it after placement's last pass, and the pass that would have assessed it did not complete.
|
|
260
|
+
const late = lateRecordsUnaddressed(P, alreadyNamed);
|
|
261
|
+
const unended = (computable ? rec.unended ?? [] : []).filter((u) => !(u.candidate_records ?? [u.record_id])
|
|
262
|
+
.some((x) => alreadyNamed.has(String(x).toLowerCase())));
|
|
263
|
+
const weighedIds = new Set(unended.flatMap((u) => u.candidate_records ?? [u.record_id]).map((x) => String(x).toLowerCase()));
|
|
264
|
+
const records = [...new Set([...weighedIds, ...left, ...late])];
|
|
265
|
+
// Out of the records the gate weighed or, where it could weigh none, the records the band holds; and the records
|
|
266
|
+
// left out besides. A late record outside the records the gate weighed is added to the total; where the gate
|
|
267
|
+
// weighed none, the band's count already holds it.
|
|
268
|
+
const base = computable ? Number(rec.totals?.candidates ?? 0) : (safeReadJson(P.registerNamedBand)?.enumerated ?? []).length;
|
|
269
|
+
const weighed = base + left.length + (computable ? late.filter((id) => !weighedIds.has(id)).length : 0);
|
|
270
|
+
// The same population by id, where the gate kept it: what a sentence stated with the writer's duty counts once.
|
|
271
|
+
const population = computable
|
|
272
|
+
? (Array.isArray(rec.candidate_ids) ? [...rec.candidate_ids, ...left, ...late] : null)
|
|
273
|
+
: [...(safeReadJson(P.registerNamedBand)?.enumerated ?? []).map((r) => String(r?.record_id ?? "").toLowerCase()), ...left];
|
|
274
|
+
return { rec, computable, left, late, unended, records, base, weighed, population };
|
|
275
|
+
};
|
|
276
|
+
// THE RECALL GATE, DELIVERED AND CLAMPED (the owner's ruling of 2026-10-19: a run is never held). A retrieved record still
|
|
277
|
+
// ending nowhere a reader can see after the run's recovery ships named, in the approved sentence for the same state,
|
|
278
|
+
// counted in records out of the records the gate weighed. A record another clause already names (the writer's duty,
|
|
279
|
+
// the floor) is left to it, so no record is counted twice. Where the writer's duty names records too, the one sentence
|
|
280
|
+
// is the duty's, stated with these (`joint`). Returns the count it clamped on, or 0.
|
|
281
|
+
const clampOnTheRecallGate = (duty = null, { again = false, gap = recallGapNow(duty), joint = null } = {}) => {
|
|
282
|
+
const { rec, computable, left, late, unended, records, base, weighed } = gap;
|
|
283
|
+
if (!left.length && !late.length && (!computable || !((rec.totals?.unended ?? 0) > 0))) {
|
|
284
|
+
if (again && gapPositivelyClosed("recall_reconciliation_unended", { recall: rec, leftOut: [...left, ...late] })) withdrawClosedGap("recall_reconciliation_unended");
|
|
285
|
+
return 0;
|
|
286
|
+
}
|
|
287
|
+
// Every record the gate would name is named by a clause standing now: its own earlier clause goes, so the record
|
|
288
|
+
// is counted once. The gap is not closed, and the result is not recomputed.
|
|
289
|
+
if (again && !records.length && unended.length < (rec?.unended ?? []).length) replaceClauses("recall_reconciliation_unended", { event: "guard-clause-named-elsewhere" });
|
|
290
|
+
if (!records.length || !(weighed > 0)) return 0;
|
|
291
|
+
const sample = [...unended.slice(0, 4).map((u) => `${u.mark_text} (${u.record_id})`), ...left.slice(0, 2), ...late.slice(0, 2)].join("; ");
|
|
292
|
+
deliverAndClamp({
|
|
293
|
+
event: "recall-reconciliation-unended-delivered",
|
|
294
|
+
defect: `recall_reconciliation_unended:${records.length}`,
|
|
295
|
+
detail: { positions: unended.length, records: records.length, candidates: base, refused: left.length, late: late.length, ...(joint ? { stated_with_duty: joint } : {}) },
|
|
296
|
+
reason: `recall_reconciliation_unended:${records.length} of ${weighed} record(s) — retrieved and screened in-scope-live on the dominant element but ending nowhere a reader can see (no finding row, no drop row, no counted crowd ruling) after the run's recovery${left.length ? `, ${left.length} of them found by a unit's re-run and left out of a band its readers could not have been dispatched over` : ""}${late.length ? `, ${late.length} of them reaching the band after placement's last pass, whose pass to assess them did not complete` : ""}: ${sample}. The report ships with these named rather than being withheld.${joint ? ` Stated with the writer's duty, once, as ${joint.n} of ${joint.m} record(s).` : ""}`,
|
|
297
|
+
again,
|
|
298
|
+
clause: clauseForDefect("recall_reconciliation_unended", records.length, weighed),
|
|
299
|
+
statedElsewhere: Boolean(joint),
|
|
300
|
+
});
|
|
301
|
+
return records.length;
|
|
302
|
+
};
|
|
303
|
+
// ── — THE DECLINATION DUTY, CHECKED AGAINST THE DELIVERED DOCUMENT ────────────────────────
|
|
304
|
+
//
|
|
305
|
+
// A SECOND NET OVER ONE REACHABLE PATH, and it exists because I argued it could not fire and was
|
|
306
|
+
// wrong. The acceptance boundary refuses a call that leaves a carried record with no exit, and the
|
|
307
|
+
// argument was that nothing could then reach delivery unaccounted. The corrective pass is the state
|
|
308
|
+
// that enumeration missed: `prepareDeclinationSpec` runs again before it over a surface that can
|
|
309
|
+
// have grown, so it is ordered against a LARGER owed set; if that call is refused,
|
|
310
|
+
// `rollbackCorrectivePass` restores the pre-corrective findings and — by T3b's ruling,
|
|
311
|
+
// deliberately — the run DELIVERS. What ships then satisfied the OLD owed set, and no acceptance
|
|
312
|
+
// boundary ever saw a call about the records added since, because the only call ordered against them
|
|
313
|
+
// was the one that was refused.
|
|
314
|
+
//
|
|
315
|
+
// JUDGED AGAIN after the delivery check repeats placement or re-runs the writer, with `again`: a gap that remains
|
|
316
|
+
// replaces its earlier clause with the current count, and a gap positively closed withdraws it (withdrawClosedGap).
|
|
317
|
+
//
|
|
318
|
+
// NO ERA STAMP, and it needs none: an archived run carries no declination spec, so `owed` is null,
|
|
319
|
+
// the reconcile is `computable:false` and this never blocks. Archive compatibility by construction.
|
|
320
|
+
const clampOnTheWritersDuty = ({ again = false } = {}) => {
|
|
321
|
+
const duty = synthesisDutyForRun(run.runDir);
|
|
322
|
+
// THE TWO GAPS STATED ONCE when both name records: the approved sentence, with each record counted once out of the
|
|
323
|
+
// records either required to be assessed (ruled 2026-10-19). The run record keeps each gap's own counts.
|
|
324
|
+
const gap = recallGapNow(duty);
|
|
325
|
+
// THE DUTY IS THE ENTRY'S, AND THE READER IS TOLD ITS RECORDS: every record of each entry left unaccounted, out of
|
|
326
|
+
// the records the owed entries hold (a duty with no record counts is a row per record, as before).
|
|
327
|
+
const dutyIds = duty?.computable === true ? duty.unaccounted.flatMap((u) => (Array.isArray(u.uris) ? u.uris : [u.uri])) : [];
|
|
328
|
+
const recordsOpen = duty?.records?.unaccounted ?? dutyIds.length;
|
|
329
|
+
const recordsOwed = duty?.records?.owed ?? duty?.totals?.owed;
|
|
330
|
+
const joint = duty?.computable === true && duty.unaccounted.length
|
|
331
|
+
? jointUnaccounted({ dutyIds, owedIds: owedUrisFor(run.runDir), recallIds: gap.records, weighedIds: gap.population })
|
|
332
|
+
: null;
|
|
333
|
+
if (duty?.computable === true && duty.unaccounted.length) {
|
|
334
|
+
const sample = duty.unaccounted.slice(0, 4).map((u) => `${u.mark ? `${u.mark} ` : ""}(${u.uri})`).join("; ");
|
|
335
|
+
// DELIVERS AND CLAMPS. It used to throw. The defect is real and stays
|
|
336
|
+
// named — a record the run judged worth a reader's attention reached the document unaccounted —
|
|
337
|
+
// but naming it to nobody was the worse outcome of the two.
|
|
338
|
+
deliverAndClamp({
|
|
339
|
+
event: "synthesis-duty-undischarged",
|
|
340
|
+
defect: `synthesis_unaccounted_delivered:${recordsOpen}`,
|
|
341
|
+
detail: { unaccounted: recordsOpen, owed: recordsOwed, uris: dutyIds.slice(0, 6) },
|
|
342
|
+
reason: `synthesis_unaccounted_delivered:${recordsOpen} of ${recordsOwed} record(s) reached the findings surface and the delivered document accounts for none of them — neither a finding that names them nor a declination with a ground: ${sample}${duty.unaccounted.length > 4 ? " …" : ""}. The report ships with this named rather than being withheld; these records are open points a reader must weigh.${joint ? ` Stated with the recall gate's records, once, as ${joint.n} of ${joint.m} record(s).` : ""}`,
|
|
343
|
+
again,
|
|
344
|
+
// — the READER's sentence: what is open, in a lawyer's nouns. Counts survive;
|
|
345
|
+
// the token, the record ids and the engine's nouns stay in `reason` and the run record.
|
|
346
|
+
// COMPOSED BY THE AUTHORITY, NOT SPELLED HERE. The same sentence has to be reachable from a
|
|
347
|
+
// run that stored no clause, where these two objects are long gone and only the reason's own
|
|
348
|
+
// counts survive; `terminal-clamp.mjs` composes it from the counts either way, so the fresh
|
|
349
|
+
// run and the republished archive cannot drift apart.
|
|
350
|
+
clause: joint ? clauseForDefect("synthesis_unaccounted_delivered", joint.n, joint.m)
|
|
351
|
+
: clauseForDefect("synthesis_unaccounted_delivered", recordsOpen, recordsOwed),
|
|
352
|
+
});
|
|
353
|
+
} else if (again && gapPositivelyClosed("synthesis_unaccounted_delivered", { duty })) withdrawClosedGap("synthesis_unaccounted_delivered");
|
|
354
|
+
const recall = clampOnTheRecallGate(duty, { again, gap, joint }); // the recall gate's gap, beside the writer's duty
|
|
355
|
+
return { duty, recall };
|
|
356
|
+
};
|
|
357
|
+
// ── — THE FLOOR DUTY, DISCLOSED AND CLAMPED AT DELIVERY (it BLOCKED until) ───
|
|
358
|
+
//
|
|
359
|
+
// The floors are placement-inquiry's one UNCAPPED obligation — every live in-class identical or
|
|
360
|
+
// near-identical record, listed individually — and the duty has been measured and never enforced.
|
|
361
|
+
// Measured on two delivered runs before it was even derived: 45 of 207 floors on one and 99 of 225
|
|
362
|
+
// on the next never reached the placement form, every one a LIVE filing.
|
|
363
|
+
//
|
|
364
|
+
// ARMED BY THE STAMP, NOT BY THE ARTIFACT'S PRESENCE. Across the 24 run directories on the test box,
|
|
365
|
+
// 19 carry no floor-duty artifact at all — and on this box "absent" means a knockout run far more
|
|
366
|
+
// often than an old one, so absence cannot be read as either "clean" or "old". The stamp is written
|
|
367
|
+
// only by a placement pass that actually ran under the code carrying the order.
|
|
368
|
+
//
|
|
369
|
+
// IT COUNTS THE SEAT'S OWN SHARE. A floor row the band gave no record id is undischarged and
|
|
370
|
+
// UNANSWERABLE — no seat behaviour could have closed it, and the repair it implies can be performed
|
|
371
|
+
// by nobody. Blocking on it would fail a run for a band defect under a rule about seat behaviour, so
|
|
372
|
+
// it is disclosed in the message and excluded from the count that blocks. That is a stated limit,
|
|
373
|
+
// not an oversight: if the unanswerable count is ever the large one, it wants its own issue against
|
|
374
|
+
// the band rather than a wider floor here.
|
|
375
|
+
//
|
|
376
|
+
// NO REPAIR RUNG, deliberately and on a measurement (ruling relayed 2026-08-27). Every
|
|
377
|
+
// registered repair composer belongs to another stage; placement has none, and building one is a
|
|
378
|
+
// larger piece of work than this floor. The blast radius said it could wait: on the day this was
|
|
379
|
+
// written today's run discharged all 60 of its floors, and the only two runs with undischarged rows
|
|
380
|
+
// carried 5 and 9 out of 222 and 352. A rung is a follow-up, never a precondition.
|
|
381
|
+
// THE FLOOR DUTY'S CLAMP, callable: applied where the terminal checks run, and again to a placement pass the
|
|
382
|
+
// delivery gate repeats, whose account the report is then rebuilt from. Returns the block it clamped on, or null.
|
|
383
|
+
const clampOnTheFloorDuty = ({ again = false } = {}) => {
|
|
384
|
+
// THE PREDICATE IS `floorDutyBlock`, called not copied — it lives in floor-duty.mjs so the arms can
|
|
385
|
+
// DRIVE it. Inline here it could only be pinned by source text, and a source-text pin cannot tell
|
|
386
|
+
// an armed check from one somebody disarmed while leaving its words in place.
|
|
387
|
+
const block = floorDutyBlock(safeReadJson(P.floorDuty), { armed: floorDutyArmed(run.runDir) });
|
|
388
|
+
if (block) {
|
|
389
|
+
// DELIVERS AND CLAMPS. This threw until a live clearance run died at
|
|
390
|
+
// delivery after 5.55 hours on ONE undischarged floor row — the guard's first real catch,
|
|
391
|
+
// working exactly as built, and the client received nothing instead of a report naming one gap.
|
|
392
|
+
// The era stamp still gates it: `floorDutyArmed` means a placement pass ran under the code
|
|
393
|
+
// carrying the order, so an archived run neither blocks nor is now accused of a defect.
|
|
394
|
+
deliverAndClamp({
|
|
395
|
+
event: "floor-duty-undischarged",
|
|
396
|
+
defect: `floor_duty_undischarged:${block.undischarged}`,
|
|
397
|
+
detail: { undischarged: block.undischarged, floors: block.floors, named_without_ground: block.named_without_ground ?? 0, unanswerable: block.unanswerable ?? 0 },
|
|
398
|
+
reason: `floor_duty_undischarged:${block.undischarged} of ${block.floors} floor row(s) — every floor is a LIVE in-class identical or near-identical record and the duty is uncapped: each is placed at any tier, or named by its record id with a one-line ground. These came back neither: ${block.sample}${block.undischarged > 4 ? " …" : ""}`
|
|
399
|
+
+ `${block.named_without_ground ? ` (${block.named_without_ground} named with no ground)` : ""}`
|
|
400
|
+
+ `${block.unanswerable ? ` — a further ${block.unanswerable} floor row(s) carry no record id at all and are excluded from this count: the band gave the seat nothing to name, so those are a band defect and not this seat's to answer` : ""}`
|
|
401
|
+
+ `. The report ships with these named rather than being withheld.`,
|
|
402
|
+
again,
|
|
403
|
+
// — the READER's sentence. "Floor row" is an engine noun; what the fact IS for a
|
|
404
|
+
// lawyer: live registrations identical or near-identical to the mark that the report does not
|
|
405
|
+
// individually address. Counts survive; token, ids and engine nouns stay in `reason`.
|
|
406
|
+
// Composed by the authority in `terminal-clamp.mjs` for the reason the sibling site above
|
|
407
|
+
// gives: a republished pre-split run has to reach the same sentence from the counts alone.
|
|
408
|
+
clause: clauseForDefect("floor_duty_undischarged", block.undischarged, block.floors),
|
|
409
|
+
});
|
|
410
|
+
} else if (again && gapPositivelyClosed("floor_duty_undischarged", { floorClosed: floorDutyClosed(safeReadJson(P.floorDuty), { armed: floorDutyArmed(run.runDir) }) }))
|
|
411
|
+
withdrawClosedGap("floor_duty_undischarged");
|
|
412
|
+
return block;
|
|
413
|
+
};
|
|
414
|
+
{
|
|
415
|
+
clampOnTheWritersDuty(); // the writer's duty and, beside it, the recall gate (defined above the floor's block)
|
|
416
|
+
|
|
417
|
+
clampOnTheFloorDuty();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// PR-3 (report voice) — the factual open-state clause per reason, INDEX-ALIGNED with clampReasons.
|
|
421
|
+
// The legalActions arm pushes the author's typed `condition` clause (fact voice) where one exists;
|
|
422
|
+
// the machinery arm's reasons are already factual states. riskStatement prefers these for its
|
|
423
|
+
// "conditional on:" lede; verdict.json.reasons stays the ask texts every other consumer renders.
|
|
424
|
+
// (All three now DECLARED ABOVE the terminal checks — — so those can clamp
|
|
425
|
+
// rather than throw. Nothing about their use here changed.)
|
|
426
|
+
// Extracted into a callable (repair-first A5): the degenerate-reviewer re-ask below can flip a
|
|
427
|
+
// stale BLOCKING to CLEAR — that outcome must pass the SAME deliver-conditional floor, never
|
|
428
|
+
// bypass it because the clamp already ran once.
|
|
429
|
+
const applyCoverageFloor = () => {
|
|
430
|
+
// Each entry is the floors' state, so delivery reads only a floor that threw since the last of these.
|
|
431
|
+
runLog(run.runDir, { event: "verdict-floors-pass" });
|
|
432
|
+
// review fix: the machinery arm below must judge the verdict AS IT ENTERED the floor —
|
|
433
|
+
// when the legalActions arm clamps CLEAR→CONDITIONAL first, the machinery gaps (coverage, frame,
|
|
434
|
+
// screen-gate, senior, registerGap) must still be computed and APPENDED, or a run
|
|
435
|
+
// with both a condition action and an unfinished register slice would disclose only the condition.
|
|
436
|
+
const entryVerdict = runState.verdict;
|
|
437
|
+
// spec 64 — the legalActions arm: the opinion's OWN typed condition actions (findings.json
|
|
438
|
+
// actions[], CONDITION_KINDS) are a verdict input, independent of the machinery clamps below.
|
|
439
|
+
// This is the CLEAR-despite-"consent before filing" fix (copper-causeway / ashen-gantry): the
|
|
440
|
+
// reviewer verdict is QC-flag semantics — once its flags are fixed the recheck legitimately
|
|
441
|
+
// returns CLEAR — so the demanded legal acts must gate HERE, derived from the data the author
|
|
442
|
+
// typed, never from a keyword grep over prose. Applies on CLEAR *and* CONDITIONAL (an already-
|
|
443
|
+
// conditional run gets its conditions RECORDED — never again kinds:{} reasons:[] under a report
|
|
444
|
+
// naming forward acts); BLOCKING stays the fail arm untouched. Never lowers. A parse failure
|
|
445
|
+
// here is noted loudly and rides on (never-kill) — the predelivery verdict-actions-coherence
|
|
446
|
+
// lint re-reads the same data independently and is the second net.
|
|
447
|
+
try {
|
|
448
|
+
if (runState.verdict === "CLEAR" || runState.verdict === "CONDITIONAL") {
|
|
449
|
+
const fdoc = existsSync(P.findings) ? parseFindingsJsonLenient(readFileSync(P.findings, "utf8")) : null;
|
|
450
|
+
const { conditions, conditionClauses } = deriveActionConditions(fdoc?.actions, fdoc?.findings);
|
|
451
|
+
if (conditions.length) {
|
|
452
|
+
const fresh = conditions.filter((c) => !runState.clampReasons.includes(c));
|
|
453
|
+
clampKinds.legalActions = true;
|
|
454
|
+
// pairwise push — clampClauses stays index-aligned with clampReasons across re-entries
|
|
455
|
+
// (the degenerate re-ask re-runs this floor; dedup is by the reason TEXT for both).
|
|
456
|
+
for (const c of fresh) clampClauses.push(conditionClauses[conditions.indexOf(c)] ?? c);
|
|
457
|
+
runState.clampReasons.push(...fresh);
|
|
458
|
+
for (const c of fresh) recordConditionReasons.add(c);
|
|
459
|
+
if (runState.verdict === "CLEAR") {
|
|
460
|
+
runLog(run.runDir, { event: "coverage-floor-clamp", cause: "forward-actions", from: "CLEAR", to: "CONDITIONAL", legalActions: conditions.length });
|
|
461
|
+
note(`deliver-conditional floor: the opinion names ${conditions.length} forward legal action(s) a human must take (${conditions[0].slice(0, 140)}${conditions.length > 1 ? `; +${conditions.length - 1} more` : ""}) — clamping CLEAR→CONDITIONAL (spec 64: the disposition is derived from the findings' named actions).`);
|
|
462
|
+
runState.verdict = "CONDITIONAL";
|
|
463
|
+
stepsRaisedTheResult = true;
|
|
464
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
465
|
+
} else if (fresh.length) {
|
|
466
|
+
runLog(run.runDir, { event: "verdict-conditions-recorded", legalActions: fresh.length });
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// ── — THE CONDITIONS THAT NEVER REACHED THE LIST ──────────────────────────────────────
|
|
470
|
+
//
|
|
471
|
+
// `conditions` above is what SURVIVED the lenient parse. An action that failed validateAction
|
|
472
|
+
// is not in it, and until this arm existed that was the whole defect: one unknown key on a
|
|
473
|
+
// senior-clearance row took a run from CLEAR→CONDITIONAL to CLEAR, because the floor and the
|
|
474
|
+
// sidecar's own coherence check both read the post-quarantine list and were blind to the drop
|
|
475
|
+
// for the same reason. The defect and the relaxation were the same event.
|
|
476
|
+
//
|
|
477
|
+
// The clamp is deliberately NOT a run failure. The lenient path exists to salvage a run whose
|
|
478
|
+
// corrective ladder is spent, and a delivered opinion that says "there are conditions, and one
|
|
479
|
+
// of them could not be stated" is worth more to the reader than no opinion. What it must never
|
|
480
|
+
// do is read as complete — so the reason says INCOMPLETE in the client's own words, and the
|
|
481
|
+
// engine-side detail (ids, defect tokens) rides the note and the log where an engineer reads.
|
|
482
|
+
const droppedConditions = quarantinedConditionRows(fdoc?.actionsQuarantined);
|
|
483
|
+
if (droppedConditions.length) stepsUnreadable = true; // a step nobody can read is never shown withdrawn
|
|
484
|
+
const droppedReason = DROPPED_CONDITIONS_REASON;
|
|
485
|
+
// ONCE, not once per entry. This floor is re-entered — the degenerate re-ask and the delivery
|
|
486
|
+
// block both call it again — so the reason, the clause and the telemetry are guarded by the
|
|
487
|
+
// reason's own presence. An event emitted on every re-entry would inflate any count keyed on
|
|
488
|
+
// it, which is how a log line stops being a measurement.
|
|
489
|
+
if (droppedConditions.length && !runState.clampReasons.includes(droppedReason)) {
|
|
490
|
+
clampKinds.actionsDropped = true;
|
|
491
|
+
clampClauses.push(droppedReason);
|
|
492
|
+
runState.clampReasons.push(droppedReason);
|
|
493
|
+
recordConditionReasons.add(droppedReason);
|
|
494
|
+
runLog(run.runDir, { event: "verdict-conditions-dropped", n: droppedConditions.length,
|
|
495
|
+
ids: droppedConditions.map((q) => q.id), kinds: droppedConditions.map((q) => q.kind),
|
|
496
|
+
errors: droppedConditions.map((q) => String(q.error ?? "").slice(0, 80)) });
|
|
497
|
+
note(`deliver-conditional floor: ${droppedConditions.length} action(s) the opinion typed were dropped by the parser and may have conditioned this result (${droppedConditions.map((q) => `${q.kind ?? "kind-unreadable"}#${q.id ?? "?"}`).join(", ")}) — the verdict cannot be CLEAR over a condition nobody can read.`);
|
|
498
|
+
}
|
|
499
|
+
// The CLAMP is outside that guard on purpose: a re-ask can flip a clamped verdict back to CLEAR,
|
|
500
|
+
// and it must meet this floor again with the reason already recorded.
|
|
501
|
+
if (droppedConditions.length && runState.verdict === "CLEAR") {
|
|
502
|
+
runLog(run.runDir, { event: "coverage-floor-clamp", cause: "dropped-actions", from: "CLEAR", to: "CONDITIONAL", actionsDropped: droppedConditions.length });
|
|
503
|
+
runState.verdict = "CONDITIONAL";
|
|
504
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
} catch (e) { note(`legal-actions floor skipped (${String(e.message).slice(0, 80)}) — never-kill; the predelivery coherence lint is the second net`); }
|
|
508
|
+
// ── — THE RECORDED DOWNGRADE, READ ──────────────────────────────────────────────────────────
|
|
509
|
+
//
|
|
510
|
+
// wrote this record deliberately and wrote it well. Nothing read it. A run whose dictated
|
|
511
|
+
// meaning sweep silently became the legacy spec-less path delivered CLEAN — no clamp, no coverage
|
|
512
|
+
// flag, nothing on the report — while `_driver/common-law-path.json` sat on disk naming the
|
|
513
|
+
// downgrade and the term of the selector that caused it. Being right is not the same as being read.
|
|
514
|
+
//
|
|
515
|
+
// THE LIVE SHAPE THIS CATCHES: a resume of a run with no `_driver/profile.json`. attachProfile
|
|
516
|
+
// stays legacy on a sidecar-less resume (ctx.profile = null, deliberately — retro-minting would
|
|
517
|
+
// apply the identity join to a grid the worker was never dictated), so profile.platforms is 0, the
|
|
518
|
+
// grid spec is never authored, and a variant-carrying non-register-only matter takes the spec-less
|
|
519
|
+
// path. made the OTHER zeroing (a manifest whose variants do not parse) loud; this is the term
|
|
520
|
+
// of the same conjunction that stayed silent.
|
|
521
|
+
//
|
|
522
|
+
// IT SITS IN ITS OWN try, NOT inside the legal-actions block above: that block's catch would
|
|
523
|
+
// swallow this reader whenever deriveActionConditions threw, and a downgrade lost because an
|
|
524
|
+
// unrelated parse failed is the same silence one layer along.
|
|
525
|
+
//
|
|
526
|
+
// The predicate is deliberately narrow — the other decision arms (single-term-grid, register-only)
|
|
527
|
+
// are legitimate paths and must not clamp. The unsplit path is the documented rollback and is NOT
|
|
528
|
+
// a failure; the defect is the silence, so this records and clamps rather than throwing.
|
|
529
|
+
try {
|
|
530
|
+
if (runState.verdict === "CLEAR" || runState.verdict === "CONDITIONAL") {
|
|
531
|
+
let rec = null;
|
|
532
|
+
try { rec = JSON.parse(readFileSync(P.commonLawPath, "utf8")); }
|
|
533
|
+
catch { /* legacy run — the record predates, or this pass never reached the gather */ }
|
|
534
|
+
const down = (rec && rec.path === "unsplit" && rec.reason === "no-grid-spec"
|
|
535
|
+
&& rec.spec_inputs?.registerOnly === false && (rec.spec_inputs?.gridVariants ?? 0) > 0) ? rec : null;
|
|
536
|
+
const clReason = down && `the dictated meaning sweep did not run: ${down.spec_inputs.gridVariants} variant(s) were written for it and no grid spec was authored, so the common-law layer ran on the legacy spec-less path and the unregistered-use coverage is not the coverage the plan dictated`;
|
|
537
|
+
// RECORD ONCE. This floor is re-entered (the degenerate re-ask, the lint repair and the
|
|
538
|
+
// post-consolidation delivery block all call it again), so the reason guards itself by presence
|
|
539
|
+
// — an event emitted per re-entry stops being a measurement.
|
|
540
|
+
if (clReason && !runState.clampReasons.includes(clReason)) {
|
|
541
|
+
clampKinds.commonLawDowngrade = true;
|
|
542
|
+
clampClauses.push(clReason); runState.clampReasons.push(clReason); // machinery reasons ARE factual open-states — clause == reason
|
|
543
|
+
runLog(run.runDir, { event: "common-law-downgrade-clamp", reason: down.reason,
|
|
544
|
+
gridVariants: down.spec_inputs.gridVariants, profilePlatforms: down.spec_inputs.profilePlatforms });
|
|
545
|
+
note(`deliver-conditional floor: ${clReason} — clamping CLEAR→CONDITIONAL so the delivered status carries the gap.`);
|
|
546
|
+
}
|
|
547
|
+
// THE CLAMP IS A SEPARATE `if` ON PURPOSE, exactly as the dropped-conditions clamp below is: a
|
|
548
|
+
// re-ask can flip a clamped verdict back to CLEAR, and it must meet this floor again with the
|
|
549
|
+
// reason ALREADY recorded. Folding these two into one guard would let the second pass skip on
|
|
550
|
+
// the dedup and deliver CLEAR — the precise defect this issue is about.
|
|
551
|
+
if (clReason && runState.verdict === "CLEAR") { runState.verdict = "CONDITIONAL"; writeRunStatus(ctx, signoffPatch(runState.verdict)); }
|
|
552
|
+
}
|
|
553
|
+
} catch (e) {
|
|
554
|
+
note(`common-law downgrade floor skipped (${String(e.message).slice(0, 80)}) — never-kill`);
|
|
555
|
+
// Nothing else would clamp this: the audit workbook names it (degraded-parts.mjs, checks).
|
|
556
|
+
try { runLog(run.runDir, { event: "verdict-floor-failed", floor: "common-law", fail: String(e?.message ?? e).slice(0, 200) }); }
|
|
557
|
+
catch { /* the note above still stands */ }
|
|
558
|
+
}
|
|
559
|
+
if (entryVerdict === "CLEAR") {
|
|
560
|
+
const frameGap = ctx.frameReopenGap === true;
|
|
561
|
+
let frameDeferrals = [];
|
|
562
|
+
try { const rp = paths(run.runDir).frameReopenReceipt; const rec = existsSync(rp) ? JSON.parse(readFileSync(rp, "utf8")) : null; frameDeferrals = Array.isArray(rec?.deferrals) ? rec.deferrals : []; } catch { /* best-effort */ }
|
|
563
|
+
const frameResidual = frameGap || frameDeferrals.length > 0;
|
|
564
|
+
// This arm's producer went live (it had none since the initial port):
|
|
565
|
+
// the unresolved set comes from ctx when THIS session's gate disclosed it, else from the durable
|
|
566
|
+
// sidecar (the resume shape — the gate disclosed, the process died, and this pass reached the
|
|
567
|
+
// floor without re-entering the gate).
|
|
568
|
+
const sgUnresolved = loadScreenGateUnresolved(run.runDir, ctx);
|
|
569
|
+
const screenGateGap = sgUnresolved.length > 0;
|
|
570
|
+
const coverageInsufficient = coverageJudgment.present && coverageJudgment.sufficient === false;
|
|
571
|
+
// WP-receipts W4 — the "clamp" arm of UNREACHABLE_SENIOR_POLICY (OFF by default: the senior lawyer decided
|
|
572
|
+
// open-item, 2026-07-05 — a stated qualification, never a rule-driven verdict change). Built so
|
|
573
|
+
// flipping the policy is one config line, not a code round.
|
|
574
|
+
const seniorGap = UNREACHABLE_SENIOR_POLICY === "clamp"
|
|
575
|
+
&& (ctx.seniorRights?.rows ?? []).some((r) => r.applicable && !r.verified);
|
|
576
|
+
// Unfinished-register clamp (copper-lattice 2026-07-08; ON by default, CLEAROTRON_REGISTER_GAP_CLAMP=0
|
|
577
|
+
// is rollback-only): a MATERIAL register slice that never (fully) ran is an EXECUTION fact, not a
|
|
578
|
+
// sufficiency judgment — the screenGateGap class ("could not examine"), read deterministically from
|
|
579
|
+
// the taint-relabelled ledger + the taint receipt, independent of the LLM's
|
|
580
|
+
// coverage_judgment (whose absent-⇒-sufficient default is the hole this closes). deferred rows only;
|
|
581
|
+
// coverage-limited stays an accepted limit.
|
|
582
|
+
const regGap = process.env.CLEAROTRON_REGISTER_GAP_CLAMP !== "0"
|
|
583
|
+
? decideRegisterGap(loadCoverageLedger(run.runDir).rows, { taintAxes: readActiveTaintAxes(run.runDir) })
|
|
584
|
+
: { gap: false, deferred: [], taintAxes: [] };
|
|
585
|
+
const registerGap = regGap.gap === true;
|
|
586
|
+
// T3 (H4, an owner-approved doctrine flip): the D1 `artifactInvalid`
|
|
587
|
+
// clamp input + kinds.artifact are DELETED — a compromised machine artifact now FAILS the run
|
|
588
|
+
// upstream (deriveNamedBand / the register-digest terminals) instead of shipping a
|
|
589
|
+
// finished-looking CONDITIONAL over unreadable receipts. What remains here are the honest
|
|
590
|
+
// sanctioned clamps: the lawyer's own sufficiency call, a disclosed frame residual, a
|
|
591
|
+
// could-not-examine record, and an unfinished register slice — CONDITIONAL carries
|
|
592
|
+
// lawyer-judged/disclosed residue only.
|
|
593
|
+
if (coverageInsufficient || frameResidual || screenGateGap || seniorGap || registerGap) {
|
|
594
|
+
// THESE SENTENCES REACH A CLIENT AND THEY ARE NOT OURS TO WRITE (owner, 2026-09-17). One of
|
|
595
|
+
// them — the screen-gate line, which says a mark "could not be record_fetched" — carried an
|
|
596
|
+
// engine identifier into the list a client reads as the conditions on their result, by a route
|
|
597
|
+
// `terminalClampDecision` guards and this one did not. A reader's sentence for it was written
|
|
598
|
+
// here and refused: the objection was the class, not the wording. RULED 2026-09-18, design item
|
|
599
|
+
// 25 — cut the clause: it stays in the run record and leaves the client's result entirely, with
|
|
600
|
+
// NOTHING written in its place. That is what the `null` clause below means.
|
|
601
|
+
const reasons = [], clauseOf = new Map(); // run-record reason → the client's clause: the same words, with any engine token taken out
|
|
602
|
+
const machinery = (reason, clause = reason) => { reasons.push(reason); clauseOf.set(reason, clause); };
|
|
603
|
+
if (coverageInsufficient) machinery(`the lawyer judged a material slice not fully cleared: ${coverageJudgment.reason || "register coverage gap"}`);
|
|
604
|
+
// The frame comparison's reason is the engine's account of its own steps: it stays in the run record, and the
|
|
605
|
+
// client's conditions get nothing in its place (ruled 2026-10-13, as the screen-gate line below).
|
|
606
|
+
if (frameGap) machinery("the blind frame-diff flagged a dominant-element omission the reopen pass did not close", null);
|
|
607
|
+
else if (frameDeferrals.length) machinery(`follow-ups left open this run: ${frameDeferrals.map((d) => plainDirective(d.directive)).slice(0, 3).join(", ")}`);
|
|
608
|
+
if (screenGateGap) machinery(`${sgUnresolved.length} in-scope mark(s) dropped on goods could not be record_fetched (unverified): ${sgUnresolved.map((g) => g.mark).join(", ")}`, null); // run record ONLY: no client clause (ruled 2026-09-18)
|
|
609
|
+
if (seniorGap) machinery(`the oldest registration in a verdict-driving family could not be retrieved (policy: clamp): ${(ctx.seniorRights?.rows ?? []).filter((r) => r.applicable && !r.verified).map((r) => r.mark).join(", ")}`);
|
|
610
|
+
if (registerGap) {
|
|
611
|
+
for (const { reason, clause } of registerGapConditions(regGap)) machinery(reason, clause);
|
|
612
|
+
// (the deferred and cut-down register lines: registerGapConditions, at the end of this file)
|
|
613
|
+
}
|
|
614
|
+
// ── THE THIRD CLAMP SITE NAMES ITSELF, AND NAMES WHICH OF ITS SIX INPUTS FIRED ────────────────
|
|
615
|
+
//
|
|
616
|
+
// All three clamp sites emitted this event under one name with the same from/to, distinguishable
|
|
617
|
+
// only by which optional payload key happened to be present. Two of them fired three milliseconds
|
|
618
|
+
// apart on a production run — the first without `frameDeferred`, the second with it — which reads
|
|
619
|
+
// as one decision logged twice. It was two different decisions wearing one name, and a tester
|
|
620
|
+
// reasonably discounted one of them. `cause` makes the event self-describing.
|
|
621
|
+
//
|
|
622
|
+
// THE EVENT NAME IS DELIBERATELY NOT SPLIT. It is a true statement about the effect — the verdict
|
|
623
|
+
// was clamped — and something downstream may already count clamps in aggregate. A discriminator is
|
|
624
|
+
// additive; three names would not be.
|
|
625
|
+
//
|
|
626
|
+
// This site is itself six causes under one name, so it also lists WHICH fired rather than
|
|
627
|
+
// leaving a reader to key on field presence and guess.
|
|
628
|
+
const clampInputs = Object.entries({
|
|
629
|
+
coverageInsufficient, frameGap, frameDeferred: frameDeferrals.length,
|
|
630
|
+
screenGate: screenGateGap ? sgUnresolved.length : 0, seniorRight: seniorGap,
|
|
631
|
+
registerGap,
|
|
632
|
+
}).filter(([, v]) => Boolean(v)).map(([k]) => k);
|
|
633
|
+
runLog(run.runDir, { event: "coverage-floor-clamp", cause: "coverage", causes: clampInputs, from: "CLEAR", to: "CONDITIONAL", coverageInsufficient: coverageInsufficient || undefined, frameGap: frameGap || undefined, frameDeferred: frameDeferrals.length || undefined, screenGate: screenGateGap ? sgUnresolved.length : undefined, seniorRight: seniorGap || undefined, registerGap: registerGap ? { deferred: regGap.deferred.length, taint: regGap.taintAxes.length } : undefined });
|
|
634
|
+
note(`deliver-conditional floor: ${reasons.join("; ")} — clamping CLEAR→CONDITIONAL so the delivered status carries the gap (never withheld, never halted).`);
|
|
635
|
+
runState.verdict = "CONDITIONAL";
|
|
636
|
+
// APPEND (dedup by exact text) — the legalActions arm may already have recorded conditions,
|
|
637
|
+
// and this callable runs more than once (degenerate re-ask, lint repair, post-consolidation).
|
|
638
|
+
const freshMachinery = reasons.filter((r) => !runState.clampReasons.includes(r));
|
|
639
|
+
clampClauses.push(...freshMachinery.map((r) => (clauseOf.has(r) ? clauseOf.get(r) : r))); // the clause is the reason less any engine token; null = the run record's alone
|
|
640
|
+
runState.clampReasons.push(...freshMachinery);
|
|
641
|
+
// The reason KINDS distinguish coverage/frame/screen-gate/senior-right/register residue for the
|
|
642
|
+
// report bound line and the client conditions row (merged — legalActions survives).
|
|
643
|
+
clampKinds = { ...clampKinds, coverage: coverageInsufficient || undefined, frame: frameResidual || undefined, screenGate: screenGateGap || undefined, seniorRight: seniorGap || undefined, registerGap: registerGap || undefined };
|
|
644
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
applyCoverageFloor();
|
|
649
|
+
// A2 / T2 — the delivered verdict + its DERIVED display fields (tier/badge/gauge
|
|
650
|
+
// off the worst live composite) become THE code-carried authority every downstream surface joins
|
|
651
|
+
// (report hero + gauge via driver-owned front-matter, composeEmailHtml, meta.json) instead of
|
|
652
|
+
// each surface re-deriving its own idea of the bound —
|
|
653
|
+
// copper-spire's three-way label contradiction was exactly three surfaces with three authorities.
|
|
654
|
+
// MANDATORY now (was best-effort): the sidecar IS the single authority; a failed write is a run
|
|
655
|
+
// failure, never a silent fallback to divergent labels. Re-invoked after findings consolidation
|
|
656
|
+
// (the delivery block) so the sidecar always reflects the FINAL findings set.
|
|
657
|
+
const composeVerdictSidecar = () => {
|
|
658
|
+
let findingsArr = [], sv = 1, actionsArr = null, actionsDropped = [];
|
|
659
|
+
try {
|
|
660
|
+
const doc = parseFindingsJsonLenient(readFileSync(P.findings, "utf8"));
|
|
661
|
+
findingsArr = doc?.findings ?? [];
|
|
662
|
+
sv = doc?.schemaVersion ?? 1;
|
|
663
|
+
actionsArr = doc?.actions ?? null;
|
|
664
|
+
actionsDropped = quarantinedConditionRows(doc?.actionsQuarantined);
|
|
665
|
+
} catch { /* no findings — derive off none */ }
|
|
666
|
+
// spec 64 — belt-and-braces: the sidecar is THE authority every surface joins; writing CLEAR
|
|
667
|
+
// while the findings carry live condition actions is the exact incoherence the derivation
|
|
668
|
+
// exists to prevent. Fail loud (StageFailure at the call sites) — never write the contradiction.
|
|
669
|
+
const actionConditions = deriveActionConditions(actionsArr, findingsArr).conditions;
|
|
670
|
+
if (runState.verdict === "CLEAR" && actionConditions.length)
|
|
671
|
+
throw new Error(`verdict CLEAR with ${actionConditions.length} live condition action(s) — applyCoverageFloor must re-derive before the sidecar writes`);
|
|
672
|
+
// — AND THE SAME INVARIANT OVER THE ONES THAT WERE DROPPED. This check read the SURVIVING
|
|
673
|
+
// actions, so it was blind to a quarantined condition in exactly the way the floor above was —
|
|
674
|
+
// two independent guards, one blind spot, because both consumed the same lossy parse. A guard
|
|
675
|
+
// that fails the way the thing it guards fails is not a second net.
|
|
676
|
+
if (runState.verdict === "CLEAR" && actionsDropped.length)
|
|
677
|
+
throw new Error(`verdict CLEAR with ${actionsDropped.length} DROPPED condition action(s) (${actionsDropped.map((q) => `${q.kind ?? "kind-unreadable"}#${q.id ?? "?"}`).join(", ")}) — a condition nobody can read is still a condition; applyCoverageFloor must clamp before the sidecar writes`);
|
|
678
|
+
// — A BLOCKING VERDICT CARRIES ITS GROUNDS, OR THIS WRITE REFUSES.
|
|
679
|
+
//
|
|
680
|
+
// `applyCoverageFloor` populates clampReasons/clampKinds on CLEAR and CONDITIONAL only — "BLOCKING
|
|
681
|
+
// stays the fail arm untouched" — so every BLOCKING sidecar shipped `reasons: []` and `kinds: {}`:
|
|
682
|
+
// the decision without its grounds, in the artifact whose entire purpose is carrying them. The prose
|
|
683
|
+
// survived in senior-eye-review.md, so nothing was lost that time; a consumer of verdict.json alone
|
|
684
|
+
// (dashboard, gate, downstream stage) saw an ungrounded BLOCKING.
|
|
685
|
+
//
|
|
686
|
+
// THE GROUNDS WERE ALREADY PARSED. `parseCorrections` is imported by this file and already walks the
|
|
687
|
+
// review for exactly these lines — it is what the corrective pass is handed at :10242. Nothing needed
|
|
688
|
+
// extracting; the two halves simply were never joined. No third copy of that walk is made here, which
|
|
689
|
+
// is the rule verify.mjs states beside `countCitedDefects` ("the line walk is countCitedDefects's,
|
|
690
|
+
// verbatim, so 'a correction line' means the same thing to both").
|
|
691
|
+
//
|
|
692
|
+
// NO CLIENT SURFACE MOVES. `riskStatement` and `bindRecommendation` both return a fixed string on
|
|
693
|
+
// BLOCKING and never read `reasons`; `deriveDisplayVerdict` passes them through to `conditions` and
|
|
694
|
+
// takes tier/badge/gauge from the findings. And post- a BLOCKING run does not reach delivery
|
|
695
|
+
// at all. This changes the record and nothing a client reads.
|
|
696
|
+
//
|
|
697
|
+
// A DEGENERATE REVIEW STILL WRITES A REASON, and this ordering is deliberate: the sidecar is written
|
|
698
|
+
// HERE, before the degenerate-BLOCKING re-ask below gets its one chance to repair a review that cited
|
|
699
|
+
// nothing. Throwing on the empty case would turn a recoverable reviewer defect into a StageFailure
|
|
700
|
+
// that ends the run before the repair it already has. So the empty case states ITSELF as the ground —
|
|
701
|
+
// "the reviewer cited nothing" is a fact about this run, and an empty array is not.
|
|
702
|
+
// LOCAL TO THIS WRITE, never pushed into clampReasons/clampKinds — and that is the whole care in it.
|
|
703
|
+
// `clampReasons` outlives the call, and the degenerate re-ask below can flip this same run to CLEAR
|
|
704
|
+
// and write again. Grounds pushed into the shared array would ride into the CLEAR sidecar as its
|
|
705
|
+
// `reasons`: a verdict claiming conditions it does not have, which is this PR's own defect arriving
|
|
706
|
+
// through its own fix. On every non-BLOCKING verdict these are pass-throughs.
|
|
707
|
+
let blockingGrounds = [];
|
|
708
|
+
let reviewerCited = false;
|
|
709
|
+
if (runState.verdict === "BLOCKING") {
|
|
710
|
+
let cited = [];
|
|
711
|
+
try { cited = parseCorrections(readFileSync(P.seniorEyeReview, "utf8")).map((r) => r.text).filter(Boolean); }
|
|
712
|
+
catch { /* unreadable or absent review — the fallback ground below is the honest record of that */ }
|
|
713
|
+
reviewerCited = cited.length > 0;
|
|
714
|
+
blockingGrounds = (reviewerCited
|
|
715
|
+
? cited.slice(0, 12).map((t) => t.slice(0, 300))
|
|
716
|
+
: ["the reviewer refused to sign and cited no file-anchored defect — a degenerate review, recorded as the ground rather than left as an empty array"]
|
|
717
|
+
).filter((g) => !runState.clampReasons.includes(g));
|
|
718
|
+
}
|
|
719
|
+
// — the lede is the opinion's, by decision: orderClausesForLede (terminal-clamp.mjs)
|
|
720
|
+
// sorts guard clauses after the opinion's condition clauses, reasons reordered in step. The
|
|
721
|
+
// rationale lives on the function so the arms can DRIVE it rather than pin this call site's text.
|
|
722
|
+
const { clauses: orderedClauses, reasons: orderedReasons } = orderClausesForLede(clampClauses, runState.clampReasons, guardClauses);
|
|
723
|
+
const reasonsOut = blockingGrounds.length ? [...orderedReasons, ...blockingGrounds] : orderedReasons;
|
|
724
|
+
// — AND EACH APPENDED GROUND CARRIES AN EXPLICIT NULL CLAUSE, which is what puts it in the
|
|
725
|
+
// run record ALONE. The block above says "no client surface moves", and that was true of the
|
|
726
|
+
// statement and the bound recommendation, both fixed strings on BLOCKING. It was never true of the
|
|
727
|
+
// CONDITIONS LIST: `clientConditions` walks the reasons and prints any reason that has no clause
|
|
728
|
+
// and no engine token, so on a delivered BLOCKING run the reviewer's own cited correction lines
|
|
729
|
+
// printed to the client as their conditions — 8 of the 13 conditions on the run this was measured
|
|
730
|
+
// on (2026-09-20). A stored null is the shipped way to say "recorded, not rendered", and the
|
|
731
|
+
// arrays stay index-aligned because `orderClausesForLede` returns them the same length.
|
|
732
|
+
const clausesOut = blockingGrounds.length
|
|
733
|
+
? [...orderedClauses, ...blockingGrounds.map(() => null)]
|
|
734
|
+
: orderedClauses;
|
|
735
|
+
const kindsOut = runState.verdict === "BLOCKING" ? { ...clampKinds, reviewerCited } : clampKinds;
|
|
736
|
+
// The invariant itself, stated over the value that is WRITTEN rather than over the branch that fills
|
|
737
|
+
// it — a guard that only holds while the code above is remembered is not a guard. Unreachable today
|
|
738
|
+
// by construction, which is the intended shape: a BLOCKING with an empty reasons array is
|
|
739
|
+
// structurally impossible, and any future path that reintroduces one dies here instead of shipping.
|
|
740
|
+
if (runState.verdict === "BLOCKING" && !reasonsOut.length)
|
|
741
|
+
throw new Error("verdict BLOCKING with no reasons — a blocking decision without its grounds; verdict.json is the artifact whose whole purpose is carrying them");
|
|
742
|
+
// doc 50 — a v4 record derives off the run's FROZEN framework (band words); deriveDisplayVerdict
|
|
743
|
+
// fail-louds if banded findings arrive with no manifest (never silently badge a rated matter LOW).
|
|
744
|
+
const derived = deriveDisplayVerdict({ verdict: runState.verdict, reasons: reasonsOut, kinds: kindsOut, findings: findingsArr,
|
|
745
|
+
manifest: sv >= 4 ? ctx.framework : null });
|
|
746
|
+
// spec 64 — THE one risk statement: composed ONCE here (band word + stance clause from the same
|
|
747
|
+
// sidecar fields), consumed verbatim by every surface (index / status / report hero / email /
|
|
748
|
+
// xlsx) so severity and disposition can never contradict across pages. PR-3 (report voice): a
|
|
749
|
+
// CONDITIONAL statement reads "<Tier> — conditional on: <factual open-state> (and N more)." —
|
|
750
|
+
// clampClauses carries the fact-voice clauses; the structured `stance` field is what every
|
|
751
|
+
// consumer keys on (never the statement's wording — the magic-string coupling is retired).
|
|
752
|
+
const statement = riskStatement({ tier: derived.tier, verdict: runState.verdict, reasons: reasonsOut, clauses: clausesOut,
|
|
753
|
+
basis: isRegisterOnly(ctx.searchPolicy) ? "register-only" : null });
|
|
754
|
+
return { derived, statement, doc: { ts: new Date().toISOString(), verdict: runState.verdict, reasons: reasonsOut, clauses: clausesOut, kinds: kindsOut,
|
|
755
|
+
tier: derived.tier, badge: derived.badge, gaugeIndex: derived.gaugeIndex, maxComposite: derived.maxComposite,
|
|
756
|
+
band: derived.band ?? null, statement, stance: verdictStance(runState.verdict) } };
|
|
757
|
+
};
|
|
758
|
+
// The label, composed above and written here. Composing is apart so the delivery check can show the stages it re-runs
|
|
759
|
+
// the label it could not yet save.
|
|
760
|
+
const writeVerdictSidecar = () => {
|
|
761
|
+
const { derived, statement, doc } = composeVerdictSidecar();
|
|
762
|
+
const tmp = paths(run.runDir).verdictJson;
|
|
763
|
+
writeFileSync(tmp, JSON.stringify(doc, null, 2));
|
|
764
|
+
renameSync(tmp, paths(run.runDir).verdict);
|
|
765
|
+
// — THE STATUS RECORD CARRIES THE BAND AND THE SENTENCE, so a reader of the run does not
|
|
766
|
+
// have to reach for `verdict` to say something about the outcome. `verdict` is the gate's decision
|
|
767
|
+
// (CLEAR / CONDITIONAL / BLOCKING) and is engine vocabulary; the band and the composed statement are
|
|
768
|
+
// what every client surface already speaks. Measured 2026-09-20: an assistant summarising a run read
|
|
769
|
+
// `verdict` and told the client "BLOCKING" beside a Medium rating, because status.json held no band.
|
|
770
|
+
writeRunStatus(ctx, { tier: derived.tier ?? null, statement: statement ?? null });
|
|
771
|
+
return derived;
|
|
772
|
+
};
|
|
773
|
+
// THE LABEL, SAVED AGAIN IN THE DELIVERY CHECK, WITHOUT ENDING THE RUN (2026-10-19). After a clamp there the label
|
|
774
|
+
// has to reach every surface the report is published from, and they all read it from the one file. A save that
|
|
775
|
+
// fails is tried again. One that still fails is owed: the stages the check re-runs are shown the label as composed,
|
|
776
|
+
// and the save is made once more before anything is published, so no surface is built from the label settled
|
|
777
|
+
// before the clamp. Returns whether it is saved.
|
|
778
|
+
runState.labelOwed = null;
|
|
779
|
+
runState.rankingBeforeRepeat = null; // where each record stood before the delivery check repeated placement
|
|
780
|
+
const saveTheLabel = (why) => {
|
|
781
|
+
const saved = saveWithRetries(() => writeVerdictSidecar());
|
|
782
|
+
if (saved.ok) {
|
|
783
|
+
if (saved.attempts > 1) runLog(run.runDir, { event: "verdict-write-retried", why, attempts: saved.attempts });
|
|
784
|
+
try { runState.displayVerdict = JSON.parse(readFileSync(paths(run.runDir).verdict, "utf8")); } catch { /* the label is re-read at reassembly */ }
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
runState.labelOwed = runState.labelOwed ?? why;
|
|
788
|
+
runLog(run.runDir, { event: "verdict-write-deferred", why, attempts: saved.attempts, fail: String(saved.error?.message ?? saved.error).slice(0, 160) });
|
|
789
|
+
note(`delivery: the label could not be saved ${why} (${String(saved.error?.message ?? saved.error).slice(0, 100)}) — it is saved again before the report is published`);
|
|
790
|
+
try { runState.displayVerdict = composeVerdictSidecar().doc; } catch { /* composed again when it is saved */ }
|
|
791
|
+
return false;
|
|
792
|
+
};
|
|
793
|
+
// THE LABEL OWED IS SAVED before anything is published from it, and the report's own label follows it. Only a run
|
|
794
|
+
// directory that refuses every save of it ends the run, and then nothing the run writes can be published.
|
|
795
|
+
const saveTheOwedLabel = () => {
|
|
796
|
+
if (!runState.labelOwed) return;
|
|
797
|
+
const owed = runState.labelOwed;
|
|
798
|
+
runState.labelOwed = null;
|
|
799
|
+
if (!saveTheLabel(`${owed}, saved again before delivery`))
|
|
800
|
+
throw new StageFailure("verdict", `the run directory refused every save of the result's label (${owed}) — no surface can be published with it`);
|
|
801
|
+
applyVerdictFrontMatter();
|
|
802
|
+
};
|
|
803
|
+
// THE CONDITIONS FOLLOW THE RECORD AFTER A REPAIR IN THE DELIVERY CHECK. Every surface reads the list from the label,
|
|
804
|
+
// and the list states the record's forward legal steps as the record stands: a repair that rewrites, withdraws or
|
|
805
|
+
// adds one moves the list with it, in the record's own words. The result moves only where the floor any result meets
|
|
806
|
+
// moves it: a CLEAR the repaired steps now condition becomes CONDITIONAL, and nothing is relaxed. A BLOCKING result
|
|
807
|
+
// states no step of its own, so only a list already stating the record's steps follows it. The caller saves the
|
|
808
|
+
// label. Returns whether the list, its kinds or the result changed.
|
|
809
|
+
const followTheRecordsActions = (why) => {
|
|
810
|
+
if (runState.verdict === "BLOCKING" && !recordConditionReasons.size) return false;
|
|
811
|
+
let raw = null, fdoc = null;
|
|
812
|
+
try { if (existsSync(P.findings)) { raw = readFileSync(P.findings, "utf8"); fdoc = parseFindingsJsonLenient(raw); } }
|
|
813
|
+
catch { fdoc = null; }
|
|
814
|
+
if (!fdoc) return false; // no record to read: the list stands as stated, and the coherence checks judge it
|
|
815
|
+
const { conditions, conditionClauses } = deriveActionConditions(fdoc.actions, fdoc.findings);
|
|
816
|
+
const now = conditions.map((c) => ({ reason: c, clause: conditionClauses[conditions.indexOf(c)] ?? c }));
|
|
817
|
+
const dropped = quarantinedConditionRows(fdoc.actionsQuarantined).length > 0;
|
|
818
|
+
if (dropped && recordConditionReasons.has(DROPPED_CONDITIONS_REASON)) now.push({ reason: DROPPED_CONDITIONS_REASON, clause: DROPPED_CONDITIONS_REASON });
|
|
819
|
+
const state = () => JSON.stringify([runState.clampReasons, clampClauses, Boolean(clampKinds.legalActions), Boolean(clampKinds.actionsDropped)]);
|
|
820
|
+
const stood = state(), was = runState.verdict;
|
|
821
|
+
const f = conditionsFollowingTheRecord({ reasons: runState.clampReasons, clauses: clampClauses, fromRecord: recordConditionReasons, now });
|
|
822
|
+
runState.clampReasons = f.reasons;
|
|
823
|
+
clampClauses = f.clauses;
|
|
824
|
+
recordConditionReasons = f.held;
|
|
825
|
+
if (!conditions.length) delete clampKinds.legalActions;
|
|
826
|
+
if (!dropped) delete clampKinds.actionsDropped;
|
|
827
|
+
// A WITHDRAWAL IS POSITIVE ONLY ON A RECORD WHOSE ACTIONS REGISTER IS A LIST that holds none of the steps. A missing
|
|
828
|
+
// or malformed register, or one with an entry dropped as unreadable, withdraws nothing.
|
|
829
|
+
if (f.held.size || conditions.length || dropped) stepsWithdrawnAt = null;
|
|
830
|
+
else if (f.withdrawn.length) stepsWithdrawnAt = actionsRegisterListed(raw) ? new Date().toISOString() : null;
|
|
831
|
+
// The floor runs again only where the repaired steps reach it, as the coherence repair runs it.
|
|
832
|
+
if (state() !== stood || (runState.verdict === "CLEAR" && (conditions.length || dropped))) applyCoverageFloor();
|
|
833
|
+
restoreTheReviewsClear();
|
|
834
|
+
if (state() === stood && runState.verdict === was) return false;
|
|
835
|
+
runLog(run.runDir, { event: "verdict-conditions-followed", why, withdrawn: f.withdrawn.length, added: f.added.length,
|
|
836
|
+
restated: f.restated.length, conditions: recordConditionReasons.size, from: was, to: runState.verdict });
|
|
837
|
+
note(`the conditions follow the record ${why} (${f.withdrawn.length} withdrawn, ${f.added.length} added, ${f.restated.length} restated${runState.verdict === was ? "" : `; ${was} → ${runState.verdict}`})`);
|
|
838
|
+
return true;
|
|
839
|
+
};
|
|
840
|
+
// A CORRECTION THAT WITHDREW EVERY STEP THAT ALONE MADE THE RESULT CONDITIONAL gives the review's CLEAR back, once the
|
|
841
|
+
// review of that change has been read and no correction since was rejected (the owner's decision, 2026-11-04). The
|
|
842
|
+
// result is recomputed as a closed gap's is, and that CLEAR meets the floor any CLEAR meets. The caller saves the label.
|
|
843
|
+
const restoreTheReviewsClear = () => {
|
|
844
|
+
let review = null;
|
|
845
|
+
try { review = JSON.parse(readFileSync(postRepairRecordPath(run.runDir), "utf8")); } catch { review = null; }
|
|
846
|
+
const now = verdictWhenTheStepsAreWithdrawn({ verdict: runState.verdict, assessed: runState.assessed, reasons: runState.clampReasons, raisedBySteps: stepsRaisedTheResult,
|
|
847
|
+
stepsUnreadable, withdrawnAt: stepsWithdrawnAt, reviewReadAt: review?.status === "read" ? review.ts : null,
|
|
848
|
+
reviewUnread: review?.status === "unread", correctionRejectedAt: runState.correctionRejectedAt,
|
|
849
|
+
// The correction of the first review owed a recheck the cycle did not get accepted: the assessment is not verified.
|
|
850
|
+
recheckUnaccepted: (correctiveEntryVerdict === "CONDITIONAL" || correctiveEntryVerdict === "BLOCKING") && !correctiveCycleSettled && !correctiveRecheckOk });
|
|
851
|
+
if (now === runState.verdict) return false;
|
|
852
|
+
runLog(run.runDir, { event: "verdict-recomputed-steps-withdrawn", from: runState.verdict, to: now, withdrawnAt: stepsWithdrawnAt, reviewReadAt: review?.ts ?? null });
|
|
853
|
+
note(`every forward legal step that made the result conditional was withdrawn, the review of that change was read, and nothing else conditions the result — ${runState.verdict} goes back to ${now}, the result the review reached`);
|
|
854
|
+
runState.verdict = now;
|
|
855
|
+
runState.restoredClear = now === "CLEAR";
|
|
856
|
+
stepsRaisedTheResult = false;
|
|
857
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
858
|
+
applyCoverageFloor(); // the floor any CLEAR meets
|
|
859
|
+
return true;
|
|
860
|
+
};
|
|
861
|
+
try { writeVerdictSidecar(); }
|
|
862
|
+
catch (e) { throw new StageFailure("verdict", `verdict sidecar write failed (the single label authority): ${String(e.message).slice(0, 120)}`); }
|
|
863
|
+
|
|
864
|
+
// T3a, ruling 2026-08-26 — "Deliver always, with open points printed. The refusal on a blocking
|
|
865
|
+
// review goes." This REVERSES T3 (H3/H5), whose flip to fail-on-BLOCKING is itself recorded
|
|
866
|
+
// itself an owner-approved decision. Both are his; this is the standing one, and the
|
|
867
|
+
// history is kept here rather than deleted because a reader who finds only one of them will conclude
|
|
868
|
+
// the code drifted from its contract. (It did not; driver/skills/clearance-search/SKILL.md was the stale half, and this
|
|
869
|
+
// change makes it true again.)
|
|
870
|
+
//
|
|
871
|
+
// COPPER-SPIRE IS STILL ANSWERED, AND NOT BY REFUSING. That failure was a BLOCKING verdict reaching
|
|
872
|
+
// delivery and then CONTRADICTING its own client summary — a report that reads finished while the
|
|
873
|
+
// reviewer refused. "Never ships" and "never ships LOOKING FINISHED" were treated as one requirement
|
|
874
|
+
// for a year; they are two, and only the second was load-bearing. The open-points section at the top
|
|
875
|
+
// of the body is what carries it now.
|
|
876
|
+
//
|
|
877
|
+
// The corrective ladder above is still the fix arm and still runs first. What changed is what happens
|
|
878
|
+
// when it is exhausted: the reviewing lawyer gets the best draft the run could produce with its weak
|
|
879
|
+
// spots named, instead of nothing.
|
|
880
|
+
if (runState.verdict === "BLOCKING") {
|
|
881
|
+
// Repair-first A5 (2026-07-05): the reviewer verdict is documented noisy (the U1 comment above —
|
|
882
|
+
// "flips on byte-identical input"), so before the terminal the gate refuses a DEGENERATE artifact:
|
|
883
|
+
// a carried BLOCKING whose own file no longer says BLOCKING (the copper-spire shape — a failed
|
|
884
|
+
// re-check silently kept the stale entry verdict while the review on disk said CLEAR), or a
|
|
885
|
+
// BLOCKING citing ZERO defects (nothing exists for the corrective ladder to fix). ONE forced-fresh
|
|
886
|
+
// re-ask demands the verdict + file-anchored defects. A REASONED blocking is never re-rolled —
|
|
887
|
+
// this repair refuses self-contradiction; it cannot overrule the reviewer.
|
|
888
|
+
// ✕ CONVERSION 9 PRE-EMPTS ONE OF THE TWO SHAPES AND NOT THE OTHER, so this branch stays and the
|
|
889
|
+
// reason is written down rather than left for somebody to re-derive from an arm that never fires.
|
|
890
|
+
//
|
|
891
|
+
// countCitedDefects === 0 PRE-EMPTED. `record_narrative_refutation` refuses a BLOCKING with an
|
|
892
|
+
// empty `flags` array in the turn it is typed, so no review this driver
|
|
893
|
+
// RENDERS can carry that shape. It survives only on a file the tool did
|
|
894
|
+
// not write — a run resumed across the conversion, or an archived
|
|
895
|
+
// review re-read from disk.
|
|
896
|
+
// parseVerdict(md) !== "BLOCKING" NOT PRE-EMPTED, and it is the copper-spire shape this repair
|
|
897
|
+
// was built for: the run CARRIES BLOCKING while the file on disk says
|
|
898
|
+
// something else. That is a disagreement between the carried entry
|
|
899
|
+
// verdict and a later render, and no per-call validation can see it —
|
|
900
|
+
// each call was individually valid.
|
|
901
|
+
//
|
|
902
|
+
// So the repair is narrower than it was and is not dead. Deleting it would take the shape that
|
|
903
|
+
// still occurs along with the one that no longer does.
|
|
904
|
+
const readReview = () => { try { return readFileSync(P.seniorEyeReview, "utf8"); } catch { return ""; } };
|
|
905
|
+
const isDegenerate = (md) => parseVerdict(md) !== "BLOCKING" || countCitedDefects(md) === 0;
|
|
906
|
+
const reviewMd = readReview();
|
|
907
|
+
const reviewLedger = ctx.repairLedger ?? (ctx.repairLedger = createRepairLedger(run.runDir, { log: (o) => runLog(run.runDir, o) }));
|
|
908
|
+
// — ONE ceiling, named once and read by BOTH ends. A literal repeated at the record site is a
|
|
909
|
+
// second statement of the same rule, and two ends stating the same rule is how they drift apart.
|
|
910
|
+
const degenerateReaskMax = 1;
|
|
911
|
+
if (isDegenerate(reviewMd) && reviewLedger.canAttempt("reviewer-degenerate-reask", run.codename, { max: degenerateReaskMax })) {
|
|
912
|
+
runLog(run.runDir, { event: "reviewer-degenerate", fileVerdict: parseVerdict(reviewMd) ?? "unparseable", citedDefects: countCitedDefects(reviewMd) });
|
|
913
|
+
note(`verdict: BLOCKING is DEGENERATE (file says ${parseVerdict(reviewMd) ?? "unparseable"}, ${countCitedDefects(reviewMd)} cited defect(s)) — one forced-fresh re-ask demanding cited defects`);
|
|
914
|
+
const rr = await stage("narrative-refutation", ctx, {
|
|
915
|
+
force: true, trigger: "degenerate-reask",
|
|
916
|
+
extra: lines(
|
|
917
|
+
`Record the review again with \`record_narrative_refutation\`: the verdict (CLEAR / CONDITIONAL / BLOCKING) and any flags that still stand.`,
|
|
918
|
+
`If your verdict is BLOCKING: cite at least one concrete, file-anchored defect per blocking reason (name the file and the exact claim). A BLOCKING with no cited defects is invalid output.`,
|
|
919
|
+
planAuditExtra(ctx) || "",
|
|
920
|
+
),
|
|
921
|
+
});
|
|
922
|
+
reviewLedger.record("reviewer-degenerate-reask", run.codename, rr.ok ? "ok" : `failed: ${rr.fail}`, { max: degenerateReaskMax });
|
|
923
|
+
if (rr.ok) {
|
|
924
|
+
runState.verdict = parseVerdict(readReview()) ?? "BLOCKING";
|
|
925
|
+
runState.assessed = runState.verdict; // the re-asked review is the assessment now
|
|
926
|
+
runLog(run.runDir, { event: "verdict-3", verdict: runState.verdict, trigger: "degenerate-reask" });
|
|
927
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
928
|
+
applyCoverageFloor(); // a re-asked CLEAR passes the same deliver-conditional floor
|
|
929
|
+
// After the floor, which judges the verdict as it entered: its machinery arm records its gaps only on a CLEAR.
|
|
930
|
+
const standing = verdictWithConditionsStanding({ verdict: runState.verdict, reasons: runState.clampReasons });
|
|
931
|
+
if (standing !== runState.verdict) {
|
|
932
|
+
runLog(run.runDir, { event: "terminal-guard-clamp", defect: `reasked_clear_over_standing_condition:${runState.clampReasons.length}`, from: runState.verdict, to: standing });
|
|
933
|
+
note(`verdict: the review asked again says ${runState.verdict}, and ${runState.clampReasons.length} condition(s) a guard recorded still stand — ${runState.verdict} becomes ${standing} on them`);
|
|
934
|
+
runState.verdict = standing;
|
|
935
|
+
writeRunStatus(ctx, signoffPatch(runState.verdict));
|
|
936
|
+
}
|
|
937
|
+
try { writeVerdictSidecar(); }
|
|
938
|
+
catch (e) { throw new StageFailure("verdict", `verdict sidecar write failed (the single label authority): ${String(e.message).slice(0, 120)}`); }
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
if (runState.verdict === "BLOCKING") {
|
|
942
|
+
// ── T3a — THE RUN DELIVERS. Ruling 2026-08-26, verbatim: "Deliver always, with open
|
|
943
|
+
// points printed. The refusal on a blocking review goes." ──────────────────────────────────
|
|
944
|
+
//
|
|
945
|
+
// What stood here threw, and its reasoning was T3: "a report the reviewer will not
|
|
946
|
+
// stand behind never ships looking finished." That decision was the owner's and it is now
|
|
947
|
+
// reversed by the owner. Both are his; this is the standing one.
|
|
948
|
+
//
|
|
949
|
+
// THE OBJECTION THAT REASONING ANSWERED IS STILL ANSWERED, AND NOT BY THIS BRANCH. Its worry
|
|
950
|
+
// was copper-spire: a BLOCKING verdict reaching delivery and then CONTRADICTING its own client
|
|
951
|
+
// summary — a report that reads finished while the reviewer refused. That is exactly what
|
|
952
|
+
// `buildReviewerOpenPointsSection` prevents, at the top of the body, code-built from the review
|
|
953
|
+
// rather than from any seat's account of it. "Never ships" and "never ships LOOKING FINISHED"
|
|
954
|
+
// were treated as one requirement; they are two, and only the second was ever load-bearing.
|
|
955
|
+
//
|
|
956
|
+
// The corrective ladder above is still the fix arm and still runs first. What changes is only
|
|
957
|
+
// what happens when it is exhausted: the reviewing lawyer receives the best draft the run could
|
|
958
|
+
// produce with its weak spots named, instead of nothing at all.
|
|
959
|
+
runLog(run.runDir, {
|
|
960
|
+
event: "verdict-blocking-delivered",
|
|
961
|
+
citedDefects: countCitedDefects(readReview()),
|
|
962
|
+
degenerate: isDegenerate(readReview()),
|
|
963
|
+
});
|
|
964
|
+
note(`verdict: BLOCKING stands after the corrective pass + re-check — the report DELIVERS, with the reviewer's open points recorded for the reviewing lawyer (${countCitedDefects(readReview())} cited defect(s)); the reviewing lawyer is the backstop`);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return { applyCoverageFloor, clampOnTheFloorDuty, clampOnTheWritersDuty, deliverAndClamp, followTheRecordsActions, saveTheLabel, saveTheOwedLabel, writeVerdictSidecar };
|
|
968
|
+
}
|