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,314 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
3
|
+
//
|
|
4
|
+
// run-outcome.mjs — how a run that cannot finish is described: the failure a stage raises, the designed refusal,
|
|
5
|
+
// the fields that say where and why it stopped, and the packet that tells the requester.
|
|
6
|
+
//
|
|
7
|
+
// Moved out of pipeline.mjs unchanged, so the Knockout pipeline can import them without importing the clearance
|
|
8
|
+
// pipeline, which imports it back. pipeline.mjs exports them again for every importer that reads them there.
|
|
9
|
+
import { CLIENT_ACTION } from "../shared/client-failure-note.mjs";
|
|
10
|
+
import { batchMarkName } from "./mark-name.mjs";
|
|
11
|
+
import { abbrev } from "./repair-contract.mjs";
|
|
12
|
+
import { REFUSAL_TERMINAL_KIND, humanWait } from "./repairs.mjs";
|
|
13
|
+
import { reportIdentityFor } from "./search-policy.mjs";
|
|
14
|
+
import { whatsappRouting } from "./stages.mjs";
|
|
15
|
+
|
|
16
|
+
export class StageFailure extends Error {
|
|
17
|
+
// opts (repair-first, 2026-07-05): `failClass` — "transient" | "deterministic" | "factual" — set by
|
|
18
|
+
// throw sites that KNOW the ground truth (e.g. fan-in reading the band's provider error blocks,
|
|
19
|
+
// screen-gate's could-not-fetch, a reasoned reviewer BLOCKING). It always wins over the text-based
|
|
20
|
+
// classifyFailureReason guess in the run-level catch. `repairs` — the bounded repairs attempted at
|
|
21
|
+
// the point of defect before throwing, carried into the failure packet so the notice can say what
|
|
22
|
+
// the machine already tried. Both optional and backward compatible.
|
|
23
|
+
// `reasonCodes` (A4, 2026-07-28 postmortem): stable machine codes for throw sites that enumerate their defects
|
|
24
|
+
// (the client gate). The recovery ladder signs the sorted unique code SET instead of the prose, so a
|
|
25
|
+
// reason list that grows or rewords between attempts can never re-arm a per-signature park budget.
|
|
26
|
+
// `quantity`: the failure's progress count — how many of the thing are still wrong — stamped by
|
|
27
|
+
// a throw site that KNOWS it exactly (the stage ladder, from the validator's own count), so the
|
|
28
|
+
// run-level catch never has to re-derive it from prose. null = this failure carries no such count;
|
|
29
|
+
// never 0, which would mean "nothing left" — the shape of a pass. Recording only: nothing decides on it.
|
|
30
|
+
constructor(stage, reason, resetsAt, opts = {}) {
|
|
31
|
+
super(`${stage}: ${reason}`); this.stage = stage; this.reason = reason; this.resetsAt = resetsAt; this.rateLimited = reason === "rate_limited";
|
|
32
|
+
this.failClass = opts.failClass; this.repairs = Array.isArray(opts.repairs) ? opts.repairs : [];
|
|
33
|
+
this.reasonCodes = Array.isArray(opts.reasonCodes) ? opts.reasonCodes : [];
|
|
34
|
+
this.quantity = Number.isFinite(opts.quantity) ? opts.quantity : null;
|
|
35
|
+
// `detail`: the OPEN-SET payload — a validator reason, a query list, a provider string — kept
|
|
36
|
+
// OUT of `reason` so a renderer can show the sentence and hide the payload. The portal used to print
|
|
37
|
+
// the whole interpolated string to a user: "merged half-grids failed the canonical validator
|
|
38
|
+
// (connotation_undisposed:KIN-ZY wikipedia, …)". A stage-internal concept, a validator enum and six
|
|
39
|
+
// raw search queries in four scripts, on a card whose reader needs one fact: it failed and it cannot
|
|
40
|
+
// be resumed from here.
|
|
41
|
+
//
|
|
42
|
+
// A THROW SITE THAT MOVES ITS PAYLOAD HERE MUST STAMP `quantity`. repairs.mjs progressQuantity reads
|
|
43
|
+
// the convergence census out of the message prose; take the census out of the message without
|
|
44
|
+
// stamping the count and `progress.kind` becomes "unknown", a run converging 29 → 11 reads as
|
|
45
|
+
// plateaued, and its recovery ladder ends early. Silent — the run just stops, having looked stuck.
|
|
46
|
+
// That is exactly what `quantity` was added for: the site that KNOWS the count states it.
|
|
47
|
+
this.detail = typeof opts.detail === "string" && opts.detail.trim() ? opts.detail.trim() : null;
|
|
48
|
+
// `refusal`: THIS THROW IS A REFUSAL THE PRODUCT IS DESIGNED TO MAKE, not a fault. Only a
|
|
49
|
+
// preflight that declines an ORDER against THIS DEPLOYMENT, before any spend, may stamp it — see
|
|
50
|
+
// REFUSAL_TERMINAL_KIND in repairs.mjs for the boundary. It is a boolean and not a free-form kind
|
|
51
|
+
// string on purpose: the throw site states the FACT, the terminal writer names the record, and a
|
|
52
|
+
// call site cannot invent a fifth spelling of "refused" that no sink knows how to read.
|
|
53
|
+
this.refusal = opts.refusal === true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Is this the product declining an order, rather than the engine failing? PURE — both lanes ask it. */
|
|
58
|
+
export const isDesignedRefusal = (e) => e instanceof StageFailure && e.refusal === true;
|
|
59
|
+
|
|
60
|
+
// T5 + repair-first phase 3 — the CODE-authored failure packet, extracted and exported (tests +
|
|
61
|
+
// the runner's re-park cap reuse it). The email/WhatsApp copy is keyed on terminalKind and QUOTES the
|
|
62
|
+
// machine reason VERBATIM: teal-causeway's notice claimed a "systemic (credentials/provider/config)"
|
|
63
|
+
// cause for a deterministic 414, and its confirmation brief invented a "corrupted query IDs" story —
|
|
64
|
+
// the notice now says only what the machine knows, and says it in the machine's own words.
|
|
65
|
+
/**
|
|
66
|
+
* — the three terminal-reason fields status.json carries, as ONE decision in one place.
|
|
67
|
+
*
|
|
68
|
+
* `reason` is capped at 200 because it rides the ping. On the 2026-08-12 round that cap fell exactly
|
|
69
|
+
* where the provider's verbatim error begins: status.json ended on
|
|
70
|
+
* "provider error on the count probe (after one in-tool retry): " with nothing after the colon, while
|
|
71
|
+
* the journal held `HTTP 400: APPLICANT_NAME - The system did not recognize the syntax`. The failure
|
|
72
|
+
* taxonomy sends a diagnosing agent to status.json, so for that failure it was the one place the answer
|
|
73
|
+
* was not — and the round read the cause as ABSENT and reasoned about the absence as if it were the
|
|
74
|
+
* defect.
|
|
75
|
+
*
|
|
76
|
+
* `reasonDetail` could not have covered it: that field carries `StageFailure.detail`, and the fan-in
|
|
77
|
+
* throw passes none. Widening the 200 cap was rejected — it is load-bearing for the ping, and the next
|
|
78
|
+
* message longer than whatever number replaced it would reopen this silently.
|
|
79
|
+
*
|
|
80
|
+
* So the cut is made VISIBLE and the tail kept beside it. `reasonTruncated` is present on every terminal
|
|
81
|
+
* failure, true or false: "no reasonFull key" and "nothing was cut" must be distinguishable, or an
|
|
82
|
+
* absence reads as an empty cause — which is the whole defect, one level along. PURE.
|
|
83
|
+
*
|
|
84
|
+
* — VISIBLE IN THE STRING, not only in a sibling key. `reason` was a bare slice, so a cut sentence
|
|
85
|
+
* read as a finished one. Three failed runs of 2026-08-19 ended theirs mid-path — ".../studio/clearance-se"
|
|
86
|
+
* — and the reader who stat'd that directory got ENOENT and diagnosed a working mechanism as a broken
|
|
87
|
+
* one. Nothing had been lost: `reasonFull` carried the whole path on all three and `reasonTruncated` was
|
|
88
|
+
* true on all three. The field that gets read FIRST simply never said it was short. `abbrev` is this
|
|
89
|
+
* repo's marker for exactly that — repair-contract.mjs: "COMPLETE, or VISIBLY MARKED as incomplete" —
|
|
90
|
+
* and its ellipsis rides INSIDE the bound, so `reason` is still 200 characters and still load-bearing
|
|
91
|
+
* for the ping. `truncated` is computed from the cap rather than from a length comparison against the
|
|
92
|
+
* marked string, so the fact stays true of the SOURCE and not of whatever the marker did to it.
|
|
93
|
+
*/
|
|
94
|
+
export function terminalReasonFields(reason, { cap = 200, fullCap = 4000 } = {}) {
|
|
95
|
+
const full = String(reason ?? "").replace(/\s+/g, " ").trim();
|
|
96
|
+
const truncated = full.length > cap;
|
|
97
|
+
return { reason: abbrev(full, cap), reasonTruncated: truncated, reasonFull: truncated ? abbrev(full, fullCap) : null };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// (enforcement check E11 in the family) — `reasonDetail` and `reasonQuantity` are PACKET FIELDS.
|
|
101
|
+
//
|
|
102
|
+
// The merge gate computes WHICH dictated connotation query dropped and hands it over as StageFailure.detail
|
|
103
|
+
// with the count as `quantity`. Before this, neither reached this packet: on E2E's preserved R1 run of 2026-08-13
|
|
104
|
+
// `_driver/failure.json` carried reason/reasonVerbatim/failClass/terminalKind and no payload at all, so the
|
|
105
|
+
// operator was told one query had dropped and never which one — E2E had to replay
|
|
106
|
+
// findDroppedConnotationQueries against the preserved artifacts to name it. `reasonDetail` already reached
|
|
107
|
+
// status.json; `reasonQuantity` reached neither file.
|
|
108
|
+
//
|
|
109
|
+
// Both are written UNCONDITIONALLY as string|null and number|null. Never omitted, never 0: "no key" and
|
|
110
|
+
// "this failure carries no count" are different facts, the same distinction `reasonTruncated` is written on
|
|
111
|
+
// every terminal failure to preserve. And per the payload stays OUT of the sentence — `whatsappText`
|
|
112
|
+
// and the CLIENT body are untouched; the staff body gets it in its own <pre>, beside the verbatim reason
|
|
113
|
+
// that body already quotes.
|
|
114
|
+
export function buildFailurePacket({ runId, agent, job = {}, failedStage, shortReason, reasonVerbatim, sig, failClass, terminalKind, repairs = [], priorAttempts = 0, reasonDetail = null, reasonQuantity = null, capWait = null }) {
|
|
115
|
+
const esc = (s) => String(s ?? "").replace(/&/g, "&").replace(/</g, "<");
|
|
116
|
+
const detail = typeof reasonDetail === "string" && reasonDetail.trim() ? reasonDetail.trim() : null;
|
|
117
|
+
const quantity = Number.isFinite(reasonQuantity) ? reasonQuantity : null;
|
|
118
|
+
// WHAT FAILED, named as ALL of it. A knockout batch is one job, one run and one price over up to
|
|
119
|
+
// eight names, and this said "IRONWHISK" for a batch of three — the requester was told one name had
|
|
120
|
+
// failed and that nothing was delivered. Both honest readings cost money: that the other two came
|
|
121
|
+
// through (they did not), or that re-ordering the named one is the fix (it re-runs one and silently
|
|
122
|
+
// drops two). The SUCCESS packet from the same lane has always stated the count, which is what makes
|
|
123
|
+
// this a defect rather than a house style.
|
|
124
|
+
//
|
|
125
|
+
// `job.marks` and the shared composer (progress.mjs), so the notice, the run's own status.json and the
|
|
126
|
+
// delivered meta all spell one fact one way. A clearance job carries a single name and composes to
|
|
127
|
+
// exactly what it did before.
|
|
128
|
+
const mark = batchMarkName(job.marks, job.markName ?? job.name ?? job.ref ?? "the matter");
|
|
129
|
+
const KIND_SENTENCES = {
|
|
130
|
+
deterministic: "The same defect reproduces on every attempt — a code or data fix is needed; retrying will not help.",
|
|
131
|
+
"repeat-signature": "The retry failed IDENTICALLY to the first attempt — further retries cannot help; a code or data fix is needed.",
|
|
132
|
+
factual: "A factual gap the machinery could not close — this is a human decision, not a retry.",
|
|
133
|
+
"non-recoverable": "A credentials/configuration cause — fix the environment, then re-trigger the run.",
|
|
134
|
+
exhausted: `Automatic recovery is exhausted after ${priorAttempts} attempt${priorAttempts === 1 ? "" : "s"} — the cause looks systemic (provider/environment), not a bad sample.`,
|
|
135
|
+
// The weather lane ran out: the run's own output was never the problem, an upstream provider was
|
|
136
|
+
// still overloaded or refusing after the whole waiting ladder. Say that, so nobody goes hunting
|
|
137
|
+
// for a defect in the run — and say that a re-trigger is the right move once the far end is back.
|
|
138
|
+
// Deliberately COUNTLESS: `priorAttempts` is the run's TOTAL park count across both lanes, so
|
|
139
|
+
// quoting it here as "waiting attempts" would re-conflate the two budgets in the one sentence that
|
|
140
|
+
// exists to keep them apart. The surrounding copy already reports the honest total.
|
|
141
|
+
"weather-exhausted": "An upstream provider stayed overloaded or unreachable through every waiting attempt this run had — nothing in the run itself failed a check. Re-trigger once the provider is healthy.",
|
|
142
|
+
// — THE ONE KIND THAT IS NOT A FAULT. Every sentence above explains a break; this one has to
|
|
143
|
+
// say that nothing broke, or the copy re-tells the lie the terminalKind was added to stop. The
|
|
144
|
+
// remedy is never "re-trigger" and never "a code fix" — it is the order or the deployment, and the
|
|
145
|
+
// verbatim reason below this line names which.
|
|
146
|
+
[REFUSAL_TERMINAL_KIND]: "Nothing failed. This deployment does not serve the search that was ordered, and said so before any work was done — the reason below names what is missing and what to change. Re-running it unchanged returns the same answer.",
|
|
147
|
+
};
|
|
148
|
+
// ── A CAP DEATH IS A SUBSCRIPTION OUTCOME, NOT AN OUTAGE (the fourth ask) ─────────────────────────
|
|
149
|
+
//
|
|
150
|
+
// The weather lane carries BOTH an overloaded provider and a usage cap, and its one sentence
|
|
151
|
+
// described the first: "stayed overloaded or unreachable … Re-trigger once the provider is healthy."
|
|
152
|
+
// Told to somebody whose subscription cap has not reset, every clause of that is wrong — the provider
|
|
153
|
+
// was healthy and answering, re-triggering now hits the same cap, and "overloaded" points the reader
|
|
154
|
+
// at an availability problem they cannot act on.
|
|
155
|
+
//
|
|
156
|
+
// The owner pre-committed the wording watching a capped run: a cap death is reported as a
|
|
157
|
+
// SUBSCRIPTION OUTCOME, NEVER AS AN ENGINE FINDING. So this names the cap, states how long the run
|
|
158
|
+
// actually held out before giving up, and says plainly that nothing about the run or the mark
|
|
159
|
+
// produced it.
|
|
160
|
+
//
|
|
161
|
+
// The elapsed wait matters as much as the cause. The cap ladder now reaches ~11h, so "3 automatic
|
|
162
|
+
// recovery attempts" — which is all the surrounding copy reports — reads as a run that gave up
|
|
163
|
+
// quickly when it waited most of a day. A reader deciding whether to re-trigger needs the hours.
|
|
164
|
+
//
|
|
165
|
+
// Falls back to the weather sentence when the history carries no cap park, so an actual outage is
|
|
166
|
+
// still described as one. capWait is null in that case BY CONSTRUCTION (capWaitFrom returns null
|
|
167
|
+
// rather than a zeroed object), which is what keeps this branch from claiming a cap that never was.
|
|
168
|
+
const capLine = capWait && terminalKind === "weather-exhausted"
|
|
169
|
+
? `A provider's usage cap was still in force after ${humanWait(capWait.waitedMin)} of waiting across ${capWait.parks} attempt${capWait.parks === 1 ? "" : "s"} — a subscription outcome, not a finding about the run or the mark. Nothing in the run itself failed a check.${capWait.statedResets ? " The provider stated its own reset time and the run waited for it." : ""} Re-trigger once the cap has reset.`
|
|
170
|
+
: null;
|
|
171
|
+
const kindLine = capLine ?? KIND_SENTENCES[terminalKind] ?? "The run stopped on a technical failure; the run directory is preserved for diagnosis.";
|
|
172
|
+
const attempted = repairs.length
|
|
173
|
+
? `<p>What the machine already attempted:</p><ul>${repairs.map((r) => `<li>${esc(r.repair)} → ${esc(r.outcome)}${r.target ? ` (${esc(r.target)})` : ""}</li>`).join("")}</ul>`
|
|
174
|
+
: "";
|
|
175
|
+
// — a designed refusal is REFUSED, not FAILED, in every string this packet composes. The packet
|
|
176
|
+
// is a sink an operator reads before any other: it is the email, and it is the WhatsApp line. Stamping
|
|
177
|
+
// the kind and leaving "❌ … FAILED at …" on the wire would leave the discriminator true in a field
|
|
178
|
+
// and false in the only sentence anybody sees.
|
|
179
|
+
const refused = terminalKind === REFUSAL_TERMINAL_KIND;
|
|
180
|
+
const retryHint = refused
|
|
181
|
+
? "nothing to fix in the engine — change the order or configure this deployment"
|
|
182
|
+
: terminalKind === "deterministic" || terminalKind === "repeat-signature"
|
|
183
|
+
? "retrying will not help — needs a code/data fix" : "needs human attention";
|
|
184
|
+
// The payload block, staff body only. "Which one" is the question the reason cannot answer: the
|
|
185
|
+
// sentence says "dropped 1 dictated connotation query", the payload names the query. Empty when the
|
|
186
|
+
// throw site carried no detail — an absent block, never a heading over nothing. A refusal carries no
|
|
187
|
+
// dropped-query detail, so the block renders only on the failure branch below.
|
|
188
|
+
const detailBlock = detail
|
|
189
|
+
? `<p>Which one${quantity === null ? "" : ` (${quantity})`}:</p><pre style="white-space:pre-wrap">${esc(detail)}</pre>`
|
|
190
|
+
: "";
|
|
191
|
+
// CLIENT-STARTED runs (2026-07-29 hardening): the email lane routes to job.forwarderEmail, and for a
|
|
192
|
+
// clientPrincipal run that address IS the client. The verbatim machine reason (String(e?.stack ?? e)
|
|
193
|
+
// upstream — absolute paths, module names, provider error text) is exactly what every client-facing
|
|
194
|
+
// listing already redacts (sanitizeRunForClient / CLIENT_FAILURE_NOTE); the failure EMAIL was the one
|
|
195
|
+
// client surface still quoting it. The client gets the same neutral notice the listings use; the
|
|
196
|
+
// verbatim reason, repairs and retry hints stay on the packet fields + WhatsApp (staff surfaces).
|
|
197
|
+
const clientRun = job.clientPrincipal === true;
|
|
198
|
+
// — WHAT FAILED, named as the thing that was ORDERED. These four strings said "Preliminary
|
|
199
|
+
// clearance" whatever the request was, so a Knockout search that died at the sweep told its requester
|
|
200
|
+
// a preliminary clearance had failed — a product they did not buy, under a name the offering no longer
|
|
201
|
+
// sells.
|
|
202
|
+
//
|
|
203
|
+
// `job.product` and not the run's frozen policy, deliberately: a failure packet is built at points
|
|
204
|
+
// where no policy has resolved (an admission refusal, a crash before the sidecar is written), and
|
|
205
|
+
// `job.product` is the ORDER — which is exactly what a failure notice is about. An absent or unknown
|
|
206
|
+
// token resolves to null, and the sentences fall back to naming no product rather than the wrong one.
|
|
207
|
+
const ordered = reportIdentityFor(job.product ?? null).identity;
|
|
208
|
+
const orderedIs = ordered ? `The ${ordered}` : "The search";
|
|
209
|
+
const orderedFor = ordered ? `${ordered} — ${mark}` : mark;
|
|
210
|
+
return {
|
|
211
|
+
// `failed: true` and `kind: "run-failed"` (added by both callers) are UNCHANGED on a refusal, and
|
|
212
|
+
// deliberately: they are the packet's ROUTING — "this run delivered nothing, send the no-delivery
|
|
213
|
+
// notice" — and every relay, the outbox and docs/DELIVERY.md are built on them. `refused` is the
|
|
214
|
+
// discriminator beside them, written true OR false on every packet for the reason: an absent key
|
|
215
|
+
// must not be the only thing separating "not a refusal" from "a packet written before the field
|
|
216
|
+
// existed".
|
|
217
|
+
runId, agent, failed: true, refused,
|
|
218
|
+
forwarder: job.forwarder, forwarderEmail: job.forwarderEmail, msgId: job.msgId,
|
|
219
|
+
conversationId: job.conversationId ?? null,
|
|
220
|
+
subject: clientRun
|
|
221
|
+
? `${orderedFor} — search ${refused ? "not started" : "stopped"}, nothing delivered`
|
|
222
|
+
: `${orderedFor} — run ${refused ? "REFUSED" : "FAILED"}, nothing delivered`,
|
|
223
|
+
emailBodyHtml: clientRun
|
|
224
|
+
// — the owner's failed-run ruling. This said "<BRAND> has been notified
|
|
225
|
+
// and will follow up. Nothing is needed from your side." Nobody had been notified; the box has no
|
|
226
|
+
// outbox. And a client told there is nothing for them to do does not tell their operator, which
|
|
227
|
+
// was the only action that would have moved it — so the sentence did not merely overclaim, it
|
|
228
|
+
// stopped the thing that would have helped. One author for all three client surfaces now.
|
|
229
|
+
? `<p>${esc(orderedIs)} for <b>${esc(mark)}</b> ${refused ? "was not started, and nothing was delivered" : "stopped before it finished, and nothing was delivered"}.</p><p>${esc(CLIENT_ACTION)}</p>`
|
|
230
|
+
: refused
|
|
231
|
+
? `<p>${esc(orderedIs)} for <b>${esc(mark)}</b> was REFUSED at stage <b>${esc(failedStage)}</b> before any work was done, and NOTHING was delivered.</p><p>${esc(kindLine)}</p><p>The driver reported, verbatim:</p><pre style="white-space:pre-wrap">${esc(reasonVerbatim)}</pre><p>The run directory is preserved; this is not a defect to diagnose.</p>`
|
|
232
|
+
: `<p>${esc(orderedIs)} for <b>${esc(mark)}</b> FAILED at stage <b>${esc(failedStage)}</b>${priorAttempts ? ` after <b>${priorAttempts} automatic recovery attempt${priorAttempts === 1 ? "" : "s"}</b>` : ""} and NOTHING was delivered.</p><p>${esc(kindLine)}</p><p>The driver reported, verbatim:</p><pre style="white-space:pre-wrap">${esc(reasonVerbatim)}</pre>${detailBlock}${attempted}<p>The run directory is preserved for diagnosis; re-trigger the run when the cause is addressed.</p>`,
|
|
233
|
+
// THE NOTICE GOES TO WHOEVER ASKED, as the completion notice does (whatsappRouting, stages.mjs): the requester's own
|
|
234
|
+
// number where one is held, the gap stated where none is, and the operator's copy beside it. It went to the agent's
|
|
235
|
+
// number, which every user of a deployment shares, so the operator was told of a failure the requester never heard.
|
|
236
|
+
...whatsappRouting(job, agent),
|
|
237
|
+
whatsappText: refused
|
|
238
|
+
? `⛔ Clearotron search for ${mark} REFUSED at ${failedStage} [${terminalKind}]: ${shortReason} — nothing was delivered and nothing broke; ${retryHint}.`
|
|
239
|
+
: `❌ Clearotron search for ${mark} FAILED at ${failedStage}${priorAttempts ? ` after ${priorAttempts} automatic recovery attempt${priorAttempts === 1 ? "" : "s"}` : ""}${terminalKind ? ` [${terminalKind}]` : ""}: ${shortReason} — nothing was delivered; ${retryHint}.`,
|
|
240
|
+
markName: job.markName ?? job.name ?? null, failedStage, reason: shortReason,
|
|
241
|
+
reasonVerbatim, failureSignature: sig, failClass, terminalKind, repairs, recoveryAttempts: priorAttempts,
|
|
242
|
+
reasonDetail: detail, reasonQuantity: quantity,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// The run.jsonl `stage` row's inputs[]: each DECLARED input's fingerprint plus `read` — did the settled
|
|
247
|
+
// turn actually open it? Exported and dependency-free (paths + the dispatch's own facts) so the honesty
|
|
248
|
+
// rule below is testable without a paid dispatch.
|
|
249
|
+
//
|
|
250
|
+
// `read` is THREE-VALUED and the null cases carry the whole point (post-merge audit of):
|
|
251
|
+
// true — the engine's reads gauge saw this exact path opened. Evidence; never downgraded.
|
|
252
|
+
// false — the turn was offered this file and demonstrably did not open it. Only claimable when the
|
|
253
|
+
// dispatch really offered it AND the gauge is complete.
|
|
254
|
+
// null — nothing can be claimed. Three ways to get here, all of them real:
|
|
255
|
+
// · the engine has no reads gauge at all (reads == null — the openai-agent shape);
|
|
256
|
+
// · the settled attempt was a WARM PATCH: a warm-resume shape, arrived at from the
|
|
257
|
+
// other direction — the CALLER asked for a fresh dispatch and the gateway's retry ladder
|
|
258
|
+
// turned attempt N into a session resume carrying only the fix instruction (gateway.mjs,
|
|
259
|
+
// `warm`). The declared inputs were offered on attempt 1 and NOT re-offered on the settled
|
|
260
|
+
// one, so an absent path there says nothing about whether the stage read it. Without this
|
|
261
|
+
// arm the row asserted `read:false` for a file the run can PROVE it opened on attempt 1,
|
|
262
|
+
// and — worse after AD-4 — stamped `followup:false, readsTruncated:false` beside it, i.e.
|
|
263
|
+
// an affirmative "the gauge was trustworthy". warmEligible fires on a shape recorded at
|
|
264
|
+
// ~43% of the archive corpus, so this is the common path, not an edge case;
|
|
265
|
+
// · the gauge was CAPPED (readsTruncated): the list is a prefix, so an absent path proves
|
|
266
|
+
// nothing at all.
|
|
267
|
+
// A FOLLOWUP used to be a fourth arm and is not one (A-1). The reasoning was "it resumes a session that
|
|
268
|
+
// already holds the files" — which the engines do not do: `resumeRef` is passed only on a warm retry and
|
|
269
|
+
// neither engine reads `sessionKey`, so a followup dispatch is attempt 1 of a fresh session that WAS
|
|
270
|
+
// offered its declared inputs. Its gauge is as groundable as any other cold dispatch's, and nulling it
|
|
271
|
+
// erased the measurement on exactly the population worth measuring. The caller still journals `followup`
|
|
272
|
+
// on the row, so the two populations remain separable by a reader.
|
|
273
|
+
// A `false` that is really "we could not tell" is the same defect class AD-4 exists to retire — and it
|
|
274
|
+
// lands in exactly the D-item record the charter routes into P2-A ("the stage largely COULD NOT read —
|
|
275
|
+
// fix the lookup before diagnosing discipline"). Its mirror image is just as bad and is what this change
|
|
276
|
+
// removes: a `null` that is really "we could tell, and it did not".
|
|
277
|
+
// ── — A COMPLETION ROW STATES ONE INSTANT, AND A WAVE NEEDS TWO ─────────────────────────────────
|
|
278
|
+
// Every wave member DOES emit a completion line — `runBatched` calls `stage()` per member and `stageOnce`
|
|
279
|
+
// writes its `{event:"stage"}` row unconditionally. What no row carries is a START. `appendLine` stamps
|
|
280
|
+
// exactly one instant, `ts`, at append time, which for a completion row is the END.
|
|
281
|
+
//
|
|
282
|
+
// Serially that is enough: the previous row's `ts` is a usable start proxy, so a stage's wall reads off
|
|
283
|
+
// the journal as [previous row, own row]. A WAVE destroys the proxy — N members are dispatched at one
|
|
284
|
+
// instant and their rows interleave by completion order, so the row before member k's row belongs to a
|
|
285
|
+
// sibling — and nothing replaced it. Each member's wall then degenerates to [0, the wave's own wall],
|
|
286
|
+
// which is verbatim what the closing round had to report: "between 0 and 10 minutes, and the journal does
|
|
287
|
+
// not say which. An absence, not a zero."
|
|
288
|
+
//
|
|
289
|
+
// The per-attempt log does not rescue it. `_driver/<stage>.jsonl` carries `wall`, but that is EXEC ONLY —
|
|
290
|
+
// `laneWaitMs` is a separate field by design, and the freshness check, the snapshot, the validator and the
|
|
291
|
+
// in-dispatch form repairs all sit outside it — and it carries no start instant either, so a stage cannot
|
|
292
|
+
// be placed on the run's timeline from it and sibling overlap stays uncomputable.
|
|
293
|
+
//
|
|
294
|
+
// THE FIELD NAMES ARE LOAD-BEARING.
|
|
295
|
+
// NOT `startedAt` — `status.json.startedAt` already means the RUN's first-ever start. It is
|
|
296
|
+
// append-only-by-deletion, it is backfilled by a script that SCANS run.jsonl, and run-quote,
|
|
297
|
+
// consumption-ledger, run-economics and the e2e ledger all read it. A stage-scoped `startedAt` on the
|
|
298
|
+
// rows that backfill scans makes a turnaround number quietly wrong months later.
|
|
299
|
+
// NOT `wall` — that name already means exec-only seconds on the per-attempt row. Two surfaces spelling
|
|
300
|
+
// two different facts the same way is how this class of defect gets rebuilt.
|
|
301
|
+
//
|
|
302
|
+
// `wallSec` is redundant with the pair by construction and is written anyway: the machine writes what must
|
|
303
|
+
// be exact, and a reader must not have to subtract ISO strings by hand. One site computes all three, so
|
|
304
|
+
// they cannot drift, and the tests assert that identity.
|
|
305
|
+
//
|
|
306
|
+
// THE ROW STATES FACTS AND JUDGES NOTHING. No `onCriticalPath`, no `boundedTheWave`. Which member bounded
|
|
307
|
+
// a wave is an inference from overlapping intervals and it belongs to the reader.
|
|
308
|
+
export function stageWallFields(tDispatch, tSettled = Date.now()) {
|
|
309
|
+
return {
|
|
310
|
+
dispatchedAt: new Date(tDispatch).toISOString(),
|
|
311
|
+
settledAt: new Date(tSettled).toISOString(),
|
|
312
|
+
wallSec: (tSettled - tDispatch) / 1000,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
3
|
+
//
|
|
4
|
+
// run-park.mjs — the one writer of `.postponed`, the marker that says a run is parked and how it resumes.
|
|
5
|
+
//
|
|
6
|
+
// A run parks for a rate limit, for a recovery, for a part not yet completed, or for a choice this machine cannot
|
|
7
|
+
// serve, and either product can park. The runner resumes a parked run the queue does not own from this marker
|
|
8
|
+
// alone, and it skips a marker without `job`, `agent` and `codename` (runner.mjs, the run-folder watcher). So every
|
|
9
|
+
// park is written here, and every marker carries the three: a park that did not name them gets them from the run.
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { atomicWrite } from "./run-record.mjs";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Write a run's `.postponed` marker. `park` holds the kind and its own fields, in the order they are written.
|
|
15
|
+
* `identity` is what a self-resume needs; each of the three the park did not already name is added after the
|
|
16
|
+
* park's own fields. A truncated marker is never visible: the write is atomic, as every sentinel's is.
|
|
17
|
+
*/
|
|
18
|
+
export function writePark(runDir, park, { job = null, agent = null, codename = null } = {}) {
|
|
19
|
+
const marker = { ...park };
|
|
20
|
+
for (const [key, value] of [["codename", codename], ["job", job], ["agent", agent]]) if (!(key in marker)) marker[key] = value ?? null;
|
|
21
|
+
atomicWrite(join(runDir, ".postponed"), JSON.stringify({ ts: new Date().toISOString(), ...marker }, null, 2) + "\n");
|
|
22
|
+
return marker;
|
|
23
|
+
}
|
package/driver/run-quote.mjs
CHANGED
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
import { resolveEffectiveScope } from "./effective-scope.mjs";
|
|
24
24
|
import { decideJxLanes } from "./jx-lanes.mjs";
|
|
25
25
|
import { quoteEffort, leversFromResolved } from "./effort-model.mjs";
|
|
26
|
+
import { note, runLog } from "./log.mjs";
|
|
27
|
+
import { readFileSync } from "node:fs";
|
|
28
|
+
import { join } from "node:path";
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* Whether a native-language lane will ACTUALLY run.
|
|
@@ -117,3 +120,32 @@ export function reconcileTurnaround({ quote = null, startedAt = null, now = Date
|
|
|
117
120
|
actualHoursIncludesParked: measured ? true : null,
|
|
118
121
|
};
|
|
119
122
|
}
|
|
123
|
+
|
|
124
|
+
// Quoted-vs-actual turnaround, written at every terminal of a run — delivered, cancelled, rate-limit-postponed,
|
|
125
|
+
// recovery-parked, failed — in pipeline.mjs and the run endings carved from it. (The call-site census test greps
|
|
126
|
+
// those files, and that is the scope it can police.) A Knockout computes no quote, so its rows carry the wall and a
|
|
127
|
+
// null quote: where it ends through run-failed.mjs (stopped, parked, failed) and where it delivers, in
|
|
128
|
+
// pipeline-knockout.mjs. The runner's `parked-for-human` grace-exit (runner.mjs parkInFlightForHuman)
|
|
129
|
+
// is not covered: it is a SIGTERM handler with no ctx and no quote in hand.
|
|
130
|
+
//
|
|
131
|
+
// AD-4 surfaced this only at the delivered terminal, so a run that failed, parked for auto-recovery or
|
|
132
|
+
// postponed on a rate-limit cap recorded nothing at all — and "we never measured this run" was byte-for-byte
|
|
133
|
+
// the same as "this run did not deliver", the exact three-valuedness the package exists to enforce. The row
|
|
134
|
+
// now always carries `state`: delivered | failed | recovery-parked | rate-limit-postponed | cancelled. A run
|
|
135
|
+
// legitimately writes SEVERAL of these across its life (a park is the terminal of an INVOCATION, not of the
|
|
136
|
+
// run) — they are append-only and the LAST row is the run's outcome; the earlier ones are the honest record
|
|
137
|
+
// of how long each leg took. HOURS ONLY: the tokens-only directive holds and no currency appears here.
|
|
138
|
+
// Best-effort telemetry — this must never affect a delivery, a failure notice or a park.
|
|
139
|
+
export function logTurnaroundReconciliation(runDir, quote, state) { // @internal
|
|
140
|
+
if (!runDir) return null;
|
|
141
|
+
try {
|
|
142
|
+
let startedAt = null;
|
|
143
|
+
// status.json `startedAt` is written once at seed and a resume deliberately never touches it, so the
|
|
144
|
+
// figure is the run's TRUE wall — see reconcileTurnaround on what that includes.
|
|
145
|
+
try { startedAt = JSON.parse(readFileSync(join(runDir, "status.json"), "utf8"))?.startedAt ?? null; } catch { /* no status yet — actualHours stays null */ }
|
|
146
|
+
const ta = reconcileTurnaround({ quote: quote ?? null, startedAt });
|
|
147
|
+
runLog(runDir, { event: "turnaround-reconciliation", state, ...ta });
|
|
148
|
+
note(`turnaround (${state}): quoted ${ta.quotedHours != null ? `${ta.quotedHours}h` : "(never sized)"}, actual ${ta.actualHours != null ? `${ta.actualHours}h` : "(no startedAt)"}${ta.ratio != null ? ` — ${ta.ratio}× the quote` : ""}${ta.actualHoursIncludesParked ? " [wall since start, includes rate-limit postpones and recovery parks]" : ""}`);
|
|
149
|
+
return ta;
|
|
150
|
+
} catch { return null; /* telemetry best-effort — never affects a run's terminal */ }
|
|
151
|
+
}
|