@kungfu-tech/buildchain 4.0.1-alpha.9 → 4.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +9 -6
  2. package/actions/v4-release-candidate-promote/README.md +3 -0
  3. package/architecture/agent-change-map.md +1017 -0
  4. package/architecture/ci-lane-change-budget.json +70 -1
  5. package/architecture/decisions/0004-v4-declarative-release-tail.md +47 -0
  6. package/architecture/internal-capabilities.json +159 -11
  7. package/architecture/maintainability-debt.json +3229 -0
  8. package/architecture/maintainability-policy.json +480 -129
  9. package/architecture/v3-core-mechanism-inventory.json +6 -3
  10. package/architecture/v3-v4-capability-closure.md +59 -0
  11. package/architecture/v3-v4-live-capability-inventory.json +102404 -0
  12. package/architecture/v4-cross-platform-adopter-qualification.json +52 -0
  13. package/architecture/v4-delivery-warrant-shadow-fixtures.json +3 -3
  14. package/architecture/v4-runtime-semantic-closure.json +710 -0
  15. package/bin/internal/trust-release-release-handlers.mjs +5 -0
  16. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
  17. package/contracts/v4-publication-qualification-v1.schema.json +51 -0
  18. package/dist/site/agent-index.json +1 -0
  19. package/dist/site/artifact-schemas.json +2 -0
  20. package/dist/site/buildchain-contract.json +123 -32
  21. package/dist/site/buildchain-site.json +96 -28
  22. package/dist/site/capability-registry.json +6 -6
  23. package/dist/site/cli-registry.json +5 -2
  24. package/dist/site/controller-registry.json +41 -5
  25. package/dist/site/kfd-claims.json +172 -23
  26. package/dist/site/kfd-upstream-aggregate.json +1 -1
  27. package/dist/site/manual-registry.json +6 -6
  28. package/dist/site/node-api-registry.json +1474 -215
  29. package/dist/site/page-registry.json +85 -17
  30. package/dist/site/public-surface-audit.json +91 -21
  31. package/dist/site/publication-authority-registry.json +28 -1
  32. package/dist/site/publication-registry.json +4 -4
  33. package/dist/site/release-provenance.json +5 -0
  34. package/dist/site/schemas/v4-publication-qualification-v1.schema.json +51 -0
  35. package/dist/site/site-manifest.json +10 -10
  36. package/dist/site/workflow-registry.json +94 -18
  37. package/docs/MAP.md +1 -1
  38. package/docs/cli-reference.md +4 -4
  39. package/docs/dev-delivery-warrant.md +33 -9
  40. package/docs/node-api-reference.md +291 -206
  41. package/docs/publish-transaction.md +11 -4
  42. package/docs/release-candidate.md +7 -0
  43. package/docs/v4-adopter-delivery.md +23 -4
  44. package/docs/v4-declarative-release-tail-migration.md +43 -0
  45. package/package.json +8 -3
  46. package/packages/core/adopter-delivery-passport.js +36 -0
  47. package/packages/core/buildchain-contract.js +31 -1
  48. package/packages/core/buildchain-publication-authority.js +1 -0
  49. package/packages/core/dev-delivery-warrant-legacy-recovery.js +246 -0
  50. package/packages/core/dev-delivery-warrant-settlement.js +239 -3
  51. package/packages/core/dev-delivery-warrant-state.js +15 -2
  52. package/packages/core/dev-delivery-warrant.js +21 -4
  53. package/packages/core/github-governance-authority.js +4 -4
  54. package/packages/core/index.js +1 -0
  55. package/packages/core/paper-scaffold-content.js +401 -0
  56. package/packages/core/paper.js +12 -378
  57. package/packages/core/publication-control-plane-audit.js +135 -111
  58. package/packages/core/publication-rehearsal-projection.js +104 -0
  59. package/packages/core/publication-rehearsal-runtime.js +190 -0
  60. package/packages/core/release-candidate-recovery.js +6 -5
  61. package/packages/core/release-passport.js +82 -184
  62. package/packages/core/v4-cross-platform-adopter-qualification.js +343 -0
  63. package/packages/core/v4-floating-consumer-policy.js +3 -2
  64. package/packages/core/v4-floating-consumer-release-passport.js +134 -15
  65. package/packages/core/v4-publication-qualification.js +222 -0
  66. package/scripts/artifact-signing-controller-core.mjs +1 -1
  67. package/scripts/audit-publication-control-plane.mjs +17 -17
  68. package/scripts/buildchain-cli-help.mjs +3 -0
  69. package/scripts/check-internal-architecture.mjs +23 -3
  70. package/scripts/check-inventory.mjs +23 -5
  71. package/scripts/check-maintainability.mjs +145 -4
  72. package/scripts/check-project-cut-merge-queue-admission.mjs +87 -0
  73. package/scripts/check-v3-v4-capability-inventory.mjs +574 -0
  74. package/scripts/check-v4-floating-consumer-policy-contract.mjs +10 -3
  75. package/scripts/check-v4-runtime-semantic-closure.mjs +266 -0
  76. package/scripts/dev-delivery-warrant-options.mjs +42 -15
  77. package/scripts/dev-delivery-warrant.mjs +59 -6
  78. package/scripts/dev-pr-auto-merge.mjs +25 -11
  79. package/scripts/dev-pr-delivery-warrant.mjs +44 -0
  80. package/scripts/dev-pr-prequeue-guard.mjs +0 -18
  81. package/scripts/dispatch-artifact-signing-authority.mjs +1 -1
  82. package/scripts/generate-agent-change-map.mjs +118 -0
  83. package/scripts/generate-release-candidate-passport.mjs +26 -1
  84. package/scripts/generate-site-bundle.mjs +6 -0
  85. package/scripts/maintainability-domain-metrics.mjs +237 -0
  86. package/scripts/maintainability-governance.mjs +473 -0
  87. package/scripts/maintainability-metrics.mjs +28 -6
  88. package/scripts/project-cut-merge-queue-admission.mjs +394 -0
  89. package/scripts/promotion-routing-evidence.mjs +35 -6
  90. package/scripts/release-candidate-resolver.mjs +44 -0
  91. package/scripts/release-line-policy.mjs +25 -15
  92. package/scripts/release-tail.mjs +19 -2
  93. package/scripts/resume-from-candidate-run.mjs +106 -103
  94. package/scripts/run-lifecycle-core.mjs +341 -376
  95. package/scripts/site-capability-metadata.mjs +4 -0
  96. package/scripts/stable-candidate-qualification.mjs +9 -10
  97. package/scripts/v3-v4-capability-catalog.mjs +439 -0
  98. package/scripts/v4-cross-platform-adopter-qualification.mjs +228 -0
  99. package/scripts/v4-declarative-promotion-admission.mjs +42 -0
