@allocator-one/rcl 4.4.19
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/LICENSE +21 -0
- package/README.md +1415 -0
- package/dist/ci.d.ts +16 -0
- package/dist/ci.js +42 -0
- package/dist/ci.js.map +1 -0
- package/dist/config/data-dir.d.ts +6 -0
- package/dist/config/data-dir.js +12 -0
- package/dist/config/data-dir.js.map +1 -0
- package/dist/config/defaults.d.ts +82 -0
- package/dist/config/defaults.js +89 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/harness.d.ts +40 -0
- package/dist/config/harness.js +151 -0
- package/dist/config/harness.js.map +1 -0
- package/dist/config/loader.d.ts +13 -0
- package/dist/config/loader.js +131 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/provider-concurrency.d.ts +4 -0
- package/dist/config/provider-concurrency.js +6 -0
- package/dist/config/provider-concurrency.js.map +1 -0
- package/dist/config/providers.d.ts +3 -0
- package/dist/config/providers.js +9 -0
- package/dist/config/providers.js.map +1 -0
- package/dist/config/schema.d.ts +179 -0
- package/dist/config/schema.js +115 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/consensus/claim-contract.d.ts +9 -0
- package/dist/consensus/claim-contract.js +307 -0
- package/dist/consensus/claim-contract.js.map +1 -0
- package/dist/consensus/claim-identity.d.ts +5 -0
- package/dist/consensus/claim-identity.js +39 -0
- package/dist/consensus/claim-identity.js.map +1 -0
- package/dist/consensus/deduper.d.ts +43 -0
- package/dist/consensus/deduper.js +1052 -0
- package/dist/consensus/deduper.js.map +1 -0
- package/dist/consensus/finding-identity.d.ts +20 -0
- package/dist/consensus/finding-identity.js +49 -0
- package/dist/consensus/finding-identity.js.map +1 -0
- package/dist/consensus/gating.d.ts +215 -0
- package/dist/consensus/gating.js +699 -0
- package/dist/consensus/gating.js.map +1 -0
- package/dist/consensus/parser.d.ts +22 -0
- package/dist/consensus/parser.js +255 -0
- package/dist/consensus/parser.js.map +1 -0
- package/dist/consensus/semantic-deduper.d.ts +10 -0
- package/dist/consensus/semantic-deduper.js +70 -0
- package/dist/consensus/semantic-deduper.js.map +1 -0
- package/dist/consensus/types.d.ts +196 -0
- package/dist/consensus/types.js +2 -0
- package/dist/consensus/types.js.map +1 -0
- package/dist/consensus/verification-contract.d.ts +8 -0
- package/dist/consensus/verification-contract.js +95 -0
- package/dist/consensus/verification-contract.js.map +1 -0
- package/dist/consensus/voter.d.ts +29 -0
- package/dist/consensus/voter.js +394 -0
- package/dist/consensus/voter.js.map +1 -0
- package/dist/converge/attempt-budget.d.ts +88 -0
- package/dist/converge/attempt-budget.js +717 -0
- package/dist/converge/attempt-budget.js.map +1 -0
- package/dist/converge/bound-fix-recovery-source.d.ts +24 -0
- package/dist/converge/bound-fix-recovery-source.js +25 -0
- package/dist/converge/bound-fix-recovery-source.js.map +1 -0
- package/dist/converge/bound-fix-recovery.d.ts +15 -0
- package/dist/converge/bound-fix-recovery.js +65 -0
- package/dist/converge/bound-fix-recovery.js.map +1 -0
- package/dist/converge/correction-anchors.d.ts +1 -0
- package/dist/converge/correction-anchors.js +2 -0
- package/dist/converge/correction-anchors.js.map +1 -0
- package/dist/converge/cycle-remote.d.ts +6 -0
- package/dist/converge/cycle-remote.js +41 -0
- package/dist/converge/cycle-remote.js.map +1 -0
- package/dist/converge/delivery-reconciliation.d.ts +17 -0
- package/dist/converge/delivery-reconciliation.js +53 -0
- package/dist/converge/delivery-reconciliation.js.map +1 -0
- package/dist/converge/finding-identity.d.ts +6 -0
- package/dist/converge/finding-identity.js +7 -0
- package/dist/converge/finding-identity.js.map +1 -0
- package/dist/converge/fresh-review.d.ts +37 -0
- package/dist/converge/fresh-review.js +351 -0
- package/dist/converge/fresh-review.js.map +1 -0
- package/dist/converge/launch-guard.d.ts +55 -0
- package/dist/converge/launch-guard.js +363 -0
- package/dist/converge/launch-guard.js.map +1 -0
- package/dist/converge/launch-preflight.d.ts +5 -0
- package/dist/converge/launch-preflight.js +41 -0
- package/dist/converge/launch-preflight.js.map +1 -0
- package/dist/converge/launch-record.d.ts +136 -0
- package/dist/converge/launch-record.js +86 -0
- package/dist/converge/launch-record.js.map +1 -0
- package/dist/converge/legacy-launch-health.d.ts +311 -0
- package/dist/converge/legacy-launch-health.js +159 -0
- package/dist/converge/legacy-launch-health.js.map +1 -0
- package/dist/converge/legacy-roster.d.ts +29 -0
- package/dist/converge/legacy-roster.js +268 -0
- package/dist/converge/legacy-roster.js.map +1 -0
- package/dist/converge/native-lock.d.ts +18 -0
- package/dist/converge/native-lock.js +122 -0
- package/dist/converge/native-lock.js.map +1 -0
- package/dist/converge/ordinary-pending-export.d.ts +67 -0
- package/dist/converge/ordinary-pending-export.js +175 -0
- package/dist/converge/ordinary-pending-export.js.map +1 -0
- package/dist/converge/ordinary-pending-package.d.ts +28 -0
- package/dist/converge/ordinary-pending-package.js +36 -0
- package/dist/converge/ordinary-pending-package.js.map +1 -0
- package/dist/converge/pending-legacy-resume.d.ts +119 -0
- package/dist/converge/pending-legacy-resume.js +720 -0
- package/dist/converge/pending-legacy-resume.js.map +1 -0
- package/dist/converge/pending-recovery-source.d.ts +131 -0
- package/dist/converge/pending-recovery-source.js +71 -0
- package/dist/converge/pending-recovery-source.js.map +1 -0
- package/dist/converge/recovery-launch.d.ts +66 -0
- package/dist/converge/recovery-launch.js +518 -0
- package/dist/converge/recovery-launch.js.map +1 -0
- package/dist/converge/retained-report.d.ts +29 -0
- package/dist/converge/retained-report.js +218 -0
- package/dist/converge/retained-report.js.map +1 -0
- package/dist/converge/retry-source.d.ts +25 -0
- package/dist/converge/retry-source.js +13 -0
- package/dist/converge/retry-source.js.map +1 -0
- package/dist/converge/review-cycle.d.ts +49 -0
- package/dist/converge/review-cycle.js +26 -0
- package/dist/converge/review-cycle.js.map +1 -0
- package/dist/converge/round-gap-schema.d.ts +66 -0
- package/dist/converge/round-gap-schema.js +51 -0
- package/dist/converge/round-gap-schema.js.map +1 -0
- package/dist/converge/round-gap.d.ts +38 -0
- package/dist/converge/round-gap.js +334 -0
- package/dist/converge/round-gap.js.map +1 -0
- package/dist/converge/run-state.d.ts +224 -0
- package/dist/converge/run-state.js +564 -0
- package/dist/converge/run-state.js.map +1 -0
- package/dist/converge/stale-report-schema.d.ts +42 -0
- package/dist/converge/stale-report-schema.js +79 -0
- package/dist/converge/stale-report-schema.js.map +1 -0
- package/dist/converge/stale-report-storage.d.ts +47 -0
- package/dist/converge/stale-report-storage.js +172 -0
- package/dist/converge/stale-report-storage.js.map +1 -0
- package/dist/converge/stale-report.d.ts +14 -0
- package/dist/converge/stale-report.js +213 -0
- package/dist/converge/stale-report.js.map +1 -0
- package/dist/converge/target-ownership.d.ts +29 -0
- package/dist/converge/target-ownership.js +95 -0
- package/dist/converge/target-ownership.js.map +1 -0
- package/dist/converge/terminal-rejection-schema.d.ts +42 -0
- package/dist/converge/terminal-rejection-schema.js +39 -0
- package/dist/converge/terminal-rejection-schema.js.map +1 -0
- package/dist/converge/terminal-rejection.d.ts +13 -0
- package/dist/converge/terminal-rejection.js +275 -0
- package/dist/converge/terminal-rejection.js.map +1 -0
- package/dist/coordination/registry-lock.d.ts +82 -0
- package/dist/coordination/registry-lock.js +498 -0
- package/dist/coordination/registry-lock.js.map +1 -0
- package/dist/discuss.d.ts +53 -0
- package/dist/discuss.js +112 -0
- package/dist/discuss.js.map +1 -0
- package/dist/dispatch/adapter.d.ts +32 -0
- package/dist/dispatch/adapter.js +2 -0
- package/dist/dispatch/adapter.js.map +1 -0
- package/dist/dispatch/anthropic.d.ts +10 -0
- package/dist/dispatch/anthropic.js +235 -0
- package/dist/dispatch/anthropic.js.map +1 -0
- package/dist/dispatch/async-lane.d.ts +127 -0
- package/dist/dispatch/async-lane.js +414 -0
- package/dist/dispatch/async-lane.js.map +1 -0
- package/dist/dispatch/capture-council.d.ts +63 -0
- package/dist/dispatch/capture-council.js +137 -0
- package/dist/dispatch/capture-council.js.map +1 -0
- package/dist/dispatch/captured-async.d.ts +67 -0
- package/dist/dispatch/captured-async.js +40 -0
- package/dist/dispatch/captured-async.js.map +1 -0
- package/dist/dispatch/captured-inputs.d.ts +50 -0
- package/dist/dispatch/captured-inputs.js +190 -0
- package/dist/dispatch/captured-inputs.js.map +1 -0
- package/dist/dispatch/checkpoint-async-context.d.ts +27 -0
- package/dist/dispatch/checkpoint-async-context.js +51 -0
- package/dist/dispatch/checkpoint-async-context.js.map +1 -0
- package/dist/dispatch/checkpoint-async-execution.d.ts +22 -0
- package/dist/dispatch/checkpoint-async-execution.js +130 -0
- package/dist/dispatch/checkpoint-async-execution.js.map +1 -0
- package/dist/dispatch/checkpoint-async-store.d.ts +134 -0
- package/dist/dispatch/checkpoint-async-store.js +534 -0
- package/dist/dispatch/checkpoint-async-store.js.map +1 -0
- package/dist/dispatch/checkpoint-async-unknown.d.ts +19 -0
- package/dist/dispatch/checkpoint-async-unknown.js +46 -0
- package/dist/dispatch/checkpoint-async-unknown.js.map +1 -0
- package/dist/dispatch/checkpoint-async.d.ts +252 -0
- package/dist/dispatch/checkpoint-async.js +270 -0
- package/dist/dispatch/checkpoint-async.js.map +1 -0
- package/dist/dispatch/checkpoint-gating-execution.d.ts +26 -0
- package/dist/dispatch/checkpoint-gating-execution.js +84 -0
- package/dist/dispatch/checkpoint-gating-execution.js.map +1 -0
- package/dist/dispatch/checkpoint-phase-limits.d.ts +5 -0
- package/dist/dispatch/checkpoint-phase-limits.js +11 -0
- package/dist/dispatch/checkpoint-phase-limits.js.map +1 -0
- package/dist/dispatch/checkpoint-verification-context.d.ts +15 -0
- package/dist/dispatch/checkpoint-verification-context.js +48 -0
- package/dist/dispatch/checkpoint-verification-context.js.map +1 -0
- package/dist/dispatch/checkpoint-verification.d.ts +213 -0
- package/dist/dispatch/checkpoint-verification.js +381 -0
- package/dist/dispatch/checkpoint-verification.js.map +1 -0
- package/dist/dispatch/checkpoint.d.ts +329 -0
- package/dist/dispatch/checkpoint.js +1418 -0
- package/dist/dispatch/checkpoint.js.map +1 -0
- package/dist/dispatch/google.d.ts +10 -0
- package/dist/dispatch/google.js +158 -0
- package/dist/dispatch/google.js.map +1 -0
- package/dist/dispatch/late-audit.d.ts +23 -0
- package/dist/dispatch/late-audit.js +133 -0
- package/dist/dispatch/late-audit.js.map +1 -0
- package/dist/dispatch/merge.d.ts +29 -0
- package/dist/dispatch/merge.js +112 -0
- package/dist/dispatch/merge.js.map +1 -0
- package/dist/dispatch/openai-compat.d.ts +30 -0
- package/dist/dispatch/openai-compat.js +166 -0
- package/dist/dispatch/openai-compat.js.map +1 -0
- package/dist/dispatch/openai.d.ts +10 -0
- package/dist/dispatch/openai.js +159 -0
- package/dist/dispatch/openai.js.map +1 -0
- package/dist/dispatch/original-execution.d.ts +30 -0
- package/dist/dispatch/original-execution.js +91 -0
- package/dist/dispatch/original-execution.js.map +1 -0
- package/dist/dispatch/original-launch.d.ts +37 -0
- package/dist/dispatch/original-launch.js +117 -0
- package/dist/dispatch/original-launch.js.map +1 -0
- package/dist/dispatch/quorum.d.ts +15 -0
- package/dist/dispatch/quorum.js +33 -0
- package/dist/dispatch/quorum.js.map +1 -0
- package/dist/dispatch/recovery-operation.d.ts +44 -0
- package/dist/dispatch/recovery-operation.js +146 -0
- package/dist/dispatch/recovery-operation.js.map +1 -0
- package/dist/dispatch/recovery-policy.d.ts +54 -0
- package/dist/dispatch/recovery-policy.js +157 -0
- package/dist/dispatch/recovery-policy.js.map +1 -0
- package/dist/dispatch/recovery.d.ts +78 -0
- package/dist/dispatch/recovery.js +299 -0
- package/dist/dispatch/recovery.js.map +1 -0
- package/dist/dispatch/retained-async.d.ts +13 -0
- package/dist/dispatch/retained-async.js +101 -0
- package/dist/dispatch/retained-async.js.map +1 -0
- package/dist/dispatch/reviewer-identity.d.ts +10 -0
- package/dist/dispatch/reviewer-identity.js +19 -0
- package/dist/dispatch/reviewer-identity.js.map +1 -0
- package/dist/dispatch/runner.d.ts +76 -0
- package/dist/dispatch/runner.js +415 -0
- package/dist/dispatch/runner.js.map +1 -0
- package/dist/dispatch/utils.d.ts +159 -0
- package/dist/dispatch/utils.js +381 -0
- package/dist/dispatch/utils.js.map +1 -0
- package/dist/dispatch/verification-execution.d.ts +48 -0
- package/dist/dispatch/verification-execution.js +252 -0
- package/dist/dispatch/verification-execution.js.map +1 -0
- package/dist/dispatch/verification-late-audit.d.ts +17 -0
- package/dist/dispatch/verification-late-audit.js +117 -0
- package/dist/dispatch/verification-late-audit.js.map +1 -0
- package/dist/evidence/claim-recovery/authenticated-carrier-projection.d.ts +30 -0
- package/dist/evidence/claim-recovery/authenticated-carrier-projection.js +100 -0
- package/dist/evidence/claim-recovery/authenticated-carrier-projection.js.map +1 -0
- package/dist/evidence/claim-recovery/authenticated-receipts.d.ts +46 -0
- package/dist/evidence/claim-recovery/authenticated-receipts.js +120 -0
- package/dist/evidence/claim-recovery/authenticated-receipts.js.map +1 -0
- package/dist/evidence/claim-recovery/carrier-inventory.d.ts +49 -0
- package/dist/evidence/claim-recovery/carrier-inventory.js +340 -0
- package/dist/evidence/claim-recovery/carrier-inventory.js.map +1 -0
- package/dist/evidence/claim-recovery/claim-index.d.ts +12 -0
- package/dist/evidence/claim-recovery/claim-index.js +56 -0
- package/dist/evidence/claim-recovery/claim-index.js.map +1 -0
- package/dist/evidence/claim-recovery/confirmation.d.ts +53 -0
- package/dist/evidence/claim-recovery/confirmation.js +151 -0
- package/dist/evidence/claim-recovery/confirmation.js.map +1 -0
- package/dist/evidence/claim-recovery/context.d.ts +15 -0
- package/dist/evidence/claim-recovery/context.js +40 -0
- package/dist/evidence/claim-recovery/context.js.map +1 -0
- package/dist/evidence/claim-recovery/proof-storage.d.ts +6 -0
- package/dist/evidence/claim-recovery/proof-storage.js +97 -0
- package/dist/evidence/claim-recovery/proof-storage.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/anchors.d.ts +20 -0
- package/dist/evidence/claim-recovery/validation/anchors.js +22 -0
- package/dist/evidence/claim-recovery/validation/anchors.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/carrier-projection.d.ts +9 -0
- package/dist/evidence/claim-recovery/validation/carrier-projection.js +364 -0
- package/dist/evidence/claim-recovery/validation/carrier-projection.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/carrier-types.d.ts +83 -0
- package/dist/evidence/claim-recovery/validation/carrier-types.js +2 -0
- package/dist/evidence/claim-recovery/validation/carrier-types.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/claim-split.d.ts +57 -0
- package/dist/evidence/claim-recovery/validation/claim-split.js +209 -0
- package/dist/evidence/claim-recovery/validation/claim-split.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/claims.d.ts +20 -0
- package/dist/evidence/claim-recovery/validation/claims.js +108 -0
- package/dist/evidence/claim-recovery/validation/claims.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/current-projection.d.ts +36 -0
- package/dist/evidence/claim-recovery/validation/current-projection.js +424 -0
- package/dist/evidence/claim-recovery/validation/current-projection.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/lexical.d.ts +18 -0
- package/dist/evidence/claim-recovery/validation/lexical.js +91 -0
- package/dist/evidence/claim-recovery/validation/lexical.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/materials.d.ts +19 -0
- package/dist/evidence/claim-recovery/validation/materials.js +160 -0
- package/dist/evidence/claim-recovery/validation/materials.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/native-material.d.ts +27 -0
- package/dist/evidence/claim-recovery/validation/native-material.js +35 -0
- package/dist/evidence/claim-recovery/validation/native-material.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/native-occurrences.d.ts +79 -0
- package/dist/evidence/claim-recovery/validation/native-occurrences.js +187 -0
- package/dist/evidence/claim-recovery/validation/native-occurrences.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/native-state.d.ts +45 -0
- package/dist/evidence/claim-recovery/validation/native-state.js +385 -0
- package/dist/evidence/claim-recovery/validation/native-state.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/obligations.d.ts +15 -0
- package/dist/evidence/claim-recovery/validation/obligations.js +65 -0
- package/dist/evidence/claim-recovery/validation/obligations.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/occurrence-source.d.ts +45 -0
- package/dist/evidence/claim-recovery/validation/occurrence-source.js +208 -0
- package/dist/evidence/claim-recovery/validation/occurrence-source.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/occurrence-types.d.ts +101 -0
- package/dist/evidence/claim-recovery/validation/occurrence-types.js +2 -0
- package/dist/evidence/claim-recovery/validation/occurrence-types.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/occurrence.d.ts +30 -0
- package/dist/evidence/claim-recovery/validation/occurrence.js +227 -0
- package/dist/evidence/claim-recovery/validation/occurrence.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/primitives.d.ts +11 -0
- package/dist/evidence/claim-recovery/validation/primitives.js +41 -0
- package/dist/evidence/claim-recovery/validation/primitives.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/receipts.d.ts +37 -0
- package/dist/evidence/claim-recovery/validation/receipts.js +83 -0
- package/dist/evidence/claim-recovery/validation/receipts.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/recovery-json.d.ts +8 -0
- package/dist/evidence/claim-recovery/validation/recovery-json.js +42 -0
- package/dist/evidence/claim-recovery/validation/recovery-json.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/semantic-cache.d.ts +3 -0
- package/dist/evidence/claim-recovery/validation/semantic-cache.js +22 -0
- package/dist/evidence/claim-recovery/validation/semantic-cache.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/semantic-validation.d.ts +9 -0
- package/dist/evidence/claim-recovery/validation/semantic-validation.js +347 -0
- package/dist/evidence/claim-recovery/validation/semantic-validation.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/sighting.d.ts +2 -0
- package/dist/evidence/claim-recovery/validation/sighting.js +15 -0
- package/dist/evidence/claim-recovery/validation/sighting.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/sources.d.ts +15 -0
- package/dist/evidence/claim-recovery/validation/sources.js +2 -0
- package/dist/evidence/claim-recovery/validation/sources.js.map +1 -0
- package/dist/evidence/claim-recovery/validation/types.d.ts +126 -0
- package/dist/evidence/claim-recovery/validation/types.js +2 -0
- package/dist/evidence/claim-recovery/validation/types.js.map +1 -0
- package/dist/evidence/claim-split.d.ts +1 -0
- package/dist/evidence/claim-split.js +2 -0
- package/dist/evidence/claim-split.js.map +1 -0
- package/dist/evidence/event-receipts.d.ts +16 -0
- package/dist/evidence/event-receipts.js +41 -0
- package/dist/evidence/event-receipts.js.map +1 -0
- package/dist/evidence/finding-recovery.d.ts +23 -0
- package/dist/evidence/finding-recovery.js +74 -0
- package/dist/evidence/finding-recovery.js.map +1 -0
- package/dist/evidence/finding-retriage.d.ts +14 -0
- package/dist/evidence/finding-retriage.js +57 -0
- package/dist/evidence/finding-retriage.js.map +1 -0
- package/dist/evidence/format.d.ts +18 -0
- package/dist/evidence/format.js +152 -0
- package/dist/evidence/format.js.map +1 -0
- package/dist/evidence/original-run/decode.d.ts +30 -0
- package/dist/evidence/original-run/decode.js +208 -0
- package/dist/evidence/original-run/decode.js.map +1 -0
- package/dist/evidence/original-run/journal.d.ts +31 -0
- package/dist/evidence/original-run/journal.js +157 -0
- package/dist/evidence/original-run/journal.js.map +1 -0
- package/dist/evidence/original-run/lock-path.d.ts +17 -0
- package/dist/evidence/original-run/lock-path.js +116 -0
- package/dist/evidence/original-run/lock-path.js.map +1 -0
- package/dist/evidence/original-run/lock-scope.d.ts +21 -0
- package/dist/evidence/original-run/lock-scope.js +61 -0
- package/dist/evidence/original-run/lock-scope.js.map +1 -0
- package/dist/evidence/original-run/lock.d.ts +33 -0
- package/dist/evidence/original-run/lock.js +259 -0
- package/dist/evidence/original-run/lock.js.map +1 -0
- package/dist/evidence/original-run/remote.d.ts +23 -0
- package/dist/evidence/original-run/remote.js +110 -0
- package/dist/evidence/original-run/remote.js.map +1 -0
- package/dist/evidence/original-run/source.d.ts +61 -0
- package/dist/evidence/original-run/source.js +267 -0
- package/dist/evidence/original-run/source.js.map +1 -0
- package/dist/evidence/reads.d.ts +11 -0
- package/dist/evidence/reads.js +16 -0
- package/dist/evidence/reads.js.map +1 -0
- package/dist/evidence/recover-finding.d.ts +17 -0
- package/dist/evidence/recover-finding.js +65 -0
- package/dist/evidence/recover-finding.js.map +1 -0
- package/dist/evidence/recover-run.d.ts +26 -0
- package/dist/evidence/recover-run.js +180 -0
- package/dist/evidence/recover-run.js.map +1 -0
- package/dist/evidence/retained-time-budget.d.ts +9 -0
- package/dist/evidence/retained-time-budget.js +14 -0
- package/dist/evidence/retained-time-budget.js.map +1 -0
- package/dist/evidence/retriage-finding.d.ts +12 -0
- package/dist/evidence/retriage-finding.js +67 -0
- package/dist/evidence/retriage-finding.js.map +1 -0
- package/dist/evidence/reviewer-lineage.d.ts +35 -0
- package/dist/evidence/reviewer-lineage.js +293 -0
- package/dist/evidence/reviewer-lineage.js.map +1 -0
- package/dist/evidence/reviewer-original.d.ts +67 -0
- package/dist/evidence/reviewer-original.js +148 -0
- package/dist/evidence/reviewer-original.js.map +1 -0
- package/dist/evidence/reviewer-recovery.d.ts +74 -0
- package/dist/evidence/reviewer-recovery.js +179 -0
- package/dist/evidence/reviewer-recovery.js.map +1 -0
- package/dist/evidence/reviewer-status.d.ts +145 -0
- package/dist/evidence/reviewer-status.js +302 -0
- package/dist/evidence/reviewer-status.js.map +1 -0
- package/dist/evidence/show.d.ts +10 -0
- package/dist/evidence/show.js +41 -0
- package/dist/evidence/show.js.map +1 -0
- package/dist/evidence/status.d.ts +38 -0
- package/dist/evidence/status.js +73 -0
- package/dist/evidence/status.js.map +1 -0
- package/dist/evidence/target.d.ts +17 -0
- package/dist/evidence/target.js +74 -0
- package/dist/evidence/target.js.map +1 -0
- package/dist/evidence/types.d.ts +176 -0
- package/dist/evidence/types.js +109 -0
- package/dist/evidence/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2688 -0
- package/dist/index.js.map +1 -0
- package/dist/models/seed.d.ts +44 -0
- package/dist/models/seed.js +175 -0
- package/dist/models/seed.js.map +1 -0
- package/dist/models/server-stats.d.ts +80 -0
- package/dist/models/server-stats.js +109 -0
- package/dist/models/server-stats.js.map +1 -0
- package/dist/models/stats-store.d.ts +84 -0
- package/dist/models/stats-store.js +572 -0
- package/dist/models/stats-store.js.map +1 -0
- package/dist/output/artifacts.d.ts +16 -0
- package/dist/output/artifacts.js +29 -0
- package/dist/output/artifacts.js.map +1 -0
- package/dist/output/assembly-refusal.d.ts +8 -0
- package/dist/output/assembly-refusal.js +14 -0
- package/dist/output/assembly-refusal.js.map +1 -0
- package/dist/output/github.d.ts +12 -0
- package/dist/output/github.js +214 -0
- package/dist/output/github.js.map +1 -0
- package/dist/output/json.d.ts +3 -0
- package/dist/output/json.js +8 -0
- package/dist/output/json.js.map +1 -0
- package/dist/output/markdown.d.ts +3 -0
- package/dist/output/markdown.js +281 -0
- package/dist/output/markdown.js.map +1 -0
- package/dist/output/progress.d.ts +55 -0
- package/dist/output/progress.js +180 -0
- package/dist/output/progress.js.map +1 -0
- package/dist/output/sanitize.d.ts +18 -0
- package/dist/output/sanitize.js +46 -0
- package/dist/output/sanitize.js.map +1 -0
- package/dist/output/terminal.d.ts +2 -0
- package/dist/output/terminal.js +172 -0
- package/dist/output/terminal.js.map +1 -0
- package/dist/prepare/chunker.d.ts +18 -0
- package/dist/prepare/chunker.js +325 -0
- package/dist/prepare/chunker.js.map +1 -0
- package/dist/prepare/language.d.ts +1 -0
- package/dist/prepare/language.js +99 -0
- package/dist/prepare/language.js.map +1 -0
- package/dist/prepare/prompt-builder.d.ts +44 -0
- package/dist/prepare/prompt-builder.js +102 -0
- package/dist/prepare/prompt-builder.js.map +1 -0
- package/dist/prepare/unified-diff.d.ts +40 -0
- package/dist/prepare/unified-diff.js +135 -0
- package/dist/prepare/unified-diff.js.map +1 -0
- package/dist/prompts/base.d.ts +3 -0
- package/dist/prompts/base.js +53 -0
- package/dist/prompts/base.js.map +1 -0
- package/dist/prompts/hardening.d.ts +19 -0
- package/dist/prompts/hardening.js +67 -0
- package/dist/prompts/hardening.js.map +1 -0
- package/dist/prompts/languages/elixir.d.ts +1 -0
- package/dist/prompts/languages/elixir.js +13 -0
- package/dist/prompts/languages/elixir.js.map +1 -0
- package/dist/prompts/languages/generic.d.ts +1 -0
- package/dist/prompts/languages/generic.js +11 -0
- package/dist/prompts/languages/generic.js.map +1 -0
- package/dist/prompts/languages/python.d.ts +1 -0
- package/dist/prompts/languages/python.js +14 -0
- package/dist/prompts/languages/python.js.map +1 -0
- package/dist/prompts/languages/typescript.d.ts +1 -0
- package/dist/prompts/languages/typescript.js +13 -0
- package/dist/prompts/languages/typescript.js.map +1 -0
- package/dist/prompts/plan.d.ts +15 -0
- package/dist/prompts/plan.js +55 -0
- package/dist/prompts/plan.js.map +1 -0
- package/dist/report/aggregation-inputs.d.ts +52 -0
- package/dist/report/aggregation-inputs.js +114 -0
- package/dist/report/aggregation-inputs.js.map +1 -0
- package/dist/report/assembly.d.ts +43 -0
- package/dist/report/assembly.js +133 -0
- package/dist/report/assembly.js.map +1 -0
- package/dist/report/blocking-health.d.ts +64 -0
- package/dist/report/blocking-health.js +156 -0
- package/dist/report/blocking-health.js.map +1 -0
- package/dist/report/checkpoint-assembly.d.ts +10 -0
- package/dist/report/checkpoint-assembly.js +17 -0
- package/dist/report/checkpoint-assembly.js.map +1 -0
- package/dist/report/checkpoint-consensus.d.ts +59 -0
- package/dist/report/checkpoint-consensus.js +197 -0
- package/dist/report/checkpoint-consensus.js.map +1 -0
- package/dist/report/checkpoint-gating.d.ts +36 -0
- package/dist/report/checkpoint-gating.js +110 -0
- package/dist/report/checkpoint-gating.js.map +1 -0
- package/dist/report/checkpoint-projection.d.ts +76 -0
- package/dist/report/checkpoint-projection.js +122 -0
- package/dist/report/checkpoint-projection.js.map +1 -0
- package/dist/report/consensus-assembly.d.ts +37 -0
- package/dist/report/consensus-assembly.js +33 -0
- package/dist/report/consensus-assembly.js.map +1 -0
- package/dist/report/recovery-source.d.ts +7 -0
- package/dist/report/recovery-source.js +7 -0
- package/dist/report/recovery-source.js.map +1 -0
- package/dist/report/reviewer-artifact.d.ts +118 -0
- package/dist/report/reviewer-artifact.js +381 -0
- package/dist/report/reviewer-artifact.js.map +1 -0
- package/dist/report/reviewer-evidence-schema.d.ts +42 -0
- package/dist/report/reviewer-evidence-schema.js +28 -0
- package/dist/report/reviewer-evidence-schema.js.map +1 -0
- package/dist/report/reviewer-evidence.d.ts +54 -0
- package/dist/report/reviewer-evidence.js +229 -0
- package/dist/report/reviewer-evidence.js.map +1 -0
- package/dist/report/reviewer-health.d.ts +62 -0
- package/dist/report/reviewer-health.js +105 -0
- package/dist/report/reviewer-health.js.map +1 -0
- package/dist/report/run-header.d.ts +219 -0
- package/dist/report/run-header.js +307 -0
- package/dist/report/run-header.js.map +1 -0
- package/dist/report/supplemental-async.d.ts +19 -0
- package/dist/report/supplemental-async.js +85 -0
- package/dist/report/supplemental-async.js.map +1 -0
- package/dist/report/uuid.d.ts +16 -0
- package/dist/report/uuid.js +41 -0
- package/dist/report/uuid.js.map +1 -0
- package/dist/resolver/git.d.ts +16 -0
- package/dist/resolver/git.js +77 -0
- package/dist/resolver/git.js.map +1 -0
- package/dist/resolver/github-client.d.ts +82 -0
- package/dist/resolver/github-client.js +27 -0
- package/dist/resolver/github-client.js.map +1 -0
- package/dist/resolver/github.d.ts +29 -0
- package/dist/resolver/github.js +166 -0
- package/dist/resolver/github.js.map +1 -0
- package/dist/resolver/local.d.ts +3 -0
- package/dist/resolver/local.js +75 -0
- package/dist/resolver/local.js.map +1 -0
- package/dist/resolver/plan.d.ts +8 -0
- package/dist/resolver/plan.js +44 -0
- package/dist/resolver/plan.js.map +1 -0
- package/dist/resolver/target.d.ts +35 -0
- package/dist/resolver/target.js +112 -0
- package/dist/resolver/target.js.map +1 -0
- package/dist/resolver/types.d.ts +43 -0
- package/dist/resolver/types.js +2 -0
- package/dist/resolver/types.js.map +1 -0
- package/dist/roles/builtin.d.ts +4 -0
- package/dist/roles/builtin.js +282 -0
- package/dist/roles/builtin.js.map +1 -0
- package/dist/roles/dispatcher.d.ts +26 -0
- package/dist/roles/dispatcher.js +96 -0
- package/dist/roles/dispatcher.js.map +1 -0
- package/dist/roles/legacy-4.1.10.d.ts +2 -0
- package/dist/roles/legacy-4.1.10.js +320 -0
- package/dist/roles/legacy-4.1.10.js.map +1 -0
- package/dist/roles/legacy-4.4.9.d.ts +4 -0
- package/dist/roles/legacy-4.4.9.js +282 -0
- package/dist/roles/legacy-4.4.9.js.map +1 -0
- package/dist/roles/loader.d.ts +10 -0
- package/dist/roles/loader.js +104 -0
- package/dist/roles/loader.js.map +1 -0
- package/dist/roles/types.d.ts +13 -0
- package/dist/roles/types.js +2 -0
- package/dist/roles/types.js.map +1 -0
- package/dist/telemetry/abort-signal.d.ts +13 -0
- package/dist/telemetry/abort-signal.js +40 -0
- package/dist/telemetry/abort-signal.js.map +1 -0
- package/dist/telemetry/attest.d.ts +98 -0
- package/dist/telemetry/attest.js +331 -0
- package/dist/telemetry/attest.js.map +1 -0
- package/dist/telemetry/attested-retry.d.ts +79 -0
- package/dist/telemetry/attested-retry.js +195 -0
- package/dist/telemetry/attested-retry.js.map +1 -0
- package/dist/telemetry/attested-reviewer-delivery.d.ts +58 -0
- package/dist/telemetry/attested-reviewer-delivery.js +238 -0
- package/dist/telemetry/attested-reviewer-delivery.js.map +1 -0
- package/dist/telemetry/backfill.d.ts +95 -0
- package/dist/telemetry/backfill.js +460 -0
- package/dist/telemetry/backfill.js.map +1 -0
- package/dist/telemetry/credentials.d.ts +44 -0
- package/dist/telemetry/credentials.js +87 -0
- package/dist/telemetry/credentials.js.map +1 -0
- package/dist/telemetry/deliver.d.ts +152 -0
- package/dist/telemetry/deliver.js +662 -0
- package/dist/telemetry/deliver.js.map +1 -0
- package/dist/telemetry/envelope-validation.d.ts +13 -0
- package/dist/telemetry/envelope-validation.js +196 -0
- package/dist/telemetry/envelope-validation.js.map +1 -0
- package/dist/telemetry/envelope.d.ts +159 -0
- package/dist/telemetry/envelope.js +288 -0
- package/dist/telemetry/envelope.js.map +1 -0
- package/dist/telemetry/events.d.ts +68 -0
- package/dist/telemetry/events.js +79 -0
- package/dist/telemetry/events.js.map +1 -0
- package/dist/telemetry/notice.d.ts +15 -0
- package/dist/telemetry/notice.js +67 -0
- package/dist/telemetry/notice.js.map +1 -0
- package/dist/telemetry/outbox.d.ts +166 -0
- package/dist/telemetry/outbox.js +741 -0
- package/dist/telemetry/outbox.js.map +1 -0
- package/dist/telemetry/quarantine.d.ts +105 -0
- package/dist/telemetry/quarantine.js +224 -0
- package/dist/telemetry/quarantine.js.map +1 -0
- package/dist/telemetry/read-sink.d.ts +31 -0
- package/dist/telemetry/read-sink.js +25 -0
- package/dist/telemetry/read-sink.js.map +1 -0
- package/dist/telemetry/recovery/command.d.ts +16 -0
- package/dist/telemetry/recovery/command.js +70 -0
- package/dist/telemetry/recovery/command.js.map +1 -0
- package/dist/telemetry/recovery/discovery.d.ts +8 -0
- package/dist/telemetry/recovery/discovery.js +277 -0
- package/dist/telemetry/recovery/discovery.js.map +1 -0
- package/dist/telemetry/recovery/files.d.ts +20 -0
- package/dist/telemetry/recovery/files.js +123 -0
- package/dist/telemetry/recovery/files.js.map +1 -0
- package/dist/telemetry/recovery/plan.d.ts +10 -0
- package/dist/telemetry/recovery/plan.js +325 -0
- package/dist/telemetry/recovery/plan.js.map +1 -0
- package/dist/telemetry/recovery/source.d.ts +328 -0
- package/dist/telemetry/recovery/source.js +253 -0
- package/dist/telemetry/recovery/source.js.map +1 -0
- package/dist/telemetry/recovery/types.d.ts +100 -0
- package/dist/telemetry/recovery/types.js +2 -0
- package/dist/telemetry/recovery/types.js.map +1 -0
- package/dist/telemetry/recovery-request-budget.d.ts +39 -0
- package/dist/telemetry/recovery-request-budget.js +102 -0
- package/dist/telemetry/recovery-request-budget.js.map +1 -0
- package/dist/telemetry/report-consistency.d.ts +11 -0
- package/dist/telemetry/report-consistency.js +111 -0
- package/dist/telemetry/report-consistency.js.map +1 -0
- package/dist/telemetry/reviewer-delivery.d.ts +39 -0
- package/dist/telemetry/reviewer-delivery.js +279 -0
- package/dist/telemetry/reviewer-delivery.js.map +1 -0
- package/dist/telemetry/reviewer-preflight.d.ts +13 -0
- package/dist/telemetry/reviewer-preflight.js +56 -0
- package/dist/telemetry/reviewer-preflight.js.map +1 -0
- package/dist/telemetry/scrub.d.ts +53 -0
- package/dist/telemetry/scrub.js +205 -0
- package/dist/telemetry/scrub.js.map +1 -0
- package/dist/telemetry/sink.d.ts +212 -0
- package/dist/telemetry/sink.js +813 -0
- package/dist/telemetry/sink.js.map +1 -0
- package/dist/telemetry/terminal-reviewer-delivery.d.ts +18 -0
- package/dist/telemetry/terminal-reviewer-delivery.js +27 -0
- package/dist/telemetry/terminal-reviewer-delivery.js.map +1 -0
- package/dist/telemetry/transient-input.d.ts +2 -0
- package/dist/telemetry/transient-input.js +37 -0
- package/dist/telemetry/transient-input.js.map +1 -0
- package/dist/telemetry/verification.d.ts +9 -0
- package/dist/telemetry/verification.js +12 -0
- package/dist/telemetry/verification.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { realpath } from 'node:fs/promises';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { inspectPendingLegacyRetry } from './legacy-launch-health.js';
|
|
7
|
+
import { completionSchema, launchSchema } from './launch-record.js';
|
|
8
|
+
import { convergeRunStatePath, loadConvergeRunState, preflightConvergeRunStateWrite, writeState } from './run-state.js';
|
|
9
|
+
import { claimConvergeAttempt, convergeAttemptStatePath, previewConvergeAttemptState } from './attempt-budget.js';
|
|
10
|
+
import { withRecoveryTarget } from './target-ownership.js';
|
|
11
|
+
import { bindOriginalCouncil } from '../dispatch/original-execution.js';
|
|
12
|
+
import { createOriginalLaunch } from '../dispatch/original-launch.js';
|
|
13
|
+
import { uuidv7 } from '../report/uuid.js';
|
|
14
|
+
import { captureSupplementalAsync } from '../report/supplemental-async.js';
|
|
15
|
+
import { stableStringify } from '../report/run-header.js';
|
|
16
|
+
import { readStable } from '../telemetry/recovery/files.js';
|
|
17
|
+
import { serializeRecoveryDocument } from '../evidence/original-run/journal.js';
|
|
18
|
+
import { prepareLockRoot } from '../evidence/original-run/lock-path.js';
|
|
19
|
+
import { retainStaleFile } from './stale-report-storage.js';
|
|
20
|
+
import { createPendingRecoverySource, createOrdinaryMigrationSource, pendingRecoverySourceSchema } from './pending-recovery-source.js';
|
|
21
|
+
import { validateOrdinaryPendingPackage } from './ordinary-pending-package.js';
|
|
22
|
+
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
23
|
+
const ordinaryPendingFinalizationReceiptBodySchema = z.object({
|
|
24
|
+
version: z.literal(1),
|
|
25
|
+
operation: z.literal('ordinary-pending-finalize-only'),
|
|
26
|
+
target: z.string().min(1),
|
|
27
|
+
headSha: z.string().regex(/^[a-f0-9]{40}$/),
|
|
28
|
+
baseSha: z.string().regex(/^[a-f0-9]{40}$/),
|
|
29
|
+
inputSha256: digestSchema,
|
|
30
|
+
sourceDigest: digestSchema,
|
|
31
|
+
migrationPackageSha256: digestSchema,
|
|
32
|
+
finalizedAttempt: z.number().int().positive().safe(),
|
|
33
|
+
round: z.number().int().positive().safe(),
|
|
34
|
+
originalPid: z.number().int().positive().safe(),
|
|
35
|
+
attemptsUsed: z.number().int().positive().safe(),
|
|
36
|
+
cap: z.number().int().positive().safe(),
|
|
37
|
+
nextFreeAttempt: z.number().int().positive().safe(),
|
|
38
|
+
blockingOutcome: z.literal('unknown'),
|
|
39
|
+
retainedAsyncSha256: z.array(digestSchema).min(1),
|
|
40
|
+
sourceNativeStateSha256: digestSchema,
|
|
41
|
+
sourceAttemptStateSha256: digestSchema,
|
|
42
|
+
finalizedNativeStateSha256: digestSchema,
|
|
43
|
+
}).strict();
|
|
44
|
+
const ordinaryPendingFinalizationReceiptSchema = ordinaryPendingFinalizationReceiptBodySchema.extend({
|
|
45
|
+
receiptDigest: digestSchema,
|
|
46
|
+
}).strict().superRefine((receipt, context) => {
|
|
47
|
+
const { receiptDigest, ...body } = receipt;
|
|
48
|
+
if (receiptDigest !== createHash('sha256').update(stableStringify(body)).digest('hex')) {
|
|
49
|
+
context.addIssue({ code: 'custom', message: 'Pending finalization receipt digest is invalid' });
|
|
50
|
+
}
|
|
51
|
+
if (receipt.nextFreeAttempt !== receipt.finalizedAttempt + 1 ||
|
|
52
|
+
receipt.attemptsUsed !== receipt.finalizedAttempt || receipt.attemptsUsed > receipt.cap ||
|
|
53
|
+
new Set(receipt.retainedAsyncSha256).size !== receipt.retainedAsyncSha256.length) {
|
|
54
|
+
context.addIssue({ code: 'custom', message: 'Pending finalization accounting is inconsistent' });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
function fail(code) { throw new Error(`pending_legacy_resume_${code}`); }
|
|
58
|
+
function defaultOwnerAlive(pid) {
|
|
59
|
+
try {
|
|
60
|
+
process.kill(pid, 0);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error.code === 'ESRCH')
|
|
65
|
+
return false;
|
|
66
|
+
fail('owner_unverifiable');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function descriptor(source) {
|
|
70
|
+
return {
|
|
71
|
+
version: 1, sourceDigest: source.digest, pendingAttempt: source.pendingAttempt,
|
|
72
|
+
round: source.round, originalPid: source.originalPid, originalStartedAt: source.startedAt,
|
|
73
|
+
blockingOutcome: 'unknown',
|
|
74
|
+
reason: 'coordinator_exited_without_durable_blocking_receipts',
|
|
75
|
+
nativeStateSha256: source.nativeStateSha256, attemptStateSha256: source.attemptStateSha256,
|
|
76
|
+
retainedAsyncSha256: [...source.retainedAsyncSha256],
|
|
77
|
+
...('migrationPackageSha256' in source ? { migrationPackageSha256: source.migrationPackageSha256 } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function sourceFromFinalized(target, launch, attempts, migrationPackage) {
|
|
81
|
+
const recovery = launch.pendingRecovery;
|
|
82
|
+
const claim = attempts.attempts.find(item => item.attempt === launch.attempt);
|
|
83
|
+
if (!recovery || !claim || launch.attempt !== recovery.pendingAttempt ||
|
|
84
|
+
launch.round !== recovery.round || launch.pid !== recovery.originalPid ||
|
|
85
|
+
launch.startedAt !== recovery.originalStartedAt)
|
|
86
|
+
fail('finalization_mismatch');
|
|
87
|
+
if (recovery.migrationPackageSha256) {
|
|
88
|
+
if (!migrationPackage)
|
|
89
|
+
fail('migration_package_required');
|
|
90
|
+
const migrationPackageSha256 = createHash('sha256').update(stableStringify(migrationPackage)).digest('hex');
|
|
91
|
+
if (migrationPackageSha256 !== recovery.migrationPackageSha256)
|
|
92
|
+
fail('finalization_mismatch');
|
|
93
|
+
const source = createOrdinaryMigrationSource({ version: 1, target, headSha: launch.headSha,
|
|
94
|
+
inputSha256: launch.inputSha256, pendingAttempt: launch.attempt, round: launch.round,
|
|
95
|
+
originalPid: launch.pid, startedAt: launch.startedAt, blockingOutcome: recovery.blockingOutcome,
|
|
96
|
+
reason: recovery.reason, nativeStateSha256: recovery.nativeStateSha256,
|
|
97
|
+
attemptStateSha256: recovery.attemptStateSha256, retainedAsyncSha256: recovery.retainedAsyncSha256,
|
|
98
|
+
migrationPackageSha256 });
|
|
99
|
+
if (source.digest !== recovery.sourceDigest)
|
|
100
|
+
fail('finalization_mismatch');
|
|
101
|
+
return source;
|
|
102
|
+
}
|
|
103
|
+
if (!claim.retrySource)
|
|
104
|
+
fail('finalization_mismatch');
|
|
105
|
+
return pendingRecoverySourceSchema.parse({
|
|
106
|
+
version: 1, target, headSha: launch.headSha, inputSha256: launch.inputSha256,
|
|
107
|
+
pendingAttempt: launch.attempt, round: launch.round, originalPid: launch.pid,
|
|
108
|
+
startedAt: launch.startedAt, blockingOutcome: recovery.blockingOutcome,
|
|
109
|
+
reason: recovery.reason, nativeStateSha256: recovery.nativeStateSha256,
|
|
110
|
+
attemptStateSha256: recovery.attemptStateSha256,
|
|
111
|
+
retainedAsyncSha256: recovery.retainedAsyncSha256, retrySource: claim.retrySource,
|
|
112
|
+
digest: recovery.sourceDigest,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function validateOptions(input) {
|
|
116
|
+
const hashes = input?.retainedAsyncSha256;
|
|
117
|
+
if (!input || typeof input.gitCommonDir !== 'string' || typeof input.target !== 'string' || !input.target.trim() ||
|
|
118
|
+
!/^[a-f0-9]{40}$/.test(input.headSha ?? '') ||
|
|
119
|
+
(input.migrationPackage && !/^[a-f0-9]{40}$/.test(input.baseSha ?? '')) ||
|
|
120
|
+
!/^[a-f0-9]{64}$/.test(input.pendingInputSha256 ?? '') ||
|
|
121
|
+
!/^[a-f0-9]{64}$/.test(input.recoveryInputSha256 ?? '') ||
|
|
122
|
+
typeof input.retryReason !== 'string' || !input.retryReason.trim() || input.retryReason.length > 500 ||
|
|
123
|
+
!Array.isArray(hashes) || hashes.length === 0 || hashes.some(value => !/^[a-f0-9]{64}$/.test(value)) ||
|
|
124
|
+
new Set(hashes).size !== hashes.length || typeof input.validate !== 'function' ||
|
|
125
|
+
typeof input.run !== 'function' || typeof input.loadRetainedAsync !== 'function' ||
|
|
126
|
+
(!input.migrationPackage && !input.legacyRetry) ||
|
|
127
|
+
!Number.isSafeInteger(input.maxAttempts) || input.maxAttempts < 1 ||
|
|
128
|
+
!Number.isSafeInteger(input.maxPhysicalCalls) || input.maxPhysicalCalls < 1 ||
|
|
129
|
+
!Number.isSafeInteger(input.maxAttemptsPerCell) || input.maxAttemptsPerCell < 1 ||
|
|
130
|
+
!Number.isSafeInteger(input.maxDurationMs) || input.maxDurationMs < 1 || input.maxDurationMs > 2_147_483_647 ||
|
|
131
|
+
(input.previewMode !== undefined && !['combined', 'finalize-only'].includes(input.previewMode))) {
|
|
132
|
+
fail('invalid_input');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function validateFinalizeOptions(input) {
|
|
136
|
+
const hashes = input?.retainedAsyncSha256;
|
|
137
|
+
if (!input || typeof input.gitCommonDir !== 'string' || typeof input.target !== 'string' || !input.target.trim() ||
|
|
138
|
+
!/^[a-f0-9]{40}$/.test(input.headSha ?? '') || !/^[a-f0-9]{40}$/.test(input.baseSha ?? '') ||
|
|
139
|
+
!/^[a-f0-9]{64}$/.test(input.pendingInputSha256 ?? '') ||
|
|
140
|
+
!/^[a-f0-9]{64}$/.test(input.nativeStateSha256 ?? '') ||
|
|
141
|
+
!/^[a-f0-9]{64}$/.test(input.attemptStateSha256 ?? '') ||
|
|
142
|
+
!Array.isArray(hashes) || hashes.length === 0 || hashes.some(value => !/^[a-f0-9]{64}$/.test(value)) ||
|
|
143
|
+
new Set(hashes).size !== hashes.length || typeof input.loadRetainedAsync !== 'function' ||
|
|
144
|
+
(input.writeFinalizedState !== undefined && typeof input.writeFinalizedState !== 'function') ||
|
|
145
|
+
!input.migrationPackage || !Number.isSafeInteger(input.maxAttempts) || input.maxAttempts < 1) {
|
|
146
|
+
fail('invalid_input');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function archiveAsync(common, source, artifacts, packet) {
|
|
150
|
+
validateAsyncArtifacts(source, artifacts, packet);
|
|
151
|
+
const directory = await prepareLockRoot(join(common, 'rcl-converge-pending-recovery', source.digest));
|
|
152
|
+
for (const artifact of artifacts) {
|
|
153
|
+
const bytes = Buffer.from(artifact.bytesBase64, 'base64');
|
|
154
|
+
await retainStaleFile(join(directory, artifact.sha256), bytes);
|
|
155
|
+
}
|
|
156
|
+
const manifest = Buffer.from(stableStringify({ version: 1, sourceDigest: source.digest,
|
|
157
|
+
blockingOutcome: 'unknown', artifacts: artifacts.map(item => ({ sha256: item.sha256 })).sort((a, b) => a.sha256.localeCompare(b.sha256)) }));
|
|
158
|
+
await retainStaleFile(join(directory, 'manifest.json'), manifest);
|
|
159
|
+
}
|
|
160
|
+
function finalizationReceiptPath(common, migrationPackageSha256) {
|
|
161
|
+
return join(common, 'rcl-converge-pending-finalizations', migrationPackageSha256, 'receipt.json');
|
|
162
|
+
}
|
|
163
|
+
function finalizationSnapshotPath(common, migrationPackageSha256, name) {
|
|
164
|
+
return join(common, 'rcl-converge-pending-finalizations', migrationPackageSha256, name);
|
|
165
|
+
}
|
|
166
|
+
async function readFinalizationReceipt(common, migrationPackageSha256) {
|
|
167
|
+
try {
|
|
168
|
+
const stored = await readStable(finalizationReceiptPath(common, migrationPackageSha256));
|
|
169
|
+
return ordinaryPendingFinalizationReceiptSchema.parse(JSON.parse(stored.text));
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (error.code === 'ENOENT')
|
|
173
|
+
return undefined;
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async function retainFinalizationReceipt(common, receipt) {
|
|
178
|
+
const directory = await prepareLockRoot(join(common, 'rcl-converge-pending-finalizations', receipt.migrationPackageSha256));
|
|
179
|
+
await retainStaleFile(join(directory, 'receipt.json'), Buffer.from(stableStringify(receipt)));
|
|
180
|
+
}
|
|
181
|
+
async function retainFinalizationSnapshots(common, receipt, sourceAttemptState, finalizedNativeState) {
|
|
182
|
+
if (createHash('sha256').update(sourceAttemptState).digest('hex') !== receipt.sourceAttemptStateSha256 ||
|
|
183
|
+
createHash('sha256').update(finalizedNativeState).digest('hex') !== receipt.finalizedNativeStateSha256) {
|
|
184
|
+
fail('finalization_snapshot_mismatch');
|
|
185
|
+
}
|
|
186
|
+
const directory = await prepareLockRoot(join(common, 'rcl-converge-pending-finalizations', receipt.migrationPackageSha256));
|
|
187
|
+
await retainStaleFile(join(directory, 'source-attempt-state.json'), sourceAttemptState);
|
|
188
|
+
await retainStaleFile(join(directory, 'finalized-native-state.json'), finalizedNativeState);
|
|
189
|
+
}
|
|
190
|
+
async function readFinalizationSnapshot(common, receipt, name, digest) {
|
|
191
|
+
const snapshot = await readStable(finalizationSnapshotPath(common, receipt.migrationPackageSha256, name));
|
|
192
|
+
if (snapshot.sha256 !== digest)
|
|
193
|
+
fail('finalization_snapshot_mismatch');
|
|
194
|
+
return snapshot.raw;
|
|
195
|
+
}
|
|
196
|
+
function isPrefix(before, after) {
|
|
197
|
+
return before.length <= after.length && before.every((value, index) => isDeepStrictEqual(value, after[index]));
|
|
198
|
+
}
|
|
199
|
+
async function finalizationSnapshotsPresent(common, receipt) {
|
|
200
|
+
try {
|
|
201
|
+
await Promise.all([
|
|
202
|
+
readFinalizationSnapshot(common, receipt, 'source-attempt-state.json', receipt.sourceAttemptStateSha256),
|
|
203
|
+
readFinalizationSnapshot(common, receipt, 'finalized-native-state.json', receipt.finalizedNativeStateSha256),
|
|
204
|
+
]);
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
if (error.code === 'ENOENT')
|
|
209
|
+
return false;
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
async function assertFinalizedStateMatchesReceipt(common, receipt) {
|
|
214
|
+
const [native, attempts] = await Promise.all([
|
|
215
|
+
readStable(convergeRunStatePath(common, receipt.target)),
|
|
216
|
+
readStable(convergeAttemptStatePath(common, receipt.target)),
|
|
217
|
+
]);
|
|
218
|
+
if (native.sha256 === receipt.finalizedNativeStateSha256 &&
|
|
219
|
+
attempts.sha256 === receipt.sourceAttemptStateSha256) {
|
|
220
|
+
return { native: native.raw, attempts: attempts.raw, exact: true };
|
|
221
|
+
}
|
|
222
|
+
let originalAttemptsBytes, finalizedNativeBytes;
|
|
223
|
+
try {
|
|
224
|
+
[originalAttemptsBytes, finalizedNativeBytes] = await Promise.all([
|
|
225
|
+
readFinalizationSnapshot(common, receipt, 'source-attempt-state.json', receipt.sourceAttemptStateSha256),
|
|
226
|
+
readFinalizationSnapshot(common, receipt, 'finalized-native-state.json', receipt.finalizedNativeStateSha256),
|
|
227
|
+
]);
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
if (error.code === 'ENOENT')
|
|
231
|
+
fail('finalization_receipt_state_mismatch');
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
const [currentNative, currentAttempts] = await Promise.all([
|
|
235
|
+
loadConvergeRunState(common, receipt.target),
|
|
236
|
+
previewConvergeAttemptState(common, receipt.target),
|
|
237
|
+
]);
|
|
238
|
+
if (!currentNative || !currentAttempts)
|
|
239
|
+
fail('finalization_receipt_state_mismatch');
|
|
240
|
+
const originalAttempts = JSON.parse(originalAttemptsBytes.toString('utf8'));
|
|
241
|
+
const finalizedNative = JSON.parse(finalizedNativeBytes.toString('utf8'));
|
|
242
|
+
const finalizedLaunch = launchSchema.safeParse(finalizedNative.lastLaunch);
|
|
243
|
+
const currentLaunch = launchSchema.safeParse(currentNative.lastLaunch);
|
|
244
|
+
const priorStale = finalizedNative.staleReportAudit ?? [], currentStale = currentNative.staleReportAudit ?? [];
|
|
245
|
+
const priorGaps = finalizedNative.roundGapAudit?.entries ?? [], currentGaps = currentNative.roundGapAudit?.entries ?? [];
|
|
246
|
+
if (originalAttempts.target !== receipt.target || currentAttempts.target !== receipt.target ||
|
|
247
|
+
originalAttempts.attemptsUsed !== receipt.attemptsUsed || originalAttempts.cap !== receipt.cap ||
|
|
248
|
+
originalAttempts.migratedAttempts !== currentAttempts.migratedAttempts ||
|
|
249
|
+
currentAttempts.attemptsUsed <= receipt.attemptsUsed ||
|
|
250
|
+
currentAttempts.cap < currentAttempts.attemptsUsed || currentAttempts.cap > receipt.cap ||
|
|
251
|
+
!isDeepStrictEqual(currentAttempts.cycle, originalAttempts.cycle) ||
|
|
252
|
+
!isPrefix(originalAttempts.attempts, currentAttempts.attempts) ||
|
|
253
|
+
currentAttempts.attempts.at(originalAttempts.attempts.length)?.attempt !== receipt.nextFreeAttempt ||
|
|
254
|
+
finalizedNative.target !== receipt.target || currentNative.target !== receipt.target ||
|
|
255
|
+
!finalizedLaunch.success || finalizedLaunch.data.status !== 'failed' ||
|
|
256
|
+
finalizedLaunch.data.attempt !== receipt.finalizedAttempt ||
|
|
257
|
+
finalizedLaunch.data.round !== receipt.round ||
|
|
258
|
+
finalizedLaunch.data.pendingRecovery?.sourceDigest !== receipt.sourceDigest ||
|
|
259
|
+
!isDeepStrictEqual(currentNative.cycle, finalizedNative.cycle) ||
|
|
260
|
+
currentNative.roundCap < finalizedNative.roundCap ||
|
|
261
|
+
!isPrefix(finalizedNative.rounds, currentNative.rounds) ||
|
|
262
|
+
!isPrefix(priorStale, currentStale) || !isPrefix(priorGaps, currentGaps) ||
|
|
263
|
+
Object.entries(finalizedNative.findings)
|
|
264
|
+
.some(([key, value]) => !isDeepStrictEqual(value, currentNative.findings[key])) ||
|
|
265
|
+
!currentLaunch.success || currentLaunch.data.attempt <= receipt.finalizedAttempt ||
|
|
266
|
+
currentLaunch.data.attempt !== currentAttempts.attemptsUsed) {
|
|
267
|
+
fail('finalization_receipt_state_mismatch');
|
|
268
|
+
}
|
|
269
|
+
return { native: native.raw, attempts: attempts.raw, exact: false };
|
|
270
|
+
}
|
|
271
|
+
function createFinalizationReceipt(input) {
|
|
272
|
+
const body = ordinaryPendingFinalizationReceiptBodySchema.parse(input);
|
|
273
|
+
return ordinaryPendingFinalizationReceiptSchema.parse({
|
|
274
|
+
...body,
|
|
275
|
+
receiptDigest: createHash('sha256').update(stableStringify(body)).digest('hex'),
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
function assertReceiptMatchesInput(receipt, input, migrationPackageSha256) {
|
|
279
|
+
if (receipt.target !== input.target || receipt.headSha !== input.headSha || receipt.baseSha !== input.baseSha ||
|
|
280
|
+
receipt.inputSha256 !== input.pendingInputSha256 || receipt.migrationPackageSha256 !== migrationPackageSha256 ||
|
|
281
|
+
receipt.sourceNativeStateSha256 !== input.nativeStateSha256 ||
|
|
282
|
+
receipt.sourceAttemptStateSha256 !== input.attemptStateSha256 ||
|
|
283
|
+
receipt.cap !== input.maxAttempts ||
|
|
284
|
+
receipt.retainedAsyncSha256.join(',') !== [...input.retainedAsyncSha256].sort().join(',')) {
|
|
285
|
+
fail('finalization_receipt_mismatch');
|
|
286
|
+
}
|
|
287
|
+
return validateOrdinaryPendingPackage(input.migrationPackage, {
|
|
288
|
+
target: receipt.target, headSha: receipt.headSha, inputSha256: receipt.inputSha256,
|
|
289
|
+
baseSha: receipt.baseSha, attempt: receipt.finalizedAttempt, round: receipt.round,
|
|
290
|
+
pid: receipt.originalPid, retainedAsyncSha256: receipt.retainedAsyncSha256,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
async function readArchivedAsync(common, sourceDigest, retainedAsyncSha256) {
|
|
294
|
+
const directory = join(common, 'rcl-converge-pending-recovery', sourceDigest);
|
|
295
|
+
const artifacts = await Promise.all(retainedAsyncSha256.map(async (digest) => {
|
|
296
|
+
const file = await readStable(join(directory, digest));
|
|
297
|
+
if (file.sha256 !== digest)
|
|
298
|
+
fail('async_binding_mismatch');
|
|
299
|
+
return { path: join(directory, digest), sha256: digest, bytesBase64: file.raw.toString('base64') };
|
|
300
|
+
}));
|
|
301
|
+
const expectedManifest = stableStringify({ version: 1, sourceDigest,
|
|
302
|
+
blockingOutcome: 'unknown', artifacts: [...retainedAsyncSha256].sort().map(sha256 => ({ sha256 })) });
|
|
303
|
+
if ((await readStable(join(directory, 'manifest.json'))).text !== expectedManifest) {
|
|
304
|
+
fail('async_binding_mismatch');
|
|
305
|
+
}
|
|
306
|
+
return artifacts;
|
|
307
|
+
}
|
|
308
|
+
async function loadOriginalOrArchivedAsync(options, source) {
|
|
309
|
+
try {
|
|
310
|
+
return await readArchivedAsync(options.gitCommonDir, source.digest, source.retainedAsyncSha256);
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
if (error.code !== 'ENOENT')
|
|
314
|
+
throw error;
|
|
315
|
+
return options.loadRetainedAsync();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/** Finalize one authenticated ordinary pending launch without claiming or dispatching its successor. */
|
|
319
|
+
export async function finalizeOrdinaryPendingLaunch(input) {
|
|
320
|
+
validateFinalizeOptions(input);
|
|
321
|
+
const options = { ...input, target: input.target.trim(),
|
|
322
|
+
retainedAsyncSha256: [...input.retainedAsyncSha256].sort(),
|
|
323
|
+
gitCommonDir: await realpath(resolve(input.gitCommonDir)) };
|
|
324
|
+
const migrationPackageSha256 = createHash('sha256')
|
|
325
|
+
.update(stableStringify(options.migrationPackage)).digest('hex');
|
|
326
|
+
return withRecoveryTarget(options.gitCommonDir, options.target, async (ownership) => {
|
|
327
|
+
const existingReceipt = await readFinalizationReceipt(options.gitCommonDir, migrationPackageSha256);
|
|
328
|
+
if (existingReceipt) {
|
|
329
|
+
const packet = assertReceiptMatchesInput(existingReceipt, options, migrationPackageSha256);
|
|
330
|
+
const state = await assertFinalizedStateMatchesReceipt(options.gitCommonDir, existingReceipt);
|
|
331
|
+
validateAsyncArtifacts({ retainedAsyncSha256: existingReceipt.retainedAsyncSha256 }, await readArchivedAsync(options.gitCommonDir, existingReceipt.sourceDigest, existingReceipt.retainedAsyncSha256), packet);
|
|
332
|
+
const snapshotsPresent = await finalizationSnapshotsPresent(options.gitCommonDir, existingReceipt);
|
|
333
|
+
if (!snapshotsPresent) {
|
|
334
|
+
if (!state.exact)
|
|
335
|
+
fail('finalization_receipt_state_mismatch');
|
|
336
|
+
await retainFinalizationSnapshots(options.gitCommonDir, existingReceipt, state.attempts, state.native);
|
|
337
|
+
}
|
|
338
|
+
return { receipt: existingReceipt, reusedReceipt: true,
|
|
339
|
+
snapshotBindingUpgraded: !snapshotsPresent };
|
|
340
|
+
}
|
|
341
|
+
const [state, attempts] = await Promise.all([
|
|
342
|
+
loadConvergeRunState(options.gitCommonDir, options.target),
|
|
343
|
+
previewConvergeAttemptState(options.gitCommonDir, options.target),
|
|
344
|
+
]);
|
|
345
|
+
if (!state || !attempts || !state.lastLaunch)
|
|
346
|
+
fail('missing_launch');
|
|
347
|
+
if (attempts.cap !== options.maxAttempts)
|
|
348
|
+
fail('attempt_cap_mismatch');
|
|
349
|
+
const current = launchSchema.parse(state.lastLaunch);
|
|
350
|
+
if (current.attempt !== attempts.attemptsUsed || current.headSha !== options.headSha ||
|
|
351
|
+
current.inputSha256 !== options.pendingInputSha256 || !['pending', 'failed'].includes(current.status)) {
|
|
352
|
+
fail('launch_mismatch');
|
|
353
|
+
}
|
|
354
|
+
const packet = validateOrdinaryPendingPackage(options.migrationPackage, {
|
|
355
|
+
target: options.target, headSha: current.headSha, inputSha256: current.inputSha256,
|
|
356
|
+
baseSha: options.baseSha, attempt: current.attempt, round: current.round, pid: current.pid,
|
|
357
|
+
retainedAsyncSha256: options.retainedAsyncSha256,
|
|
358
|
+
});
|
|
359
|
+
let source;
|
|
360
|
+
let sourceAttemptStateBytes;
|
|
361
|
+
if (current.status === 'pending') {
|
|
362
|
+
if ((options.ownerAlive ?? defaultOwnerAlive)(current.pid))
|
|
363
|
+
fail('owner_alive');
|
|
364
|
+
const [nativeBytes, attemptBytes] = await Promise.all([
|
|
365
|
+
readStable(convergeRunStatePath(options.gitCommonDir, options.target)),
|
|
366
|
+
readStable(convergeAttemptStatePath(options.gitCommonDir, options.target)),
|
|
367
|
+
]);
|
|
368
|
+
sourceAttemptStateBytes = attemptBytes.raw;
|
|
369
|
+
source = createOrdinaryMigrationSource({ version: 1, target: options.target,
|
|
370
|
+
headSha: current.headSha, inputSha256: current.inputSha256, pendingAttempt: current.attempt,
|
|
371
|
+
round: current.round, originalPid: current.pid, startedAt: current.startedAt,
|
|
372
|
+
blockingOutcome: 'unknown', reason: 'coordinator_exited_without_durable_blocking_receipts',
|
|
373
|
+
nativeStateSha256: nativeBytes.sha256, attemptStateSha256: attemptBytes.sha256,
|
|
374
|
+
retainedAsyncSha256: options.retainedAsyncSha256, migrationPackageSha256 });
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
source = sourceFromFinalized(options.target, current, attempts, packet);
|
|
378
|
+
}
|
|
379
|
+
if (source.nativeStateSha256 !== options.nativeStateSha256 ||
|
|
380
|
+
source.attemptStateSha256 !== options.attemptStateSha256)
|
|
381
|
+
fail('source_digest_mismatch');
|
|
382
|
+
// Once the failed/unknown native state exists, archive publication already
|
|
383
|
+
// completed. Resume from those immutable bytes so a lost acknowledgment
|
|
384
|
+
// does not depend on the original async store still being available.
|
|
385
|
+
const artifacts = current.status === 'pending'
|
|
386
|
+
? await loadOriginalOrArchivedAsync(options, source)
|
|
387
|
+
: await readArchivedAsync(options.gitCommonDir, source.digest, source.retainedAsyncSha256);
|
|
388
|
+
validateAsyncArtifacts(source, artifacts, packet);
|
|
389
|
+
let finalizedNativeStateSha256;
|
|
390
|
+
if (current.status === 'pending') {
|
|
391
|
+
state.lastLaunch = { ...current, status: 'failed', pendingRecovery: descriptor(source) };
|
|
392
|
+
state.updatedAt = new Date().toISOString();
|
|
393
|
+
finalizedNativeStateSha256 = createHash('sha256')
|
|
394
|
+
.update(serializeRecoveryDocument(state)).digest('hex');
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
finalizedNativeStateSha256 = (await readStable(convergeRunStatePath(options.gitCommonDir, options.target))).sha256;
|
|
398
|
+
}
|
|
399
|
+
// Construct and validate the exact receipt before the first write. The
|
|
400
|
+
// native serializer is shared with writeState, so its post-state digest is
|
|
401
|
+
// known without publishing a partially validated operation.
|
|
402
|
+
const receipt = createFinalizationReceipt({ version: 1, operation: 'ordinary-pending-finalize-only',
|
|
403
|
+
target: options.target, headSha: current.headSha, baseSha: options.baseSha,
|
|
404
|
+
inputSha256: current.inputSha256, sourceDigest: source.digest, migrationPackageSha256,
|
|
405
|
+
finalizedAttempt: current.attempt, round: current.round, originalPid: current.pid,
|
|
406
|
+
attemptsUsed: attempts.attemptsUsed, cap: attempts.cap, nextFreeAttempt: current.attempt + 1,
|
|
407
|
+
blockingOutcome: 'unknown', retainedAsyncSha256: options.retainedAsyncSha256,
|
|
408
|
+
sourceNativeStateSha256: source.nativeStateSha256,
|
|
409
|
+
sourceAttemptStateSha256: source.attemptStateSha256,
|
|
410
|
+
finalizedNativeStateSha256 });
|
|
411
|
+
if (current.status === 'pending') {
|
|
412
|
+
await preflightConvergeRunStateWrite(options.gitCommonDir, state, ownership);
|
|
413
|
+
}
|
|
414
|
+
// Every fallible authentication and accounting check above precedes the
|
|
415
|
+
// first durable write. Archive publication is idempotent if this process
|
|
416
|
+
// stops before the native failed/unknown state or receipt is published.
|
|
417
|
+
await archiveAsync(options.gitCommonDir, source, artifacts, packet);
|
|
418
|
+
if (current.status === 'pending') {
|
|
419
|
+
await (options.writeFinalizedState ?? writeState)(options.gitCommonDir, state, ownership);
|
|
420
|
+
}
|
|
421
|
+
const finalizedNative = await readStable(convergeRunStatePath(options.gitCommonDir, options.target));
|
|
422
|
+
if (finalizedNative.sha256 !== finalizedNativeStateSha256)
|
|
423
|
+
fail('finalization_write_mismatch');
|
|
424
|
+
const finalizedAttempts = await readStable(convergeAttemptStatePath(options.gitCommonDir, options.target));
|
|
425
|
+
sourceAttemptStateBytes ??= finalizedAttempts.raw;
|
|
426
|
+
await retainFinalizationSnapshots(options.gitCommonDir, receipt, sourceAttemptStateBytes, finalizedNative.raw);
|
|
427
|
+
await retainFinalizationReceipt(options.gitCommonDir, receipt);
|
|
428
|
+
return { receipt, reusedReceipt: false, snapshotBindingUpgraded: false };
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function validateAsyncArtifacts(source, artifacts, packet) {
|
|
432
|
+
const expected = [...source.retainedAsyncSha256].sort();
|
|
433
|
+
const actual = artifacts.map(item => item.sha256).sort();
|
|
434
|
+
if (expected.length !== actual.length || expected.some((item, index) => item !== actual[index])) {
|
|
435
|
+
fail('async_binding_mismatch');
|
|
436
|
+
}
|
|
437
|
+
for (const artifact of artifacts) {
|
|
438
|
+
const bytes = Buffer.from(artifact.bytesBase64, 'base64');
|
|
439
|
+
if (createHash('sha256').update(bytes).digest('hex') !== artifact.sha256)
|
|
440
|
+
fail('async_binding_mismatch');
|
|
441
|
+
if (packet) {
|
|
442
|
+
const descriptor = packet.retainedAsync.find(item => item.sha256 === artifact.sha256);
|
|
443
|
+
let row;
|
|
444
|
+
try {
|
|
445
|
+
row = JSON.parse(bytes.toString('utf8'));
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
fail('async_binding_mismatch');
|
|
449
|
+
}
|
|
450
|
+
if (!descriptor || row.model !== descriptor.model || row.role !== descriptor.role ||
|
|
451
|
+
row.provider !== descriptor.provider)
|
|
452
|
+
fail('async_binding_mismatch');
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
/** Authenticate an ordinary dead-owner recovery under its target lock without mutating native state. */
|
|
457
|
+
export async function previewOrdinaryPendingLaunch(input) {
|
|
458
|
+
validateOptions(input);
|
|
459
|
+
if (!input.migrationPackage)
|
|
460
|
+
fail('migration_package_required');
|
|
461
|
+
const options = { ...input, target: input.target.trim(), retainedAsyncSha256: [...input.retainedAsyncSha256].sort(),
|
|
462
|
+
gitCommonDir: await realpath(resolve(input.gitCommonDir)) };
|
|
463
|
+
return withRecoveryTarget(options.gitCommonDir, options.target, async (ownership) => {
|
|
464
|
+
const [state, attempts] = await Promise.all([
|
|
465
|
+
loadConvergeRunState(options.gitCommonDir, options.target),
|
|
466
|
+
previewConvergeAttemptState(options.gitCommonDir, options.target),
|
|
467
|
+
]);
|
|
468
|
+
if (!state || !attempts || !state.lastLaunch)
|
|
469
|
+
fail('missing_launch');
|
|
470
|
+
const current = launchSchema.parse(state.lastLaunch);
|
|
471
|
+
const record = attempts.attempts.find(item => item.attempt === current.attempt);
|
|
472
|
+
if (!record || current.status !== 'pending' || current.attempt !== attempts.attemptsUsed ||
|
|
473
|
+
current.headSha !== options.headSha || current.inputSha256 !== options.pendingInputSha256)
|
|
474
|
+
fail('launch_mismatch');
|
|
475
|
+
if (options.previewMode === 'finalize-only'
|
|
476
|
+
? attempts.cap !== options.maxAttempts
|
|
477
|
+
: options.maxAttempts > current.attempt + 1)
|
|
478
|
+
fail('attempt_cap_mismatch');
|
|
479
|
+
if (options.previewMode !== 'finalize-only' && attempts.attemptsUsed >= attempts.cap) {
|
|
480
|
+
fail('attempt_cap_exhausted');
|
|
481
|
+
}
|
|
482
|
+
if ((options.ownerAlive ?? defaultOwnerAlive)(current.pid))
|
|
483
|
+
fail('owner_alive');
|
|
484
|
+
const packet = validateOrdinaryPendingPackage(options.migrationPackage, {
|
|
485
|
+
target: options.target, headSha: current.headSha, inputSha256: current.inputSha256,
|
|
486
|
+
baseSha: options.baseSha, attempt: current.attempt, round: current.round, pid: current.pid,
|
|
487
|
+
retainedAsyncSha256: options.retainedAsyncSha256,
|
|
488
|
+
});
|
|
489
|
+
const [nativeBytes, attemptBytes] = await Promise.all([
|
|
490
|
+
readStable(convergeRunStatePath(options.gitCommonDir, options.target)),
|
|
491
|
+
readStable(convergeAttemptStatePath(options.gitCommonDir, options.target)),
|
|
492
|
+
]);
|
|
493
|
+
const source = createOrdinaryMigrationSource({ version: 1, target: options.target,
|
|
494
|
+
headSha: current.headSha, inputSha256: current.inputSha256, pendingAttempt: current.attempt,
|
|
495
|
+
round: current.round, originalPid: current.pid, startedAt: current.startedAt,
|
|
496
|
+
blockingOutcome: 'unknown', reason: 'coordinator_exited_without_durable_blocking_receipts',
|
|
497
|
+
nativeStateSha256: nativeBytes.sha256, attemptStateSha256: attemptBytes.sha256,
|
|
498
|
+
retainedAsyncSha256: options.retainedAsyncSha256,
|
|
499
|
+
migrationPackageSha256: createHash('sha256').update(stableStringify(packet)).digest('hex'),
|
|
500
|
+
});
|
|
501
|
+
validateAsyncArtifacts(source, await options.loadRetainedAsync(), packet);
|
|
502
|
+
return { source, nativeStateSha256: nativeBytes.sha256, attemptStateSha256: attemptBytes.sha256,
|
|
503
|
+
attemptsUsed: attempts.attemptsUsed, cap: attempts.cap, nextAttempt: current.attempt + 1 };
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
async function runBound(options, ownership, state, claim, source, launch, resume) {
|
|
507
|
+
const journal = await bindOriginalCouncil({ commonDir: options.gitCommonDir, ownership,
|
|
508
|
+
captured: options.captured.captured, launch });
|
|
509
|
+
const emptyAsync = captureSupplementalAsync([], 0).bytes;
|
|
510
|
+
const bindings = await journal.readBindings();
|
|
511
|
+
if (bindings['supplemental-async'] === undefined) {
|
|
512
|
+
await journal.bind('supplemental-async', emptyAsync, ownership);
|
|
513
|
+
}
|
|
514
|
+
else if (bindings['supplemental-async'] !== emptyAsync)
|
|
515
|
+
fail('async_binding_mismatch');
|
|
516
|
+
try {
|
|
517
|
+
const completion = completionSchema.parse(await options.run({ context: { target: options.target,
|
|
518
|
+
attempt: claim.attempt, round: source.round }, claim, ownership, journal,
|
|
519
|
+
launch, skipAsyncLaunch: true }));
|
|
520
|
+
if (completion.runId !== resume.runId)
|
|
521
|
+
fail('run_mismatch');
|
|
522
|
+
state.lastLaunch = { ...state.lastLaunch, ...completion, status: 'completed',
|
|
523
|
+
pendingResume: { ...resume, pid: process.pid, phase: 'finished' } };
|
|
524
|
+
state.updatedAt = new Date().toISOString();
|
|
525
|
+
await writeState(options.gitCommonDir, state, ownership);
|
|
526
|
+
return completion;
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
state.lastLaunch = { ...state.lastLaunch, status: 'failed',
|
|
530
|
+
pendingResume: { ...resume, pid: process.pid, phase: 'finished' } };
|
|
531
|
+
state.updatedAt = new Date().toISOString();
|
|
532
|
+
await writeState(options.gitCommonDir, state, ownership);
|
|
533
|
+
throw error;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
async function claimFresh(options, ownership, state, source) {
|
|
537
|
+
if (options.maxAttempts > source.pendingAttempt + 1)
|
|
538
|
+
fail('attempt_cap_mismatch');
|
|
539
|
+
const now = (options.nowMs ?? Date.now)();
|
|
540
|
+
if (!Number.isSafeInteger(now) || now < 0)
|
|
541
|
+
fail('invalid_clock');
|
|
542
|
+
const resume = { version: 1, runId: uuidv7(), planDigest: options.captured.plan.digest,
|
|
543
|
+
capturedInputsSha256: options.captured.captured.digest, originalPid: source.originalPid,
|
|
544
|
+
pid: process.pid, phase: 'running', startedAtMs: now,
|
|
545
|
+
expiresAtMs: now + options.maxDurationMs, maxPhysicalCalls: options.maxPhysicalCalls,
|
|
546
|
+
maxAttemptsPerCell: options.maxAttemptsPerCell };
|
|
547
|
+
const launch = createOriginalLaunch({ runId: resume.runId, target: options.target,
|
|
548
|
+
originalNativeClaim: { attempt: source.pendingAttempt + 1, round: source.round },
|
|
549
|
+
capturedInputsSha256: resume.capturedInputsSha256, planDigest: resume.planDigest,
|
|
550
|
+
startedAtMs: resume.startedAtMs, expiresAtMs: resume.expiresAtMs,
|
|
551
|
+
maxPhysicalCalls: resume.maxPhysicalCalls, maxAttemptsPerCell: resume.maxAttemptsPerCell });
|
|
552
|
+
let completion;
|
|
553
|
+
let failure;
|
|
554
|
+
const claim = await claimConvergeAttempt({
|
|
555
|
+
gitCommonDir: options.gitCommonDir, target: options.target, maxAttempts: options.maxAttempts,
|
|
556
|
+
ownership, pendingRecoverySource: source,
|
|
557
|
+
afterClaim: async (claimed, claimOwnership) => {
|
|
558
|
+
state.lastLaunch = { status: 'pending', attempt: claimed.attempt, round: source.round,
|
|
559
|
+
headSha: options.headSha, inputSha256: options.recoveryInputSha256,
|
|
560
|
+
startedAt: new Date(now).toISOString(), pid: process.pid,
|
|
561
|
+
retryReason: options.retryReason.trim(),
|
|
562
|
+
pendingRecovery: descriptor(source), pendingResume: resume };
|
|
563
|
+
state.updatedAt = new Date().toISOString();
|
|
564
|
+
await writeState(options.gitCommonDir, state, claimOwnership);
|
|
565
|
+
try {
|
|
566
|
+
completion = await runBound(options, claimOwnership, state, claimed, source, launch, resume);
|
|
567
|
+
}
|
|
568
|
+
catch (error) {
|
|
569
|
+
failure = error;
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
});
|
|
573
|
+
if (failure)
|
|
574
|
+
throw failure;
|
|
575
|
+
return { claim, completion: completion, reusedCompletion: false };
|
|
576
|
+
}
|
|
577
|
+
async function resumeFresh(options, ownership, state, attempts, current) {
|
|
578
|
+
const record = attempts.attempts.at(-1);
|
|
579
|
+
const source = record?.pendingRecoverySource;
|
|
580
|
+
if (!source || record.attempt !== attempts.attemptsUsed)
|
|
581
|
+
fail('capture_mismatch');
|
|
582
|
+
const claim = { target: options.target, attempt: record.attempt, attemptsUsed: attempts.attemptsUsed,
|
|
583
|
+
cap: attempts.cap, stateFile: convergeAttemptStatePath(options.gitCommonDir, options.target) };
|
|
584
|
+
// The attempt ledger is the first durable A35 boundary. If the process died
|
|
585
|
+
// before publishing lastLaunch, no provider could have run because the
|
|
586
|
+
// checkpoint and runner are created only after that publication.
|
|
587
|
+
if (current.attempt === source.pendingAttempt) {
|
|
588
|
+
if (current.status !== 'failed' || current.pendingRecovery?.sourceDigest !== source.digest ||
|
|
589
|
+
current.headSha !== options.headSha || current.inputSha256 !== options.pendingInputSha256) {
|
|
590
|
+
fail('claim_gap_mismatch');
|
|
591
|
+
}
|
|
592
|
+
await options.validate();
|
|
593
|
+
await archiveAsync(options.gitCommonDir, source, await options.loadRetainedAsync(), options.migrationPackage);
|
|
594
|
+
const now = (options.nowMs ?? Date.now)();
|
|
595
|
+
if (!Number.isSafeInteger(now) || now < 0)
|
|
596
|
+
fail('invalid_clock');
|
|
597
|
+
const resume = { version: 1, runId: uuidv7(), planDigest: options.captured.plan.digest,
|
|
598
|
+
capturedInputsSha256: options.captured.captured.digest, originalPid: source.originalPid,
|
|
599
|
+
pid: process.pid, phase: 'running', startedAtMs: now,
|
|
600
|
+
expiresAtMs: now + options.maxDurationMs, maxPhysicalCalls: options.maxPhysicalCalls,
|
|
601
|
+
maxAttemptsPerCell: options.maxAttemptsPerCell };
|
|
602
|
+
const launch = createOriginalLaunch({ runId: resume.runId, target: options.target,
|
|
603
|
+
originalNativeClaim: { attempt: claim.attempt, round: source.round },
|
|
604
|
+
capturedInputsSha256: resume.capturedInputsSha256, planDigest: resume.planDigest,
|
|
605
|
+
startedAtMs: resume.startedAtMs, expiresAtMs: resume.expiresAtMs,
|
|
606
|
+
maxPhysicalCalls: resume.maxPhysicalCalls, maxAttemptsPerCell: resume.maxAttemptsPerCell });
|
|
607
|
+
state.lastLaunch = { status: 'pending', attempt: claim.attempt, round: source.round,
|
|
608
|
+
headSha: options.headSha, inputSha256: options.recoveryInputSha256,
|
|
609
|
+
startedAt: new Date(now).toISOString(), pid: process.pid,
|
|
610
|
+
retryReason: options.retryReason.trim(), pendingRecovery: descriptor(source), pendingResume: resume };
|
|
611
|
+
state.updatedAt = new Date().toISOString();
|
|
612
|
+
await writeState(options.gitCommonDir, state, ownership);
|
|
613
|
+
const completion = await runBound(options, ownership, state, claim, source, launch, resume);
|
|
614
|
+
return { claim, completion, reusedCompletion: false };
|
|
615
|
+
}
|
|
616
|
+
const resume = current.pendingResume;
|
|
617
|
+
if (!resume || current.attempt !== attempts.attemptsUsed ||
|
|
618
|
+
current.headSha !== options.headSha || current.inputSha256 !== options.recoveryInputSha256 ||
|
|
619
|
+
resume.planDigest !== options.captured.plan.digest ||
|
|
620
|
+
resume.capturedInputsSha256 !== options.captured.captured.digest ||
|
|
621
|
+
current.pendingRecovery?.sourceDigest !== source.digest)
|
|
622
|
+
fail('capture_mismatch');
|
|
623
|
+
if (current.status === 'completed') {
|
|
624
|
+
if (!current.runId || current.runId !== resume.runId)
|
|
625
|
+
fail('completed_mismatch');
|
|
626
|
+
return { claim, completion: completionSchema.parse(current), reusedCompletion: true };
|
|
627
|
+
}
|
|
628
|
+
if (resume.phase === 'running' && (options.ownerAlive ?? defaultOwnerAlive)(resume.pid))
|
|
629
|
+
fail('owner_alive');
|
|
630
|
+
await options.validate();
|
|
631
|
+
const artifacts = await options.loadRetainedAsync();
|
|
632
|
+
await archiveAsync(options.gitCommonDir, source, artifacts);
|
|
633
|
+
const launch = createOriginalLaunch({ runId: resume.runId, target: options.target,
|
|
634
|
+
originalNativeClaim: { attempt: current.attempt, round: current.round },
|
|
635
|
+
capturedInputsSha256: resume.capturedInputsSha256, planDigest: resume.planDigest,
|
|
636
|
+
startedAtMs: resume.startedAtMs, expiresAtMs: resume.expiresAtMs,
|
|
637
|
+
maxPhysicalCalls: resume.maxPhysicalCalls, maxAttemptsPerCell: resume.maxAttemptsPerCell });
|
|
638
|
+
state.lastLaunch = { ...current, status: 'pending',
|
|
639
|
+
pendingResume: { ...resume, pid: process.pid, phase: 'running' } };
|
|
640
|
+
state.updatedAt = new Date().toISOString();
|
|
641
|
+
await writeState(options.gitCommonDir, state, ownership);
|
|
642
|
+
const completion = await runBound(options, ownership, state, claim, source, launch, { ...resume, pid: process.pid, phase: 'running' });
|
|
643
|
+
return { claim, completion, reusedCompletion: false };
|
|
644
|
+
}
|
|
645
|
+
export async function resumePendingLegacyLaunch(input) {
|
|
646
|
+
if (input.preview)
|
|
647
|
+
return previewOrdinaryPendingLaunch(input);
|
|
648
|
+
validateOptions(input);
|
|
649
|
+
const options = { ...input, target: input.target.trim(), retainedAsyncSha256: [...input.retainedAsyncSha256].sort(),
|
|
650
|
+
gitCommonDir: await realpath(resolve(input.gitCommonDir)) };
|
|
651
|
+
return withRecoveryTarget(options.gitCommonDir, options.target, async (ownership) => {
|
|
652
|
+
const [state, attempts] = await Promise.all([
|
|
653
|
+
loadConvergeRunState(options.gitCommonDir, options.target),
|
|
654
|
+
previewConvergeAttemptState(options.gitCommonDir, options.target),
|
|
655
|
+
]);
|
|
656
|
+
if (!state || !attempts || !state.lastLaunch)
|
|
657
|
+
fail('missing_launch');
|
|
658
|
+
const current = launchSchema.parse(state.lastLaunch);
|
|
659
|
+
const persistedSource = attempts.attempts.at(-1)?.pendingRecoverySource;
|
|
660
|
+
const original = persistedSource ?? current;
|
|
661
|
+
const originalAttempt = 'pendingAttempt' in original ? original.pendingAttempt : original.attempt;
|
|
662
|
+
const originalPid = 'originalPid' in original ? original.originalPid : original.pid;
|
|
663
|
+
const migrationPackage = options.migrationPackage && validateOrdinaryPendingPackage(options.migrationPackage, {
|
|
664
|
+
target: options.target, headSha: original.headSha, inputSha256: original.inputSha256,
|
|
665
|
+
baseSha: options.baseSha, attempt: originalAttempt, round: original.round, pid: originalPid,
|
|
666
|
+
retainedAsyncSha256: options.retainedAsyncSha256,
|
|
667
|
+
});
|
|
668
|
+
// Combined finalize-and-successor recovery is explicit one-attempt
|
|
669
|
+
// authority. Refuse a broader cap before archiving evidence or changing
|
|
670
|
+
// the pending launch to failed/unknown.
|
|
671
|
+
if (options.maxAttempts > originalAttempt + 1)
|
|
672
|
+
fail('attempt_cap_mismatch');
|
|
673
|
+
if (persistedSource) {
|
|
674
|
+
return resumeFresh(options, ownership, state, attempts, current);
|
|
675
|
+
}
|
|
676
|
+
const record = attempts.attempts.find(item => item.attempt === current.attempt);
|
|
677
|
+
if (!record || (!record.retrySource && !migrationPackage) || (migrationPackage && record.retrySource) ||
|
|
678
|
+
current.attempt !== attempts.attemptsUsed || current.headSha !== options.headSha ||
|
|
679
|
+
current.inputSha256 !== options.pendingInputSha256 || !['pending', 'failed'].includes(current.status)) {
|
|
680
|
+
fail('launch_mismatch');
|
|
681
|
+
}
|
|
682
|
+
let source;
|
|
683
|
+
if (current.status === 'pending') {
|
|
684
|
+
if ((options.ownerAlive ?? defaultOwnerAlive)(current.pid))
|
|
685
|
+
fail('owner_alive');
|
|
686
|
+
const [nativeBytes, attemptBytes] = await Promise.all([
|
|
687
|
+
readStable(convergeRunStatePath(options.gitCommonDir, options.target)),
|
|
688
|
+
readStable(convergeAttemptStatePath(options.gitCommonDir, options.target)),
|
|
689
|
+
]);
|
|
690
|
+
source = migrationPackage ? createOrdinaryMigrationSource({ version: 1, target: options.target,
|
|
691
|
+
headSha: current.headSha, inputSha256: current.inputSha256, pendingAttempt: current.attempt,
|
|
692
|
+
round: current.round, originalPid: current.pid, startedAt: current.startedAt,
|
|
693
|
+
blockingOutcome: 'unknown', reason: 'coordinator_exited_without_durable_blocking_receipts',
|
|
694
|
+
nativeStateSha256: nativeBytes.sha256, attemptStateSha256: attemptBytes.sha256,
|
|
695
|
+
retainedAsyncSha256: options.retainedAsyncSha256,
|
|
696
|
+
migrationPackageSha256: createHash('sha256').update(stableStringify(migrationPackage)).digest('hex'),
|
|
697
|
+
}) : createPendingRecoverySource({ version: 1, target: options.target,
|
|
698
|
+
headSha: current.headSha, inputSha256: current.inputSha256, pendingAttempt: current.attempt,
|
|
699
|
+
round: current.round, originalPid: current.pid, startedAt: current.startedAt,
|
|
700
|
+
blockingOutcome: 'unknown', reason: 'coordinator_exited_without_durable_blocking_receipts',
|
|
701
|
+
nativeStateSha256: nativeBytes.sha256, attemptStateSha256: attemptBytes.sha256,
|
|
702
|
+
retainedAsyncSha256: options.retainedAsyncSha256, retrySource: (await inspectPendingLegacyRetry(options.legacyRetry, options.gitCommonDir, state, current, attempts)).binding });
|
|
703
|
+
}
|
|
704
|
+
else
|
|
705
|
+
source = sourceFromFinalized(options.target, current, attempts, migrationPackage);
|
|
706
|
+
if (source.retainedAsyncSha256.join(',') !== options.retainedAsyncSha256.join(',')) {
|
|
707
|
+
fail('async_binding_mismatch');
|
|
708
|
+
}
|
|
709
|
+
await options.validate();
|
|
710
|
+
const artifacts = await options.loadRetainedAsync();
|
|
711
|
+
await archiveAsync(options.gitCommonDir, source, artifacts);
|
|
712
|
+
if (current.status === 'pending') {
|
|
713
|
+
state.lastLaunch = { ...current, status: 'failed', pendingRecovery: descriptor(source) };
|
|
714
|
+
state.updatedAt = new Date().toISOString();
|
|
715
|
+
await writeState(options.gitCommonDir, state, ownership);
|
|
716
|
+
}
|
|
717
|
+
return claimFresh(options, ownership, state, source);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
//# sourceMappingURL=pending-legacy-resume.js.map
|