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,162 @@
|
|
|
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
|
+
// run-choices.mjs — the engine and the register a run started on, frozen in the run so a resume keeps them.
|
|
4
|
+
//
|
|
5
|
+
// Both used to be read from the environment at every activation and recorded nowhere. A run parked on one engine
|
|
6
|
+
// and resumed after the machine's setting changed carried on under the other, and nothing in its record said so.
|
|
7
|
+
// The choice is now written once, when the run starts, and belongs to the run from then on:
|
|
8
|
+
//
|
|
9
|
+
// - a later change to the machine's setting applies to new runs only;
|
|
10
|
+
// - a resumed run keeps its recorded engine, and one this driver cannot serve is refused by name rather than
|
|
11
|
+
// swapped for the machine's default;
|
|
12
|
+
// - a run with no record is left without one. Nothing here writes a record for a run that has already started,
|
|
13
|
+
// because that would date today's setting back to a start nobody recorded.
|
|
14
|
+
//
|
|
15
|
+
// The record holds the two names and nothing else. Each must name an engine this driver ships or a register it
|
|
16
|
+
// knows, so no other string (a credential included) can be written into it.
|
|
17
|
+
//
|
|
18
|
+
// A LEAF: it reads the shipped-engine table, not the engine registry. The jurisdiction lanes' turn runner reads the
|
|
19
|
+
// record, tool servers reach that runner, and the registry would bring both engine adapters and every setting they
|
|
20
|
+
// read into each tool server's imports. The registry's `engineForRun` serves a run's turns from this record.
|
|
21
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
22
|
+
import { driverDir, ensureDriverDir } from "../../shared/driver-dir.mjs";
|
|
23
|
+
import { ENGINE_BINARIES, PROVIDERS, REGISTER_PROVIDER, activeProvider } from "../driver.config.mjs";
|
|
24
|
+
|
|
25
|
+
export const RUN_CHOICES_FILE = "run-choices.json";
|
|
26
|
+
|
|
27
|
+
const nameOf = (v) => (v == null ? null : String(v).trim().toLowerCase() || null);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Write the run's engine and register, once. A record already on disk is never rewritten: the call answers
|
|
31
|
+
* with what is there and `written: false`, so a cold start that is retried keeps its first choice.
|
|
32
|
+
* `register` is null when the machine has none set; that is recorded as it was, not guessed.
|
|
33
|
+
*/
|
|
34
|
+
export function recordRunChoices(runDir, { engine, register }) {
|
|
35
|
+
const held = readRunChoices(runDir);
|
|
36
|
+
if (held.state !== "none") return { written: false, ...held };
|
|
37
|
+
const e = nameOf(engine), r = nameOf(register);
|
|
38
|
+
if (!e || !Object.hasOwn(ENGINE_BINARIES, e))
|
|
39
|
+
throw new Error(`run-choices: "${e}" is not an engine this driver ships (${Object.keys(ENGINE_BINARIES).join(", ")})`);
|
|
40
|
+
if (r !== null && !Object.hasOwn(PROVIDERS, r))
|
|
41
|
+
throw new Error(`run-choices: "${r}" is not a register this driver knows (${Object.keys(PROVIDERS).join(", ")})`);
|
|
42
|
+
ensureDriverDir(runDir);
|
|
43
|
+
const p = driverDir(runDir, RUN_CHOICES_FILE);
|
|
44
|
+
writeFileSync(`${p}.tmp`, JSON.stringify({ schema: 1, engine: e, register: r }, null, 2) + "\n");
|
|
45
|
+
renameSync(`${p}.tmp`, p);
|
|
46
|
+
return { written: true, state: "recorded", engine: e, register: r };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What the run recorded: `{ state: "recorded", engine, register }`, `{ state: "none" }` for a run that has no
|
|
51
|
+
* record, or `{ state: "unreadable", detail }` for one whose record does not read back as the two names.
|
|
52
|
+
*/
|
|
53
|
+
export function readRunChoices(runDir) {
|
|
54
|
+
if (!runDir) return { state: "none" };
|
|
55
|
+
const p = driverDir(runDir, RUN_CHOICES_FILE);
|
|
56
|
+
if (!existsSync(p)) return { state: "none" };
|
|
57
|
+
let o;
|
|
58
|
+
try { o = JSON.parse(readFileSync(p, "utf8")); }
|
|
59
|
+
catch (err) { return { state: "unreadable", detail: `does not parse: ${String(err?.message ?? err).slice(0, 200)}` }; }
|
|
60
|
+
const engine = nameOf(o?.engine), register = nameOf(o?.register);
|
|
61
|
+
if (!engine) return { state: "unreadable", detail: "names no engine" };
|
|
62
|
+
if (o?.register != null && typeof o.register !== "string") return { state: "unreadable", detail: "its register is not a name" };
|
|
63
|
+
return { state: "recorded", engine, register };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A resumed run whose recorded engine or register this process cannot serve.
|
|
68
|
+
*
|
|
69
|
+
* It is a PARK, not a failure. It is raised before any check spends anything and before the run's markers are cleared,
|
|
70
|
+
* so the run keeps every stage it finished, and `dependency` names what it waits for. The pipeline holds the run until
|
|
71
|
+
* a process that serves the recorded choice resumes it. There is no deadline, and the run is never moved to the
|
|
72
|
+
* machine's choice. `run` is the run's identity, because this is raised before the pipeline holds one.
|
|
73
|
+
*
|
|
74
|
+
* `kind` is one of:
|
|
75
|
+
* register this runner cannot serve the run's register: a credential or a capability it needs is missing here;
|
|
76
|
+
* engine this driver has no adapter for the run's engine;
|
|
77
|
+
* engine-program the run's engine program is not installed here;
|
|
78
|
+
* engine-sign-in the run's engine refused a turn for a configuration fault (signed out, no key).
|
|
79
|
+
*/
|
|
80
|
+
export const RUN_CHOICE_KINDS = Object.freeze(["register", "engine", "engine-program", "engine-sign-in"]);
|
|
81
|
+
export class RunChoiceUnavailable extends Error {
|
|
82
|
+
constructor({ kind, recorded, machine = null, detail = null, run = null }) {
|
|
83
|
+
if (!RUN_CHOICE_KINDS.includes(kind)) throw new Error(`RunChoiceUnavailable: unknown kind "${kind}"`);
|
|
84
|
+
const what = kind === "register" ? `the ${recorded} register` : `the ${recorded} engine`;
|
|
85
|
+
const why = kind === "register" ? "this runner cannot serve it"
|
|
86
|
+
: kind === "engine" ? "this driver has no adapter for it"
|
|
87
|
+
: kind === "engine-program" ? "its program is not installed here"
|
|
88
|
+
: "it cannot take a turn here";
|
|
89
|
+
super(`run ${run?.codename ?? "(unnamed)"} started on ${what}, and ${why}${detail ? ` (${String(detail).slice(0, 300)})` : ""}. It is parked with its work kept, and resumes on ${what}.`);
|
|
90
|
+
this.name = "RunChoiceUnavailable";
|
|
91
|
+
this.dependency = { kind, recorded, machine, detail: detail == null ? null : String(detail).slice(0, 300) };
|
|
92
|
+
this.run = run;
|
|
93
|
+
// For the park's own record, as the rate-limit park writes its two lines: what it waits for, and what ends the wait.
|
|
94
|
+
this.waitingOn = `${what}, which this run started on (${why})`;
|
|
95
|
+
this.resolvedBy = kind === "register"
|
|
96
|
+
? `${what}'s credentials and capabilities set for this runner, on this build; the run resumes where it stopped`
|
|
97
|
+
: `${what} made available to this runner (installed and signed in), on this build; the run resumes where it stopped`;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Which recorded choice this process cannot serve, before anything is checked or spent, or null. The engine is
|
|
103
|
+
* unservable here only when no adapter is registered for it; a missing program or sign-in is found by the engine doors.
|
|
104
|
+
* The register is not decided here: a recorded register is served wherever this runner holds what it needs, whatever
|
|
105
|
+
* the machine's default, and the register's own door finds out (`registerEnvFor`, steps/open-run.mjs). PURE.
|
|
106
|
+
*/
|
|
107
|
+
export function unservedChoice(recorded, { engineRegistered }) {
|
|
108
|
+
if (recorded?.state !== "recorded") return null;
|
|
109
|
+
if (!engineRegistered) return { kind: "engine", recorded: recorded.engine, machine: null };
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The environment the register's door checks for this run: a copy of `env` naming the run's recorded register, or `env`
|
|
115
|
+
* itself for a run with no record or one that started with none set. A copy, so one run's register never changes the
|
|
116
|
+
* process environment every concurrent run shares. PURE.
|
|
117
|
+
*/
|
|
118
|
+
export function registerEnvFor(recorded, env = process.env) {
|
|
119
|
+
return recorded?.state === "recorded" && recorded.register ? { ...env, CLEAROTRON_DATABASE: recorded.register } : env;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The register door a run meets: null where it skips the door, else `{ env, parks }`. `env` is what the door checks
|
|
124
|
+
* (`registerEnvFor`), and `parks` says a refusal parks the run rather than failing it, which it does only for a
|
|
125
|
+
* recorded register that is not the machine's. A run whose record fetches are injected (an offline replay) skips the
|
|
126
|
+
* door. So does a Knockout on the machine's own register, as it always has; a Knockout recorded on another register
|
|
127
|
+
* meets the door, because its counts and filings are that register's. PURE.
|
|
128
|
+
*/
|
|
129
|
+
export function registerDoor(recorded, { machineRegister = null, knockout = false, fetchesInjected = false, env = process.env } = {}) {
|
|
130
|
+
if (fetchesInjected) return null;
|
|
131
|
+
const differs = recorded?.state === "recorded" && Boolean(recorded.register) && recorded.register !== (machineRegister ?? null);
|
|
132
|
+
if (knockout && !differs) return null;
|
|
133
|
+
return { env: registerEnvFor(recorded, env), parks: differs };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The register that serves this run: the one it recorded when it started, or the machine's for a run with no record or
|
|
138
|
+
* one that started with none set, whatever the machine's default is now. It is the one place a run's register is
|
|
139
|
+
* decided. A recorded register this runner cannot serve parks the run at the register's door before any stage. PURE
|
|
140
|
+
* but for reading the record.
|
|
141
|
+
*/
|
|
142
|
+
export function registerForRun(runDir) {
|
|
143
|
+
const rec = readRunChoices(runDir);
|
|
144
|
+
return rec.state === "recorded" && rec.register ? rec.register : (REGISTER_PROVIDER ?? null);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The register the run recorded, or null for a run with no record or one that started with none set. PURE but for the read. */
|
|
148
|
+
export function recordedRegister(runDir) {
|
|
149
|
+
const rec = readRunChoices(runDir);
|
|
150
|
+
return rec.state === "recorded" && rec.register ? rec.register : null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The register adapter for a run's register (`ctx.register`), or the machine's when none is named: the one way a place
|
|
155
|
+
* that reads a register for a run asks for its adapter. A name this driver does not know throws, as `activeProvider` does.
|
|
156
|
+
*/
|
|
157
|
+
export function registerAdapter(register = null) {
|
|
158
|
+
if (!register) return activeProvider();
|
|
159
|
+
const a = PROVIDERS[register];
|
|
160
|
+
if (!a) throw new Error(`[register-provider] unknown register "${register}". Known: ${Object.keys(PROVIDERS).join(", ")}`);
|
|
161
|
+
return a;
|
|
162
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
// stamps.mjs — what the `engine` word on a saved attempt row means.
|
|
4
|
+
//
|
|
5
|
+
// It imports nothing, so the rollup readers can ask it without joining an import loop or loading an adapter.
|
|
6
|
+
// The word on a row is wider than the registered engines: this table is about rows already on disk.
|
|
7
|
+
//
|
|
8
|
+
// A CLOSED TABLE, NOT A PREFIX RULE. `anthropic-*` → anthropic is shorter and would silently adopt any
|
|
9
|
+
// future engine whose name began that way, which is how a vendor claim becomes a guess. An engine this
|
|
10
|
+
// table does not know is reported BY NAME and blocks the single-vendor claim, because "I do not know who
|
|
11
|
+
// billed this" and "one vendor" are different answers and only one of them is safe to print.
|
|
12
|
+
//
|
|
13
|
+
// THE NATIVE-LANGUAGE ROWS STAMP THE VENDOR ITSELF. jxBillingStamp (jx-lanes.mjs) writes as the row's
|
|
14
|
+
// engine the provider the engine door resolved, `anthropic` or `openai` (engine/auth.mjs), so those two
|
|
15
|
+
// names are engines this table must place. Without them an Anthropic-only run with a native-language turn
|
|
16
|
+
// named `anthropic` as an engine that bills to no vendor, in the same sentence that named anthropic as its
|
|
17
|
+
// one vendor. Two exact names, still a closed table.
|
|
18
|
+
//
|
|
19
|
+
// `catalog` says how to key a row with no `modelUsed`: "tier" reads its `model` through Claude's catalog
|
|
20
|
+
// (`resolveModel`), "served" keys it as the id it carries, and a stamp without the field has no honest key.
|
|
21
|
+
// `nativeLanguage` marks a row whose `model` is the id that served the turn and not the tier it asked for.
|
|
22
|
+
const ENGINE_STAMPS = Object.freeze({
|
|
23
|
+
"anthropic-agent": { vendor: "anthropic", catalog: "tier" },
|
|
24
|
+
"anthropic-direct": { vendor: "anthropic" },
|
|
25
|
+
"anthropic-completions": { vendor: "anthropic" },
|
|
26
|
+
"openai-agent": { vendor: "openai" },
|
|
27
|
+
"anthropic": { vendor: "anthropic", catalog: "tier", nativeLanguage: true },
|
|
28
|
+
"openai": { vendor: "openai", catalog: "served", nativeLanguage: true },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/** What this table says about a stamp, or an empty record when it does not name it. */
|
|
32
|
+
export const engineStamp = (engine) => (Object.hasOwn(ENGINE_STAMPS, String(engine ?? "")) ? ENGINE_STAMPS[String(engine)] : {});
|
|
33
|
+
|
|
34
|
+
/** The vendor an engine bills to, or null when the table does not name one. */
|
|
35
|
+
export const vendorOf = (engine) => engineStamp(engine).vendor ?? null;
|
|
@@ -183,7 +183,7 @@ export function undeclaredFieldsWarning(names) {
|
|
|
183
183
|
return `job carries ${names.length} field(s) no door declares: ${list} — DECLARED_JOB_FIELDS does not `
|
|
184
184
|
+ `name them, so nothing validates them, no door gate can rule on them, and any assembling door `
|
|
185
185
|
+ `drops them silently. Declare them in driver/enqueue-schema.mjs if they are meaningful, or stop `
|
|
186
|
-
+ `writing them
|
|
186
|
+
+ `writing them.`;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
// — "DID THE REQUEST NAME ANY CLASSES?", ONCE.
|
|
@@ -206,7 +206,7 @@ export function undeclaredFieldsWarning(names) {
|
|
|
206
206
|
// which is softer — and softer is why it would survive a reading and not a run.
|
|
207
207
|
//
|
|
208
208
|
// So the door owns the vocabulary and the framing builders read it. `driver/stages.mjs` still carries
|
|
209
|
-
// its own correct copy
|
|
209
|
+
// its own correct copy; the three are pinned against
|
|
210
210
|
// each other in driver/test/knockout-classes-predicate.test.mjs, so a copy that drifts is a red suite
|
|
211
211
|
// rather than a prompt aimed at the wrong goods.
|
|
212
212
|
export function requestNamesClasses(job) {
|
|
@@ -409,7 +409,7 @@ export function validateJob(job, { atClaim = false } = {}) {
|
|
|
409
409
|
const sidecarNote = `promptParts declares the prose rides as SIDECAR files and none arrived — expected `
|
|
410
410
|
+ `one or more of ${Object.values(PROSE_PARTS).map((x) => `<base>${x}`).join(", ")} beside the manifest. `
|
|
411
411
|
+ `A mis-named manifest is the observed cause: sidecars key on the BARE base, so <base>.manifest.json `
|
|
412
|
-
+ `leaves them unmatched
|
|
412
|
+
+ `leaves them unmatched.`;
|
|
413
413
|
if (sidecarsMissing) warnings.push(sidecarNote);
|
|
414
414
|
|
|
415
415
|
if (!hasMark) errs.push(sidecarsMissing ? `missing mark name(s) — ${sidecarNote}` : "missing mark name(s)");
|
|
@@ -924,7 +924,7 @@ export function validateJob(job, { atClaim = false } = {}) {
|
|
|
924
924
|
job.deadline = new Date(t).toISOString();
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
|
-
if (!job.ref && !job.tmp) warnings.push("
|
|
927
|
+
if (!job.ref && !job.tmp) warnings.push("No reference number was given, so this search has none.");
|
|
928
928
|
// Repair-first phase 3 (the teal-causeway msgId defect): a 32-hex msgId is the SANITIZED HASH base
|
|
929
929
|
// (the job-id derivation), not a Graph message id — the delivery send-tool's inReplyTo lookup will fail and the
|
|
930
930
|
// notice/delivery falls back off the client thread. Never blocks (still deliverable via fallback);
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
// that envelopeDecision prices belong to the late, ledger-level arm, which is untouched and still runs.
|
|
35
35
|
// Deliberately, therefore, nothing here reads job.deadline — and no string it produces mentions time.
|
|
36
36
|
|
|
37
|
-
import { existsSync,
|
|
37
|
+
import { existsSync, writeFileSync, renameSync } from "node:fs";
|
|
38
38
|
import { isCapabilityGapReason } from "./coverage-ledger.mjs";
|
|
39
39
|
import { fullyDeferredAxes } from "./register-plan.mjs";
|
|
40
40
|
import { readPartNotCompleted } from "./parts-not-completed.mjs";
|
|
41
|
+
import { readJson } from "./run-record.mjs";
|
|
41
42
|
|
|
42
43
|
export const SETTLE_SCHEMA_VERSION = 1;
|
|
43
44
|
|
|
@@ -83,7 +84,7 @@ export function partitionReceiptDeferrals(plan, receipt, { sticky = new Set() }
|
|
|
83
84
|
export function readEnvelopeDecision(P) {
|
|
84
85
|
try {
|
|
85
86
|
const p = P?.envelopeDecision;
|
|
86
|
-
return p && existsSync(p) ?
|
|
87
|
+
return p && existsSync(p) ? readJson(p) : null;
|
|
87
88
|
} catch { return null; } // unreadable ⇒ treated as absent ⇒ re-settled ⇒ overwritten
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -118,7 +118,7 @@ export function issueForFlag(flag) {
|
|
|
118
118
|
`| Flag record | \`${flag?.id ?? "—"}.json\` in the feedback store |`,
|
|
119
119
|
``,
|
|
120
120
|
`---`,
|
|
121
|
-
`_Minted from a report flag
|
|
121
|
+
`_Minted from a report flag. Nothing here is triaged: no status label, no rating, and no_`,
|
|
122
122
|
`_reading of what the lawyer meant. A human decides what this becomes._`,
|
|
123
123
|
].join("\n");
|
|
124
124
|
|
package/driver/feedback-mint.mjs
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
// duplicate issue is a nuisance a human closes in ten seconds, and a lost flag is lawyer feedback nobody
|
|
15
15
|
// knows was given.
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { readdirSync, writeFileSync } from "node:fs";
|
|
18
18
|
import { join } from "node:path";
|
|
19
19
|
import { issueForFlag } from "./feedback-issues.mjs";
|
|
20
|
+
import { readJson } from "./run-record.mjs";
|
|
20
21
|
|
|
21
22
|
/** A flag that has not yet become an issue. */
|
|
22
23
|
export const isPending = (flag) => !!flag && !flag.issue;
|
|
@@ -43,7 +44,7 @@ export async function mintPending({ dir, createIssue, log = () => {}, now = () =
|
|
|
43
44
|
const path = join(dir, name);
|
|
44
45
|
let flag;
|
|
45
46
|
// A half-written or hand-edited file is not a reason to stop draining the other seventy-four.
|
|
46
|
-
try { flag =
|
|
47
|
+
try { flag = readJson(path); }
|
|
47
48
|
catch { log(`skip ${name}: not readable as JSON`); skipped++; continue; }
|
|
48
49
|
if (!isPending(flag)) { skipped++; continue; }
|
|
49
50
|
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
// would have hidden.
|
|
24
24
|
|
|
25
25
|
import { randomUUID } from "node:crypto";
|
|
26
|
-
import { mkdirSync,
|
|
26
|
+
import { mkdirSync, readdirSync, writeFileSync } from "node:fs";
|
|
27
27
|
import { join } from "node:path";
|
|
28
|
+
import { readJson } from "./run-record.mjs";
|
|
28
29
|
|
|
29
30
|
/** good/bad, as the issue rules it: "Good flags matter as much as bad." */
|
|
30
31
|
export const VERDICTS = new Set(["good", "bad"]);
|
|
@@ -111,7 +112,7 @@ export function listFlags(dir) {
|
|
|
111
112
|
catch { return []; }
|
|
112
113
|
const out = [];
|
|
113
114
|
for (const n of names) {
|
|
114
|
-
try { out.push(
|
|
115
|
+
try { out.push(readJson(join(dir, n))); }
|
|
115
116
|
catch { /* a half-written or hand-edited file is not a reason to lose the other 74 */ }
|
|
116
117
|
}
|
|
117
118
|
return out.sort((a, b) => String(b.capturedAt ?? "").localeCompare(String(a.capturedAt ?? "")));
|
|
@@ -1815,7 +1815,7 @@ function validateNet(f, ord, mode) {
|
|
|
1815
1815
|
// `findings?_` and would aim the repair turn at register-coverage-ledger.json — forbidding the model
|
|
1816
1816
|
// to rewrite the only file that could fix it.
|
|
1817
1817
|
// It reaches the wire as a validator `reason` (verify.mjs checkFindingsSibling), which is the only shape
|
|
1818
|
-
// gateway.mjs
|
|
1818
|
+
// judgeArtifacts() in gateway.mjs mints as `invalid_file:<path>:<token>`; a bespoke throw would match nothing.
|
|
1819
1819
|
// The precedent is one line up the file: findings_mark_assessment_* was named plural for the same
|
|
1820
1820
|
// routing reason.
|
|
1821
1821
|
//
|
package/driver/flag-snapshot.mjs
CHANGED
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
// than being unable to ask. Failing closed here would mean a file-read error takes the whole portal
|
|
42
42
|
// down — trading a rare wrong-greyed-out option for a total outage.
|
|
43
43
|
|
|
44
|
-
import { writeFileSync,
|
|
44
|
+
import { writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
45
45
|
import { dirname, join } from "node:path";
|
|
46
46
|
import { BUILT } from "./search-policy.mjs";
|
|
47
47
|
import { isEntrypoint } from "../shared/is-entrypoint.mjs"; // — one entry-point test, all spellings
|
|
48
|
+
import { readJson } from "./run-record.mjs";
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* How a flag's absence is felt by a user. This field is what stops the staff screen lying.
|
|
@@ -239,7 +240,7 @@ export function buildFlagSnapshot(env, { capturedAt, registerProvider = null, re
|
|
|
239
240
|
*/
|
|
240
241
|
export const PRODUCTION_POSTURE = {
|
|
241
242
|
source: "production unit environment, read 2026-08-04 with owner authorisation; the flag half "
|
|
242
|
-
+ "retired 2026-08-20 when
|
|
243
|
+
+ "retired 2026-08-20 when every switch it named was deleted",
|
|
243
244
|
// The three it named are gone — deleted BECAUSE production ran them on while the source shipped them
|
|
244
245
|
// off, which is the delta this block existed to expose. There is nothing left to differ about, and
|
|
245
246
|
// saying that in an empty object beats leaving three names that no code reads.
|
|
@@ -261,7 +262,7 @@ export function postureDelta(snapshot, expected = PRODUCTION_POSTURE) {
|
|
|
261
262
|
if (!Object.keys(expected.flags ?? {}).length) {
|
|
262
263
|
rows.push({ what: "flags", here: Object.keys(snapshot.flags ?? {}).length, production: 0,
|
|
263
264
|
effect: "no flag is declared on either side — the flag half of this comparison checked nothing, "
|
|
264
|
-
+ "which is not the same as finding no difference (
|
|
265
|
+
+ "which is not the same as finding no difference (all four were deleted)" });
|
|
265
266
|
}
|
|
266
267
|
for (const [name, want] of Object.entries(expected.flags ?? {})) {
|
|
267
268
|
const here = snapshot.flags?.[name]?.on === true;
|
|
@@ -386,7 +387,7 @@ export function readFlagSnapshot(poolRoot) {
|
|
|
386
387
|
// The file's pre-rename name is read when the new one is not there yet, so an upgraded install does
|
|
387
388
|
// not read as "no snapshot" until its first write under the new name.
|
|
388
389
|
const legacy = join(poolRoot, "_state", "prelim-flag-snapshot.json");
|
|
389
|
-
const raw =
|
|
390
|
+
const raw = readJson(existsSync(snapshotPath(poolRoot)) || !existsSync(legacy) ? snapshotPath(poolRoot) : legacy);
|
|
390
391
|
if (!raw || typeof raw !== "object" || typeof raw.flags !== "object") return null;
|
|
391
392
|
return raw;
|
|
392
393
|
} catch {
|
package/driver/floor-duty.mjs
CHANGED
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
// placement-carry, and for the same reason: the dictation that orders the record ids ships WITH this
|
|
33
33
|
// check, so every run predating it reports its whole floor unmet. That is the correct reading of those
|
|
34
34
|
// runs, not a broken check.
|
|
35
|
-
import { existsSync, writeFileSync
|
|
36
|
-
import { driverDir, ensureDriverDir } from "../shared/driver-dir.mjs"; // — one definition of where `_driver/` is
|
|
35
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
37
36
|
import { entryUris } from "./placement-carry.mjs";
|
|
37
|
+
import { driverDir, ensureDriverDir, paths, readJson } from "./run-record.mjs"; // — one definition of where `_driver/` is
|
|
38
38
|
|
|
39
39
|
export const FLOOR_DUTY_SCHEMA_VERSION = 1;
|
|
40
40
|
|
|
@@ -109,7 +109,7 @@ export function floorDutyBlocksSkip(runDir, stageName) {
|
|
|
109
109
|
if (stageName !== FLOOR_DUTY_STAGE) return false;
|
|
110
110
|
if (!floorDutyArmed(runDir)) return false;
|
|
111
111
|
let artifact;
|
|
112
|
-
try { artifact =
|
|
112
|
+
try { artifact = readJson(paths(String(runDir ?? "")).floorDuty); }
|
|
113
113
|
catch { return false; }
|
|
114
114
|
return Boolean(floorDutyBlock(artifact, { armed: true }));
|
|
115
115
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// Blanking is blankForeignRecordLinks (findings-model.mjs): a register link becomes "", the value that
|
|
16
16
|
// already means "this register publishes no page for the record".
|
|
17
17
|
import { writeFileSync } from "node:fs";
|
|
18
|
-
import { driverDir } from "
|
|
18
|
+
import { driverDir } from "./run-record.mjs";
|
|
19
19
|
import { blankForeignRecordLinks } from "./findings-model.mjs";
|
|
20
20
|
import { activeRecordOrigins } from "./record-origins.mjs";
|
|
21
21
|
import { runLog } from "./log.mjs";
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
50
50
|
import { captureCall, stampVerdict } from "./call-capture.mjs";
|
|
51
51
|
import { join } from "node:path";
|
|
52
|
-
import { driverDir } from "../shared/driver-dir.mjs"; //
|
|
53
52
|
import { parseFrameDiff } from "./frame-diff-model.mjs";
|
|
54
53
|
import { parseBlindFrameModel } from "./blind-frame-model.mjs";
|
|
55
54
|
import { dominantElementFromManifest } from "./scope-ledger.mjs";
|
|
55
|
+
import { paths } from "./run-record.mjs";
|
|
56
56
|
|
|
57
57
|
export const MODEL_FILE = "frame-diff.json";
|
|
58
58
|
export const PROSE_FILE = "frame-diff.md";
|
|
@@ -100,7 +100,7 @@ export function boundDominantElement(runDir) {
|
|
|
100
100
|
|
|
101
101
|
/** Where the call's evidence lives — the driver's own record of what the seat handed it. */
|
|
102
102
|
export function frameDiffCallPaths(runDir) {
|
|
103
|
-
const dir =
|
|
103
|
+
const dir = paths(runDir).frameDiffCalls;
|
|
104
104
|
return { dir, payload: join(dir, "call-001.json") };
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -243,9 +243,3 @@ export function recordFrameDiff(runDir, received, { now = () => new Date().toISO
|
|
|
243
243
|
capture_failed: captureFailed,
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
|
-
|
|
247
|
-
/** Read back what was written — used by the tool's answer so the seat is told the stored state. */
|
|
248
|
-
export function readRecordedFrameDiff(runDir) {
|
|
249
|
-
try { return parseFrameDiff(readFileSync(join(String(runDir ?? ""), MODEL_FILE), "utf8")); }
|
|
250
|
-
catch { return null; }
|
|
251
|
-
}
|
package/driver/framework.mjs
CHANGED
|
@@ -31,7 +31,7 @@ export const manifestPathFor = (fwPath) => String(fwPath).replace(/\.md$/, ".man
|
|
|
31
31
|
// {
|
|
32
32
|
// "schema_version": 1,
|
|
33
33
|
// "framework_key": "house-default", // the rated_under_framework tripwire token
|
|
34
|
-
// "title": "
|
|
34
|
+
// "title": "Standard risk scale",
|
|
35
35
|
// "source_deck": "<the deck of record this transcribes>",
|
|
36
36
|
// "entity_label": "the company", // how the deck names the client side in prose
|
|
37
37
|
// "bands": [{ "label": "Very High", "tone": "severe" }, ...], // ordered highest → lowest
|
package/driver/gate-metrics.mjs
CHANGED
|
@@ -28,16 +28,15 @@
|
|
|
28
28
|
import { readFileSync, readdirSync, existsSync, statSync } from "node:fs";
|
|
29
29
|
import { join } from "node:path";
|
|
30
30
|
import { FATES } from "./hit-list.mjs"; // — THE fate set, imported, never re-declared
|
|
31
|
-
import { driverDir } from "../shared/driver-dir.mjs"; //
|
|
32
31
|
import { slugStability, groupByMark } from "./plan-stability.mjs";
|
|
33
32
|
|
|
34
33
|
// doc 50: the composite table is imported (one source, legacy runs only); a v4 finding's canonical
|
|
35
34
|
// word is its own `band` — telemetry compares against whichever the finding carries.
|
|
36
35
|
import { CLIENT_TIER_BY_COMPOSITE as TIER_BY_COMPOSITE } from "./findings-model.mjs";
|
|
37
36
|
import { isEntrypoint } from "../shared/is-entrypoint.mjs"; // — realpath both sides, or a symlinked invocation exits 0 silently
|
|
37
|
+
import { paths, readJson, readJsonOrNull } from "./run-record.mjs";
|
|
38
38
|
const canonicalWord = (f) => f?.band != null ? String(f.band) : TIER_BY_COMPOSITE[f?.composite];
|
|
39
39
|
const norm = (s) => String(s ?? "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
40
|
-
const readJson = (p) => { try { return JSON.parse(readFileSync(p, "utf8")); } catch { return null; } };
|
|
41
40
|
const readText = (p) => { try { return readFileSync(p, "utf8"); } catch { return ""; } };
|
|
42
41
|
|
|
43
42
|
export function findRunDirs(roots) {
|
|
@@ -69,11 +68,11 @@ function deferralSlice(directive) {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
export function deferralsRendered(runDir) {
|
|
72
|
-
const rec =
|
|
71
|
+
const rec = readJsonOrNull(paths(runDir).frameReopenReceipt);
|
|
73
72
|
const defs = rec?.deferrals ?? [];
|
|
74
73
|
if (!defs.length) return null;
|
|
75
74
|
const report = norm(readText(join(runDir, "report.md")));
|
|
76
|
-
const f =
|
|
75
|
+
const f = readJsonOrNull(join(runDir, "findings.json"));
|
|
77
76
|
const covText = norm((f?.coverage ?? []).map((c) => `${c.area} ${c.note ?? ""}`).join(" "));
|
|
78
77
|
let rendered = 0;
|
|
79
78
|
for (const d of defs) {
|
|
@@ -108,7 +107,7 @@ export function skepticConsumed(runDir) {
|
|
|
108
107
|
if (!bullets.length) return null;
|
|
109
108
|
// An absent register is not a run where nothing was consumed — it is a run this metric cannot read.
|
|
110
109
|
// Returning 0-of-N here would print as a total collapse in skeptic uptake.
|
|
111
|
-
const parsed =
|
|
110
|
+
const parsed = readJsonOrNull(join(runDir, "findings.json"));
|
|
112
111
|
if (!parsed) return null;
|
|
113
112
|
const register = norm(findingsText(parsed));
|
|
114
113
|
let consumed = 0;
|
|
@@ -124,7 +123,7 @@ export function skepticConsumed(runDir) {
|
|
|
124
123
|
// "Scored" = composite>=3 (legacy) or band-rated at all (doc 50 v4 — off-field carries no band, so
|
|
125
124
|
// band-presence IS the rated line; telemetry only, so no manifest rank needed here).
|
|
126
125
|
export function scoredFetched(runDir) {
|
|
127
|
-
const f =
|
|
126
|
+
const f = readJsonOrNull(join(runDir, "findings.json"));
|
|
128
127
|
const scored = (f?.findings ?? []).filter((x) => (x?.composite ?? 0) >= 3 || x?.band != null);
|
|
129
128
|
if (!scored.length) return null;
|
|
130
129
|
// ── THE FATE CODES, WHERE THE RUN HAS THEM ──────────────────────────────────
|
|
@@ -147,7 +146,7 @@ export function scoredFetched(runDir) {
|
|
|
147
146
|
// uppercase. Both sides are lowercased before joining, as the `_records/` path below already does. An
|
|
148
147
|
// un-normalised join here would miss ALL of them, not some — and a total miss reads as a clean
|
|
149
148
|
// `fetched: 0`, which is this metric's alert, not its absence.
|
|
150
|
-
const lines =
|
|
149
|
+
const lines = readJsonOrNull(join(runDir, "register-hit-list.json"))?.lines;
|
|
151
150
|
// NOT COMPUTED WHERE THE CODES ARE NOT THERE. The reading step is not asked for fate codes, and a list whose
|
|
152
151
|
// lines carry none says nothing about what judgment opened: read as a measurement, every scored finding would
|
|
153
152
|
// count as unfetched, an alarm about nothing. It says it could not be computed instead.
|
|
@@ -209,7 +208,7 @@ export function scoredFetched(runDir) {
|
|
|
209
208
|
const fetched = new Set();
|
|
210
209
|
for (const file of readdirSync(recDir)) {
|
|
211
210
|
if (!file.endsWith(".json")) continue;
|
|
212
|
-
const uri =
|
|
211
|
+
const uri = readJsonOrNull(join(recDir, file))?._uri;
|
|
213
212
|
if (uri) fetched.add(String(uri).toLowerCase());
|
|
214
213
|
}
|
|
215
214
|
let ok = 0;
|
|
@@ -228,7 +227,7 @@ export function scoredFetched(runDir) {
|
|
|
228
227
|
// archived runs it was built for. Read a null here as "no such surface", never as a failing join.
|
|
229
228
|
export function clientTierMatch(runDir) {
|
|
230
229
|
const cs = readText(join(runDir, "client-summary.md"));
|
|
231
|
-
const f =
|
|
230
|
+
const f = readJsonOrNull(join(runDir, "findings.json"));
|
|
232
231
|
if (!cs.trim() || !f?.findings?.length) return null;
|
|
233
232
|
const blocks = [...cs.matchAll(/^## +([^\n—-]+).*\n([\s\S]*?)(?=^## |\s*$)/gm)];
|
|
234
233
|
let total = 0, match = 0;
|
|
@@ -252,7 +251,7 @@ function pct(agg) { return agg.den ? Math.round((100 * agg.num) / agg.den) : nul
|
|
|
252
251
|
// states the linted constraints in the drafting prompts; this is the before/after meter.
|
|
253
252
|
export function lintFirstPassTax(runDir) {
|
|
254
253
|
try {
|
|
255
|
-
const sink =
|
|
254
|
+
const sink = readJson(paths(runDir).predeliveryLint);
|
|
256
255
|
if (!Array.isArray(sink?.initialFailures)) return null;
|
|
257
256
|
return { initialFailures: sink.initialFailures.length };
|
|
258
257
|
} catch { return null; }
|
|
@@ -263,7 +262,7 @@ export function lintFirstPassTax(runDir) {
|
|
|
263
262
|
// both covered, keyed on trigger). Read off the append-only run.jsonl spine, so it survives everything
|
|
264
263
|
// including in-place overwrites. Returns null when the run never tripped (legacy runs by construction).
|
|
265
264
|
export function documentGrowth(runDir) {
|
|
266
|
-
const raw = readText(
|
|
265
|
+
const raw = readText(paths(runDir).run);
|
|
267
266
|
if (!raw) return null;
|
|
268
267
|
const trips = [];
|
|
269
268
|
for (const ln of raw.split("\n")) {
|