@@ -97,6 +97,13 @@ state for `vX.Y.Z-alpha.N` and cannot resume it with the same transaction
97
97
  identity, alpha version selection must advance to the next prerelease instead
98
98
  of reusing or overwriting that failed transaction slot.
99
99
 
100
+ The immutable `publish-gate/{alpha,release}/.../<version>` source lock also
101
+ reserves its exact version when a failure happens before durable transaction
102
+ state can be created. A later candidate with a different source SHA advances to
103
+ the next version; it never rebinds or overwrites the earlier source lock. The
104
+ same source SHA reuses its own lock so authority planning and mutation stay on
105
+ one exact version.
106
+
100
107
  `release-candidate-promote.yml` can establish or restore this state from an
101
108
  older successful candidate run through the documented fresh-event recovery
102
109
  inputs. The recovery receipt and sealed bundle are verified before the action
@@ -251,10 +258,10 @@ Example reused OCI evidence entry (the pre-publish requirement may omit
251
258
 
252
259
  Buildchain distinguishes two npm release modes:
253
260
 
254
- | Mode | Use | Auth | npm operation |
255
- | --- | --- | --- | --- |
256
- | `publish-final-version` | normal alpha or stable publication | `trusted-publishing` | `npm publish --tag <alpha|vX.Y-alpha|latest>` |
257
- | `promote-existing-version` | same-version alpha-to-latest recovery | `npm-token` | `npm dist-tag add <pkg>@<version> latest` |
261
+ | Mode | Use | Auth | npm operation |
262
+ | -------------------------- | ------------------------------------- | -------------------- | ----------------------------------------------- |
263
+ | `publish-final-version` | normal alpha or stable publication | `trusted-publishing` | `npm publish --tag <alpha\|vX.Y-alpha\|latest>` |
264
+ | `promote-existing-version` | same-version alpha-to-latest recovery | `npm-token` | `npm dist-tag add <pkg>@<version> latest` |
258
265
 
259
266
  The normal libnode path is `publish-final-version`: publish an alpha package set
260
267
  such as `22.22.3-kf.3-alpha.0` with the `alpha` dist-tag, then publish a
@@ -234,6 +234,13 @@ restored sealed bundle, and a conflicting payload digest fails closed. Ordinary
234
234
  duplicate publication without a complete recovery receipt retains the stricter
235
235
  same-name/same-digest rule for all assets.
236
236
 
237
+ If that explicit complete recovery finds that the public Release Passport is
238
+ absent, it may restore the complete locally verified evidence closure. Before
239
+ the first upload, Buildchain rejects undeclared remote assets and compares every
240
+ same-name remote asset byte-for-byte; any unknown name or digest conflict fails
241
+ closed without mutation. Ordinary duplicate publication cannot enter this
242
+ repair path.
243
+
237
244
  After a transaction finalizes, the target branch can legitimately advance from
238
245
  the original promotion SHA. Repeating explicit recovery accepts that movement
239
246
  only when the caller supplies the exact durable transaction identity, the
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  status: preview
3
- period: 2026-08-16
3
+ period: 2026-08-27
4
4
  theme: buildchain-v4-adopter-delivery
5
5
  doc_type: product-manual
6
6
  source_level: local-files
@@ -8,12 +8,12 @@ confidence: high
8
8
  sensitivity: public
9
9
  evidence_grade: A
10
10
  review_state: self-reviewed
11
- last_reviewed: 2026-08-16
11
+ last_reviewed: 2026-08-27
12
12
  ai_provenance:
13
13
  model_family: GPT-5
14
14
  product: Codex
15
- generated_at: 2026-08-16
16
- visible_context: Exact protected v3 adopter-delivery cut, v4 pure contract core, published npm archive bytes, and public consumer policy.
15
+ generated_at: 2026-08-27
16
+ visible_context: Exact protected v3 adopter-delivery cut, v4 pure contract core, published npm archive bytes, public consumer policy, complete v3 capability inventory, and rooted cross-platform qualification reports.
17
17
  invisible_context_boundary: No credentials, provider mutations, signing operations, publication operations, or release authority were used.
18
18
  ---
19
19
 
@@ -124,6 +124,25 @@ committed byte roots, semantic identity, and authority readback root. It has
124
124
  only `contents: read`; no provider credential or production writer is accepted
125
125
  or synthesized.
126
126
 
127
+ ## Cross-platform capability qualification
128
+
129
+ The reusable workflow also produces a rooted report on `linux-x64`,
130
+ `macos-arm64`, and `windows-x64`. Each report binds `job.workflow_sha`, the
131
+ consumer source SHA, and the complete 4,648-row v3-to-v4 inventory. Source-only
132
+ capabilities retain their raw category counts with an `exact-source-route`
133
+ applicability; they are not mislabeled as operating-system executions.
134
+
135
+ The executable boundary is exercised rather than inferred: a public run must
136
+ pass, a substituted readback must fail, retry must reproduce the original root,
137
+ terminal verification and N-1 bootstrap must pass, and the independent
138
+ `ledger-specification-driver` clean-room test must pass without a KFD package.
139
+ The workflow then reconciles one exact report from each platform. Final family
140
+ qualification combines the Buildchain self-dogfood and `agent-hub-demo`
141
+ matrices through the exported
142
+ `@kungfu-tech/buildchain/v4-cross-platform-adopter-qualification` aggregator.
143
+ The report and aggregate explicitly grant no production, provider, release, or
144
+ stable-publication authority.
145
+
127
146
  ## Offline vectors
128
147
 
129
148
  [`offline-vectors.json`](../contracts/fixtures/v4-adopter-delivery-v1/offline-vectors.json)
@@ -0,0 +1,43 @@
1
+ ---
2
+ status: active
3
+ period: ongoing
4
+ theme: buildchain-v4-declarative-release-tail
5
+ doc_type: migration-guide
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: self-reviewed
11
+ last_reviewed: 2026-08-26
12
+ ai_provenance:
13
+ model_family: GPT-5
14
+ product: Codex
15
+ generated_at: 2026-08-26
16
+ invisible_context: unavailable
17
+ ---
18
+
19
+ # Migrate a release-candidate promotion to the v4 Provider Plane
20
+
21
+ Persist the public workflow call at the floating major ref and keep the matching contract lock in the consumer repository:
22
+
23
+ ```yaml
24
+ jobs:
25
+ promote:
26
+ uses: kungfu-systems/buildchain/.github/workflows/release-candidate-promote.yml@v4
27
+ with:
28
+ buildchain-contract-lock-path: .buildchain/contract-lock.json
29
+ declarative-release-tail: true
30
+ ```
31
+
32
+ The Build/Verify workflow now uploads these candidate-owned inputs together:
33
+
34
+ - `release-candidate-passport.json`
35
+ - `release-candidate-stage-capsules.json`
36
+ - `release-candidate-publication-qualification.json`
37
+ - the typed payload and manifest artifacts bound by those documents
38
+
39
+ Remove all v4 values for `publish-command`, `publication-gate-command`, `publication-consumer-qualification-command`, `publication-commit-command`, `release-activation-command`, `release-passport-evidence-command`, KFD/invariant command inputs, and every other `command`, `cmd`, `script`, `shell`, or `run` field. v4 admission rejects them before publication planning. Do not replace them with a wrapper script or a standalone workflow; declare provider evidence and let the reusable workflow execute the fixed Provider Plane.
40
+
41
+ On interruption, rerun with the same candidate and transaction state. Buildchain verifies the candidate/source/artifact/policy roots and continues from the first missing standardized receipt. Never delete the state file to make a failed capability replay from the beginning.
42
+
43
+ v3 workflow calls retain their existing command-compatible behavior. Migrating a v3 consumer is an explicit contract change, not an automatic reinterpretation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungfu-tech/buildchain",
3
- "version": "4.0.1-alpha.9",
3
+ "version": "4.0.2-alpha.0",
4
4
  "private": false,
5
5
  "description": "Buildchain Release Passport, release governance, CLI toolkit, and site facts.",
6
6
  "repository": "https://github.com/kungfu-systems/buildchain",
@@ -48,6 +48,9 @@
48
48
  "./v4-tail-reseal": "./packages/core/v4-tail-reseal.js",
49
49
  "./v4-tail-reseal-receipt": "./packages/core/v4-tail-reseal-receipt.js",
50
50
  "./v4-publication-rehearsal": "./packages/core/v4-publication-rehearsal.js",
51
+ "./publication-rehearsal-runtime": "./packages/core/publication-rehearsal-runtime.js",
52
+ "./publication-rehearsal-projection": "./packages/core/publication-rehearsal-projection.js",
53
+ "./v4-publication-qualification": "./packages/core/v4-publication-qualification.js",
51
54
  "./adopter-delivery-gate": "./packages/core/adopter-delivery-gate.js",
52
55
  "./kfd-adopter-category-driver": "./packages/core/kfd-adopter-category-driver.js",
53
56
  "./buildchain-delivery-infrastructure": "./packages/core/buildchain-delivery-infrastructure.js",
@@ -58,6 +61,7 @@
58
61
  "./adopter-delivery-passport": "./packages/core/adopter-delivery-passport.js",
59
62
  "./adopter-delivery-vectors": "./packages/core/adopter-delivery-vectors.js",
60
63
  "./v4-adopter-delivery": "./packages/core/v4-adopter-delivery.js",
64
+ "./v4-cross-platform-adopter-qualification": "./packages/core/v4-cross-platform-adopter-qualification.js",
61
65
  "./logging": "./packages/core/logging.js",
62
66
  "./portable-dev-cache": "./packages/core/portable-dev-cache.js",
63
67
  "./publication-artifact": "./packages/core/publication-artifact.js",
@@ -114,6 +118,7 @@
114
118
  "./site/schemas/v4-publication-rehearsal-capsule-v1.schema.json": "./dist/site/schemas/v4-publication-rehearsal-capsule-v1.schema.json",
115
119
  "./site/schemas/v4-adopter-delivery-v1.schema.json": "./dist/site/schemas/v4-adopter-delivery-v1.schema.json",
116
120
  "./site/schemas/release-tail-capabilities-v1.schema.json": "./dist/site/schemas/release-tail-capabilities-v1.schema.json",
121
+ "./site/schemas/v4-publication-qualification-v1.schema.json": "./dist/site/schemas/v4-publication-qualification-v1.schema.json",
117
122
  "./site/buildchain-contract.json": "./dist/site/buildchain-contract.json",
118
123
  "./site/product-mechanism.json": "./dist/site/product-mechanism.json",
119
124
  "./site/release-provenance.json": "./dist/site/release-provenance.json",
@@ -151,8 +156,8 @@
151
156
  "scripts": {
152
157
  "precheck:static": "prettier --check architecture/decisions/0003-two-phase-delivery-warrant.md architecture/v4-delivery-authority-parity.json contracts/dev-delivery-authority-v2.schema.json dist/site/schemas/dev-delivery-authority-v2.schema.json docs/dev-delivery-qualification-landing-adr.md packages/core/dev-delivery-authority-candidate.js packages/core/dev-delivery-authority-evidence.js packages/core/dev-delivery-authority-landing.js packages/core/dev-delivery-authority-observation.js packages/core/dev-delivery-authority-qualification.js packages/core/dev-delivery-authority-settlement.js packages/core/dev-delivery-authority-state.js packages/core/dev-delivery-execution-failure.js packages/core/dev-delivery-execution-transfer.js packages/core/dev-delivery-landing-readback.js packages/core/dev-delivery-landing-terminal-evidence.js packages/core/dev-delivery-landing-testing-port.js packages/core/dev-delivery-native-execution.js packages/core/dev-delivery-native-proof.js packages/core/dev-delivery-process-boundary.js packages/core/dev-delivery-warrant-qualification.js packages/core/dev-delivery-warrant-state.js scripts/dev-delivery-authority-command-adapters.mjs scripts/dev-delivery-authority-provider.mjs scripts/dev-delivery-authority.mjs scripts/dev-delivery-native-run.mjs scripts/dev-delivery-process-boundary.mjs scripts/dev-delivery-two-phase-resume.mjs scripts/dev-delivery-two-phase.mjs scripts/dev-delivery-warrant-options.mjs scripts/dev-delivery-warrant-store.mjs templates/native-dev-delivery.yml",
153
158
  "operator:windows-jit": "bash scripts/aws-windows-jit-operator.sh",
154
- "check": "pnpm run check:static && node scripts/check-ci-lane-change-budget.mjs && node scripts/check-v4-public-dogfood-contract.mjs && node scripts/check-v4-floating-consumer-policy-contract.mjs && pnpm run check:v4-bridge && pnpm run check:v4-contracts && node scripts/check-maintainability.mjs && node scripts/check-internal-architecture.mjs && node scripts/check-inventory.mjs && node scripts/check-core-mechanism-inventory.mjs && node scripts/check-release-tail-contract.mjs && node scripts/v4-publication-rehearsal-fixture.mjs --check && node scripts/v4-architecture.mjs validate && node scripts/v4-warrant-shadow-plan.mjs validate && pnpm run check:site && pnpm run check:workflows && pnpm run test:unit && pnpm run check:golden-path && node scripts/check-action-bundles.mjs",
155
- "check:static": "node scripts/check-javascript-syntax.mjs && prettier --check architecture/*.json contracts/release-tail-provider-bindings-v1.schema.json contracts/v4-canonical-contracts-v1.schema.json contracts/v4-compatibility-facts-v1.schema.json contracts/v4-delivery-warrant-semantic-diff-report-v1.schema.json contracts/v4-delivery-warrant-trace-v1.schema.json contracts/v4-floating-consumer-policy-receipt-v1.schema.json contracts/v4-runtime-ref-resume-authority-v1.schema.json contracts/v4-tail-reseal-v1.schema.json contracts/v4-host-contract-v1.schema.json contracts/v4-provider-operation-journal-v1.schema.json contracts/v4-release-activation-shadow-v1.schema.json contracts/v4-stable-publication-fence-v1.schema.json contracts/v4-partial-mutation-recovery-v1.schema.json contracts/v4-stage-capsule-v1.schema.json contracts/v4-stage-capsule-store-v1.schema.json contracts/v4-stage-capsule-resume-v1.schema.json contracts/release-tail-capabilities-v1.schema.json contracts/fixtures/release-tail-capabilities-v1/*.json contracts/fixtures/v4-delivery-warrant-trace-v1/*.json contracts/fixtures/v4-floating-consumer-policy-v1/*.json contracts/fixtures/v4-runtime-ref-resume-authority-v1/*.json contracts/fixtures/v4-tail-reseal-v1/*.json contracts/fixtures/v4-compatibility-facts-v1/*.json contracts/fixtures/v4-provider-operation-journal-v1/*.json contracts/fixtures/v4-provider-readback-idempotency-v1/*.json contracts/fixtures/v4-release-activation-shadow-v1/*.json contracts/fixtures/v4-stable-publication-fence-v1/*.json contracts/fixtures/v4-partial-mutation-recovery-v1/*.json contracts/fixtures/v4-stage-capsule-v1/*.json contracts/fixtures/v4-stage-capsule-store-v1/*.json contracts/fixtures/v4-stage-capsule-resume-v1/*.json bin/internal/command-registry.mjs bin/internal/compatibility-facts-cli.mjs packages/core/v4-canonical-contracts.js packages/core/kungfu-temporal-fact.js packages/core/buildchain-compatibility-fact.js packages/core/buildchain-compatibility-authority.js packages/core/buildchain-compatibility-proof.js packages/core/v4-floating-consumer-evidence.js packages/core/v4-floating-consumer-policy.js packages/core/v4-floating-consumer-release-passport.js packages/core/v4-runtime-ref-resume-authority.js packages/core/v4-tail-reseal-contract.js packages/core/v4-tail-reseal-github.js packages/core/v4-tail-reseal-receipt.js packages/core/v4-tail-reseal.js packages/core/v4-runtime-selector-persistence.js packages/core/v4-provider-operation-journal.js packages/core/v4-provider-readback-idempotency.js packages/core/v4-release-activation-shadow.js packages/core/v4-stable-publication-fence.js packages/core/v4-partial-mutation-recovery-qualification.js packages/core/v4-stage-capsule.js packages/core/v4-stage-capsule-store.js packages/core/v4-stage-capsule-local-store.js packages/core/v4-platform-stage-checkpoints.js packages/core/v4-stage-capsule-resume-planner.js packages/core/v4-stage-capsule-qualification.js packages/core/v4-stage-capsule-qualification-campaign.js packages/core/v4-delivery-warrant-fixture-runner.js packages/core/v4-delivery-warrant-read-candidate.js packages/core/v4-delivery-warrant-semantic-diff-gate.js packages/core/v4-delivery-warrant-shadow-adapter.js scripts/authorize-promotion-runtime-override.cjs scripts/check-core-mechanism-inventory.mjs scripts/check-release-tail-contract.mjs scripts/check-javascript-syntax.mjs scripts/check-maintainability.mjs scripts/dev-pr-prequeue-guard.mjs scripts/check-v4-public-dogfood-contract.mjs scripts/maintainability-metrics.mjs scripts/public-reference.mjs scripts/site-reference-registry.mjs scripts/generate-public-reference.mjs scripts/v4-architecture.mjs scripts/v4-bridge-bootstrap.mjs scripts/v4-bridge-evidence.mjs scripts/v4-consumer-policy.mjs scripts/v4-host-adapter.mjs scripts/v4-platform-stage-checkpoint-rehearsal.mjs scripts/v4-stage-capsule-resume-rehearsal.mjs scripts/v4-stage-capsule-qualification.mjs scripts/v4-tail-reseal-macos-rehearsal.mjs scripts/v4-tail-reseal.mjs scripts/v4-warrant-shadow-plan.mjs scripts/verify-golden-path.mjs tests/authorize-promotion-runtime-override.test.mjs tests/command-registry.test.mjs tests/core-mechanism-inventory.test.mjs tests/release-tail-contract.test.mjs tests/maintainability.test.mjs tests/promotion-responsibilities.test.mjs tests/public-reference.test.mjs tests/v4-architecture.test.mjs tests/v4-bridge.test.mjs tests/v4-canonical-contracts.test.mjs tests/v4-delivery-warrant-fixture-runner.test.mjs tests/v4-delivery-warrant-read-candidate.test.mjs tests/v4-floating-consumer-policy.test.mjs tests/v4-runtime-ref-resume-authority.test.mjs tests/v4-tail-reseal.test.mjs tests/v4-tail-reseal-parity.test.mjs tests/v4-compatibility-facts.test.mjs tests/v4-platform-stage-checkpoints.test.mjs tests/v4-provider-operation-journal.test.mjs tests/v4-provider-readback-idempotency.test.mjs tests/v4-public-dogfood-contract.test.mjs tests/v4-release-activation-shadow.test.mjs tests/v4-stable-publication-fence.test.mjs tests/v4-partial-mutation-recovery-qualification.test.mjs tests/v4-stage-capsule.test.mjs tests/v4-stage-capsule-store.test.mjs tests/v4-stage-capsule-resume-planner.test.mjs tests/v4-stage-capsule-qualification.test.mjs tests/v4-warrant-shadow-plan.test.mjs",
159
+ "check": "pnpm run check:static && node scripts/check-ci-lane-change-budget.mjs && node scripts/check-v4-public-dogfood-contract.mjs && node scripts/check-v4-floating-consumer-policy-contract.mjs && pnpm run check:v4-bridge && pnpm run check:v4-contracts && node scripts/check-maintainability.mjs && node scripts/check-internal-architecture.mjs && node scripts/generate-agent-change-map.mjs && node scripts/check-inventory.mjs && node scripts/check-core-mechanism-inventory.mjs && node scripts/check-v4-runtime-semantic-closure.mjs && node scripts/check-v3-v4-capability-inventory.mjs && node scripts/check-release-tail-contract.mjs && node scripts/v4-publication-rehearsal-fixture.mjs --check && node scripts/v4-architecture.mjs validate && node scripts/v4-warrant-shadow-plan.mjs validate && pnpm run check:site && pnpm run check:workflows && pnpm run test:unit && pnpm run check:golden-path && node scripts/check-action-bundles.mjs",
160
+ "check:static": "node scripts/check-javascript-syntax.mjs && prettier --check architecture/*.json contracts/release-tail-provider-bindings-v1.schema.json contracts/v4-canonical-contracts-v1.schema.json contracts/v4-compatibility-facts-v1.schema.json contracts/v4-delivery-warrant-semantic-diff-report-v1.schema.json contracts/v4-delivery-warrant-trace-v1.schema.json contracts/v4-floating-consumer-policy-receipt-v1.schema.json contracts/v4-runtime-ref-resume-authority-v1.schema.json contracts/v4-tail-reseal-v1.schema.json contracts/v4-host-contract-v1.schema.json contracts/v4-provider-operation-journal-v1.schema.json contracts/v4-release-activation-shadow-v1.schema.json contracts/v4-stable-publication-fence-v1.schema.json contracts/v4-partial-mutation-recovery-v1.schema.json contracts/v4-stage-capsule-v1.schema.json contracts/v4-stage-capsule-store-v1.schema.json contracts/v4-stage-capsule-resume-v1.schema.json contracts/release-tail-capabilities-v1.schema.json contracts/fixtures/release-tail-capabilities-v1/*.json contracts/fixtures/v4-delivery-warrant-trace-v1/*.json contracts/fixtures/v4-floating-consumer-policy-v1/*.json contracts/fixtures/v4-runtime-ref-resume-authority-v1/*.json contracts/fixtures/v4-tail-reseal-v1/*.json contracts/fixtures/v4-compatibility-facts-v1/*.json contracts/fixtures/v4-provider-operation-journal-v1/*.json contracts/fixtures/v4-provider-readback-idempotency-v1/*.json contracts/fixtures/v4-release-activation-shadow-v1/*.json contracts/fixtures/v4-stable-publication-fence-v1/*.json contracts/fixtures/v4-partial-mutation-recovery-v1/*.json contracts/fixtures/v4-stage-capsule-v1/*.json contracts/fixtures/v4-stage-capsule-store-v1/*.json contracts/fixtures/v4-stage-capsule-resume-v1/*.json bin/internal/command-registry.mjs bin/internal/compatibility-facts-cli.mjs packages/core/v4-canonical-contracts.js packages/core/kungfu-temporal-fact.js packages/core/buildchain-compatibility-fact.js packages/core/buildchain-compatibility-authority.js packages/core/buildchain-compatibility-proof.js packages/core/v4-floating-consumer-evidence.js packages/core/v4-floating-consumer-policy.js packages/core/v4-floating-consumer-release-passport.js packages/core/v4-runtime-ref-resume-authority.js packages/core/v4-tail-reseal-contract.js packages/core/v4-tail-reseal-github.js packages/core/v4-tail-reseal-receipt.js packages/core/v4-tail-reseal.js packages/core/v4-runtime-selector-persistence.js packages/core/v4-provider-operation-journal.js packages/core/v4-provider-readback-idempotency.js packages/core/v4-release-activation-shadow.js packages/core/v4-stable-publication-fence.js packages/core/v4-partial-mutation-recovery-qualification.js packages/core/v4-stage-capsule.js packages/core/v4-stage-capsule-store.js packages/core/v4-stage-capsule-local-store.js packages/core/v4-platform-stage-checkpoints.js packages/core/v4-stage-capsule-resume-planner.js packages/core/v4-stage-capsule-qualification.js packages/core/v4-stage-capsule-qualification-campaign.js packages/core/v4-delivery-warrant-fixture-runner.js packages/core/v4-delivery-warrant-read-candidate.js packages/core/v4-delivery-warrant-semantic-diff-gate.js packages/core/v4-delivery-warrant-shadow-adapter.js scripts/authorize-promotion-runtime-override.cjs scripts/check-core-mechanism-inventory.mjs scripts/check-v4-runtime-semantic-closure.mjs scripts/check-release-tail-contract.mjs scripts/check-javascript-syntax.mjs scripts/check-maintainability.mjs scripts/dev-pr-prequeue-guard.mjs scripts/check-v4-public-dogfood-contract.mjs scripts/maintainability-metrics.mjs scripts/maintainability-domain-metrics.mjs scripts/maintainability-governance.mjs scripts/generate-agent-change-map.mjs scripts/public-reference.mjs scripts/site-reference-registry.mjs scripts/generate-public-reference.mjs scripts/v4-architecture.mjs scripts/v4-bridge-bootstrap.mjs scripts/v4-bridge-evidence.mjs scripts/v4-consumer-policy.mjs scripts/v4-host-adapter.mjs scripts/v4-platform-stage-checkpoint-rehearsal.mjs scripts/v4-stage-capsule-resume-rehearsal.mjs scripts/v4-stage-capsule-qualification.mjs scripts/v4-tail-reseal-macos-rehearsal.mjs scripts/v4-tail-reseal.mjs scripts/v4-warrant-shadow-plan.mjs scripts/verify-golden-path.mjs tests/authorize-promotion-runtime-override.test.mjs tests/command-registry.test.mjs tests/core-mechanism-inventory.test.mjs tests/release-tail-contract.test.mjs tests/maintainability.test.mjs tests/maintainability-governance.test.mjs tests/promotion-responsibilities.test.mjs tests/public-reference.test.mjs tests/v4-architecture.test.mjs tests/v4-bridge.test.mjs tests/v4-canonical-contracts.test.mjs tests/v4-delivery-warrant-fixture-runner.test.mjs tests/v4-delivery-warrant-read-candidate.test.mjs tests/v4-floating-consumer-policy.test.mjs tests/v4-runtime-ref-resume-authority.test.mjs tests/v4-runtime-semantic-closure.test.mjs tests/v4-tail-reseal.test.mjs tests/v4-tail-reseal-parity.test.mjs tests/v4-compatibility-facts.test.mjs tests/v4-platform-stage-checkpoints.test.mjs tests/v4-provider-operation-journal.test.mjs tests/v4-provider-readback-idempotency.test.mjs tests/v4-public-dogfood-contract.test.mjs tests/v4-release-activation-shadow.test.mjs tests/v4-stable-publication-fence.test.mjs tests/v4-partial-mutation-recovery-qualification.test.mjs tests/v4-stage-capsule.test.mjs tests/v4-stage-capsule-store.test.mjs tests/v4-stage-capsule-resume-planner.test.mjs tests/v4-stage-capsule-qualification.test.mjs tests/v4-warrant-shadow-plan.test.mjs",
156
161
  "check:v4-bridge": "cargo fmt --manifest-path crates/buildchain-v4-bridge/Cargo.toml -- --check && cargo clippy --locked --manifest-path crates/buildchain-v4-bridge/Cargo.toml -- -D warnings && cargo test --locked --manifest-path crates/buildchain-v4-bridge/Cargo.toml",
157
162
  "check:v4-contracts": "cargo fmt --manifest-path crates/buildchain-v4-contracts/Cargo.toml -- --check && cargo clippy --locked --manifest-path crates/buildchain-v4-contracts/Cargo.toml -- -D warnings && cargo test --locked --manifest-path crates/buildchain-v4-contracts/Cargo.toml && node --test tests/v4-canonical-contracts.test.mjs tests/v4-delivery-warrant-fixture-runner.test.mjs tests/v4-delivery-warrant-read-candidate.test.mjs tests/v4-floating-consumer-policy-contract.test.mjs tests/v4-floating-consumer-policy.test.mjs tests/v4-runtime-ref-resume-authority.test.mjs tests/v4-tail-reseal.test.mjs tests/v4-tail-reseal-parity.test.mjs tests/v4-compatibility-facts.test.mjs tests/v4-publication-rehearsal.test.mjs tests/v4-platform-stage-checkpoints.test.mjs tests/v4-provider-operation-journal.test.mjs tests/v4-provider-readback-idempotency.test.mjs tests/v4-public-dogfood-contract.test.mjs tests/v4-release-activation-shadow.test.mjs tests/v4-stable-publication-fence.test.mjs tests/v4-partial-mutation-recovery-qualification.test.mjs tests/v4-stage-capsule.test.mjs tests/v4-stage-capsule-store.test.mjs tests/v4-stage-capsule-resume-planner.test.mjs tests/v4-stage-capsule-qualification.test.mjs",
158
163
  "check:workflows": "bash scripts/check-workflows.sh",
@@ -7,6 +7,42 @@ export const ADOPTER_DELIVERY_PASSPORT_BINDING_CONTRACT =
7
7
  "kungfu-buildchain-adopter-delivery-passport-binding";
8
8
 
9
9
  const ROOT_PATTERN = /^sha256:[0-9a-f]{64}$/;
10
+ const EXACT_SHA_PATTERN = /^[0-9a-f]{40}$/u;
11
+
12
+ export function releasePassportKfdAdopterSourceSha({
13
+ passportSourceSha = "",
14
+ release = undefined,
15
+ } = {}) {
16
+ const exactSha = (value) =>
17
+ EXACT_SHA_PATTERN.test(String(value || "").trim());
18
+ const candidateSourceSha = String(release?.candidateSourceSha || "").trim();
19
+ const builtSourceSha = String(release?.builtSourceSha || "").trim();
20
+ const promotionChannelSha = String(release?.promotionChannelSha || "").trim();
21
+ const candidateSourceTreeSha = String(
22
+ release?.candidateSourceTreeSha || "",
23
+ ).trim();
24
+ const builtSourceTreeSha = String(release?.builtSourceTreeSha || "").trim();
25
+ const promotionChannelTreeSha = String(
26
+ release?.promotionChannelTreeSha || "",
27
+ ).trim();
28
+ if (
29
+ release?.treeEquivalent !== true ||
30
+ !exactSha(passportSourceSha) ||
31
+ !exactSha(candidateSourceSha) ||
32
+ !exactSha(builtSourceSha) ||
33
+ !exactSha(promotionChannelSha) ||
34
+ candidateSourceSha !== builtSourceSha ||
35
+ promotionChannelSha !== passportSourceSha ||
36
+ !exactSha(candidateSourceTreeSha) ||
37
+ !exactSha(builtSourceTreeSha) ||
38
+ !exactSha(promotionChannelTreeSha) ||
39
+ candidateSourceTreeSha !== builtSourceTreeSha ||
40
+ candidateSourceTreeSha !== promotionChannelTreeSha
41
+ ) {
42
+ return passportSourceSha;
43
+ }
44
+ return candidateSourceSha;
45
+ }
10
46
 
11
47
  function issue(code, message, details = {}) {
12
48
  return { code, message, details };
@@ -166,6 +166,36 @@ function declarativeAuditableDemoSurface(root, pkg, majorLine) {
166
166
  });
167
167
  }
168
168
 
169
+ function v4ReleaseCandidatePromoteSurface(root, majorLine) {
170
+ return surface(root, {
171
+ id: "v4-release-candidate-promote-action",
172
+ kind: "action",
173
+ path: "actions/v4-release-candidate-promote/action.yml",
174
+ publicRef: `kungfu-systems/buildchain/actions/v4-release-candidate-promote@${majorLine}`,
175
+ requiredInputs: [
176
+ "token", "repository", "source-sha", "version", "tag", "channel",
177
+ "candidate-passport-path", "stage-capsules-path",
178
+ "publication-qualification-path",
179
+ ],
180
+ requiredOutputs: [
181
+ "release-passport-path", "release-passport-root", "transaction-state",
182
+ "declaration-root", "transaction-root", "state-root",
183
+ "receipt-roots-json",
184
+ ],
185
+ breakingDefaults: {
186
+ statePath: ".buildchain/release-tail/state.json",
187
+ executionBoundary: "built-in-provider-plane-only",
188
+ },
189
+ optionalInputs: ["artifact-paths", "state-path", "failure-after-capability"],
190
+ guarantees: [
191
+ "v4 promotion consumes only sealed candidate, Stage Capsule, qualification, and artifact evidence",
192
+ "GitHub Release, signed-channel commit, activation, readback, and released-evidence synthesis use built-in provider adapters",
193
+ "durable provider checkpoints resume completed capabilities without replay",
194
+ "no consumer command, script, shell, checkout, or executable tail hook is accepted",
195
+ ],
196
+ });
197
+ }
198
+
169
199
  export function createBuildchainContractWorld({
170
200
  root = process.cwd(),
171
201
  packageJson = undefined,
@@ -484,7 +514,7 @@ export function createBuildchainContractWorld({
484
514
  "Build Images owns encoding, Buildchain owns qualification and receipts, and site repositories own browser loading and accessibility behavior",
485
515
  "media qualification does not claim browser playback, responsive layout, reduced-motion behavior, accessibility, or production deployment",
486
516
  ],
487
- }), declarativeAuditableDemoSurface(root, pkg, majorLine),
517
+ }), declarativeAuditableDemoSurface(root, pkg, majorLine), v4ReleaseCandidatePromoteSurface(root, majorLine),
488
518
  surface(root, {
489
519
  id: "promote-buildchain-ref-action",
490
520
  kind: "action",
@@ -58,6 +58,7 @@ const DESCRIPTORS = Object.freeze([
58
58
  [".github/workflows/release-tail.yml", "product-publication", true, ["artifact.publish", "signed-channel.commit", "release.activate", "released-evidence.synthesize"], "caller-secrets", "caller-bound", "caller-bound", "fixed"],
59
59
  [".github/workflows/release-verify.yml", "governance-write"],
60
60
  [".github/workflows/stable-candidate-patrol.yml", "governance-write"],
61
+ [".github/workflows/v4-declarative-release-tail-dogfood.yml", "product-publication", true, ["artifact.publish", "signed-channel.commit", "release.activate", "released-evidence.synthesize"], "caller-secrets", "none", "fixed", "fixed"],
61
62
  ]);
62
63
 
63
64
  export function buildchainPublicationAuthorityDescriptors() {
@@ -0,0 +1,246 @@
1
+ import {
2
+ devDeliveryClone as clone,
3
+ devDeliveryContentRoot,
4
+ devDeliveryExactRoot as exactRoot,
5
+ devDeliveryExactSha as exactSha,
6
+ devDeliveryPositiveInteger as positiveInteger,
7
+ devDeliveryText as text,
8
+ devDeliveryTimestamp as timestamp,
9
+ } from "./dev-delivery-common.js";
10
+ import {
11
+ TERMINAL_STATES,
12
+ normalizeDevDeliveryQueue,
13
+ } from "./dev-delivery-warrant-state.js";
14
+
15
+ export const LEGACY_TERMINAL_RECOVERY_REQUEST_SCHEMA =
16
+ "kungfu.buildchain.legacy-terminal-recovery-request/v1";
17
+ export const LEGACY_HOSTED_TERMINAL_EVIDENCE_SCHEMA =
18
+ "kungfu.buildchain.legacy-hosted-terminal-evidence/v1";
19
+ export const LEGACY_TERMINAL_RECOVERY_RECEIPT_SCHEMA =
20
+ "kungfu.buildchain.legacy-terminal-recovery-receipt/v1";
21
+
22
+ function legacyLiveNativeCandidate(candidate) {
23
+ return (
24
+ !TERMINAL_STATES.has(candidate.status) &&
25
+ candidate.deliveryClass !== "non-native-fast" &&
26
+ (!candidate.environmentRoot || !candidate.nativeCommandContract)
27
+ );
28
+ }
29
+
30
+ function normalizeProviderJob(input, runAttempt) {
31
+ const job = {
32
+ id: positiveInteger(input?.id, "provider job id"),
33
+ name: text(input?.name),
34
+ runAttempt: positiveInteger(input?.runAttempt, "provider job runAttempt"),
35
+ status: text(input?.status).toLowerCase(),
36
+ conclusion: text(input?.conclusion).toLowerCase(),
37
+ completedAt: timestamp(input?.completedAt, "provider job completedAt"),
38
+ };
39
+ if (job.runAttempt !== runAttempt) {
40
+ throw new Error("legacy provider job run attempt mismatch");
41
+ }
42
+ if (job.status !== "completed" || !job.conclusion) {
43
+ throw new Error(
44
+ "legacy recovery requires every provider job to be terminal",
45
+ );
46
+ }
47
+ return job;
48
+ }
49
+
50
+ function normalizeEvidence(input) {
51
+ const runAttempt = positiveInteger(input?.runAttempt, "runAttempt");
52
+ if (!Array.isArray(input?.jobs) || input.jobs.length === 0) {
53
+ throw new Error("legacy terminal evidence requires provider jobs");
54
+ }
55
+ const jobs = input.jobs
56
+ .map((job) => normalizeProviderJob(job, runAttempt))
57
+ .sort((left, right) => left.id - right.id);
58
+ if (new Set(jobs.map((job) => job.id)).size !== jobs.length) {
59
+ throw new Error(
60
+ "legacy terminal evidence contains duplicate provider jobs",
61
+ );
62
+ }
63
+ if (!jobs.some((job) => job.conclusion === "failure")) {
64
+ throw new Error(
65
+ "legacy failed run evidence requires a failed provider job",
66
+ );
67
+ }
68
+ const runUpdatedAt = timestamp(input?.runUpdatedAt, "runUpdatedAt");
69
+ if (
70
+ jobs.some((job) => Date.parse(job.completedAt) > Date.parse(runUpdatedAt))
71
+ ) {
72
+ throw new Error("legacy provider job completion follows the run readback");
73
+ }
74
+ const body = {
75
+ schema: text(input?.schema),
76
+ candidateId: exactRoot(input?.candidateId, "candidateId"),
77
+ pullRequestNumber: positiveInteger(
78
+ input?.pullRequestNumber,
79
+ "pullRequestNumber",
80
+ ),
81
+ sourceHead: exactSha(input?.sourceHead, "sourceHead"),
82
+ sourceWorkflowRunId: positiveInteger(
83
+ input?.sourceWorkflowRunId,
84
+ "sourceWorkflowRunId",
85
+ ),
86
+ runAttempt,
87
+ runStatus: text(input?.runStatus).toLowerCase(),
88
+ runConclusion: text(input?.runConclusion).toLowerCase(),
89
+ runUpdatedAt,
90
+ totalJobCount: jobs.length,
91
+ nonterminalJobCount: 0,
92
+ workerTerminationProven: true,
93
+ jobs,
94
+ reason: text(input?.reason),
95
+ };
96
+ if (body.schema !== LEGACY_HOSTED_TERMINAL_EVIDENCE_SCHEMA) {
97
+ throw new Error(
98
+ `legacy terminal evidence must use ${LEGACY_HOSTED_TERMINAL_EVIDENCE_SCHEMA}`,
99
+ );
100
+ }
101
+ if (
102
+ body.runStatus !== "completed" ||
103
+ body.runConclusion !== "failure" ||
104
+ !body.reason
105
+ ) {
106
+ throw new Error(
107
+ "legacy terminal evidence requires one completed failed run with zero nonterminal jobs and proven worker termination",
108
+ );
109
+ }
110
+ const evidenceRoot = devDeliveryContentRoot(body);
111
+ if (exactRoot(input?.evidenceRoot, "evidenceRoot") !== evidenceRoot) {
112
+ throw new Error("legacy terminal evidence root mismatch");
113
+ }
114
+ return { ...body, evidenceRoot };
115
+ }
116
+
117
+ function assertExactCoverage(candidates, evidence) {
118
+ const expected = candidates.map((candidate) => candidate.candidateId).sort();
119
+ const observed = evidence.map((entry) => entry.candidateId).sort();
120
+ if (
121
+ expected.length !== observed.length ||
122
+ expected.some((candidateId, index) => candidateId !== observed[index])
123
+ ) {
124
+ throw new Error(
125
+ "legacy terminal recovery must cover every live legacy native candidate exactly once",
126
+ );
127
+ }
128
+ }
129
+
130
+ export function recoverLegacyTerminalDevDeliveryQueue(
131
+ queueInput,
132
+ requestInput,
133
+ { now = new Date().toISOString() } = {},
134
+ ) {
135
+ const currentTime = timestamp(now, "now");
136
+ const request = requestInput || {};
137
+ if (request.schema !== LEGACY_TERMINAL_RECOVERY_REQUEST_SCHEMA) {
138
+ throw new Error(
139
+ `legacy terminal recovery must use ${LEGACY_TERMINAL_RECOVERY_REQUEST_SCHEMA}`,
140
+ );
141
+ }
142
+ const before = normalizeDevDeliveryQueue(queueInput, {
143
+ allowLegacyV3Readback: true,
144
+ });
145
+ const expectedOldStateRoot = exactRoot(
146
+ request.expectedOldStateRoot,
147
+ "expectedOldStateRoot",
148
+ );
149
+ if (expectedOldStateRoot !== before.stateRoot) {
150
+ throw new Error("legacy terminal recovery expected-old state drift");
151
+ }
152
+ const legacyCandidates = before.candidates.filter(legacyLiveNativeCandidate);
153
+ if (legacyCandidates.length === 0) {
154
+ throw new Error("legacy terminal recovery found no live legacy candidate");
155
+ }
156
+ if (!Array.isArray(request.evidence)) {
157
+ throw new Error("legacy terminal recovery evidence must be an array");
158
+ }
159
+ const evidence = request.evidence.map(normalizeEvidence);
160
+ if (
161
+ new Set(evidence.map((entry) => entry.candidateId)).size !== evidence.length
162
+ ) {
163
+ throw new Error(
164
+ "legacy terminal recovery evidence contains duplicate candidates",
165
+ );
166
+ }
167
+ assertExactCoverage(legacyCandidates, evidence);
168
+
169
+ const queue = clone(before);
170
+ delete queue.stateRoot;
171
+ const transitions = [];
172
+ for (const entry of evidence) {
173
+ const candidate = queue.candidates.find(
174
+ (row) => row.candidateId === entry.candidateId,
175
+ );
176
+ if (
177
+ !candidate ||
178
+ candidate.pullRequestNumber !== entry.pullRequestNumber ||
179
+ candidate.sourceHead !== entry.sourceHead ||
180
+ candidate.sourceWorkflowRunId !== entry.sourceWorkflowRunId
181
+ ) {
182
+ throw new Error(
183
+ "legacy terminal evidence does not match candidate identity",
184
+ );
185
+ }
186
+ const active = queue.activeWarrant?.candidateId === candidate.candidateId;
187
+ if (!active && candidate.status !== "queued") {
188
+ throw new Error(
189
+ `legacy candidate status ${candidate.status} requires the exact active Warrant`,
190
+ );
191
+ }
192
+ const priorStatus = candidate.status;
193
+ candidate.status = "terminal-failure";
194
+ candidate.updatedAt = currentTime;
195
+ candidate.terminal = {
196
+ outcome: "terminal-failure",
197
+ reason: entry.reason,
198
+ evidenceRoot: entry.evidenceRoot,
199
+ authority: "legacy-hosted-native-terminal-recovery",
200
+ sourceWorkflowRunId: entry.sourceWorkflowRunId,
201
+ runAttempt: entry.runAttempt,
202
+ workerTerminationProven: true,
203
+ closedAt: currentTime,
204
+ ...(active
205
+ ? {
206
+ fencingToken: queue.activeWarrant.fencingToken,
207
+ leaseGeneration: queue.activeWarrant.generation,
208
+ }
209
+ : {}),
210
+ };
211
+ transitions.push({
212
+ candidateId: candidate.candidateId,
213
+ pullRequestNumber: candidate.pullRequestNumber,
214
+ sourceHead: candidate.sourceHead,
215
+ priorStatus,
216
+ activeWarrant: active,
217
+ outcome: "terminal-failure",
218
+ evidenceRoot: entry.evidenceRoot,
219
+ });
220
+ }
221
+ queue.activeWarrant = null;
222
+ queue.generation += 1;
223
+ queue.updatedAt = currentTime;
224
+ queue.stateRoot = devDeliveryContentRoot(queue);
225
+ const after = normalizeDevDeliveryQueue(queue);
226
+ const requestBody = {
227
+ schema: LEGACY_TERMINAL_RECOVERY_REQUEST_SCHEMA,
228
+ expectedOldStateRoot,
229
+ evidence,
230
+ };
231
+ const requestRoot = devDeliveryContentRoot(requestBody);
232
+ const receipt = {
233
+ schema: LEGACY_TERMINAL_RECOVERY_RECEIPT_SCHEMA,
234
+ action: "legacy-terminal-recovery",
235
+ expectedOldStateRoot,
236
+ nextStateRoot: after.stateRoot,
237
+ requestRoot,
238
+ transitions,
239
+ nextAction: "Select the next strictly valid queued candidate, if any.",
240
+ };
241
+ return {
242
+ queue: after,
243
+ receipt,
244
+ receiptRoot: devDeliveryContentRoot(receipt),
245
+ };
246
+ }