clearotron 0.5.1 → 0.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +7 -7
- package/INSTALL.md +10 -10
- package/QUICKSTART.md +6 -6
- package/README.md +2 -2
- package/THIRD-PARTY-NOTICES.md +4 -4
- package/bin/README.md +2 -2
- package/bin/clearotron.mjs +1 -1
- package/bin/connect.mjs +1 -1
- package/bin/disconnect.mjs +1 -1
- package/bin/example.mjs +2 -2
- package/bin/grant.mjs +1 -1
- package/bin/onboard.mjs +78 -23
- package/bin/start.mjs +49 -18
- package/bin/update.mjs +13 -3
- package/build-info.json +2 -2
- package/docs/DELIVERY.md +1 -1
- package/docs/PORTAL.md +1 -1
- package/docs/RELEASES.md +1 -1
- package/docs/architecture/02-architecture.md +10 -2
- package/docs/architecture/03-run-lifecycle.md +6 -2
- package/docs/architecture/04-configuration-reference.md +3 -3
- package/docs/architecture/05-config-governance.md +5 -4
- package/docs/architecture/08-development-guide.md +4 -4
- package/docs/architecture/09-security-and-data.md +1 -1
- package/{driver/skills/clearance-search/SKILL.md → docs/architecture/retired-manuals/clearance-search-spine.md} +17 -30
- package/{driver/skills/clearance-search/templates/email/generic.md → docs/architecture/retired-manuals/email-generic.md} +1 -1
- package/{driver/skills/clearance-search → docs/architecture/retired-manuals}/template-formatting.md +3 -4
- package/docs/configuration.md +1 -1
- package/docs/decisions/0002-no-dark-functionality.md +5 -0
- package/driver/CHANGELOG.md +60 -0
- package/driver/README.md +11 -1
- package/driver/accepted-order.mjs +13 -5
- package/driver/attempt-rows.mjs +64 -0
- package/driver/attributed-span.mjs +1 -1
- package/driver/authority-trees.mjs +1 -1
- package/driver/best-draft.mjs +3 -3
- package/driver/blind-frame-record.mjs +2 -2
- package/driver/cancel.mjs +3 -2
- package/driver/carry-through.mjs +2 -2
- package/driver/citation-census.json +3 -3
- package/driver/clearance-variants-record.mjs +4 -10
- package/driver/common-law-coverage-status.mjs +3 -3
- package/driver/common-law-receipts.mjs +2 -2
- package/driver/compare.mjs +1 -1
- package/driver/config-inventory.mjs +6 -79
- package/driver/consumption-ledger.mjs +2 -1
- package/driver/contract-dictation-registry.mjs +5 -0
- package/driver/contract-e3-backlog.mjs +45 -66
- package/driver/contract-e3-baseline.json +16 -16
- package/driver/contract-vocabulary.mjs +8 -6
- package/driver/corrections-feedforward.mjs +3 -1
- package/driver/coverage-form-io.mjs +7 -8
- package/driver/coverage-tool.mjs +1 -1
- package/driver/declination-tool.mjs +2 -2
- package/driver/degraded-parts.mjs +9 -9
- package/driver/demo-container.mjs +5 -4
- package/driver/deploy-live-run-guard.mjs +19 -7
- package/driver/derived-state.mjs +2 -2
- package/driver/dev-portal.mjs +2 -1
- package/driver/dispatch-record.mjs +1 -1
- package/driver/disposition-tool.mjs +2 -1
- package/driver/doubt-closure-tool.mjs +2 -2
- package/driver/driver.config.mjs +35 -724
- package/driver/e2e-rounds.mjs +3 -4
- package/driver/engine/CONTRACT.md +3 -0
- package/driver/engine/README.md +2 -0
- package/driver/engine/anthropic-agent.mjs +8 -37
- package/driver/engine/auth.mjs +74 -0
- package/driver/engine/child-record.mjs +1 -1
- package/driver/engine/deny-authority-write.mjs +2 -2
- package/driver/engine/jx-turn.mjs +10 -2
- package/driver/engine/mcp/README.md +1 -1
- package/driver/engine/mcp/band-server.mjs +6 -6
- package/driver/engine/mcp/codex-config.mjs +1 -1
- package/driver/engine/mcp/declination-server.mjs +2 -3
- package/driver/engine/mcp/dispositions-server.mjs +3 -3
- package/driver/engine/mcp/gather-config.mjs +24 -19
- package/driver/engine/mcp/grid-provenance.mjs +1 -1
- package/driver/engine/mcp/held-answers.mjs +5 -5
- package/driver/engine/mcp/perplexity-server.mjs +16 -7
- package/driver/engine/mcp/recording-server.mjs +7 -6
- package/driver/engine/mcp/register-server.mjs +29 -0
- package/driver/engine/mcp/stdio-server.mjs +5 -5
- package/driver/engine/mcp/supplemental.mjs +9 -9
- package/driver/engine/openai-agent.mjs +5 -2
- package/driver/engine/registry.mjs +103 -0
- package/driver/engine/run-choices.mjs +162 -0
- package/driver/engine/stamps.mjs +35 -0
- package/driver/enqueue-schema.mjs +4 -4
- package/driver/envelope-settle.mjs +3 -2
- package/driver/feedback-issues.mjs +1 -1
- package/driver/feedback-mint.mjs +3 -2
- package/driver/feedback-store.mjs +3 -2
- package/driver/findings-model.mjs +1 -1
- package/driver/flag-snapshot.mjs +5 -4
- package/driver/floor-duty.mjs +3 -3
- package/driver/foreign-record-links.mjs +1 -1
- package/driver/frame-diff-record.mjs +2 -8
- package/driver/framework.mjs +1 -1
- package/driver/gate-metrics.mjs +10 -11
- package/driver/gateway.mjs +220 -839
- package/driver/goods-evidence.mjs +10 -6
- package/driver/jx-lanes.mjs +3 -3
- package/driver/jx-units.mjs +31 -37
- package/driver/jx.mjs +44 -59
- package/driver/knockout-assess-record.mjs +3 -3
- package/driver/knockout-caveats.mjs +21 -0
- package/driver/knockout-correction-record.mjs +58 -28
- package/driver/knockout-frame-record.mjs +2 -2
- package/driver/knockout-register-read.mjs +38 -21
- package/driver/knockout-register-record.mjs +5 -6
- package/driver/knockout-review-record.mjs +12 -11
- package/driver/ladder/model-gauge.mjs +88 -0
- package/driver/ladder/next-rung.mjs +296 -0
- package/driver/ladder/rescue.mjs +146 -0
- package/driver/ladder/stage-tools.mjs +57 -0
- package/driver/ladder/turn-failure.mjs +166 -0
- package/driver/log.mjs +2 -2
- package/driver/matter-frame-record.mjs +4 -4
- package/driver/methodology-witness.mjs +2 -2
- package/driver/narrative-refutation-record.mjs +145 -42
- package/driver/one-build-per-run.mjs +62 -0
- package/driver/outbox-backoff.mjs +4 -4
- package/driver/owner-screen.mjs +0 -10
- package/driver/owner-use-check.mjs +2 -28
- package/driver/package.json +1 -1
- package/driver/partial-payload-baseline.json +1 -1
- package/driver/parts-not-completed.mjs +1 -1
- package/driver/pipeline-knockout.mjs +1015 -1001
- package/driver/pipeline.mjs +511 -9265
- package/driver/placement-decisions.mjs +2 -2
- package/driver/placement-form-io.mjs +7 -9
- package/driver/placement-union.mjs +0 -6
- package/driver/plan-stability.mjs +7 -10
- package/driver/portal-acks.mjs +3 -2
- package/driver/portal-confirmation.mjs +48 -0
- package/driver/portal-families.mjs +3 -2
- package/driver/portal-local-auth.mjs +1 -2
- package/driver/portal-routes/README.md +24 -0
- package/driver/portal-routes/admin.mjs +425 -0
- package/driver/portal-routes/compose.mjs +66 -0
- package/driver/portal-routes/config.mjs +118 -0
- package/driver/portal-routes/connect.mjs +283 -0
- package/driver/portal-routes/feedback.mjs +178 -0
- package/driver/portal-routes/me.mjs +165 -0
- package/driver/portal-routes/queue.mjs +64 -0
- package/driver/portal-routes/report.mjs +106 -0
- package/driver/portal-routes/run.mjs +508 -0
- package/driver/portal-routes/runs.mjs +127 -0
- package/driver/portal-routes/usage.mjs +82 -0
- package/driver/portal-runs.mjs +588 -0
- package/driver/portal-service.mjs +78 -2592
- package/driver/portal-static.mjs +3 -1
- package/driver/predelivery-lint.mjs +92 -9
- package/driver/production-pool-guard.mjs +1 -1
- package/driver/profiles.mjs +5 -4
- package/driver/progress.mjs +29 -24
- package/driver/publish/README.md +10 -5
- package/driver/publish/archive-tags.mjs +3 -2
- package/driver/publish/demo-marking.mjs +2 -2
- package/driver/publish/index.mjs +215 -140
- package/driver/publish/knockout.mjs +153 -107
- package/driver/publish/office-record-links.mjs +22 -0
- package/driver/publish/parse.mjs +20 -5
- package/driver/publish/pool-admin.mjs +9 -3
- package/driver/publish/render.mjs +11 -3
- package/driver/publish/report-dates.mjs +3 -4
- package/driver/publish/report-registry.mjs +7 -10
- package/driver/publish/seed-pool.mjs +3 -2
- package/driver/publish/shell.mjs +106 -0
- package/driver/publish/templates/report.css +3 -1
- package/driver/queue-order.mjs +4 -3
- package/driver/record-carry.mjs +0 -9
- package/driver/record-discard.mjs +1 -4
- package/driver/record-fold.mjs +3 -3
- package/driver/record-goods.mjs +5 -5
- package/driver/reference-score.mjs +2 -3
- package/driver/register-capabilities.mjs +0 -6
- package/driver/register-count.mjs +3 -2
- package/driver/register-digest-record.mjs +7 -7
- package/driver/register-fixture-marker.mjs +3 -3
- package/driver/register-plan.mjs +2 -2
- package/driver/register-records.mjs +2 -2
- package/driver/register-taint.mjs +3 -3
- package/driver/register-unit-record.mjs +48 -9
- package/driver/register-unreachable.mjs +4 -3
- package/driver/registry-fidelity.mjs +79 -34
- package/driver/repair-composers.mjs +14 -9
- package/driver/repair-digest.mjs +4 -6
- package/driver/repair-scope.mjs +3 -3
- package/driver/repair-targets.mjs +24 -9
- package/driver/repairs.mjs +44 -58
- package/driver/replay-archive.mjs +7 -7
- package/driver/report-card-record.mjs +3 -3
- package/driver/report-overview-record.mjs +4 -4
- package/driver/research-answers.mjs +38 -6
- package/driver/research-checks.mjs +4 -4
- package/driver/result-noun-fields.mjs +28 -11
- package/driver/review-addresses.mjs +163 -0
- package/driver/rule-shape.mjs +1 -1
- package/driver/run-delivered.mjs +340 -0
- package/driver/run-economics.mjs +8 -26
- package/driver/run-failed.mjs +545 -0
- package/driver/run-integrity.mjs +1 -1
- package/driver/run-outcome.mjs +314 -0
- package/driver/run-park.mjs +23 -0
- package/driver/run-quote.mjs +32 -0
- package/driver/run-record.mjs +352 -0
- package/driver/run-requirements.mjs +22 -0
- package/driver/run-shell.mjs +55 -0
- package/driver/runner.mjs +71 -33
- package/driver/saved-register-pages.mjs +4 -4
- package/driver/score-redaction.mjs +2 -2
- package/driver/search-policy.mjs +12 -13
- package/driver/settle-stamp.mjs +4 -3
- package/driver/skeptic-record.mjs +2 -2
- package/driver/skeptic-search.mjs +1 -1
- package/driver/skills/README.md +7 -7
- package/driver/skills/blind-frame/SKILL.md +1 -2
- package/driver/skills/case-law-citation/SKILL.md +9 -37
- package/driver/skills/case-law-citation/sources/courtlistener.md +1 -3
- package/driver/skills/case-law-citation/sources/eurlex.md +8 -11
- package/driver/skills/case-law-citation/sources/legaldatahunter.md +1 -1
- package/driver/skills/clearance-common-law/SKILL.md +45 -111
- package/driver/skills/clearance-common-law/perplexity-prompts.md +7 -79
- package/driver/skills/clearance-register/SKILL.md +15 -33
- package/driver/skills/clearance-register/digest.md +31 -92
- package/driver/skills/clearance-register/providers/clarivate.md +2 -2
- package/driver/skills/clearance-register/providers/corsearch.md +5 -5
- package/driver/skills/clearance-register/providers/euipo.md +1 -2
- package/driver/skills/clearance-register/providers/free-tier.md +0 -19
- package/driver/skills/clearance-register/providers/signa.md +6 -25
- package/driver/skills/clearance-register/providers/uspto-local.md +0 -24
- package/driver/skills/clearance-register/register-recipes.md +8 -15
- package/driver/skills/clearance-register/status-rules.md +6 -24
- package/driver/skills/clearance-register/unit.md +11 -20
- package/driver/skills/clearance-search/delivery-contract.md +24 -120
- package/driver/skills/clearance-search/field-doctrine-pharma.md +1 -5
- package/driver/skills/clearance-search/firm-wide-reasoning.md +24 -43
- package/driver/skills/clearance-search/phase2-execution.md +29 -77
- package/driver/skills/clearance-search/report-prose.md +3 -4
- package/driver/skills/clearance-search/risk-framework-demo.md +1 -1
- package/driver/skills/clearance-search/risk-framework-triage.manifest.json +3 -3
- package/driver/skills/clearance-search/risk-framework-triage.md +7 -9
- package/driver/skills/clearance-search/risk-framework.manifest.json +1 -1
- package/driver/skills/clearance-search/risk-framework.md +1 -1
- package/driver/skills/clearance-search/synthesis-rules.md +30 -107
- package/driver/skills/clearance-search/worked-examples.md +5 -5
- package/driver/skills/clearance-variants/SKILL.md +46 -45
- package/driver/skills/clearance-variants/transliteration-scripts.md +4 -4
- package/driver/skills/frame-diff/SKILL.md +1 -1
- package/driver/skills/knockout-assess/SKILL.md +6 -14
- package/driver/skills/knockout-frame/SKILL.md +1 -1
- package/driver/skills/matter-frame/SKILL.md +7 -12
- package/driver/skills/matter-frame/watchlist-reference.md +1 -4
- package/driver/skills/narrative-refutation/SKILL.md +20 -30
- package/driver/skills/placement-inquiry/SKILL.md +8 -18
- package/driver/skills-store-provenance.mjs +1 -1
- package/driver/stage-context.mjs +32 -35
- package/driver/stage-freshness.mjs +127 -11
- package/driver/stages-knockout.mjs +49 -22
- package/driver/stages.mjs +88 -283
- package/driver/status-snapshot.mjs +2 -1
- package/driver/steps/correction-cycle.mjs +311 -0
- package/driver/steps/corrections.mjs +644 -0
- package/driver/steps/delivery.mjs +1287 -0
- package/driver/steps/frame-comparison.mjs +922 -0
- package/driver/steps/intake.mjs +84 -0
- package/driver/steps/open-run.mjs +419 -0
- package/driver/steps/overview-and-cards.mjs +899 -0
- package/driver/steps/placement-and-digest.mjs +23 -0
- package/driver/steps/register-sweep.mjs +1563 -0
- package/driver/steps/skeptic-and-follow-up.mjs +831 -0
- package/driver/steps/synthesis.mjs +261 -0
- package/driver/steps/verdict-gate.mjs +968 -0
- package/driver/suite-census.json +403 -91
- package/driver/surface-exit-verdict.mjs +0 -8
- package/driver/synthesis-record.mjs +72 -6
- package/driver/terminal-clamp.mjs +10 -0
- package/driver/tokens.mjs +8 -62
- package/driver/tool-calls.mjs +2 -2
- package/driver/unit-state-verdict.mjs +1 -1
- package/driver/usage-ledger.mjs +2 -1
- package/driver/verify-knockout.mjs +20 -35
- package/driver/verify.mjs +47 -36
- package/driver/web-grid.mjs +3 -4
- package/driver/whatif-memo-run.mjs +2 -2
- package/driver/whatif-queue.mjs +4 -3
- package/driver/withheld-families.mjs +14 -15
- package/driver/worker-heartbeat.mjs +3 -2
- package/driver/write-up-form.mjs +0 -3
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/http-server.mjs +1 -1
- package/mcp-server/lib/brief.mjs +22 -4
- package/mcp-server/lib/events.mjs +2 -2
- package/mcp-server/lib/evidence.mjs +3 -2
- package/mcp-server/lib/findings.mjs +2 -1
- package/mcp-server/lib/knockout.mjs +9 -10
- package/mcp-server/lib/ops.mjs +9 -9
- package/mcp-server/lib/runs.mjs +9 -10
- package/mcp-server/lib/trace.mjs +1 -1
- package/mcp-server/lib/whatif.mjs +2 -3
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +5 -5
- package/package.json +2 -1
- package/portal-ui/dist/assets/{index-fPqAU0sx.js → index-D5rkCjDc.js} +26 -14
- package/portal-ui/dist/index.html +1 -1
- package/portal-ui/package.json +3 -3
- package/providers/README.md +1 -1
- package/providers/_shared/answer-memory.mjs +4 -5
- package/providers/_shared/execute-plan.mjs +48 -1
- package/providers/_shared/records-from-search.mjs +46 -0
- package/providers/clarivate/README.md +2 -2
- package/providers/clarivate/src/adapter.js +147 -0
- package/providers/clarivate/src/core.js +1 -14
- package/{driver/engine/mcp/clarivate-server.mjs → providers/clarivate/src/mount.js} +5 -10
- package/providers/corsearch/README.md +3 -3
- package/providers/corsearch/src/adapter.js +80 -0
- package/providers/corsearch/src/core.js +14 -11
- package/{driver/engine/mcp/corsearch-server.mjs → providers/corsearch/src/mount.js} +5 -10
- package/providers/euipo/README.md +2 -2
- package/providers/euipo/src/adapter.js +85 -0
- package/providers/euipo/src/core.js +1 -1
- package/providers/euipo/src/euipo-client.js +1 -2
- package/{driver/engine/mcp/euipo-server.mjs → providers/euipo/src/mount.js} +5 -10
- package/providers/free-tier/README.md +2 -2
- package/providers/free-tier/src/adapter.js +127 -0
- package/{driver/engine/mcp/free-tier-server.mjs → providers/free-tier/src/mount.js} +5 -10
- package/providers/jx-subclass/coverage.mjs +1 -6
- package/providers/jx-subclass/score-truth.mjs +2 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/perplexity/src/core.js +2 -2
- package/providers/signa/README.md +2 -2
- package/providers/signa/src/adapter.js +157 -0
- package/providers/signa/src/capabilities.js +0 -3
- package/providers/signa/src/core.js +2 -2
- package/{driver/engine/mcp/signa-server.mjs → providers/signa/src/mount.js} +7 -12
- package/providers/signa/src/offices.generated.js +17 -15
- package/providers/uspto-local/README.md +1 -1
- package/providers/uspto-local/bin/verify-index.mjs +1 -1
- package/providers/uspto-local/src/adapter.js +75 -0
- package/{driver/engine/mcp/uspto-local-server.mjs → providers/uspto-local/src/mount.js} +5 -10
- package/scripts/band-shape-probe.mjs +2 -2
- package/scripts/citation-line-check.mjs +7 -7
- package/scripts/compare.mjs +1 -1
- package/scripts/dead-names.mjs +2 -2
- package/scripts/e2e-first-time.mjs +19 -7
- package/scripts/e2e.mjs +13 -13
- package/scripts/engine-probe.mjs +1 -1
- package/scripts/env-audit.mjs +7 -4
- package/scripts/env-classify.mjs +5 -1
- package/scripts/feedback-mint.mjs +1 -1
- package/scripts/freeze-example-run.mjs +7 -7
- package/scripts/mint-suite-census.mjs +2 -2
- package/scripts/nightly-notice.mjs +1 -1
- package/scripts/release-cut-decision.mjs +7 -2
- package/scripts/release-note-required.mjs +26 -9
- package/scripts/release-notes-lint.mjs +3 -2
- package/scripts/release-version-pr-checks.mjs +1 -1
- package/scripts/settings-render-check.mjs +23 -3
- package/scripts/test-run.mjs +5 -5
- package/scripts/travelling-predicates.mjs +1 -1
- package/scripts/undeclared-field-census.mjs +1 -1
- package/scripts/unexecuted-asserts.mjs +1 -1
- package/scripts/verify-publishable.mjs +1 -1
- package/shared/client-door.mjs +1 -1
- package/shared/connect-clients.mjs +1 -1
- package/shared/connector-signin-probe.mjs +1 -1
- package/shared/env-aliases.mjs +1 -1
- package/shared/invocation.mjs +14 -2
- package/shared/names-in-force.mjs +2 -0
- package/shared/register-selection.mjs +2 -2
- package/shared/store-in-repo.mjs +3 -3
- package/shared/summary-blocks.mjs +0 -3
- package/shared/trigger-lane.mjs +1 -1
- package/shared/vacuous-pass.mjs +2 -2
- package/shared/verb-shim.mjs +4 -2
- package/node_modules/exceljs/README.md +0 -3023
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// WHAT STANDS, STANDS BY CONSTRUCTION. A call may touch only the names a defect concerns, and a name no defect concerns cannot
|
|
11
11
|
// drift, nor its block in the summary, because no field reaches them. Inside an affected name the repair reaches what it needs,
|
|
12
12
|
// and says which defect each moved finding serves. A call sends only what changes, and its rows merge onto the chunk the run holds.
|
|
13
|
+
// ONE STATEMENT, WHEREVER IT PRINTS. A finding is copied onto each name it bears on, so a line a defect names on one name can stand
|
|
14
|
+
// on another that no defect names. A call may correct that same finding there (design, 2026-11-09), and nothing else on that name.
|
|
13
15
|
//
|
|
14
16
|
// THE CHUNK IS THE RECORD, so a corrected batch composes as a rated one does, through the same steps and the same gate, and
|
|
15
17
|
// a resumed run reads the correction back rather than losing it. An accepted repair stands when later work fails: only a change
|
|
@@ -23,10 +25,10 @@ import { copyFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
23
25
|
import { basename, dirname, join } from "node:path";
|
|
24
26
|
|
|
25
27
|
import { captureCall, stampVerdict } from "./call-capture.mjs";
|
|
26
|
-
import { DRIVER_DIR, driverDir } from "../shared/driver-dir.mjs";
|
|
27
28
|
import { acceptedEnvelope } from "./preserve-merge.mjs";
|
|
28
29
|
import { acceptKnockoutAssess, knockoutAssessCallPaths, knockoutAssessChunkFile, refuseUndeclared } from "./knockout-assess-record.mjs";
|
|
29
30
|
import { validators as koValidators } from "./verify-knockout.mjs";
|
|
31
|
+
import { DRIVER_DIR, driverDir, paths, readJsonOrNull } from "./run-record.mjs";
|
|
30
32
|
|
|
31
33
|
const TOKEN = "knockoutcorrection";
|
|
32
34
|
const SCHEMA_VERSION = 1;
|
|
@@ -36,12 +38,11 @@ export const knockoutCorrectionFile = (runDir, chunkNo) => join(String(runDir ??
|
|
|
36
38
|
export const KNOCKOUT_CORRECTION_RE = /^knockout-correction-\d+\.json$/;
|
|
37
39
|
|
|
38
40
|
/** The driver's own account of the round: the record the check read, and each defect with its address. */
|
|
39
|
-
export const correctionWorkPath = (runDir) =>
|
|
40
|
-
const chunkBasePath = (runDir, chunkNo) => driverDir(runDir, `knockout-correction-base-${Number(chunkNo)}.json`);
|
|
41
|
+
export const correctionWorkPath = (runDir) => paths(runDir).knockoutCorrectionWork;
|
|
42
|
+
export const chunkBasePath = (runDir, chunkNo) => driverDir(runDir, `knockout-correction-base-${Number(chunkNo)}.json`);
|
|
41
43
|
const correctionCallDir = (runDir, chunkNo) => driverDir(runDir, join("knockout-correction-calls", `chunk-${Number(chunkNo)}`));
|
|
42
44
|
|
|
43
45
|
const nameKey = (s) => String(s ?? "").trim().toLowerCase();
|
|
44
|
-
const readJson = (path) => { try { return JSON.parse(readFileSync(path, "utf8")); } catch { return null; } };
|
|
45
46
|
/** A finding's identity across a renumbering: the gate re-ranks on the band, so an ordinal does not survive a move. */
|
|
46
47
|
export const sameFinding = (a, b) => nameKey(a?.name) === nameKey(b?.name) && nameKey(a?.owner) === nameKey(b?.owner);
|
|
47
48
|
const withoutOrdinal = (f) => { const { ordinal: _ordinal, ...rest } = f ?? {}; return JSON.stringify(rest); };
|
|
@@ -62,7 +63,7 @@ export function correctionWork({ rated, material, chunks }) {
|
|
|
62
63
|
return { schema_version: SCHEMA_VERSION, rated, defects };
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
export const readCorrectionWork = (runDir) =>
|
|
66
|
+
export const readCorrectionWork = (runDir) => readJsonOrNull(correctionWorkPath(runDir));
|
|
66
67
|
|
|
67
68
|
/** Keep each chunk a defect touches as it was rated. Written once: a resumed round must not take a corrected chunk for the base. */
|
|
68
69
|
export function keepChunkBases(runDir, chunkNos) {
|
|
@@ -91,7 +92,26 @@ export function chunkScope(work, chunkNo, base) {
|
|
|
91
92
|
}
|
|
92
93
|
byMark.set(key, row);
|
|
93
94
|
}
|
|
94
|
-
return { defects, byMark };
|
|
95
|
+
return { defects, byMark, namedFindings: defects.flatMap((d) => (d.names ? [d.names] : [])) };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const isNamedFinding = (f, named) => (named ?? []).some((n) => sameFinding(f, n));
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The ordinals a call's row changes or removes on a name no defect concerns that no defect's answer lists, beyond the findings
|
|
102
|
+
* a defect names. Empty when every change is answered for. PURE.
|
|
103
|
+
*
|
|
104
|
+
* A correction may reach a name no defect concerns where its repair genuinely needs to (design ruling, 2026-11-10: the
|
|
105
|
+
* Knockout corrects the way the clearance does, recording what moved and why and putting it to the recheck). What it
|
|
106
|
+
* owes for that is the reason, in the answer to the defect it serves, so the recheck can read the connection.
|
|
107
|
+
*/
|
|
108
|
+
function unansweredOrdinals(row, mark, scope, answers) {
|
|
109
|
+
const listed = new Set((Array.isArray(answers) ? answers : []).flatMap((a) => (Array.isArray(a?.findings) ? a.findings : [])));
|
|
110
|
+
const ratedAt = (o) => (mark?.findings ?? []).find((x) => x?.ordinal === o);
|
|
111
|
+
// A finding a defect names, sent back still that finding, is the repair itself; every other change or removal is not.
|
|
112
|
+
const sent = (Array.isArray(row?.findings) ? row.findings : []).filter((f) => { const was = ratedAt(f?.ordinal); return !(was && isNamedFinding(was, scope.namedFindings) && sameFinding(f, was)); });
|
|
113
|
+
const changed = [...sent.map((f) => f?.ordinal), ...(Array.isArray(row?.remove_findings) ? row.remove_findings : [])];
|
|
114
|
+
return changed.filter((o) => !listed.has(o));
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
/** One name's block in a chunk summary: its `## NAME` sub-header to the next. Null where it has none. PURE. */
|
|
@@ -115,9 +135,9 @@ function patchedFindings(mark, row, stop) {
|
|
|
115
135
|
}
|
|
116
136
|
|
|
117
137
|
/**
|
|
118
|
-
* The chunk with one call applied, or why it cannot be. PURE. \`held\` is the chunk as it now stands. A
|
|
119
|
-
*
|
|
120
|
-
*
|
|
138
|
+
* The chunk with one call applied, or why it cannot be. PURE. \`held\` is the chunk as it now stands. A defect's repair may reach
|
|
139
|
+
* whatever findings of its own name it needs, and a name no defect concerns where the repair depends on it, listing each such
|
|
140
|
+
* finding in an answer's \`findings\` with the reason (\`mergedAnswers\`), so the check that follows can read the connection.
|
|
121
141
|
*/
|
|
122
142
|
export function applyCorrectionCall({ held, call, scope }) {
|
|
123
143
|
const refuse = (what) => ({ ok: false, reason: `${TOKEN}_${what}` });
|
|
@@ -127,9 +147,10 @@ export function applyCorrectionCall({ held, call, scope }) {
|
|
|
127
147
|
const moved = [];
|
|
128
148
|
for (const row of Array.isArray(call?.marks) ? call.marks : []) {
|
|
129
149
|
const name = String(row?.name ?? "");
|
|
130
|
-
if (!scope.byMark.has(nameKey(name))) return refuse(`scope:${name}: no material defect concerns this name. Leave it as it stands.`);
|
|
131
150
|
const i = marks.findIndex((m) => nameKey(m?.name) === nameKey(name));
|
|
151
|
+
const concerned = scope.byMark.has(nameKey(name));
|
|
132
152
|
if (i < 0) return refuse(`scope:${name}: this name is not in the chunk you were handed.`);
|
|
153
|
+
if (!concerned && unansweredOrdinals(row, marks[i], scope, call?.answers).length) return refuse(`scope:${name}: No defect concerns this name. List each finding you change or remove on it in the \`findings\` of the defect your repair serves, and say why in that answer.`);
|
|
133
154
|
const { findings: _findings, remove_findings: _removed, ...fields } = row;
|
|
134
155
|
const next = { ...marks[i], ...fields };
|
|
135
156
|
if (row.findings !== undefined || row.remove_findings !== undefined) {
|
|
@@ -147,10 +168,7 @@ export function applyCorrectionCall({ held, call, scope }) {
|
|
|
147
168
|
moved.push(name);
|
|
148
169
|
}
|
|
149
170
|
const chunkSummary = call?.chunkSummary ?? held?.chunkSummary;
|
|
150
|
-
|
|
151
|
-
if (scope.byMark.has(nameKey(m?.name))) continue;
|
|
152
|
-
if (summaryBlock(chunkSummary, m.name) !== summaryBlock(held?.chunkSummary, m.name)) return refuse(`summary:${m.name}: no defect concerns this name, so its block in chunkSummary stays as it was.`);
|
|
153
|
-
}
|
|
171
|
+
// A block that moves under a name no defect concerns is recorded and rechecked with that name (movedOutsideScope), not refused.
|
|
154
172
|
for (const name of moved) {
|
|
155
173
|
const m = marks.find((x) => nameKey(x?.name) === nameKey(name));
|
|
156
174
|
const block = summaryBlock(chunkSummary, name);
|
|
@@ -217,14 +235,14 @@ export function recordKnockoutCorrection(runDir, received, { boundOrdinal = null
|
|
|
217
235
|
|
|
218
236
|
const work = readCorrectionWork(dir);
|
|
219
237
|
const file = knockoutAssessChunkFile(dir, chunkNo);
|
|
220
|
-
const held =
|
|
238
|
+
const held = readJsonOrNull(file), base = readJsonOrNull(chunkBasePath(dir, chunkNo));
|
|
221
239
|
if (!work || !held || !base) return refused(`${TOKEN}_state: this run holds no correction for chunk ${chunkNo}.`);
|
|
222
240
|
const scope = chunkScope(work, chunkNo, base);
|
|
223
241
|
|
|
224
242
|
const applied = applyCorrectionCall({ held, call: rest, scope });
|
|
225
243
|
if (!applied.ok) return refused(applied.reason);
|
|
226
244
|
const receipt = knockoutCorrectionFile(dir, chunkNo);
|
|
227
|
-
const answers = mergedAnswers(
|
|
245
|
+
const answers = mergedAnswers(readJsonOrNull(receipt)?.answers, receivedAnswers, scope, { base, chunk: applied.chunk });
|
|
228
246
|
if (!answers.ok) return refused(answers.reason);
|
|
229
247
|
|
|
230
248
|
// THE SAME GATES A RATED CHUNK PASSED, at the call, while the seat can still repair what they name.
|
|
@@ -273,14 +291,14 @@ export function rollBackName(runDir, work, name) {
|
|
|
273
291
|
const defects = (work?.defects ?? []).filter((d) => nameKey(d.mark) === nameKey(name));
|
|
274
292
|
const chunkNo = defects[0]?.chunk;
|
|
275
293
|
if (chunkNo == null) return;
|
|
276
|
-
const base =
|
|
294
|
+
const base = readJsonOrNull(chunkBasePath(runDir, chunkNo)), held = readJsonOrNull(knockoutAssessChunkFile(runDir, chunkNo));
|
|
277
295
|
const rated = (base?.marks ?? []).find((m) => nameKey(m?.name) === nameKey(name));
|
|
278
296
|
if (!base || !held || !rated) return;
|
|
279
297
|
const was = summaryBlock(base.chunkSummary, name), now = summaryBlock(held.chunkSummary, name);
|
|
280
298
|
const chunkSummary = was != null && now != null ? held.chunkSummary.replace(now, () => was) : held.chunkSummary;
|
|
281
299
|
const text = JSON.stringify({ ...held, chunkSummary, marks: held.marks.map((m) => (nameKey(m?.name) === nameKey(name) ? rated : m)) }, null, 2) + "\n";
|
|
282
300
|
writeFileSync(knockoutAssessChunkFile(runDir, chunkNo), text);
|
|
283
|
-
const receipt =
|
|
301
|
+
const receipt = readJsonOrNull(knockoutCorrectionFile(runDir, chunkNo));
|
|
284
302
|
const ns = new Set(defects.map((d) => d.n));
|
|
285
303
|
if (receipt) writeFileSync(knockoutCorrectionFile(runDir, chunkNo), JSON.stringify({ ...receipt, chunkSha: chunkSha(text),
|
|
286
304
|
answers: (receipt.answers ?? []).filter((a) => !ns.has(a.defect)), rolledBack: [...new Set([...(receipt.rolledBack ?? []), ...ns])] }, null, 2) + "\n");
|
|
@@ -297,7 +315,7 @@ export function knockoutCorrectionRefusalsFor(runDir, chunkNo = 0) {
|
|
|
297
315
|
/** The answers every chunk of the round has given, by defect. */
|
|
298
316
|
export function correctionAnswers(runDir, chunkNos) {
|
|
299
317
|
const out = new Map();
|
|
300
|
-
for (const c of chunkNos) for (const a of
|
|
318
|
+
for (const c of chunkNos) for (const a of readJsonOrNull(knockoutCorrectionFile(runDir, c))?.answers ?? []) out.set(a.defect, a);
|
|
301
319
|
return out;
|
|
302
320
|
}
|
|
303
321
|
|
|
@@ -326,17 +344,29 @@ export function correctionOutcomes(work, after, answers = new Map()) {
|
|
|
326
344
|
}
|
|
327
345
|
|
|
328
346
|
/**
|
|
329
|
-
* What moved under a name no defect concerns
|
|
330
|
-
*
|
|
347
|
+
* What moved under a name no defect concerns: its record, or its block in the batch summary, each with its before and after.
|
|
348
|
+
* The correction may reach such a name where its repair needs to, and says why in its answers; the recheck reads every one
|
|
349
|
+
* listed here. A finding a defect names, corrected where it prints on this name, is allowed, and it is listed all the same,
|
|
350
|
+
* with the defects whose finding it is: the review accounts for every name that changed. `complete: false` when either record
|
|
351
|
+
* cannot be read: an absent record cannot show that nothing moved, and the recheck then reads the whole batch. PURE.
|
|
331
352
|
*/
|
|
332
353
|
export function movedOutsideScope(work, after) {
|
|
333
|
-
const
|
|
334
|
-
const
|
|
335
|
-
|
|
354
|
+
const defects = work?.defects ?? [];
|
|
355
|
+
const concerned = new Set(defects.map((d) => nameKey(d.mark)));
|
|
356
|
+
const shape = (m) => (m ? JSON.stringify({ ...m, findings: (m.findings ?? []).map(withoutOrdinal) }) : null);
|
|
357
|
+
const namedOn = (m, names) => JSON.stringify((m?.findings ?? []).filter((f) => sameFinding(f, names)).map(withoutOrdinal));
|
|
358
|
+
const marks = [], blocks = [], moved = [];
|
|
359
|
+
if (!Array.isArray(work?.rated?.marks) || !Array.isArray(after?.marks)) return { marks, blocks, moved, complete: false };
|
|
360
|
+
for (const was of work.rated.marks) {
|
|
336
361
|
if (concerned.has(nameKey(was?.name))) continue;
|
|
337
|
-
const now =
|
|
338
|
-
|
|
339
|
-
|
|
362
|
+
const now = after.marks.find((m) => nameKey(m?.name) === nameKey(was?.name)) ?? null;
|
|
363
|
+
const blockWas = summaryBlock(work.rated?.batch?.executiveSummary, was.name), blockNow = summaryBlock(after?.batch?.executiveSummary, was.name);
|
|
364
|
+
const record = shape(was) !== shape(now), block = blockWas !== blockNow;
|
|
365
|
+
if (record) marks.push(was.name);
|
|
366
|
+
if (block) blocks.push(was.name);
|
|
367
|
+
if (!record && !block) continue;
|
|
368
|
+
const linked = defects.filter((d) => d.names && namedOn(was, d.names) !== namedOn(now, d.names)).map((d) => d.n);
|
|
369
|
+
moved.push({ name: was.name, defects: linked, before: { mark: was, block: blockWas }, after: { mark: now, block: blockNow } });
|
|
340
370
|
}
|
|
341
|
-
return { marks, blocks };
|
|
371
|
+
return { marks, blocks, moved, complete: true };
|
|
342
372
|
}
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
import { mkdirSync, writeFileSync, readFileSync } from "node:fs";
|
|
45
45
|
import { captureCall, stampVerdict } from "./call-capture.mjs";
|
|
46
46
|
import { join } from "node:path";
|
|
47
|
-
import { driverDir } from "../shared/driver-dir.mjs";
|
|
48
47
|
import { refuseUndeclared as refuseUndeclaredShared, keepIfAbsent, lastAccepted, acceptedEnvelope } from "./preserve-merge.mjs";
|
|
49
48
|
// The collision predicate itself, imported. See the duplication note above: two copies of a rule are how
|
|
50
49
|
// two gates come to disagree about what they are enforcing.
|
|
@@ -52,6 +51,7 @@ import { kebabCollisions } from "./search-policy.mjs";
|
|
|
52
51
|
// The plan's own checks for the web search's lists, one definition: the call is refused with the plan's
|
|
53
52
|
// sentence, so the seat hears the rule once, in the same words, whichever door it reaches first.
|
|
54
53
|
import { placesDefect, spellingsDefect, useKindDefect, alternativesDefect } from "./verify-knockout.mjs";
|
|
54
|
+
import { paths as runPaths } from "./run-record.mjs";
|
|
55
55
|
|
|
56
56
|
const SCHEMA_VERSION = 1;
|
|
57
57
|
|
|
@@ -67,7 +67,7 @@ export function knockoutFrameFiles(runDir) {
|
|
|
67
67
|
* directory cannot be overwritten by a sibling.
|
|
68
68
|
*/
|
|
69
69
|
export function knockoutFrameCallPaths(runDir) {
|
|
70
|
-
const dir =
|
|
70
|
+
const dir = runPaths(runDir).knockoutFrameCalls;
|
|
71
71
|
return { dir, payload: join(dir, "call-001.json"), accepted: join(dir, "accepted.json"),
|
|
72
72
|
refusals: join(dir, "refusals.jsonl") };
|
|
73
73
|
}
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
//
|
|
25
25
|
// NO MODEL TOUCHES A ROW. The step names record ids; this module joins them to what the register answered.
|
|
26
26
|
|
|
27
|
-
import { appendFileSync, mkdirSync, readdirSync,
|
|
27
|
+
import { appendFileSync, mkdirSync, readdirSync, renameSync, writeFileSync } from "node:fs";
|
|
28
28
|
import { dirname, join } from "node:path";
|
|
29
|
+
import { createHash } from "node:crypto";
|
|
29
30
|
|
|
30
|
-
import { driverDir } from "../shared/driver-dir.mjs";
|
|
31
31
|
import { kebab } from "./search-policy.mjs";
|
|
32
32
|
import { resolveRegions } from "./register-plan.mjs";
|
|
33
33
|
import { reachableRegions } from "./register-availability.mjs";
|
|
@@ -35,6 +35,7 @@ import { RECORD_BASIS, fixtureLister, toRecord } from "./register-records.mjs";
|
|
|
35
35
|
import { ENUMERATE_CEILING_DEFAULT } from "../providers/_shared/enumerate.mjs";
|
|
36
36
|
export { writeFixtureMarker } from "./register-fixture-marker.mjs";
|
|
37
37
|
import { withFilingGoods } from "./filing-goods.mjs";
|
|
38
|
+
import { driverDir, readJson } from "./run-record.mjs";
|
|
38
39
|
|
|
39
40
|
export const QUESTION_PLAN_FILE = "register-plan.json";
|
|
40
41
|
export const BAND_DIR = "register-units";
|
|
@@ -115,7 +116,7 @@ export function knockoutQuestionPlan({ marks, classes = null, jurisdictions = nu
|
|
|
115
116
|
/** The questions the frame's added classes owe one name, from the run's frozen plan: each class's identical-name question. */
|
|
116
117
|
export function addedClassQuestions(runDir, name) {
|
|
117
118
|
let plan = null;
|
|
118
|
-
try { plan =
|
|
119
|
+
try { plan = readJson(questionPlanPath(runDir)); } catch { return []; }
|
|
119
120
|
return addedOf(plan, name);
|
|
120
121
|
}
|
|
121
122
|
const addedOf = (plan, name) => (plan?.entries ?? []).filter((e) => e?.axis === knockoutAxis(name) && e?.added_class_reason)
|
|
@@ -125,7 +126,7 @@ const addedOf = (plan, name) => (plan?.entries ?? []).filter((e) => e?.axis ===
|
|
|
125
126
|
export function knockoutBandBlocks(runDir, name) {
|
|
126
127
|
const out = new Map();
|
|
127
128
|
let doc;
|
|
128
|
-
try { doc =
|
|
129
|
+
try { doc = readJson(knockoutBandPath(runDir, name)); } catch { return out; }
|
|
129
130
|
for (const b of Array.isArray(doc) ? doc : []) if (b?.qid) out.set(String(b.qid), b);
|
|
130
131
|
return out;
|
|
131
132
|
}
|
|
@@ -134,7 +135,7 @@ export function knockoutBandBlocks(runDir, name) {
|
|
|
134
135
|
export function knockoutProposals(runDir, name) {
|
|
135
136
|
const path = join(String(runDir ?? ""), BAND_DIR, `${knockoutAxis(name)}-supplemental-plan.json`);
|
|
136
137
|
try {
|
|
137
|
-
const doc =
|
|
138
|
+
const doc = readJson(path);
|
|
138
139
|
return { entries: Array.isArray(doc?.entries) ? doc.entries : [], rejected: Array.isArray(doc?.rejected) ? doc.rejected : [] };
|
|
139
140
|
} catch { return { entries: [], rejected: [] }; }
|
|
140
141
|
}
|
|
@@ -578,7 +579,7 @@ export function knockoutListView(runDir, { qid, record_id: recordId = null }, go
|
|
|
578
579
|
try { files = readdirSync(dir).filter((f) => f.endsWith("-band.json")); } catch { files = []; }
|
|
579
580
|
for (const f of files) {
|
|
580
581
|
let doc;
|
|
581
|
-
try { doc =
|
|
582
|
+
try { doc = readJson(join(dir, f)); } catch { continue; }
|
|
582
583
|
for (const b of Array.isArray(doc) ? doc : []) if (String(b?.qid ?? "") === want) found = b;
|
|
583
584
|
if (found) break;
|
|
584
585
|
}
|
|
@@ -602,7 +603,7 @@ export function knockoutListView(runDir, { qid, record_id: recordId = null }, go
|
|
|
602
603
|
|
|
603
604
|
/** All the wording held for one filing: its whole held record where one was written, else the statements its view carries. */
|
|
604
605
|
function heldWording(record, runDir) {
|
|
605
|
-
try { if (record.fullRecord) return { full_record:
|
|
606
|
+
try { if (record.fullRecord) return { full_record: readJson(join(String(runDir ?? ""), record.fullRecord)) }; }
|
|
606
607
|
catch { /* the view below is what is left to read */ }
|
|
607
608
|
return { goods: record.goods };
|
|
608
609
|
}
|
|
@@ -632,36 +633,52 @@ const MATCH_MODES = Object.freeze({ exact: "exact", default: "default", phonetic
|
|
|
632
633
|
* never as a zero. For offline runs and tests alone, and it sends nothing anywhere. Returns the executor's summary text.
|
|
633
634
|
*/
|
|
634
635
|
export async function executeQuestionsWithLister(lister, { plan_path: planPath, axis, output_path: outputPath, qids = null }) {
|
|
635
|
-
const plan =
|
|
636
|
+
const plan = readJson(planPath);
|
|
636
637
|
const wanted = Array.isArray(qids) && qids.length ? new Set(qids.map(String)) : null;
|
|
637
|
-
const
|
|
638
|
-
if (!
|
|
638
|
+
const asked = (plan?.entries ?? []).filter((e) => e?.axis === axis && (!wanted || wanted.has(String(e?.qid))));
|
|
639
|
+
if (!asked.length) return { type: "text", text: `ERROR: the plan carries no entries for axis "${axis}".` };
|
|
639
640
|
let band = [];
|
|
640
|
-
try { const had =
|
|
641
|
-
const owned = new Set(entries.map((e) => String(e.qid)));
|
|
642
|
-
const states = {};
|
|
643
|
-
const blocks = [];
|
|
641
|
+
try { const had = readJson(outputPath); if (Array.isArray(had)) band = had; } catch { /* first write */ }
|
|
644
642
|
// What the name's own question was asked over: a question over other classes is a narrower one, and is keyed as one.
|
|
645
643
|
let nameClasses = null;
|
|
646
644
|
try {
|
|
647
|
-
const frozen =
|
|
645
|
+
const frozen = readJson(driverDir(dirname(dirname(outputPath)), QUESTION_PLAN_FILE));
|
|
648
646
|
nameClasses = (frozen?.entries ?? []).find((f) => f?.axis === axis && f?.provenance === "mark" && !f?.added_class_reason)?.nice_classes ?? null;
|
|
649
647
|
} catch { nameClasses = null; }
|
|
650
648
|
const sameClasses = (a) => JSON.stringify([...(a ?? [])].map(String).sort()) === JSON.stringify([...(nameClasses ?? [])].map(String).sort());
|
|
649
|
+
/** What one question sends the register, term by term. */
|
|
650
|
+
const sentFor = (e) => (Array.isArray(e?.terms) ? e.terms : [e?.term]).map((term) => ({ term, classes: sameClasses(e.nice_classes) ? [] : (e.nice_classes ?? []),
|
|
651
|
+
regions: e.regions ?? [], matchMode: MATCH_MODES[e?.predicate] ?? "default", goods: e.goods_text ?? null, scoped: true }));
|
|
652
|
+
const sentKey = (e) => createHash("sha256").update(JSON.stringify(sentFor(e))).digest("hex").slice(0, 16);
|
|
653
|
+
// NEVER PAID FOR TWICE (2026-11-11). A register answer is paid for, and it does not change within the run. So a
|
|
654
|
+
// question this run already holds an answer to is not sent again, whoever asks it and however often: a resume, a
|
|
655
|
+
// step run again, or the code asking what the plan owes on every pass. Its answer stands in the band. A failed
|
|
656
|
+
// answer is no answer, so that question is asked again, as finishing the run would ask it.
|
|
657
|
+
//
|
|
658
|
+
// AN ANSWER STANDS ONLY FOR THE QUESTION IT ANSWERED. The plan is written again on every pass from the framed names,
|
|
659
|
+
// and a name's own questions keep their ids when the frame changes their words or classes. So each block records
|
|
660
|
+
// what was sent for it (`sent`), and a held answer stands only where the question now sends exactly that. A block
|
|
661
|
+
// that records nothing of what was sent cannot show it answered this question, so the question is asked again.
|
|
662
|
+
const answered = new Map(band.filter((b) => b?.qid && b.error !== true).map((b) => [String(b.qid), b]));
|
|
663
|
+
const holds = (e) => answered.get(String(e.qid))?.sent === sentKey(e);
|
|
664
|
+
const held = asked.filter(holds);
|
|
665
|
+
const entries = asked.filter((e) => !holds(e));
|
|
666
|
+
const states = Object.fromEntries(held.map((e) => [e.qid, answered.get(String(e.qid)).state ?? "held"]));
|
|
667
|
+
if (!entries.length) return { type: "text", text: JSON.stringify({ skipped: [], held: held.map((e) => e.qid), states }) };
|
|
668
|
+
const owned = new Set(entries.map((e) => String(e.qid)));
|
|
669
|
+
const blocks = [];
|
|
651
670
|
for (const e of entries) {
|
|
652
|
-
const
|
|
653
|
-
const base = { qid: e.qid, query: { term: e.term ?? null, terms: e.terms ?? null, predicate: e.predicate ?? null } };
|
|
671
|
+
const base = { qid: e.qid, query: { term: e.term ?? null, terms: e.terms ?? null, predicate: e.predicate ?? null }, sent: sentKey(e) };
|
|
654
672
|
const rows = [];
|
|
655
673
|
const seen = new Set();
|
|
656
674
|
const warnings = [];
|
|
657
675
|
let total = 0;
|
|
658
676
|
let failure = null;
|
|
659
677
|
if (e?.unsupported) failure = String(e.unsupported_reason ?? "this register cannot express this question");
|
|
660
|
-
for (const t of failure ? [] :
|
|
678
|
+
for (const { term: t, ...asks } of failure ? [] : sentFor(e)) {
|
|
661
679
|
let r;
|
|
662
680
|
try {
|
|
663
|
-
r = await lister(t,
|
|
664
|
-
matchMode: MATCH_MODES[e?.predicate] ?? "default", goods: e.goods_text ?? null, scoped: true });
|
|
681
|
+
r = await lister(t, asks);
|
|
665
682
|
} catch (err) { r = { ok: false, reason: `record listing threw: ${String(err?.message ?? err).slice(0, 200)}` }; }
|
|
666
683
|
if (!r?.ok || !Array.isArray(r?.records)) { failure = String(r?.reason ?? "the question was not answered"); break; }
|
|
667
684
|
total += Number.isFinite(r.total) ? r.total : r.records.length;
|
|
@@ -685,7 +702,7 @@ export async function executeQuestionsWithLister(lister, { plan_path: planPath,
|
|
|
685
702
|
mkdirSync(dirname(outputPath), { recursive: true });
|
|
686
703
|
writeFileSync(`${outputPath}.tmp`, JSON.stringify([...band.filter((b) => !owned.has(String(b?.qid))), ...blocks], null, 2) + "\n");
|
|
687
704
|
renameSync(`${outputPath}.tmp`, outputPath);
|
|
688
|
-
return { type: "text", text: JSON.stringify({ skipped: [], states }) };
|
|
705
|
+
return { type: "text", text: JSON.stringify({ skipped: [], ...(held.length ? { held: held.map((e) => e.qid) } : {}), states }) };
|
|
689
706
|
}
|
|
690
707
|
|
|
691
708
|
/**
|
|
@@ -17,9 +17,9 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
17
17
|
import { basename, dirname, join } from "node:path";
|
|
18
18
|
|
|
19
19
|
import { captureCall, stampVerdict } from "./call-capture.mjs";
|
|
20
|
-
import { DRIVER_DIR, driverDir } from "../shared/driver-dir.mjs";
|
|
21
20
|
import { refuseUndeclared, lastAccepted, acceptedEnvelope } from "./preserve-merge.mjs";
|
|
22
21
|
import { addedClassQuestions, carriedIds, formQid, formsOfName, knockoutBandBlocks, knockoutProposals, namesAddedClass, openingQid, questionsOwed } from "./knockout-register-read.mjs";
|
|
22
|
+
import { DRIVER_DIR, paths as runPaths, readJsonOrNull } from "./run-record.mjs";
|
|
23
23
|
|
|
24
24
|
const TOKEN = "knockoutregisterread";
|
|
25
25
|
const SCHEMA_VERSION = 1;
|
|
@@ -37,7 +37,7 @@ export const knockoutRegisterFile = (runDir) => join(String(runDir ?? ""), "knoc
|
|
|
37
37
|
|
|
38
38
|
/** One file per call, refusals included, beside the other transports' capture directories. */
|
|
39
39
|
export function knockoutRegisterCallPaths(runDir) {
|
|
40
|
-
const dir =
|
|
40
|
+
const dir = runPaths(runDir).knockoutRegisterCalls;
|
|
41
41
|
return { dir, accepted: join(dir, "accepted.json"), refusals: join(dir, "refusals.jsonl") };
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -85,7 +85,6 @@ export function acceptKnockoutRegister(call) {
|
|
|
85
85
|
return { ok: true, model: { schema_version: SCHEMA_VERSION, marks } };
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const readJson = (path) => { try { return JSON.parse(readFileSync(path, "utf8")); } catch { return null; } };
|
|
89
88
|
|
|
90
89
|
/** Why one name's row cannot stand against what this run holds, or null. The record says what the step decided; this checks only that it adds up. */
|
|
91
90
|
function rowDefect(row, n, { counts, plan, runDir }) {
|
|
@@ -131,12 +130,12 @@ function rowDefect(row, n, { counts, plan, runDir }) {
|
|
|
131
130
|
* `standing` is the rows that hold whatever the verdict on the others.
|
|
132
131
|
*/
|
|
133
132
|
export function checkKnockoutRegisterAgainstRun(model, runDir) {
|
|
134
|
-
const scope =
|
|
133
|
+
const scope = readJsonOrNull(runPaths(runDir).instructedScope);
|
|
135
134
|
const instructed = (Array.isArray(scope?.marks) ? scope.marks : []).map((n) => String(n));
|
|
136
135
|
if (!instructed.length) return { ok: false, standing: [], reason: `${TOKEN}_scope: the run's instructed scope could not be read, so the names cannot be checked.` };
|
|
137
136
|
const byName = new Map(model.marks.map((m) => [nameKey(m.name), m]));
|
|
138
137
|
const known = new Set(instructed.map(nameKey));
|
|
139
|
-
const context = { counts:
|
|
138
|
+
const context = { counts: readJsonOrNull(runPaths(runDir).registerCounts), plan: readJsonOrNull(join(runDir, "knockout-plan.json")), runDir };
|
|
140
139
|
const defects = model.marks.filter((m) => !known.has(nameKey(m.name))).map((m) => `${TOKEN}_names: "${m.name}" is not an instructed name. Names verbatim from the instructed scope.`);
|
|
141
140
|
const missing = instructed.filter((n) => !byName.has(nameKey(n)));
|
|
142
141
|
if (missing.length) defects.push(`${TOKEN}_names: no row for ${missing.map((n) => `"${n}"`).join(", ")}. Send one row per instructed name.`);
|
|
@@ -168,7 +167,7 @@ export function validateKnockoutRegisterFile(file, content) {
|
|
|
168
167
|
if (!shape.ok) return shape;
|
|
169
168
|
const dir = dirname(file);
|
|
170
169
|
const runDir = basename(dir) === DRIVER_DIR ? dirname(dir) : dir;
|
|
171
|
-
if (!existsSync(
|
|
170
|
+
if (!existsSync(runPaths(runDir).instructedScope)) return { ok: false, reason: "the run's instructed scope is not on disk, so this record cannot be checked." };
|
|
172
171
|
return checkKnockoutRegisterAgainstRun(shape.model, runDir);
|
|
173
172
|
}
|
|
174
173
|
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
// its own accepted call, bound by the ordinal in its label, so nothing the first pass sent carries into it.
|
|
44
44
|
import { writeFileSync, readFileSync, existsSync } from "node:fs";
|
|
45
45
|
import { join, dirname, basename } from "node:path";
|
|
46
|
-
import { driverDir, DRIVER_DIR } from "../shared/driver-dir.mjs";
|
|
47
46
|
import { captureCall, stampVerdict } from "./call-capture.mjs";
|
|
48
47
|
import { refuseUndeclared as refuseUndeclaredShared, lastAccepted, acceptedEnvelope } from "./preserve-merge.mjs";
|
|
49
48
|
import { knockoutVisibleProse } from "./predelivery-lint.mjs"; // the walk is the authority on what a reader sees
|
|
@@ -52,6 +51,7 @@ import { plainRegisterFlags } from "./plain-register.mjs"; // the pinned
|
|
|
52
51
|
// for saying WHICH line was probably meant; it never decides whether an address resolves.
|
|
53
52
|
import { queryKey } from "./connotation-search.mjs";
|
|
54
53
|
import { PERMITTED_SOURCES, registerRecordIdsHeld, urlHeldFor } from "./verify-knockout.mjs";
|
|
54
|
+
import { DRIVER_DIR, driverDir, paths as runPaths, readJson } from "./run-record.mjs";
|
|
55
55
|
|
|
56
56
|
const SCHEMA_VERSION = 1;
|
|
57
57
|
|
|
@@ -115,7 +115,7 @@ export const MATERIAL_KINDS = Object.freeze({ band: false, missing: true, exclus
|
|
|
115
115
|
|
|
116
116
|
/** One file per call, refusals included, beside the other transports' capture directories. A later pass keeps its own. */
|
|
117
117
|
export function knockoutReviewCallPaths(runDir, pass = 0) {
|
|
118
|
-
const dir = pass ? driverDir(runDir, join("knockout-review-calls", `pass-${Number(pass)}`)) :
|
|
118
|
+
const dir = pass ? driverDir(runDir, join("knockout-review-calls", `pass-${Number(pass)}`)) : runPaths(runDir).knockoutReviewCalls;
|
|
119
119
|
return { dir, accepted: join(dir, "accepted.json"), refusals: join(dir, "refusals.jsonl") };
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -413,7 +413,7 @@ export function validateKnockoutReviewFile(file, text) {
|
|
|
413
413
|
return { ok: false, reason: `the merged record is not on disk at ${findingsFile}, so no address could be checked` };
|
|
414
414
|
}
|
|
415
415
|
let merged;
|
|
416
|
-
try { merged =
|
|
416
|
+
try { merged = readJson(findingsFile); }
|
|
417
417
|
catch (e) { return { ok: false, reason: `the merged record will not parse, so no address could be checked: ${e.message}` }; }
|
|
418
418
|
const fault = joinFault(doc, merged, runDir);
|
|
419
419
|
return fault ? { ok: false, reason: fault } : { ok: true };
|
|
@@ -457,20 +457,21 @@ function materialFault(m, merged, runDir) {
|
|
|
457
457
|
// one name. A question the run asked is held too, by its qid. Anything else is refused, in words about those sources and not the run.
|
|
458
458
|
const records = registerRecordIdsHeld(runDir);
|
|
459
459
|
let questions = new Set();
|
|
460
|
-
try { questions = new Set((
|
|
460
|
+
try { questions = new Set((readJson(runPaths(runDir).registerRecords).marks ?? []).flatMap((e) => (e?.terms ?? []).map((t) => String(t?.qid ?? "")))); } catch { questions = new Set(); }
|
|
461
461
|
const urlHeld = urlHeldFor(runDir);
|
|
462
462
|
const stranger = (m.rests_on ?? []).find((r) => !records.has(r) && !questions.has(r) && !urlHeld(r));
|
|
463
463
|
return stranger ? `the material row on "${m.mark}" rests on "${stranger}", which is not traceable to ${PERMITTED_SOURCES}, or a question this run asked. Copy a recordId, question qid, or URL from what this run holds.` : null;
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
/**
|
|
467
|
-
* The rewrites of a first pass that still have a line to land on after a correction: those on a name
|
|
468
|
-
* standing caveats. A
|
|
469
|
-
* afresh.
|
|
467
|
+
* The rewrites of a first pass that still have a line to land on after a correction: those on a name the correction did not
|
|
468
|
+
* change, and the standing caveats. A changed name, whether a defect named it or the correction reached it, is renumbered and
|
|
469
|
+
* reworded, and the batch summary with it, so the second pass reads those afresh. `changedNames` null means the correction's
|
|
470
|
+
* reach could not be compared: no rewrite on a name is taken to be independent of it, and only the caveats stand. PURE.
|
|
470
471
|
*/
|
|
471
|
-
export function rewritesThatSurvive(review,
|
|
472
|
-
const corrected = new Set([...
|
|
473
|
-
const stands = (r) => r?.at?.field === "batch.standardCaveats" || (r?.at?.mark != null && !corrected.has(String(r.at.mark).trim().toLowerCase()));
|
|
472
|
+
export function rewritesThatSurvive(review, changedNames) {
|
|
473
|
+
const corrected = changedNames == null ? null : new Set([...changedNames].map((n) => String(n ?? "").trim().toLowerCase()));
|
|
474
|
+
const stands = (r) => r?.at?.field === "batch.standardCaveats" || (corrected != null && r?.at?.mark != null && !corrected.has(String(r.at.mark).trim().toLowerCase()));
|
|
474
475
|
return { ...review, rewrites: (review?.rewrites ?? []).filter(stands) };
|
|
475
476
|
}
|
|
476
477
|
|
|
@@ -581,7 +582,7 @@ export function recordKnockoutReview(runDir, received, { boundOrdinal = null, no
|
|
|
581
582
|
}
|
|
582
583
|
|
|
583
584
|
// Where the record is on disk the seat hears the join now, in its turn. Where it is not, the stage's own check says it could not look.
|
|
584
|
-
const held = (() => { try { return
|
|
585
|
+
const held = (() => { try { return readJson(join(dir, "knockout-findings.json")); } catch { return null; } })();
|
|
585
586
|
const fault = held ? joinFault(verdict.model, held, dir) : null;
|
|
586
587
|
if (fault) {
|
|
587
588
|
journal(fault);
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
// model-gauge.mjs — which model a turn asked for, which one the wire says served it, and which program ran it.
|
|
4
|
+
//
|
|
5
|
+
// The stage ladder (gateway.mjs runStageLadder) writes these on every attempt row and run event, and fails a turn
|
|
6
|
+
// whose model the wire contradicts (turn-failure.mjs nameTheFailure). Both functions read the turn and the
|
|
7
|
+
// machine and change nothing.
|
|
8
|
+
|
|
9
|
+
import { modelFamily, modelSnapshotKind, preflightEngineBinary, olderThanFloor, ENGINE_BINARIES } from "../driver.config.mjs";
|
|
10
|
+
import { probeCliVersion } from "../engine/cli-version.mjs";
|
|
11
|
+
import { modelIdOf } from "../engine/registry.mjs";
|
|
12
|
+
|
|
13
|
+
// ── corruption 3 — WHAT WAS ASKED FOR vs WHAT ACTUALLY RAN ─────────────────────────────────
|
|
14
|
+
//
|
|
15
|
+
// Until this landed, every model figure on every record was a pure function of the REQUESTED alias:
|
|
16
|
+
// `resolveModel(model)` / `engine.resolveModelId(model)`, computed here without ever looking at the
|
|
17
|
+
// provider's answer. So `--model gemini` logged `google/gemini-3.1-pro-preview` and ran sonnet (the
|
|
18
|
+
// engine's alias table substituted, silently), a haiku stage that bounced to sonnet logged haiku,
|
|
19
|
+
// and every attribution downstream — the A/B arm's manifest, tokens.mjs' per-model rollup, the
|
|
20
|
+
// billing classes — was keyed to a model that had not run. Patching the log would not have fixed
|
|
21
|
+
// it; the log was already saying what the code believed.
|
|
22
|
+
//
|
|
23
|
+
// TWO FIELDS, NEVER COLLAPSED INTO ONE:
|
|
24
|
+
// modelUsed — the requested resolution, unchanged in meaning and value: run-economics.mjs and
|
|
25
|
+
// tokens.mjs both read it, and a field that quietly changes meaning is its own corruption.
|
|
26
|
+
// modelActual — the id the WIRE reported (engine tuple `modelWire`), or NULL when the stream never
|
|
27
|
+
// said: an engine that does not emit one (codex), a turn killed before any event, a
|
|
28
|
+
// spawn error. It NEVER falls back to the requested alias, and `modelBasis` ("actual" or
|
|
29
|
+
// "unknown") never dresses a requested value as an observed one. `providerReported` is
|
|
30
|
+
// the provider word the same stream gave (tuple `providerWire`), null on the same terms.
|
|
31
|
+
export function modelGauge(engine, model, turn) {
|
|
32
|
+
const modelRequested = modelIdOf(engine, model);
|
|
33
|
+
const modelActual = (typeof turn.modelWire === "string" && turn.modelWire) ? turn.modelWire : null;
|
|
34
|
+
const modelBasis = modelActual ? "actual" : "unknown";
|
|
35
|
+
const providerReported = (typeof turn.providerWire === "string" && turn.providerWire) ? turn.providerWire : null;
|
|
36
|
+
// WHETHER THE OBSERVED ID NAMES A FIXED BUILD. `modelBasis: "actual"` says the provider answered,
|
|
37
|
+
// not that the answer is pinned: two of the three tiers come back as undated aliases the provider
|
|
38
|
+
// may repoint, and recorded beside a dated one they read identically. null when there is nothing to
|
|
39
|
+
// judge, never collapsed into "alias".
|
|
40
|
+
const modelSnapshot = modelSnapshotKind(modelActual);
|
|
41
|
+
// The comparison is by FAMILY (driver.config modelFamily), because `--model haiku` legitimately comes
|
|
42
|
+
// back as `claude-haiku-4-5-20251001`. THREE-VALUED: null when either side names no family this
|
|
43
|
+
// build recognises — an unknown is recorded as unknown and never as agreement.
|
|
44
|
+
const famRequested = modelFamily(modelRequested), famActual = modelFamily(modelActual);
|
|
45
|
+
const modelMismatch = (famRequested && famActual) ? famRequested !== famActual : null;
|
|
46
|
+
return { modelRequested, modelActual, modelBasis, providerReported, modelSnapshot, famRequested, famActual, modelMismatch };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// WHICH BUILD OF THE TOOL SERVED THIS TURN. `modelSnapshot` above answers "did the model move";
|
|
50
|
+
// this answers "did the tool move", and the two have one symptom — a run whose judgment differs from
|
|
51
|
+
// last week's. Captured at dispatch rather than read back afterwards, because the binary a reader
|
|
52
|
+
// could probe later is not necessarily the one that ran.
|
|
53
|
+
//
|
|
54
|
+
// Written as an object with its own `probe` field, so an unreadable version is a RECORDED state
|
|
55
|
+
// rather than a missing one. Omitting it on failure would collapse "asked and could not say" into
|
|
56
|
+
// "written before anybody asked", which is the distinction the field exists for. One spawn per
|
|
57
|
+
// binary per process; a probe never throws, because taking down a dispatch to record a version
|
|
58
|
+
// would be a worse defect than the gap it closes.
|
|
59
|
+
// `source` says WHICH copy served (explicit / path / installed), and it is attached here, outside the
|
|
60
|
+
// probe's cache: that cache is keyed by the file, and one file can be reached by more than one route.
|
|
61
|
+
export function servingProgram() {
|
|
62
|
+
try {
|
|
63
|
+
const pre = preflightEngineBinary(process.env);
|
|
64
|
+
const probed = probeCliVersion(pre?.resolved ?? null);
|
|
65
|
+
// ── THE FLOOR, COMPARED WHERE THE RUN CAN SEE IT ────────────────────────────────────────
|
|
66
|
+
//
|
|
67
|
+
// The build declares a minimum version for each engine's program, and until now nothing
|
|
68
|
+
// compared a running copy against it. The floor was passed to the installer, so a copy this
|
|
69
|
+
// product installs cannot land beneath it — but resolution walks PATH first and takes the
|
|
70
|
+
// first hit, so a copy already on the machine wins and was never measured against anything.
|
|
71
|
+
// That is the common case, not the edge one: most machines have their own copy. A stage then
|
|
72
|
+
// runs on a program below the floor and is served whatever that program serves, silently.
|
|
73
|
+
//
|
|
74
|
+
// RECORDED, NOT REFUSED. Refusing here would stop every run on any machine whose copy is
|
|
75
|
+
// behind — including ones already deployed and working — and that is a decision about those
|
|
76
|
+
// deployments rather than a defect fix. What was missing is the fact, so the fact is what is
|
|
77
|
+
// written: an operator, and anyone reading the run afterwards, can now see it. Whether it
|
|
78
|
+
// should also refuse is a separate question and is not answered here.
|
|
79
|
+
//
|
|
80
|
+
// THREE-VALUED and written unconditionally, like the model fields below: true, false, or null
|
|
81
|
+
// when either side names no version this build can compare — an unknown is an unknown, never
|
|
82
|
+
// an all-clear. The floor itself rides along so the record says what it was measured against
|
|
83
|
+
// rather than leaving a later reader to guess which build's floor applied.
|
|
84
|
+
const floor = ENGINE_BINARIES[pre?.engine]?.floor ?? null;
|
|
85
|
+
const belowFloor = floor ? olderThanFloor(probed?.version ?? null, floor) : null;
|
|
86
|
+
return { ...probed, source: pre?.source ?? null, floor, belowFloor };
|
|
87
|
+
} catch (e) { return { version: null, probe: "unreadable", why: String(e?.message ?? e).slice(0, 160), source: null, floor: null, belowFloor: null }; }
|
|
88
|
+
}
|