@kungfu-tech/buildchain 4.0.1 → 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.
- package/architecture/agent-change-map.md +3 -1
- package/architecture/internal-capabilities.json +4 -1
- package/architecture/maintainability-debt.json +6 -6
- package/architecture/maintainability-policy.json +4 -4
- package/architecture/v3-core-mechanism-inventory.json +2 -0
- package/dist/site/buildchain-contract.json +4 -4
- package/dist/site/buildchain-site.json +6 -6
- package/dist/site/kfd-claims.json +4 -4
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/page-registry.json +2 -2
- package/dist/site/public-surface-audit.json +8 -3
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/site-manifest.json +4 -4
- package/dist/site/workflow-registry.json +4 -4
- package/docs/dev-delivery-warrant.md +21 -0
- package/package.json +1 -1
- package/packages/core/dev-delivery-warrant-legacy-recovery.js +246 -0
- package/scripts/dev-delivery-warrant-options.mjs +15 -4
- package/scripts/dev-delivery-warrant.mjs +16 -3
|
@@ -894,6 +894,7 @@ Owner: Buildchain protected delivery maintainers
|
|
|
894
894
|
- `packages/core/dev-delivery-warrant.js`
|
|
895
895
|
- `packages/core/dev-delivery-warrant-state.js`
|
|
896
896
|
- `packages/core/dev-delivery-warrant-qualification.js`
|
|
897
|
+
- `packages/core/dev-delivery-warrant-legacy-recovery.js`
|
|
897
898
|
- `packages/core/dev-delivery-native-proof.js`
|
|
898
899
|
- `packages/core/dev-delivery-native-execution.js`
|
|
899
900
|
- `packages/core/dev-delivery-execution-failure.js`
|
|
@@ -940,6 +941,7 @@ Owner: Buildchain protected delivery maintainers
|
|
|
940
941
|
|
|
941
942
|
- `tests/dev-delivery-warrant.test.mjs`
|
|
942
943
|
- `tests/dev-delivery-warrant-command.test.mjs`
|
|
944
|
+
- `tests/dev-delivery-warrant-legacy-recovery.test.mjs`
|
|
943
945
|
- `tests/dev-delivery-two-phase.test.mjs`
|
|
944
946
|
- `tests/dev-delivery-two-phase-run.test.mjs`
|
|
945
947
|
- `tests/dev-delivery-native-run.test.mjs`
|
|
@@ -956,7 +958,7 @@ Owner: Buildchain protected delivery maintainers
|
|
|
956
958
|
|
|
957
959
|
### Minimal validation
|
|
958
960
|
|
|
959
|
-
- `node --test tests/dev-delivery-warrant.test.mjs tests/dev-delivery-warrant-command.test.mjs tests/dev-delivery-two-phase.test.mjs tests/dev-delivery-two-phase-run.test.mjs tests/dev-delivery-native-run.test.mjs tests/dev-delivery-process-boundary.test.mjs tests/dev-delivery-process-boundary-negative.test.mjs tests/dev-delivery-provider-heartbeat.test.mjs tests/dev-delivery-authority.test.mjs tests/build-surface.test.mjs tests/v4-delivery-authority-parity.test.mjs`
|
|
961
|
+
- `node --test tests/dev-delivery-warrant.test.mjs tests/dev-delivery-warrant-command.test.mjs tests/dev-delivery-warrant-legacy-recovery.test.mjs tests/dev-delivery-two-phase.test.mjs tests/dev-delivery-two-phase-run.test.mjs tests/dev-delivery-native-run.test.mjs tests/dev-delivery-process-boundary.test.mjs tests/dev-delivery-process-boundary-negative.test.mjs tests/dev-delivery-provider-heartbeat.test.mjs tests/dev-delivery-authority.test.mjs tests/build-surface.test.mjs tests/v4-delivery-authority-parity.test.mjs`
|
|
960
962
|
|
|
961
963
|
## v4-publication-rehearsal
|
|
962
964
|
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"packages/core/dev-delivery-warrant.js",
|
|
77
77
|
"packages/core/dev-delivery-warrant-state.js",
|
|
78
78
|
"packages/core/dev-delivery-warrant-qualification.js",
|
|
79
|
+
"packages/core/dev-delivery-warrant-legacy-recovery.js",
|
|
79
80
|
"packages/core/dev-delivery-native-proof.js",
|
|
80
81
|
"packages/core/dev-delivery-native-execution.js",
|
|
81
82
|
"packages/core/dev-delivery-execution-failure.js",
|
|
@@ -591,6 +592,7 @@
|
|
|
591
592
|
"packages/core/dev-delivery-warrant.js",
|
|
592
593
|
"packages/core/dev-delivery-warrant-state.js",
|
|
593
594
|
"packages/core/dev-delivery-warrant-qualification.js",
|
|
595
|
+
"packages/core/dev-delivery-warrant-legacy-recovery.js",
|
|
594
596
|
"packages/core/dev-delivery-native-proof.js",
|
|
595
597
|
"packages/core/dev-delivery-native-execution.js",
|
|
596
598
|
"packages/core/dev-delivery-execution-failure.js",
|
|
@@ -624,6 +626,7 @@
|
|
|
624
626
|
"tests": [
|
|
625
627
|
"tests/dev-delivery-warrant.test.mjs",
|
|
626
628
|
"tests/dev-delivery-warrant-command.test.mjs",
|
|
629
|
+
"tests/dev-delivery-warrant-legacy-recovery.test.mjs",
|
|
627
630
|
"tests/dev-delivery-two-phase.test.mjs",
|
|
628
631
|
"tests/dev-delivery-two-phase-run.test.mjs",
|
|
629
632
|
"tests/dev-delivery-native-run.test.mjs",
|
|
@@ -649,7 +652,7 @@
|
|
|
649
652
|
"dist/site/schemas/dev-delivery-authority-v2.schema.json"
|
|
650
653
|
],
|
|
651
654
|
"validationCommands": [
|
|
652
|
-
"node --test tests/dev-delivery-warrant.test.mjs tests/dev-delivery-warrant-command.test.mjs tests/dev-delivery-two-phase.test.mjs tests/dev-delivery-two-phase-run.test.mjs tests/dev-delivery-native-run.test.mjs tests/dev-delivery-process-boundary.test.mjs tests/dev-delivery-process-boundary-negative.test.mjs tests/dev-delivery-provider-heartbeat.test.mjs tests/dev-delivery-authority.test.mjs tests/build-surface.test.mjs tests/v4-delivery-authority-parity.test.mjs"
|
|
655
|
+
"node --test tests/dev-delivery-warrant.test.mjs tests/dev-delivery-warrant-command.test.mjs tests/dev-delivery-warrant-legacy-recovery.test.mjs tests/dev-delivery-two-phase.test.mjs tests/dev-delivery-two-phase-run.test.mjs tests/dev-delivery-native-run.test.mjs tests/dev-delivery-process-boundary.test.mjs tests/dev-delivery-process-boundary-negative.test.mjs tests/dev-delivery-provider-heartbeat.test.mjs tests/dev-delivery-authority.test.mjs tests/build-surface.test.mjs tests/v4-delivery-authority-parity.test.mjs"
|
|
653
656
|
]
|
|
654
657
|
},
|
|
655
658
|
{
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"totalExcessLedger": {
|
|
9
9
|
"metric": "calibrated-full-dimensional-excess-v1",
|
|
10
|
-
"measuredExcess":
|
|
11
|
-
"current":
|
|
10
|
+
"measuredExcess": 67948,
|
|
11
|
+
"current": 59887
|
|
12
12
|
},
|
|
13
13
|
"defaults": {
|
|
14
14
|
"owner": "Buildchain architecture maintainers",
|
|
@@ -1398,21 +1398,21 @@
|
|
|
1398
1398
|
"scripts/dev-delivery-warrant-options.mjs": {
|
|
1399
1399
|
"baseline": {
|
|
1400
1400
|
"functions": {
|
|
1401
|
-
"devDeliveryCliOptions@
|
|
1401
|
+
"devDeliveryCliOptions@61": {
|
|
1402
1402
|
"lines": 247
|
|
1403
1403
|
}
|
|
1404
1404
|
}
|
|
1405
1405
|
},
|
|
1406
1406
|
"current": {
|
|
1407
1407
|
"functions": {
|
|
1408
|
-
"devDeliveryCliOptions@
|
|
1409
|
-
"lines":
|
|
1408
|
+
"devDeliveryCliOptions@61": {
|
|
1409
|
+
"lines": 233
|
|
1410
1410
|
}
|
|
1411
1411
|
}
|
|
1412
1412
|
},
|
|
1413
1413
|
"target": {
|
|
1414
1414
|
"functions": {
|
|
1415
|
-
"devDeliveryCliOptions@
|
|
1415
|
+
"devDeliveryCliOptions@61": {
|
|
1416
1416
|
"lines": 180
|
|
1417
1417
|
}
|
|
1418
1418
|
}
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"repositoryBudgets": {
|
|
28
28
|
"baselineRevision": "858dbe00b6206a8f356b4a12d2659bee7a72e71b",
|
|
29
|
-
"maxHandMaintainedSourceFiles":
|
|
30
|
-
"maxHandMaintainedSourceLines":
|
|
29
|
+
"maxHandMaintainedSourceFiles": 444,
|
|
30
|
+
"maxHandMaintainedSourceLines": 164728,
|
|
31
31
|
"maxWorkflowFiles": 77,
|
|
32
32
|
"maxWorkflowLines": 26791,
|
|
33
|
-
"latestTransition": "
|
|
34
|
-
"latestTransitionRationale": "
|
|
33
|
+
"latestTransition": "Legacy provisional Warrant recovery is isolated behind one terminal-only authority boundary.",
|
|
34
|
+
"latestTransitionRationale": "One bounded source module admits only a complete exact set of failed hosted legacy runs, requires every provider job to be terminal, and performs one expected-old transition into the current strict state contract. The CLI parser extracts state-coordinate options from its oversized compatibility mapping, reducing devDeliveryCliOptions from 247 to 233 lines; dedicated recovery tests remain below the default test-file budget.",
|
|
35
35
|
"rationale": "Bounded modules separate candidate, evidence, native proof and execution, canonical failure verification, closed-set execution transfer, process-boundary verification, Warrant state and qualification, authority state, qualification, Landing acquisition, verified-attempt admission, Landing settlement and fence validation, provider attempt and heartbeat readback, sealed terminal evidence, hosted heartbeat, resume, store, options, command-specific adapters, and CLI orchestration responsibilities. The protected delivery workflow gives candidate and seal jobs no provider write credential, recursively rejects transfer drift, scopes every transfer artifact to the exact provider run attempt, chains every durable heartbeat state and receipt root on a distinct hosted runner domain, and permits qualification or exact failure settlement only after the finalizer verifies live jobs and the latest durable authority state. Public Landing admission and heartbeat always perform non-injectable fresh exact-attempt provider readback, tolerate only a not-yet-materialized seal job while retaining exact native and duplicate-job rejection, and heartbeat-loss coordination never invokes GitHub's run-scoped cancellation API where a successor rerun could race. The hosted process boundary anchors trust in the kernel-resolved versioned Runner.Worker path while accepting an equivalent argv-zero spelling with the same basename; its public boundary marker is allowed only at the one exact non-secret value, so a forged value under the same credential-like name still fails closed. The credentialless transfer seal validates the rooted native reuse decision against the Warrant-bound source, closure, dependency, toolchain, environment and command inputs; qualifiedBase stays in the proof and decision where it is rooted and later independently rechecked, rather than being assumed on the Warrant schema. V2 mutation cannot initialize a second empty authority beside a legacy ref: migration reads and roots the canonical live v1 ref, rechecks it, applies the explicit configured v2 policy, and atomically replaces its bytes through one expected-old non-force update, so old v1 controllers fail closed while the prior commit remains immutable history. Candidate ancestry classifies the GitHub artifact runtime token as credential authority. Every Landing settlement, including an unexpired fence, requires product-owned terminal readback. Terminal cleanup reads the immutable historical attempt, derives workflow and hosted Landing job identity from live run data, reads the exact protected ref head and compares containment against that immutable SHA, and seals merged only when the admitted merge-group head is contained by that protected base; a later different-head merge settles the old attempt as dequeued. Terminal normalization preserves transfer, finalizer boundary, native and seal job, admitted provider attempt, protected-base head, containment result, and terminal readback coordinates. The public reusable workflow truthfully retains its single-flight v1 authority without advertising v2 migration, while bounded v2 remains a separate opt-in CLI, Node API, and schema contract; the tracked self-caller stays on public v4-alpha with matching stable and alpha locks, and transient train selection is dispatch-only. Next-development parity adds one versioned transition authority, one durable controller, one bounded reservation adapter, and pure public-contract recovery evidence while retaining the existing thin floating-channel callers byte-for-byte. The floating-consumer gate reuses the existing contract-world evaluator so SHA drift passes only under the selected lock's compatibility policy, breaking surface drift still fails closed, and external certification reconstructs the receipt from the observed workflow SHA rather than the lock's historical evidence SHA. Tail reseal adds no Stage Capsule effect or general rebuild authority: it verifies the exact retained four-platform bytes, admits one known macOS tail failure through live provider readback, fences signing and finalization to explicit credentials and Warrant identity, and requires standard candidate Passport plus provider and protected readback. Compatibility Facts parity isolates canonical encoding, temporal verification, lifecycle validation, fixture projection, public authority projection, and CLI adaptation into bounded modules; legacy digest and proof arrays are derived only from exact current Fact lineage. Publication Rehearsal adds no production release authority: the content-addressed capsule contract binds source, candidate, manifest, config, canonical data-only provider bindings, provider policy, observations and core version separately from filesystem, runtime and rehearsal-only provider authority; simulate, replay and explicitly authorized provider rehearsal all reuse the release-tail planner, while same-commit local dogfood resolves the new reusable contract and exact current runtime before external callers remain on floating v4-alpha. Cross-runtime candidate recovery preserves original runtime and provider roots and creates resume lineage only after exact public ref, tag, ancestry, npm version and integrity readback. Adopter Delivery restores the reviewed public v3 gate, drivers, Passport binding, N-1 bootstrap and exact archive loader through one public v4 surface while keeping provider and release authority explicit non-claims. Floating Alpha bootstrap uses only the existing exact resolver and protected Alpha private shell to move an otherwise stale floating shell, retains public v4 stable promotion, and removes itself after protected readback. CI lane change-budget enforcement adds a bounded parser, evaluator, guard, and tests without creating another merge authority.",
|
|
36
36
|
"governance": "legacy-debt-sunset-2026q4"
|
|
37
37
|
},
|
|
@@ -293,6 +293,7 @@
|
|
|
293
293
|
"sourcePaths": [
|
|
294
294
|
"packages/core/dev-delivery-proof.js",
|
|
295
295
|
"packages/core/dev-delivery-warrant-cancellation.js",
|
|
296
|
+
"packages/core/dev-delivery-warrant-legacy-recovery.js",
|
|
296
297
|
"packages/core/dev-delivery-warrant-qualification.js",
|
|
297
298
|
"packages/core/dev-delivery-warrant-settlement.js",
|
|
298
299
|
"packages/core/dev-delivery-warrant-state.js",
|
|
@@ -306,6 +307,7 @@
|
|
|
306
307
|
"testPaths": [
|
|
307
308
|
"tests/dev-delivery-warrant.test.mjs",
|
|
308
309
|
"tests/dev-delivery-warrant-command.test.mjs",
|
|
310
|
+
"tests/dev-delivery-warrant-legacy-recovery.test.mjs",
|
|
309
311
|
"tests/release-blocker-priority.test.mjs"
|
|
310
312
|
],
|
|
311
313
|
"migrationDisposition": "rebuild-in-rust-with-compatibility-projection",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"product": {
|
|
5
5
|
"name": "Buildchain",
|
|
6
6
|
"package": "@kungfu-tech/buildchain",
|
|
7
|
-
"version": "4.0.
|
|
7
|
+
"version": "4.0.2-alpha.0",
|
|
8
8
|
"repository": "https://github.com/kungfu-systems/buildchain"
|
|
9
9
|
},
|
|
10
10
|
"majorLine": "v4",
|
|
@@ -1646,7 +1646,7 @@
|
|
|
1646
1646
|
"resume-from-candidate-run is fail-closed and uses a fresh caller event instead of rerunning a frozen startup graph"
|
|
1647
1647
|
],
|
|
1648
1648
|
"breakingDigest": "sha256:9db8dd07152855d03ff30f9c571438593c689d3e8139fa45431d000f548242f5",
|
|
1649
|
-
"auditDigest": "sha256:
|
|
1649
|
+
"auditDigest": "sha256:1b77b563669a70c8e0a7c6d335f2ddcef9a95178d08e742ecf4aaf66652e7b4f",
|
|
1650
1650
|
"compatibleBreakingDigests": [
|
|
1651
1651
|
"sha256:aa30f22e3af0a89841310bdbdc900844dd95a66974db173fa140a71bbd7e82c0"
|
|
1652
1652
|
],
|
|
@@ -5173,7 +5173,7 @@
|
|
|
5173
5173
|
"missing receipts are non-qualifying and must not be represented as a successful controller run"
|
|
5174
5174
|
],
|
|
5175
5175
|
"breakingDigest": "sha256:015d8de793adbd4c539416be7d7512e18cc92097e629b0203fa06d2c183e98bd",
|
|
5176
|
-
"auditDigest": "sha256:
|
|
5176
|
+
"auditDigest": "sha256:1b77b563669a70c8e0a7c6d335f2ddcef9a95178d08e742ecf4aaf66652e7b4f"
|
|
5177
5177
|
},
|
|
5178
5178
|
{
|
|
5179
5179
|
"contractVersion": 1,
|
|
@@ -5399,5 +5399,5 @@
|
|
|
5399
5399
|
"compatibilityFactCutRoot": "sha256:f61b975d4a96c921cc4bd37fb3ed9a0596b47004fe34dc7219979d697e3707f9",
|
|
5400
5400
|
"compatibilityProofRegistryRoot": "sha256:b7194b811e4d3af2df4390bc4d1731e16a86215bd64ee18cb630dd5492f4fb63",
|
|
5401
5401
|
"compatibilityDigest": "sha256:20411029d83211dff426fb6535a608902129844a5ccb4788db77d3f81becb839",
|
|
5402
|
-
"contractDigest": "sha256:
|
|
5402
|
+
"contractDigest": "sha256:9b8272580aaff37c2ee2772f9a72ca9de83160994f8e7c12156cc3c60fbee5f5"
|
|
5403
5403
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"contract": "kungfu-buildchain-site-bundle",
|
|
4
|
-
"generatedAt": "2026-08-28T20:
|
|
5
|
-
"publishedAt": "2026-08-28T20:
|
|
4
|
+
"generatedAt": "2026-08-28T20:30:35.956Z",
|
|
5
|
+
"publishedAt": "2026-08-28T20:30:35.956Z",
|
|
6
6
|
"reproducible": true,
|
|
7
7
|
"timestampPolicy": "ci-injected",
|
|
8
8
|
"deterministicInputs": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"declared Buildchain surface manifest contract"
|
|
20
20
|
],
|
|
21
21
|
"sourceDateEpoch": "0",
|
|
22
|
-
"sourceRevision": "
|
|
22
|
+
"sourceRevision": "3881f9dea6fa750ce5e561fc86419a163ca19b90",
|
|
23
23
|
"timestampPolicyDetails": {
|
|
24
24
|
"contract": "kungfu-buildchain-surface-timestamp-policy",
|
|
25
25
|
"timestampFields": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"package": {
|
|
39
39
|
"name": "@kungfu-tech/buildchain",
|
|
40
|
-
"version": "4.0.
|
|
40
|
+
"version": "4.0.2-alpha.0",
|
|
41
41
|
"versionSource": "package.json#version"
|
|
42
42
|
},
|
|
43
43
|
"source": {
|
|
@@ -2279,7 +2279,7 @@
|
|
|
2279
2279
|
],
|
|
2280
2280
|
"maturity": "stable",
|
|
2281
2281
|
"sourcePath": "docs/dev-delivery-warrant.md",
|
|
2282
|
-
"digest": "sha256:
|
|
2282
|
+
"digest": "sha256:5feb5f64f19446f31023ceb1af830cd98383141aeacf689c89e980d7ce9f88ab",
|
|
2283
2283
|
"headings": [
|
|
2284
2284
|
{
|
|
2285
2285
|
"level": 1,
|
|
@@ -2317,7 +2317,7 @@
|
|
|
2317
2317
|
"anchor": "workflow-rollout-and-rollback"
|
|
2318
2318
|
}
|
|
2319
2319
|
],
|
|
2320
|
-
"markdown": "---\nstatus: accepted\nperiod: ongoing\ntheme: dev-delivery-warrant\ndoc_type: technical-reference\nsource_level: local-files\nconfidence: high\nsensitivity: public\nevidence_grade: A\nreview_state: self-reviewed\nlast_reviewed: 2026-08-17\nai_provenance:\n model_family: GPT-5\n product: Codex\n generated_at: 2026-08-11\n invisible_context: not asserted\n---\n\n# Dev Delivery Warrant Queue\n\nBuildchain's Dev Delivery Warrant Queue gives a qualified slow pull request a\ndurable, non-preemptive delivery turn without replacing GitHub Merge Queue as\nthe final protected-ref authority.\n\nThe queue is stored on a dedicated Git ref below\n`buildchain/dev-delivery-warrant/`. Every update creates a child Git commit and\nadvances the ref without force. The transition receipt binds the expected old\nstate root; a competing controller receives a visible non-fast-forward failure\ninstead of a second authority claim.\n\n## Contract\n\nA submission binds the repository, protected dev line, pull request, semantic\nsource identity, exact source head, native Assignment and Initiative roots,\nsource patch or tree intent, reusable Source Qualification Proof, plan,\naffected closure, dependencies, toolchain, delivery class, priority, attempts,\nand retained enqueue time.\n\nSelection is deterministic FIFO plus aging with bounded priority. Priority may\nreorder queued work, but it cannot preempt the active Warrant. Exactly one\ncandidate receives a `provisional` leased Warrant containing a fencing token,\nlease generation, expected-old state root, expiry, and the complete exact\nsource binding. It reserves the next protected-dev landing before expensive\nnative shards start, but it is not GitHub Merge Queue admission authority.\nHeartbeat extends only that generation. Native proof success atomically\nupgrades the same token and generation to `qualified`; only then may enqueue\nbegin. Expiry fences further mutations by the old token, but it does not prove\nthat the old native process stopped. The active Warrant therefore remains in\nplace until bounded termination is proven by rooted terminal evidence. Only\nthat exact fenced settlement may clear the holder and permit successor\nselection.\n\nA terminal event may cancel a candidate before selection without minting a\nWarrant. This transition is limited to an exact non-active queued candidate and\nbinds its candidate root, pull request, recorded source head, event-observed\nsource head, terminal event action, evidence root, and expected-old queue root.\nAn active candidate still requires its current fencing token and lease\ngeneration. Exact duplicate cancellation evidence is a visible no-op; identity,\nstate, event, or evidence drift fails closed.\n\nThe reusable terminal controller classifies authoritative completion,\ncancellation, supersession, native failure, and transient dequeue separately.\n`dequeued` retains only a provisional Warrant whose native worker may still be\nrunning: a fresh holder continues with the same generation and token, while an\nexpired holder waits for proof that its fenced worker stopped. A qualified or\nhistorical phase-less holder has no unproven native worker to fence, so its exact\ndequeue closes atomically and persists the rooted queued-successor wake. Queued\nwork may also settle as dequeued because it never started native execution. The\ncontroller uses one `settle` operation for active, queued, already-terminal,\nand never-admitted pull requests. An active Warrant still requires its exact\nfence and evidence. A matching queued cancellation is persisted normally. A\nduplicate terminal event replays the persisted wake, while a pull request that\nnever entered Warrant authority returns a rooted explicit no-op instead of\nfailing the workflow or inventing queue state.\n\nThe supported priority classes are `ordinary`, `expedited`, and `emergency`.\nThe queue does not infer an emergency: callers must choose it explicitly under\ntheir reviewed policy. Delivery classes are `non-native-fast`,\n`native-proof-required`, `cross-platform`, and `release`.\n\n## CI lane change budget\n\n`architecture/ci-lane-change-budget.json` pins the exact protected-Dev cut\nthat predates lane-budget enforcement. `scripts/check-ci-lane-change-budget.mjs`\ncompares the current workflow job set with that cut on every repository check.\nLegacy jobs remain readable without invented metadata, while every newly added\njob fails closed until its exact `<workflow>#<job>` lane declares:\n\n- merge or non-merge authority class;\n- trigger class;\n- concurrency scope and `cancel-in-progress` behavior;\n- expected runner-minutes per run;\n- cancellation/settlement behavior; and\n- merge-critical SLO impact, expected contribution, metric, and rationale.\n\nThe guard is repository policy only. It does not become another required\nGitHub status, acquire merge-queue authority, or relax Delivery Warrant,\nexact-head, approval, required-check, and protected-ref enforcement. A removed\nlane must also remove its declaration, so stale budget records cannot conceal\nworkflow drift.\n\nA release-blocker candidate may additionally carry a rooted priority claim\ncreated from a settled Release Train dual landing. The claim binds the exact\nAssignment, Initiative, repair, prior and successor cuts, candidate generation,\ncut candidate, Dev head, semantic patch, both landing evidence roots, and\npublication gate. Only a claim whose repository, protected base, Work roots,\nhead, patch, and claim root match the queued candidate enters the blocker lane.\nThat lane outranks not-yet-leased ordinary work, but never preempts or rewrites\nan active Warrant; unrelated, conflicted, mismatched, or fabricated claims fail\nclosed before selection.\n\n## Three proof authorities\n\nSource Qualification Proof is created from the cheap source-acceptance gate. It\nbinds the semantic source, exact source head and patch/tree intent, plan,\naffected closure, dependencies, toolchain, covered paths, and exact acceptance\nevidence. Ready state and approval are established before provisional\nselection.\n\nNative Qualification Proof is separate. Its v4 form binds semantic source and patch,\nplan, affected closure, dependency graph, toolchain, the exact execution\nenvironment contract, covered paths, native shard evidence, the exact dev\nbase used by the native composition, and the v3 native heartbeat-run receipt.\nThat receipt exposes and roots the exact repository, protected base, source\nhead, qualified base, toolchain, and environment binding established before\nprocess spawn. The proof carries the exact receipt bytes as well as repeating\nthe binding and receipt roots in its shard evidence. Public verification\nrecomputes those bytes and requires a successful outcome, positive heartbeat\ncount, exact command root, ordered start/completion/qualification timestamps,\nand the complete execution binding; caller-computed roots without the receipt\nbytes are not a v4 proof. Before reuse, the consumer roots the\ncomplete attributed Dev delta, including both sides of every rename, then\nclassifies it:\n\n- unchanged semantic roots plus an unrelated fully attributed base delta reuse\n native qualification and run only a cheap Project Cut replay. GitHub's `behind`\n state is accepted only when a rooted replay proof binds the exact current\n protected base, unchanged PR head and source patch, replay tree, required\n context roots, and a qualified `project.cut.merge-queue-admission/v1`\n receipt;\n- an overlapping delta reruns affected native shards or the full native plan;\n- an unknown or truncated graph, ambiguous rename, missing attribution, or\n changed source, plan, closure, dependency, toolchain, or environment root\n fails closed to full native qualification.\n\nHistorical Native Qualification Proof v1, v2, and v3 values remain readable,\nbut they cannot be reused because they do not carry the current v4 exact native\nexecution evidence. They fail closed to explicit native revalidation and\nproduce a v4 proof.\n\nThe reuse decision binds the exact old and current Dev heads, normalized changed\npaths and rename pairs in `baseDeltaRoot`. This makes local and hosted replay of\nthe same inputs byte-deterministic. Generated outputs that participate in the\naffected closure must be listed in `affected-paths-json`; a delta touching one\nof those surfaces is overlap, not a documentation-only advance.\n\nIntegration Delivery Proof is separate and cannot be cached across candidates.\nIt binds the exact current dev base, replay tree, GitHub `merge_group` head and\ntree, active Warrant fencing generation, Source Qualification Proof root, and\nfinal required-context roots. GitHub's exact merge-group checks remain the\nfinal integration authority.\n\n## CLI\n\nQueue commands are dry-run by default:\n\n```sh\nbuildchain dev warrant submit --repository owner/repository \\\n --branch dev/v4/v4.0 --pull-request 123 --source-head <sha> \\\n --assignment-root <root> --initiative-root <root> \\\n --source-identity-root <root> --source-patch-root <root> \\\n --source-proof-root <root> --plan-root <root> --closure-root <root> \\\n --dependency-root <root> --toolchain-root <root> \\\n --environment-root <root> \\\n --delivery-class native-proof-required\n\nbuildchain dev warrant select --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\n\nbuildchain dev proof native --branch dev/v4/v4.0 \\\n --source-head <sha> --qualified-base <sha> \\\n --environment-root <root> \\\n --native-execution-receipt native-heartbeat-run.json \\\n --affected-paths-json '[\"packages/native\"]' ...\n\nbuildchain dev proof classify-native --source-proof native-proof.json \\\n --current-base <sha> --graph-known true --attribution-complete true \\\n --changed-paths-json '[]' --renames-json '[]' ...\n\nbuildchain dev warrant qualify --repository owner/repository \\\n --branch dev/v4/v4.0 --fencing-token <root> --lease-generation 1 \\\n --native-proof native-proof.json \\\n --native-reuse-decision native-reuse-decision.json --execute\n\nbuildchain dev warrant cancel-queued --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> --pull-request 123 \\\n --expected-source-head <queued-sha> --observed-source-head <event-sha> \\\n --expected-old <queue-root> --event-action closed --outcome cancelled \\\n --evidence-root <terminal-event-root> --execute\n```\n\n`heartbeat`, `qualify`, `recover`, `close`, `settle`, `cancel-queued`, and `observe` use the same durable authority.\nWarrant-scoped mutations require the exact fencing token and lease generation.\n`close` also requires a rooted terminal evidence object.\n\nOn the v4 line, `observe` also has an explicit `--read-mode v4` candidate. It requires retained exact semantic-diff qualification and source binding, invokes the effect-disabled Rust projection, retains parity evidence, and returns the existing observation shape. The default and rollback mode remains `v3`; mutation commands ignore the read switch. See [`v4-delivery-warrant-read-candidate.md`](v4-delivery-warrant-read-candidate.md).\n\nExpensive native commands must run through `dev-delivery-native-run.mjs` (or an\nequivalent exact consumer). Before spawn it validates the environment and\nexecution roots and traverses the complete Linux `/proc` ancestry. An unreadable\nprocess environment or status is a failure, as is any variable name containing a\ngeneric auth, credential, key, password, secret, or token segment. The child\nstill receives only the fixed process-basics allowlist. The command root,\nexact execution binding and root, successful outcome, child start and completion\ntimes, and heartbeat count are included in the native receipt. The controller\nkeeps retained-fence heartbeats across the direct child lifetime and requires a\nfinal successful heartbeat after child exit; process-group termination on fence\nloss remains fail-closed runtime behavior rather than a claimed receipt field.\n\nThe reusable workflow does not run that controller in a credentialed job. A\nGitHub-hosted `native-execution` job has read-only checkout permission, no\nprovider write credential in the candidate step or its ancestry, and cannot\nqualify, settle, enqueue, or renew provider state. It copies only rooted proof\nand Warrant bytes into a dedicated staging directory and uploads that closed set.\nThe success artifact contains exactly its transfer manifest, Warrant, native\nresult, native proof, and reuse decision; the failed-native artifact contains\nexactly its transfer manifest, Warrant, canonical rooted failure, and\nprovider-settlement binding. Recursive verification rejects missing or extra\nentries, duplicate or case-colliding paths, traversal, symlinks, directories,\nother non-regular entries, non-canonical failure or manifest JSON bytes, byte\ndrift, and mutation between the first and second recursive membership\nsnapshots. A\ndependent GitHub-hosted finalizer downloads those bytes and uses live\nActions job readback to prove different positive job ids, different runner\nidentities, a matching run attempt, and strict native-completion-before-finalizer\nordering. It recomputes the canonical failure root and binds that exact root,\ntransfer root, native job, Warrant state and fence into the live provider\nboundary. Failure settlement consumes those verified coordinates directly; it\ndoes not synthesize a second failure. The boundary also roots a live open-PR\nhead and protected-ref readback. The trusted finalizer uses its provider credential only for\nthose GET readbacks until the byte transfer, runner boundary, and semantic native\nproof have passed independent verification. It then rereads the live PR head,\nprotected base, and Warrant fence before qualifying or settling. A missing or\ncorrupt artifact, unreadable `/proc`, same job or runner, invalid timestamp,\nself-hosted label, stale PR/base/fence, or readback mismatch fails closed. Native\nexit zero is only evidence input.\n\nProof commands create, verify, classify, and compose the two proof layers:\n\n```sh\nbuildchain dev proof source ...\nbuildchain dev proof classify --source-proof source-proof.json ...\nbuildchain dev proof replay ...\nbuildchain dev proof replay-proof \\\n --qualification-receipt project-cut-admission.json ...\nbuildchain dev proof integration --warrant-result warrant.json ...\n```\n\n## Opt-in bounded qualification and exclusive landing\n\nBuildchain also defines an explicit production opt-in that turns successful\nshadow evidence into a separate v2 authority state. It does not widen or\nreinterpret the v1 Warrant queue. The accepted\n[`Qualification Lease and Landing Warrant ADR`](dev-delivery-qualification-landing-adr.md)\nand `contracts/dev-delivery-authority-v2.schema.json` are authoritative.\n\nIn `bounded-qualification-landing` mode, a configured number of exact\nQualification Leases may coexist. Each lease carries\n`authority = qualification-only` and `mergeGroupAdmission = false`. Completing\nqualification records evidence and releases that lease. Qualified candidates\nthen wait for the one `Landing Warrant`, which alone carries\n`authority = merge-group-admission` and may be checked for `merge_group`\nadmission.\n\nConcurrency is granted only across disjoint rooted `qualificationDomains`.\nOverlap and unknown domains are held behind the active safety boundary with an\nexplicit content-rooted reason. `maxLandingOvertakes` prevents a slow older\ncandidate from being bypassed indefinitely, while `maxQualificationAttempts`\nturns repeated heartbeat loss into a rooted terminal failure. Every release\nreturns a deterministic rooted wake instruction; an exact duplicate release or\nrecovery is a state-root-preserving no-op.\n\nAn expired qualification-only lease may release its bounded compute slot. An\nexpired Landing Warrant does not release exclusive provider authority by time\nalone: recovery retains it and requires exact provider-stop or terminal\nsettlement evidence for the same token and generation before another landing\ncandidate can be selected. Expired cleanup invokes a separate independent\nprovider terminal verifier after candidate exit. Its rooted readback must match\nthe exact repository, protected base, authority state root, candidate, pull\nrequest, source head, Landing token and generation, provider run and job, and a\nfresh observation for that Warrant. Caller assertions, forged roots, wrong\nbindings, nonterminal states, and stale observations cannot release the slot.\nThe verifier reads the immutable historical run-attempt endpoint. A later rerun\nor synchronized PR head cannot rewrite the admitted attempt or prevent its\nterminal settlement; current PR identity and protected base still must match.\nThe reader rejects an empty run conclusion, nonterminal run or job state,\nunsupported job conclusion, or pull-request state outside `open|closed` before\nit can seal product-owned cleanup evidence.\n\nThe public two-phase workflow keeps heartbeat authority in a fourth,\nGitHub-hosted job on a runner domain distinct from admission, native execution,\nevidence sealing, and finalization. Each successful heartbeat records the exact\nexpected-old and next authority state roots plus its receipt root. The\ncredentialless native job holds only its immutable admission binding; the\nhosted coordinator alone renews durable state. After heartbeat loss it records\nthe exact current attempt but never invokes GitHub's run-scoped cancellation\nAPI, so a successor rerun cannot be cancelled through a stale coordinate. All boundary jobs must prove the exact\n`GitHub Actions` hosted runner group and reject `self-hosted`. The finalizer\nrereads the provider job set and live authority state, rejects missing\nor reordered receipt continuity, and requires the live state root to equal the\nreceipt's latest root before it can qualify, settle, or land.\n\nA terminal native failure retains the complete provider chain through every\nwrite-normalize-observe-remutate cycle: `transferRoot`,\n`finalizerBoundaryRoot`, `nativeJobId`, `sealJobId`, the exact admitted\n`providerAttempt`, and, when expiry cleanup was required, the independent\n`providerTerminalReadbackRoot`.\n\nBuildchain's tracked self-delivery caller invokes\n`kungfu-systems/buildchain/.github/workflows/dev-pr-auto-merge.yml@v4-alpha`.\nThe durable selector remains the floating alpha channel, the repository keeps\nmatching `.buildchain/contract-lock.json` (`v4`) and\n`.buildchain/alpha-contract-lock.json` (`v4-alpha`), and a train runtime may be\nselected only through the trusted, non-persistent `workflow_dispatch` input.\nNo candidate SHA or train ref is persisted in the caller.\n\nOnly complete `verified-native-qualification` evidence can mint a new Landing\nWarrant. Migrated `legacy-compatibility-only` evidence may preserve an exact\nalready-active historical Landing fence, but it cannot create a successor\nLanding or acquire native proof authority.\n\nThe public command family is explicit:\n\n```sh\nbuildchain dev authority migrate --repository owner/repository \\\n --branch dev/v4/v4.0 --execute --json\nbuildchain dev authority submit --repository owner/repository \\\n --branch dev/v4/v4.0 --environment-root <root> \\\n --qualification-domains '[\"<root>\"]' ... --execute\nbuildchain dev authority lease-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 --execute\nbuildchain dev authority complete-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --evidence-root <qualification-root> --execute\nbuildchain dev authority lease-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --provider-attempt admitted-provider-attempt.json --execute\nbuildchain dev authority recover --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority admit-merge-group --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --merge-group-head <sha>\n```\n\nTerminal settlement releases either authority immediately from exact evidence;\nit does not wait for TTL. Exact duplicate settlement is a state-root-preserving\nno-op. The default `buildchain dev warrant` commands, v1 state bytes, and\nsingle-flight behavior do not change while this mode is off.\n\nMigration also accepts the historical non-native v1 form whose active Warrant\npredates the `phase` field. It preserves that exact fence as Landing authority\nand records a schema-safe `legacy-compatibility-only` qualification carrying the\nexact legacy state root, token, generation, source proof, and phase. Fields that\nv1 never established remain explicitly null, including the phase-less\nqualification time and every native proof field. A migrated qualified v1\nWarrant retains its historical proof roots as compatibility facts, but\n`nativeProofAuthority` remains false because migration cannot reconstruct the\nv2 execution binding or qualification contract. Neither form can claim new\nnative proof or reuse authority. Phase-less native candidates remain invalid.\n\n## Workflow rollout and rollback\n\nThe reusable `dev-pr-auto-merge.yml` supports three explicit rollout modes:\n\n- `off` preserves the previous exact-head admission controller;\n- `shadow` qualifies the source and emits a read-only queue submission plan;\n- `required` persists the submission, selects a provisional Warrant, runs or\n reuses semantic native proof under heartbeat, atomically qualifies the same\n fence, and refuses GitHub enqueue unless the immutable queue commit, state root, active Warrant, and\n selected candidate all pass exact readback validation. Immediately before\n enqueue, the controller writes and then reads back both the exact-head queue\n admission status and active lease status. Only after those statuses are\n visible at their required states does it reread the pull request head,\n protected base, native merge queue, and current protected Warrant state. The\n final rooted admission transaction binds the frozen base, source head,\n candidate, fencing token, generation, native proof roots, Project Cut proof,\n and both status contexts. Status propagation is retried before enqueue;\n base, head, queue-predecessor, lease, or Warrant drift revokes both statuses\n without attempting enqueue. A previously valid result is not authority after terminal\n closeout. Re-running qualification for the same selected head may regenerate\n timestamped proof bytes, but it retains the immutable active Warrant and its\n originally selected proof instead of rewriting or rejecting that attempt.\n Each candidate also retains the exact successful source workflow run. If a\n controller discovers that another candidate owns the active Warrant, a\n configured consumer workflow is dispatched immediately for that exact PR,\n head, source run, Assignment and Initiative, source identity and patch,\n plan, closure, dependency, toolchain, environment, affected paths, delivery\n class, and priority; the candidate is not left waiting for a patrol cron.\n The shipped Buildchain caller and native template configure this handoff path\n and accept the same complete input contract. A historical phase-less owner\n uses the distinct `legacy-phase-less-active-owner` command path. That path\n carries the exact queue state root observed before its duplicate submission,\n fencing token, generation, PR, head, and source-run binding. The submission\n receipt proves that pre-transition root even though the queue transition\n advances the current state root. The path omits `environment-root`, `native-command`, and\n `native-command-root`, and rejects readback drift. It therefore resumes the\n historical non-native authority without inventing a native command contract\n or upgrading the owner to native proof authority.\n\n The PR-controlled native candidate runs in a distinct GitHub-hosted job with\n no provider write credential in the step or process ancestry. The dependent\n credentialed finalizer runs on another live-readback-proven GitHub-hosted job\n and runner, verifies the content-addressed transfer, then independently rereads\n the PR, protected base, and provider fence before qualification or settlement.\n Detached descendants, including descendants that unset runner tracking, remain\n in the native runner authority domain and cannot enter the fresh finalizer\n domain. Exit zero alone is never treated as provider mutation authority,\n Landing authority, or completed delivery.\n\n Persistent self-hosted runners are intentionally outside this contract. A\n `needs` edge alone does not prove process cleanup or a new authority domain, so\n the finalizer rejects a self-hosted label. Supporting self-hosted execution\n would require separately attested one-job runner destruction and a provider\n readback contract at least as strong as the GitHub-hosted boundary.\n\n Required-mode admission also performs a latest-base Project Cut immediately\n before enqueue. If the protected base advanced, the controller reclassifies\n the exact attributed delta against the rooted native proof. Only a disjoint,\n fully attributed move may reuse that proof; overlap, unknown attribution,\n missing composition, or merge conflict fails with a stable pre-enqueue reason.\n The rooted Project Cut receipt binds the frozen and admitted base SHAs,\n GitHub's exact synthetic merge commit and replay tree, and the unchanged PR\n head. A final base/head/queue/Warrant compare-and-swap readback must still\n match that receipt before the enqueue mutation is attempted.\n\n The protected branch ref is the base authority for that compare-and-swap.\n A pull request's `base.sha` may remain an older composition snapshot while\n GitHub reports the pull request as behind, so it is diagnostic rather than a\n substitute for the separately read protected ref and rooted Project Cut.\n\nFor a required native delivery class, the reusable controller rejects a\nmissing or malformed environment root before runtime checkout, candidate\nsubmission, Warrant selection, or native execution. The input remains\nconditionally optional so `off`, `shadow`, and `non-native-fast` callers keep\ntheir documented behavior.\n\nThe controller persists a completed native proof before its final base\nreclassification. A later exact retry can supply that proof and avoid the\nexpensive native command when the rooted delta still proves reuse safe. A\nduplicate dispatch against the same already-qualified Warrant returns the same\nproof and reuse roots plus a rooted qualification replay output without another\nqueue mutation. Both result forms carry\n`landingAuthority: false`: only the live qualified Warrant plus exact-head\nGitHub merge-queue admission can authorize landing.\n\nThe required controller checks the protected base again after native work. A\ndisjoint attributed delta reuses the proof. Overlap or unknown attribution\ntriggers one automatic revalidation on the latest base; continued overlap,\nnative failure, cancellation, semantic head movement, or an unrecoverable merge\nconflict closes the exact fence. The next queued candidate is notified through\nthe `buildchain-dev-delivery-wake` repository event. Its complete semantic\ncandidate is carried under the single `client_payload.candidate` envelope so\nGitHub's ten-property top-level limit cannot discard proof bindings. If\ncancellation prevents cleanup, lease expiry recovers retained queue age and\nmints a new fence.\n\nConsumers should deploy `shadow` first, inspect receipts, then change their\nprotected caller to `required`. Rollback is a reviewed caller change back to\n`off`; it does not delete queue history or reinterpret old receipts. The\nterminal reusable workflow creates the exact Integration Delivery Proof for a\nmerged candidate (or accepts explicit evidence for another terminal outcome),\nthen closes only the current fencing generation. The separate queued\ncancellation reusable workflow cannot close an active generation; it advances\nthe state ref only when the caller's complete terminal binding and expected-old\nroot still match. A delayed `dequeued` event is ignored when GitHub readback\nshows the same exact PR head is already queued again, so an earlier queue event\ncannot close a newer active Warrant generation.\n\nBuildchain uses the same contract for its own protected dev line through\n`buildchain-dev-delivery.yml`. The manual caller requires the exact PR head and\nsemantic source roots, accepts an optional reusable native proof, keeps both\nthe durable public selector and explicit runtime input on `v4-alpha`, selects\n`delivery-warrant-mode: required`, and targets GitHub Merge Queue. It does not\noffer an `off` switch: rollback is a reviewed change to this caller, not an\noperator-time weakening of a specific delivery attempt.\n\n`templates/native-dev-delivery.yml` provides the corresponding protected-dev\nconsumer workflow. It supports both explicit dispatch and the bounded wake\nevent, calls the allowed floating `@v4-alpha` selector, explicitly passes the v4\nruntime ref that locks every delivery job to the same checkout, and keeps the\nnative command in the consumer repository rather than inventing\nprovider-specific shards. Both callers explicitly bind the queue-admission\nand active-lease status contexts so write/readback fencing uses the same exact\nnames. The reusable workflow defaults the explicit runtime input to\n`v4-alpha`; an empty input or any v3 selector fails before the first runtime\ncheckout.\n\nThis mechanism schedules protected delivery only. It does not serialize local\ndevelopment, source-only checks, unrelated channels, release publication, or\nrunner provisioning. It never grants authority to enable cloud runner\ncampaigns."
|
|
2320
|
+
"markdown": "---\nstatus: accepted\nperiod: ongoing\ntheme: dev-delivery-warrant\ndoc_type: technical-reference\nsource_level: local-files\nconfidence: high\nsensitivity: public\nevidence_grade: A\nreview_state: self-reviewed\nlast_reviewed: 2026-08-17\nai_provenance:\n model_family: GPT-5\n product: Codex\n generated_at: 2026-08-11\n invisible_context: not asserted\n---\n\n# Dev Delivery Warrant Queue\n\nBuildchain's Dev Delivery Warrant Queue gives a qualified slow pull request a\ndurable, non-preemptive delivery turn without replacing GitHub Merge Queue as\nthe final protected-ref authority.\n\nThe queue is stored on a dedicated Git ref below\n`buildchain/dev-delivery-warrant/`. Every update creates a child Git commit and\nadvances the ref without force. The transition receipt binds the expected old\nstate root; a competing controller receives a visible non-fast-forward failure\ninstead of a second authority claim.\n\n## Contract\n\nA submission binds the repository, protected dev line, pull request, semantic\nsource identity, exact source head, native Assignment and Initiative roots,\nsource patch or tree intent, reusable Source Qualification Proof, plan,\naffected closure, dependencies, toolchain, delivery class, priority, attempts,\nand retained enqueue time.\n\nSelection is deterministic FIFO plus aging with bounded priority. Priority may\nreorder queued work, but it cannot preempt the active Warrant. Exactly one\ncandidate receives a `provisional` leased Warrant containing a fencing token,\nlease generation, expected-old state root, expiry, and the complete exact\nsource binding. It reserves the next protected-dev landing before expensive\nnative shards start, but it is not GitHub Merge Queue admission authority.\nHeartbeat extends only that generation. Native proof success atomically\nupgrades the same token and generation to `qualified`; only then may enqueue\nbegin. Expiry fences further mutations by the old token, but it does not prove\nthat the old native process stopped. The active Warrant therefore remains in\nplace until bounded termination is proven by rooted terminal evidence. Only\nthat exact fenced settlement may clear the holder and permit successor\nselection.\n\nA terminal event may cancel a candidate before selection without minting a\nWarrant. This transition is limited to an exact non-active queued candidate and\nbinds its candidate root, pull request, recorded source head, event-observed\nsource head, terminal event action, evidence root, and expected-old queue root.\nAn active candidate still requires its current fencing token and lease\ngeneration. Exact duplicate cancellation evidence is a visible no-op; identity,\nstate, event, or evidence drift fails closed.\n\nThe reusable terminal controller classifies authoritative completion,\ncancellation, supersession, native failure, and transient dequeue separately.\n`dequeued` retains only a provisional Warrant whose native worker may still be\nrunning: a fresh holder continues with the same generation and token, while an\nexpired holder waits for proof that its fenced worker stopped. A qualified or\nhistorical phase-less holder has no unproven native worker to fence, so its exact\ndequeue closes atomically and persists the rooted queued-successor wake. Queued\nwork may also settle as dequeued because it never started native execution. The\ncontroller uses one `settle` operation for active, queued, already-terminal,\nand never-admitted pull requests. An active Warrant still requires its exact\nfence and evidence. A matching queued cancellation is persisted normally. A\nduplicate terminal event replays the persisted wake, while a pull request that\nnever entered Warrant authority returns a rooted explicit no-op instead of\nfailing the workflow or inventing queue state.\n\nThe supported priority classes are `ordinary`, `expedited`, and `emergency`.\nThe queue does not infer an emergency: callers must choose it explicitly under\ntheir reviewed policy. Delivery classes are `non-native-fast`,\n`native-proof-required`, `cross-platform`, and `release`.\n\n## CI lane change budget\n\n`architecture/ci-lane-change-budget.json` pins the exact protected-Dev cut\nthat predates lane-budget enforcement. `scripts/check-ci-lane-change-budget.mjs`\ncompares the current workflow job set with that cut on every repository check.\nLegacy jobs remain readable without invented metadata, while every newly added\njob fails closed until its exact `<workflow>#<job>` lane declares:\n\n- merge or non-merge authority class;\n- trigger class;\n- concurrency scope and `cancel-in-progress` behavior;\n- expected runner-minutes per run;\n- cancellation/settlement behavior; and\n- merge-critical SLO impact, expected contribution, metric, and rationale.\n\nThe guard is repository policy only. It does not become another required\nGitHub status, acquire merge-queue authority, or relax Delivery Warrant,\nexact-head, approval, required-check, and protected-ref enforcement. A removed\nlane must also remove its declaration, so stale budget records cannot conceal\nworkflow drift.\n\nA release-blocker candidate may additionally carry a rooted priority claim\ncreated from a settled Release Train dual landing. The claim binds the exact\nAssignment, Initiative, repair, prior and successor cuts, candidate generation,\ncut candidate, Dev head, semantic patch, both landing evidence roots, and\npublication gate. Only a claim whose repository, protected base, Work roots,\nhead, patch, and claim root match the queued candidate enters the blocker lane.\nThat lane outranks not-yet-leased ordinary work, but never preempts or rewrites\nan active Warrant; unrelated, conflicted, mismatched, or fabricated claims fail\nclosed before selection.\n\n## Three proof authorities\n\nSource Qualification Proof is created from the cheap source-acceptance gate. It\nbinds the semantic source, exact source head and patch/tree intent, plan,\naffected closure, dependencies, toolchain, covered paths, and exact acceptance\nevidence. Ready state and approval are established before provisional\nselection.\n\nNative Qualification Proof is separate. Its v4 form binds semantic source and patch,\nplan, affected closure, dependency graph, toolchain, the exact execution\nenvironment contract, covered paths, native shard evidence, the exact dev\nbase used by the native composition, and the v3 native heartbeat-run receipt.\nThat receipt exposes and roots the exact repository, protected base, source\nhead, qualified base, toolchain, and environment binding established before\nprocess spawn. The proof carries the exact receipt bytes as well as repeating\nthe binding and receipt roots in its shard evidence. Public verification\nrecomputes those bytes and requires a successful outcome, positive heartbeat\ncount, exact command root, ordered start/completion/qualification timestamps,\nand the complete execution binding; caller-computed roots without the receipt\nbytes are not a v4 proof. Before reuse, the consumer roots the\ncomplete attributed Dev delta, including both sides of every rename, then\nclassifies it:\n\n- unchanged semantic roots plus an unrelated fully attributed base delta reuse\n native qualification and run only a cheap Project Cut replay. GitHub's `behind`\n state is accepted only when a rooted replay proof binds the exact current\n protected base, unchanged PR head and source patch, replay tree, required\n context roots, and a qualified `project.cut.merge-queue-admission/v1`\n receipt;\n- an overlapping delta reruns affected native shards or the full native plan;\n- an unknown or truncated graph, ambiguous rename, missing attribution, or\n changed source, plan, closure, dependency, toolchain, or environment root\n fails closed to full native qualification.\n\nHistorical Native Qualification Proof v1, v2, and v3 values remain readable,\nbut they cannot be reused because they do not carry the current v4 exact native\nexecution evidence. They fail closed to explicit native revalidation and\nproduce a v4 proof.\n\nThe reuse decision binds the exact old and current Dev heads, normalized changed\npaths and rename pairs in `baseDeltaRoot`. This makes local and hosted replay of\nthe same inputs byte-deterministic. Generated outputs that participate in the\naffected closure must be listed in `affected-paths-json`; a delta touching one\nof those surfaces is overlap, not a documentation-only advance.\n\nIntegration Delivery Proof is separate and cannot be cached across candidates.\nIt binds the exact current dev base, replay tree, GitHub `merge_group` head and\ntree, active Warrant fencing generation, Source Qualification Proof root, and\nfinal required-context roots. GitHub's exact merge-group checks remain the\nfinal integration authority.\n\n## CLI\n\nQueue commands are dry-run by default:\n\n```sh\nbuildchain dev warrant submit --repository owner/repository \\\n --branch dev/v4/v4.0 --pull-request 123 --source-head <sha> \\\n --assignment-root <root> --initiative-root <root> \\\n --source-identity-root <root> --source-patch-root <root> \\\n --source-proof-root <root> --plan-root <root> --closure-root <root> \\\n --dependency-root <root> --toolchain-root <root> \\\n --environment-root <root> \\\n --delivery-class native-proof-required\n\nbuildchain dev warrant select --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\n\nbuildchain dev proof native --branch dev/v4/v4.0 \\\n --source-head <sha> --qualified-base <sha> \\\n --environment-root <root> \\\n --native-execution-receipt native-heartbeat-run.json \\\n --affected-paths-json '[\"packages/native\"]' ...\n\nbuildchain dev proof classify-native --source-proof native-proof.json \\\n --current-base <sha> --graph-known true --attribution-complete true \\\n --changed-paths-json '[]' --renames-json '[]' ...\n\nbuildchain dev warrant qualify --repository owner/repository \\\n --branch dev/v4/v4.0 --fencing-token <root> --lease-generation 1 \\\n --native-proof native-proof.json \\\n --native-reuse-decision native-reuse-decision.json --execute\n\nbuildchain dev warrant cancel-queued --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> --pull-request 123 \\\n --expected-source-head <queued-sha> --observed-source-head <event-sha> \\\n --expected-old <queue-root> --event-action closed --outcome cancelled \\\n --evidence-root <terminal-event-root> --execute\n```\n\n`heartbeat`, `qualify`, `recover`, `close`, `settle`, `cancel-queued`, and `observe` use the same durable authority.\nWarrant-scoped mutations require the exact fencing token and lease generation.\n`close` also requires a rooted terminal evidence object.\n\nLegacy v3 queues that predate the native command contract can be observed but\ncannot enter ordinary mutation paths. If every live legacy candidate has an\nexact completed failed hosted run with zero nonterminal jobs, an operator may\natomically terminalize that complete live set:\n\n```sh\nbuildchain dev warrant recover-legacy-terminal \\\n --repository owner/repository --branch dev/v4/v4.0 \\\n --expected-old sha256:<current-state-root> \\\n --legacy-terminal-recovery legacy-terminal-recovery.json --execute\n```\n\nThe request must cover every live legacy native candidate exactly once and\nbind each stored candidate, source workflow run, terminal provider result, and\ncontent-addressed evidence object. Each evidence object carries the exact\nprovider job identities, attempts, conclusions, and completion timestamps; all\njobs must be terminal and at least one must have failed. The transition writes\none expected-old state update and requires the resulting queue to pass the\ncurrent strict native-proof contract. The recovery cannot qualify, merge,\nrequeue, or partially advance a legacy authority state.\n\nOn the v4 line, `observe` also has an explicit `--read-mode v4` candidate. It requires retained exact semantic-diff qualification and source binding, invokes the effect-disabled Rust projection, retains parity evidence, and returns the existing observation shape. The default and rollback mode remains `v3`; mutation commands ignore the read switch. See [`v4-delivery-warrant-read-candidate.md`](v4-delivery-warrant-read-candidate.md).\n\nExpensive native commands must run through `dev-delivery-native-run.mjs` (or an\nequivalent exact consumer). Before spawn it validates the environment and\nexecution roots and traverses the complete Linux `/proc` ancestry. An unreadable\nprocess environment or status is a failure, as is any variable name containing a\ngeneric auth, credential, key, password, secret, or token segment. The child\nstill receives only the fixed process-basics allowlist. The command root,\nexact execution binding and root, successful outcome, child start and completion\ntimes, and heartbeat count are included in the native receipt. The controller\nkeeps retained-fence heartbeats across the direct child lifetime and requires a\nfinal successful heartbeat after child exit; process-group termination on fence\nloss remains fail-closed runtime behavior rather than a claimed receipt field.\n\nThe reusable workflow does not run that controller in a credentialed job. A\nGitHub-hosted `native-execution` job has read-only checkout permission, no\nprovider write credential in the candidate step or its ancestry, and cannot\nqualify, settle, enqueue, or renew provider state. It copies only rooted proof\nand Warrant bytes into a dedicated staging directory and uploads that closed set.\nThe success artifact contains exactly its transfer manifest, Warrant, native\nresult, native proof, and reuse decision; the failed-native artifact contains\nexactly its transfer manifest, Warrant, canonical rooted failure, and\nprovider-settlement binding. Recursive verification rejects missing or extra\nentries, duplicate or case-colliding paths, traversal, symlinks, directories,\nother non-regular entries, non-canonical failure or manifest JSON bytes, byte\ndrift, and mutation between the first and second recursive membership\nsnapshots. A\ndependent GitHub-hosted finalizer downloads those bytes and uses live\nActions job readback to prove different positive job ids, different runner\nidentities, a matching run attempt, and strict native-completion-before-finalizer\nordering. It recomputes the canonical failure root and binds that exact root,\ntransfer root, native job, Warrant state and fence into the live provider\nboundary. Failure settlement consumes those verified coordinates directly; it\ndoes not synthesize a second failure. The boundary also roots a live open-PR\nhead and protected-ref readback. The trusted finalizer uses its provider credential only for\nthose GET readbacks until the byte transfer, runner boundary, and semantic native\nproof have passed independent verification. It then rereads the live PR head,\nprotected base, and Warrant fence before qualifying or settling. A missing or\ncorrupt artifact, unreadable `/proc`, same job or runner, invalid timestamp,\nself-hosted label, stale PR/base/fence, or readback mismatch fails closed. Native\nexit zero is only evidence input.\n\nProof commands create, verify, classify, and compose the two proof layers:\n\n```sh\nbuildchain dev proof source ...\nbuildchain dev proof classify --source-proof source-proof.json ...\nbuildchain dev proof replay ...\nbuildchain dev proof replay-proof \\\n --qualification-receipt project-cut-admission.json ...\nbuildchain dev proof integration --warrant-result warrant.json ...\n```\n\n## Opt-in bounded qualification and exclusive landing\n\nBuildchain also defines an explicit production opt-in that turns successful\nshadow evidence into a separate v2 authority state. It does not widen or\nreinterpret the v1 Warrant queue. The accepted\n[`Qualification Lease and Landing Warrant ADR`](dev-delivery-qualification-landing-adr.md)\nand `contracts/dev-delivery-authority-v2.schema.json` are authoritative.\n\nIn `bounded-qualification-landing` mode, a configured number of exact\nQualification Leases may coexist. Each lease carries\n`authority = qualification-only` and `mergeGroupAdmission = false`. Completing\nqualification records evidence and releases that lease. Qualified candidates\nthen wait for the one `Landing Warrant`, which alone carries\n`authority = merge-group-admission` and may be checked for `merge_group`\nadmission.\n\nConcurrency is granted only across disjoint rooted `qualificationDomains`.\nOverlap and unknown domains are held behind the active safety boundary with an\nexplicit content-rooted reason. `maxLandingOvertakes` prevents a slow older\ncandidate from being bypassed indefinitely, while `maxQualificationAttempts`\nturns repeated heartbeat loss into a rooted terminal failure. Every release\nreturns a deterministic rooted wake instruction; an exact duplicate release or\nrecovery is a state-root-preserving no-op.\n\nAn expired qualification-only lease may release its bounded compute slot. An\nexpired Landing Warrant does not release exclusive provider authority by time\nalone: recovery retains it and requires exact provider-stop or terminal\nsettlement evidence for the same token and generation before another landing\ncandidate can be selected. Expired cleanup invokes a separate independent\nprovider terminal verifier after candidate exit. Its rooted readback must match\nthe exact repository, protected base, authority state root, candidate, pull\nrequest, source head, Landing token and generation, provider run and job, and a\nfresh observation for that Warrant. Caller assertions, forged roots, wrong\nbindings, nonterminal states, and stale observations cannot release the slot.\nThe verifier reads the immutable historical run-attempt endpoint. A later rerun\nor synchronized PR head cannot rewrite the admitted attempt or prevent its\nterminal settlement; current PR identity and protected base still must match.\nThe reader rejects an empty run conclusion, nonterminal run or job state,\nunsupported job conclusion, or pull-request state outside `open|closed` before\nit can seal product-owned cleanup evidence.\n\nThe public two-phase workflow keeps heartbeat authority in a fourth,\nGitHub-hosted job on a runner domain distinct from admission, native execution,\nevidence sealing, and finalization. Each successful heartbeat records the exact\nexpected-old and next authority state roots plus its receipt root. The\ncredentialless native job holds only its immutable admission binding; the\nhosted coordinator alone renews durable state. After heartbeat loss it records\nthe exact current attempt but never invokes GitHub's run-scoped cancellation\nAPI, so a successor rerun cannot be cancelled through a stale coordinate. All boundary jobs must prove the exact\n`GitHub Actions` hosted runner group and reject `self-hosted`. The finalizer\nrereads the provider job set and live authority state, rejects missing\nor reordered receipt continuity, and requires the live state root to equal the\nreceipt's latest root before it can qualify, settle, or land.\n\nA terminal native failure retains the complete provider chain through every\nwrite-normalize-observe-remutate cycle: `transferRoot`,\n`finalizerBoundaryRoot`, `nativeJobId`, `sealJobId`, the exact admitted\n`providerAttempt`, and, when expiry cleanup was required, the independent\n`providerTerminalReadbackRoot`.\n\nBuildchain's tracked self-delivery caller invokes\n`kungfu-systems/buildchain/.github/workflows/dev-pr-auto-merge.yml@v4-alpha`.\nThe durable selector remains the floating alpha channel, the repository keeps\nmatching `.buildchain/contract-lock.json` (`v4`) and\n`.buildchain/alpha-contract-lock.json` (`v4-alpha`), and a train runtime may be\nselected only through the trusted, non-persistent `workflow_dispatch` input.\nNo candidate SHA or train ref is persisted in the caller.\n\nOnly complete `verified-native-qualification` evidence can mint a new Landing\nWarrant. Migrated `legacy-compatibility-only` evidence may preserve an exact\nalready-active historical Landing fence, but it cannot create a successor\nLanding or acquire native proof authority.\n\nThe public command family is explicit:\n\n```sh\nbuildchain dev authority migrate --repository owner/repository \\\n --branch dev/v4/v4.0 --execute --json\nbuildchain dev authority submit --repository owner/repository \\\n --branch dev/v4/v4.0 --environment-root <root> \\\n --qualification-domains '[\"<root>\"]' ... --execute\nbuildchain dev authority lease-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 --execute\nbuildchain dev authority complete-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --evidence-root <qualification-root> --execute\nbuildchain dev authority lease-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --provider-attempt admitted-provider-attempt.json --execute\nbuildchain dev authority recover --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority admit-merge-group --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --merge-group-head <sha>\n```\n\nTerminal settlement releases either authority immediately from exact evidence;\nit does not wait for TTL. Exact duplicate settlement is a state-root-preserving\nno-op. The default `buildchain dev warrant` commands, v1 state bytes, and\nsingle-flight behavior do not change while this mode is off.\n\nMigration also accepts the historical non-native v1 form whose active Warrant\npredates the `phase` field. It preserves that exact fence as Landing authority\nand records a schema-safe `legacy-compatibility-only` qualification carrying the\nexact legacy state root, token, generation, source proof, and phase. Fields that\nv1 never established remain explicitly null, including the phase-less\nqualification time and every native proof field. A migrated qualified v1\nWarrant retains its historical proof roots as compatibility facts, but\n`nativeProofAuthority` remains false because migration cannot reconstruct the\nv2 execution binding or qualification contract. Neither form can claim new\nnative proof or reuse authority. Phase-less native candidates remain invalid.\n\n## Workflow rollout and rollback\n\nThe reusable `dev-pr-auto-merge.yml` supports three explicit rollout modes:\n\n- `off` preserves the previous exact-head admission controller;\n- `shadow` qualifies the source and emits a read-only queue submission plan;\n- `required` persists the submission, selects a provisional Warrant, runs or\n reuses semantic native proof under heartbeat, atomically qualifies the same\n fence, and refuses GitHub enqueue unless the immutable queue commit, state root, active Warrant, and\n selected candidate all pass exact readback validation. Immediately before\n enqueue, the controller writes and then reads back both the exact-head queue\n admission status and active lease status. Only after those statuses are\n visible at their required states does it reread the pull request head,\n protected base, native merge queue, and current protected Warrant state. The\n final rooted admission transaction binds the frozen base, source head,\n candidate, fencing token, generation, native proof roots, Project Cut proof,\n and both status contexts. Status propagation is retried before enqueue;\n base, head, queue-predecessor, lease, or Warrant drift revokes both statuses\n without attempting enqueue. A previously valid result is not authority after terminal\n closeout. Re-running qualification for the same selected head may regenerate\n timestamped proof bytes, but it retains the immutable active Warrant and its\n originally selected proof instead of rewriting or rejecting that attempt.\n Each candidate also retains the exact successful source workflow run. If a\n controller discovers that another candidate owns the active Warrant, a\n configured consumer workflow is dispatched immediately for that exact PR,\n head, source run, Assignment and Initiative, source identity and patch,\n plan, closure, dependency, toolchain, environment, affected paths, delivery\n class, and priority; the candidate is not left waiting for a patrol cron.\n The shipped Buildchain caller and native template configure this handoff path\n and accept the same complete input contract. A historical phase-less owner\n uses the distinct `legacy-phase-less-active-owner` command path. That path\n carries the exact queue state root observed before its duplicate submission,\n fencing token, generation, PR, head, and source-run binding. The submission\n receipt proves that pre-transition root even though the queue transition\n advances the current state root. The path omits `environment-root`, `native-command`, and\n `native-command-root`, and rejects readback drift. It therefore resumes the\n historical non-native authority without inventing a native command contract\n or upgrading the owner to native proof authority.\n\n The PR-controlled native candidate runs in a distinct GitHub-hosted job with\n no provider write credential in the step or process ancestry. The dependent\n credentialed finalizer runs on another live-readback-proven GitHub-hosted job\n and runner, verifies the content-addressed transfer, then independently rereads\n the PR, protected base, and provider fence before qualification or settlement.\n Detached descendants, including descendants that unset runner tracking, remain\n in the native runner authority domain and cannot enter the fresh finalizer\n domain. Exit zero alone is never treated as provider mutation authority,\n Landing authority, or completed delivery.\n\n Persistent self-hosted runners are intentionally outside this contract. A\n `needs` edge alone does not prove process cleanup or a new authority domain, so\n the finalizer rejects a self-hosted label. Supporting self-hosted execution\n would require separately attested one-job runner destruction and a provider\n readback contract at least as strong as the GitHub-hosted boundary.\n\n Required-mode admission also performs a latest-base Project Cut immediately\n before enqueue. If the protected base advanced, the controller reclassifies\n the exact attributed delta against the rooted native proof. Only a disjoint,\n fully attributed move may reuse that proof; overlap, unknown attribution,\n missing composition, or merge conflict fails with a stable pre-enqueue reason.\n The rooted Project Cut receipt binds the frozen and admitted base SHAs,\n GitHub's exact synthetic merge commit and replay tree, and the unchanged PR\n head. A final base/head/queue/Warrant compare-and-swap readback must still\n match that receipt before the enqueue mutation is attempted.\n\n The protected branch ref is the base authority for that compare-and-swap.\n A pull request's `base.sha` may remain an older composition snapshot while\n GitHub reports the pull request as behind, so it is diagnostic rather than a\n substitute for the separately read protected ref and rooted Project Cut.\n\nFor a required native delivery class, the reusable controller rejects a\nmissing or malformed environment root before runtime checkout, candidate\nsubmission, Warrant selection, or native execution. The input remains\nconditionally optional so `off`, `shadow`, and `non-native-fast` callers keep\ntheir documented behavior.\n\nThe controller persists a completed native proof before its final base\nreclassification. A later exact retry can supply that proof and avoid the\nexpensive native command when the rooted delta still proves reuse safe. A\nduplicate dispatch against the same already-qualified Warrant returns the same\nproof and reuse roots plus a rooted qualification replay output without another\nqueue mutation. Both result forms carry\n`landingAuthority: false`: only the live qualified Warrant plus exact-head\nGitHub merge-queue admission can authorize landing.\n\nThe required controller checks the protected base again after native work. A\ndisjoint attributed delta reuses the proof. Overlap or unknown attribution\ntriggers one automatic revalidation on the latest base; continued overlap,\nnative failure, cancellation, semantic head movement, or an unrecoverable merge\nconflict closes the exact fence. The next queued candidate is notified through\nthe `buildchain-dev-delivery-wake` repository event. Its complete semantic\ncandidate is carried under the single `client_payload.candidate` envelope so\nGitHub's ten-property top-level limit cannot discard proof bindings. If\ncancellation prevents cleanup, lease expiry recovers retained queue age and\nmints a new fence.\n\nConsumers should deploy `shadow` first, inspect receipts, then change their\nprotected caller to `required`. Rollback is a reviewed caller change back to\n`off`; it does not delete queue history or reinterpret old receipts. The\nterminal reusable workflow creates the exact Integration Delivery Proof for a\nmerged candidate (or accepts explicit evidence for another terminal outcome),\nthen closes only the current fencing generation. The separate queued\ncancellation reusable workflow cannot close an active generation; it advances\nthe state ref only when the caller's complete terminal binding and expected-old\nroot still match. A delayed `dequeued` event is ignored when GitHub readback\nshows the same exact PR head is already queued again, so an earlier queue event\ncannot close a newer active Warrant generation.\n\nBuildchain uses the same contract for its own protected dev line through\n`buildchain-dev-delivery.yml`. The manual caller requires the exact PR head and\nsemantic source roots, accepts an optional reusable native proof, keeps both\nthe durable public selector and explicit runtime input on `v4-alpha`, selects\n`delivery-warrant-mode: required`, and targets GitHub Merge Queue. It does not\noffer an `off` switch: rollback is a reviewed change to this caller, not an\noperator-time weakening of a specific delivery attempt.\n\n`templates/native-dev-delivery.yml` provides the corresponding protected-dev\nconsumer workflow. It supports both explicit dispatch and the bounded wake\nevent, calls the allowed floating `@v4-alpha` selector, explicitly passes the v4\nruntime ref that locks every delivery job to the same checkout, and keeps the\nnative command in the consumer repository rather than inventing\nprovider-specific shards. Both callers explicitly bind the queue-admission\nand active-lease status contexts so write/readback fencing uses the same exact\nnames. The reusable workflow defaults the explicit runtime input to\n`v4-alpha`; an empty input or any v3 selector fails before the first runtime\ncheckout.\n\nThis mechanism schedules protected delivery only. It does not serialize local\ndevelopment, source-only checks, unrelated channels, release publication, or\nrunner provisioning. It never grants authority to enable cloud runner\ncampaigns."
|
|
2321
2321
|
},
|
|
2322
2322
|
{
|
|
2323
2323
|
"id": "manual:dev-qualification-patrol",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"contract": "kungfu-buildchain-public-surface-reverse-audit",
|
|
22
22
|
"path": "dist/site/public-surface-audit.json",
|
|
23
23
|
"status": "passed",
|
|
24
|
-
"sha256": "
|
|
24
|
+
"sha256": "3ba4e7c9bdccd207be8b168f85704ee0fe0403c64fa06deb27ecf6910407646e",
|
|
25
25
|
"summary": {
|
|
26
26
|
"cliCommandCount": 117,
|
|
27
27
|
"workflowCount": 77,
|
|
28
28
|
"actionCount": 8,
|
|
29
29
|
"sitePageCount": 84,
|
|
30
|
-
"docCommandRefCount":
|
|
30
|
+
"docCommandRefCount": 1050,
|
|
31
31
|
"failureCount": 0
|
|
32
32
|
},
|
|
33
33
|
"auditBoundary": {
|
|
@@ -246,13 +246,13 @@
|
|
|
246
246
|
"contract": "kungfu-buildchain-public-surface-reverse-audit",
|
|
247
247
|
"path": "dist/site/public-surface-audit.json",
|
|
248
248
|
"status": "passed",
|
|
249
|
-
"sha256": "
|
|
249
|
+
"sha256": "3ba4e7c9bdccd207be8b168f85704ee0fe0403c64fa06deb27ecf6910407646e",
|
|
250
250
|
"summary": {
|
|
251
251
|
"cliCommandCount": 117,
|
|
252
252
|
"workflowCount": 77,
|
|
253
253
|
"actionCount": 8,
|
|
254
254
|
"sitePageCount": 84,
|
|
255
|
-
"docCommandRefCount":
|
|
255
|
+
"docCommandRefCount": 1050,
|
|
256
256
|
"failureCount": 0
|
|
257
257
|
},
|
|
258
258
|
"auditBoundary": {
|
|
@@ -2213,7 +2213,7 @@
|
|
|
2213
2213
|
],
|
|
2214
2214
|
"maturity": "stable",
|
|
2215
2215
|
"sourcePath": "docs/dev-delivery-warrant.md",
|
|
2216
|
-
"digest": "sha256:
|
|
2216
|
+
"digest": "sha256:5feb5f64f19446f31023ceb1af830cd98383141aeacf689c89e980d7ce9f88ab",
|
|
2217
2217
|
"headings": [
|
|
2218
2218
|
{
|
|
2219
2219
|
"level": 1,
|
|
@@ -2251,7 +2251,7 @@
|
|
|
2251
2251
|
"anchor": "workflow-rollout-and-rollback"
|
|
2252
2252
|
}
|
|
2253
2253
|
],
|
|
2254
|
-
"markdown": "---\nstatus: accepted\nperiod: ongoing\ntheme: dev-delivery-warrant\ndoc_type: technical-reference\nsource_level: local-files\nconfidence: high\nsensitivity: public\nevidence_grade: A\nreview_state: self-reviewed\nlast_reviewed: 2026-08-17\nai_provenance:\n model_family: GPT-5\n product: Codex\n generated_at: 2026-08-11\n invisible_context: not asserted\n---\n\n# Dev Delivery Warrant Queue\n\nBuildchain's Dev Delivery Warrant Queue gives a qualified slow pull request a\ndurable, non-preemptive delivery turn without replacing GitHub Merge Queue as\nthe final protected-ref authority.\n\nThe queue is stored on a dedicated Git ref below\n`buildchain/dev-delivery-warrant/`. Every update creates a child Git commit and\nadvances the ref without force. The transition receipt binds the expected old\nstate root; a competing controller receives a visible non-fast-forward failure\ninstead of a second authority claim.\n\n## Contract\n\nA submission binds the repository, protected dev line, pull request, semantic\nsource identity, exact source head, native Assignment and Initiative roots,\nsource patch or tree intent, reusable Source Qualification Proof, plan,\naffected closure, dependencies, toolchain, delivery class, priority, attempts,\nand retained enqueue time.\n\nSelection is deterministic FIFO plus aging with bounded priority. Priority may\nreorder queued work, but it cannot preempt the active Warrant. Exactly one\ncandidate receives a `provisional` leased Warrant containing a fencing token,\nlease generation, expected-old state root, expiry, and the complete exact\nsource binding. It reserves the next protected-dev landing before expensive\nnative shards start, but it is not GitHub Merge Queue admission authority.\nHeartbeat extends only that generation. Native proof success atomically\nupgrades the same token and generation to `qualified`; only then may enqueue\nbegin. Expiry fences further mutations by the old token, but it does not prove\nthat the old native process stopped. The active Warrant therefore remains in\nplace until bounded termination is proven by rooted terminal evidence. Only\nthat exact fenced settlement may clear the holder and permit successor\nselection.\n\nA terminal event may cancel a candidate before selection without minting a\nWarrant. This transition is limited to an exact non-active queued candidate and\nbinds its candidate root, pull request, recorded source head, event-observed\nsource head, terminal event action, evidence root, and expected-old queue root.\nAn active candidate still requires its current fencing token and lease\ngeneration. Exact duplicate cancellation evidence is a visible no-op; identity,\nstate, event, or evidence drift fails closed.\n\nThe reusable terminal controller classifies authoritative completion,\ncancellation, supersession, native failure, and transient dequeue separately.\n`dequeued` retains only a provisional Warrant whose native worker may still be\nrunning: a fresh holder continues with the same generation and token, while an\nexpired holder waits for proof that its fenced worker stopped. A qualified or\nhistorical phase-less holder has no unproven native worker to fence, so its exact\ndequeue closes atomically and persists the rooted queued-successor wake. Queued\nwork may also settle as dequeued because it never started native execution. The\ncontroller uses one `settle` operation for active, queued, already-terminal,\nand never-admitted pull requests. An active Warrant still requires its exact\nfence and evidence. A matching queued cancellation is persisted normally. A\nduplicate terminal event replays the persisted wake, while a pull request that\nnever entered Warrant authority returns a rooted explicit no-op instead of\nfailing the workflow or inventing queue state.\n\nThe supported priority classes are `ordinary`, `expedited`, and `emergency`.\nThe queue does not infer an emergency: callers must choose it explicitly under\ntheir reviewed policy. Delivery classes are `non-native-fast`,\n`native-proof-required`, `cross-platform`, and `release`.\n\n## CI lane change budget\n\n`architecture/ci-lane-change-budget.json` pins the exact protected-Dev cut\nthat predates lane-budget enforcement. `scripts/check-ci-lane-change-budget.mjs`\ncompares the current workflow job set with that cut on every repository check.\nLegacy jobs remain readable without invented metadata, while every newly added\njob fails closed until its exact `<workflow>#<job>` lane declares:\n\n- merge or non-merge authority class;\n- trigger class;\n- concurrency scope and `cancel-in-progress` behavior;\n- expected runner-minutes per run;\n- cancellation/settlement behavior; and\n- merge-critical SLO impact, expected contribution, metric, and rationale.\n\nThe guard is repository policy only. It does not become another required\nGitHub status, acquire merge-queue authority, or relax Delivery Warrant,\nexact-head, approval, required-check, and protected-ref enforcement. A removed\nlane must also remove its declaration, so stale budget records cannot conceal\nworkflow drift.\n\nA release-blocker candidate may additionally carry a rooted priority claim\ncreated from a settled Release Train dual landing. The claim binds the exact\nAssignment, Initiative, repair, prior and successor cuts, candidate generation,\ncut candidate, Dev head, semantic patch, both landing evidence roots, and\npublication gate. Only a claim whose repository, protected base, Work roots,\nhead, patch, and claim root match the queued candidate enters the blocker lane.\nThat lane outranks not-yet-leased ordinary work, but never preempts or rewrites\nan active Warrant; unrelated, conflicted, mismatched, or fabricated claims fail\nclosed before selection.\n\n## Three proof authorities\n\nSource Qualification Proof is created from the cheap source-acceptance gate. It\nbinds the semantic source, exact source head and patch/tree intent, plan,\naffected closure, dependencies, toolchain, covered paths, and exact acceptance\nevidence. Ready state and approval are established before provisional\nselection.\n\nNative Qualification Proof is separate. Its v4 form binds semantic source and patch,\nplan, affected closure, dependency graph, toolchain, the exact execution\nenvironment contract, covered paths, native shard evidence, the exact dev\nbase used by the native composition, and the v3 native heartbeat-run receipt.\nThat receipt exposes and roots the exact repository, protected base, source\nhead, qualified base, toolchain, and environment binding established before\nprocess spawn. The proof carries the exact receipt bytes as well as repeating\nthe binding and receipt roots in its shard evidence. Public verification\nrecomputes those bytes and requires a successful outcome, positive heartbeat\ncount, exact command root, ordered start/completion/qualification timestamps,\nand the complete execution binding; caller-computed roots without the receipt\nbytes are not a v4 proof. Before reuse, the consumer roots the\ncomplete attributed Dev delta, including both sides of every rename, then\nclassifies it:\n\n- unchanged semantic roots plus an unrelated fully attributed base delta reuse\n native qualification and run only a cheap Project Cut replay. GitHub's `behind`\n state is accepted only when a rooted replay proof binds the exact current\n protected base, unchanged PR head and source patch, replay tree, required\n context roots, and a qualified `project.cut.merge-queue-admission/v1`\n receipt;\n- an overlapping delta reruns affected native shards or the full native plan;\n- an unknown or truncated graph, ambiguous rename, missing attribution, or\n changed source, plan, closure, dependency, toolchain, or environment root\n fails closed to full native qualification.\n\nHistorical Native Qualification Proof v1, v2, and v3 values remain readable,\nbut they cannot be reused because they do not carry the current v4 exact native\nexecution evidence. They fail closed to explicit native revalidation and\nproduce a v4 proof.\n\nThe reuse decision binds the exact old and current Dev heads, normalized changed\npaths and rename pairs in `baseDeltaRoot`. This makes local and hosted replay of\nthe same inputs byte-deterministic. Generated outputs that participate in the\naffected closure must be listed in `affected-paths-json`; a delta touching one\nof those surfaces is overlap, not a documentation-only advance.\n\nIntegration Delivery Proof is separate and cannot be cached across candidates.\nIt binds the exact current dev base, replay tree, GitHub `merge_group` head and\ntree, active Warrant fencing generation, Source Qualification Proof root, and\nfinal required-context roots. GitHub's exact merge-group checks remain the\nfinal integration authority.\n\n## CLI\n\nQueue commands are dry-run by default:\n\n```sh\nbuildchain dev warrant submit --repository owner/repository \\\n --branch dev/v4/v4.0 --pull-request 123 --source-head <sha> \\\n --assignment-root <root> --initiative-root <root> \\\n --source-identity-root <root> --source-patch-root <root> \\\n --source-proof-root <root> --plan-root <root> --closure-root <root> \\\n --dependency-root <root> --toolchain-root <root> \\\n --environment-root <root> \\\n --delivery-class native-proof-required\n\nbuildchain dev warrant select --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\n\nbuildchain dev proof native --branch dev/v4/v4.0 \\\n --source-head <sha> --qualified-base <sha> \\\n --environment-root <root> \\\n --native-execution-receipt native-heartbeat-run.json \\\n --affected-paths-json '[\"packages/native\"]' ...\n\nbuildchain dev proof classify-native --source-proof native-proof.json \\\n --current-base <sha> --graph-known true --attribution-complete true \\\n --changed-paths-json '[]' --renames-json '[]' ...\n\nbuildchain dev warrant qualify --repository owner/repository \\\n --branch dev/v4/v4.0 --fencing-token <root> --lease-generation 1 \\\n --native-proof native-proof.json \\\n --native-reuse-decision native-reuse-decision.json --execute\n\nbuildchain dev warrant cancel-queued --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> --pull-request 123 \\\n --expected-source-head <queued-sha> --observed-source-head <event-sha> \\\n --expected-old <queue-root> --event-action closed --outcome cancelled \\\n --evidence-root <terminal-event-root> --execute\n```\n\n`heartbeat`, `qualify`, `recover`, `close`, `settle`, `cancel-queued`, and `observe` use the same durable authority.\nWarrant-scoped mutations require the exact fencing token and lease generation.\n`close` also requires a rooted terminal evidence object.\n\nOn the v4 line, `observe` also has an explicit `--read-mode v4` candidate. It requires retained exact semantic-diff qualification and source binding, invokes the effect-disabled Rust projection, retains parity evidence, and returns the existing observation shape. The default and rollback mode remains `v3`; mutation commands ignore the read switch. See [`v4-delivery-warrant-read-candidate.md`](v4-delivery-warrant-read-candidate.md).\n\nExpensive native commands must run through `dev-delivery-native-run.mjs` (or an\nequivalent exact consumer). Before spawn it validates the environment and\nexecution roots and traverses the complete Linux `/proc` ancestry. An unreadable\nprocess environment or status is a failure, as is any variable name containing a\ngeneric auth, credential, key, password, secret, or token segment. The child\nstill receives only the fixed process-basics allowlist. The command root,\nexact execution binding and root, successful outcome, child start and completion\ntimes, and heartbeat count are included in the native receipt. The controller\nkeeps retained-fence heartbeats across the direct child lifetime and requires a\nfinal successful heartbeat after child exit; process-group termination on fence\nloss remains fail-closed runtime behavior rather than a claimed receipt field.\n\nThe reusable workflow does not run that controller in a credentialed job. A\nGitHub-hosted `native-execution` job has read-only checkout permission, no\nprovider write credential in the candidate step or its ancestry, and cannot\nqualify, settle, enqueue, or renew provider state. It copies only rooted proof\nand Warrant bytes into a dedicated staging directory and uploads that closed set.\nThe success artifact contains exactly its transfer manifest, Warrant, native\nresult, native proof, and reuse decision; the failed-native artifact contains\nexactly its transfer manifest, Warrant, canonical rooted failure, and\nprovider-settlement binding. Recursive verification rejects missing or extra\nentries, duplicate or case-colliding paths, traversal, symlinks, directories,\nother non-regular entries, non-canonical failure or manifest JSON bytes, byte\ndrift, and mutation between the first and second recursive membership\nsnapshots. A\ndependent GitHub-hosted finalizer downloads those bytes and uses live\nActions job readback to prove different positive job ids, different runner\nidentities, a matching run attempt, and strict native-completion-before-finalizer\nordering. It recomputes the canonical failure root and binds that exact root,\ntransfer root, native job, Warrant state and fence into the live provider\nboundary. Failure settlement consumes those verified coordinates directly; it\ndoes not synthesize a second failure. The boundary also roots a live open-PR\nhead and protected-ref readback. The trusted finalizer uses its provider credential only for\nthose GET readbacks until the byte transfer, runner boundary, and semantic native\nproof have passed independent verification. It then rereads the live PR head,\nprotected base, and Warrant fence before qualifying or settling. A missing or\ncorrupt artifact, unreadable `/proc`, same job or runner, invalid timestamp,\nself-hosted label, stale PR/base/fence, or readback mismatch fails closed. Native\nexit zero is only evidence input.\n\nProof commands create, verify, classify, and compose the two proof layers:\n\n```sh\nbuildchain dev proof source ...\nbuildchain dev proof classify --source-proof source-proof.json ...\nbuildchain dev proof replay ...\nbuildchain dev proof replay-proof \\\n --qualification-receipt project-cut-admission.json ...\nbuildchain dev proof integration --warrant-result warrant.json ...\n```\n\n## Opt-in bounded qualification and exclusive landing\n\nBuildchain also defines an explicit production opt-in that turns successful\nshadow evidence into a separate v2 authority state. It does not widen or\nreinterpret the v1 Warrant queue. The accepted\n[`Qualification Lease and Landing Warrant ADR`](dev-delivery-qualification-landing-adr.md)\nand `contracts/dev-delivery-authority-v2.schema.json` are authoritative.\n\nIn `bounded-qualification-landing` mode, a configured number of exact\nQualification Leases may coexist. Each lease carries\n`authority = qualification-only` and `mergeGroupAdmission = false`. Completing\nqualification records evidence and releases that lease. Qualified candidates\nthen wait for the one `Landing Warrant`, which alone carries\n`authority = merge-group-admission` and may be checked for `merge_group`\nadmission.\n\nConcurrency is granted only across disjoint rooted `qualificationDomains`.\nOverlap and unknown domains are held behind the active safety boundary with an\nexplicit content-rooted reason. `maxLandingOvertakes` prevents a slow older\ncandidate from being bypassed indefinitely, while `maxQualificationAttempts`\nturns repeated heartbeat loss into a rooted terminal failure. Every release\nreturns a deterministic rooted wake instruction; an exact duplicate release or\nrecovery is a state-root-preserving no-op.\n\nAn expired qualification-only lease may release its bounded compute slot. An\nexpired Landing Warrant does not release exclusive provider authority by time\nalone: recovery retains it and requires exact provider-stop or terminal\nsettlement evidence for the same token and generation before another landing\ncandidate can be selected. Expired cleanup invokes a separate independent\nprovider terminal verifier after candidate exit. Its rooted readback must match\nthe exact repository, protected base, authority state root, candidate, pull\nrequest, source head, Landing token and generation, provider run and job, and a\nfresh observation for that Warrant. Caller assertions, forged roots, wrong\nbindings, nonterminal states, and stale observations cannot release the slot.\nThe verifier reads the immutable historical run-attempt endpoint. A later rerun\nor synchronized PR head cannot rewrite the admitted attempt or prevent its\nterminal settlement; current PR identity and protected base still must match.\nThe reader rejects an empty run conclusion, nonterminal run or job state,\nunsupported job conclusion, or pull-request state outside `open|closed` before\nit can seal product-owned cleanup evidence.\n\nThe public two-phase workflow keeps heartbeat authority in a fourth,\nGitHub-hosted job on a runner domain distinct from admission, native execution,\nevidence sealing, and finalization. Each successful heartbeat records the exact\nexpected-old and next authority state roots plus its receipt root. The\ncredentialless native job holds only its immutable admission binding; the\nhosted coordinator alone renews durable state. After heartbeat loss it records\nthe exact current attempt but never invokes GitHub's run-scoped cancellation\nAPI, so a successor rerun cannot be cancelled through a stale coordinate. All boundary jobs must prove the exact\n`GitHub Actions` hosted runner group and reject `self-hosted`. The finalizer\nrereads the provider job set and live authority state, rejects missing\nor reordered receipt continuity, and requires the live state root to equal the\nreceipt's latest root before it can qualify, settle, or land.\n\nA terminal native failure retains the complete provider chain through every\nwrite-normalize-observe-remutate cycle: `transferRoot`,\n`finalizerBoundaryRoot`, `nativeJobId`, `sealJobId`, the exact admitted\n`providerAttempt`, and, when expiry cleanup was required, the independent\n`providerTerminalReadbackRoot`.\n\nBuildchain's tracked self-delivery caller invokes\n`kungfu-systems/buildchain/.github/workflows/dev-pr-auto-merge.yml@v4-alpha`.\nThe durable selector remains the floating alpha channel, the repository keeps\nmatching `.buildchain/contract-lock.json` (`v4`) and\n`.buildchain/alpha-contract-lock.json` (`v4-alpha`), and a train runtime may be\nselected only through the trusted, non-persistent `workflow_dispatch` input.\nNo candidate SHA or train ref is persisted in the caller.\n\nOnly complete `verified-native-qualification` evidence can mint a new Landing\nWarrant. Migrated `legacy-compatibility-only` evidence may preserve an exact\nalready-active historical Landing fence, but it cannot create a successor\nLanding or acquire native proof authority.\n\nThe public command family is explicit:\n\n```sh\nbuildchain dev authority migrate --repository owner/repository \\\n --branch dev/v4/v4.0 --execute --json\nbuildchain dev authority submit --repository owner/repository \\\n --branch dev/v4/v4.0 --environment-root <root> \\\n --qualification-domains '[\"<root>\"]' ... --execute\nbuildchain dev authority lease-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 --execute\nbuildchain dev authority complete-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --evidence-root <qualification-root> --execute\nbuildchain dev authority lease-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --provider-attempt admitted-provider-attempt.json --execute\nbuildchain dev authority recover --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority admit-merge-group --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --merge-group-head <sha>\n```\n\nTerminal settlement releases either authority immediately from exact evidence;\nit does not wait for TTL. Exact duplicate settlement is a state-root-preserving\nno-op. The default `buildchain dev warrant` commands, v1 state bytes, and\nsingle-flight behavior do not change while this mode is off.\n\nMigration also accepts the historical non-native v1 form whose active Warrant\npredates the `phase` field. It preserves that exact fence as Landing authority\nand records a schema-safe `legacy-compatibility-only` qualification carrying the\nexact legacy state root, token, generation, source proof, and phase. Fields that\nv1 never established remain explicitly null, including the phase-less\nqualification time and every native proof field. A migrated qualified v1\nWarrant retains its historical proof roots as compatibility facts, but\n`nativeProofAuthority` remains false because migration cannot reconstruct the\nv2 execution binding or qualification contract. Neither form can claim new\nnative proof or reuse authority. Phase-less native candidates remain invalid.\n\n## Workflow rollout and rollback\n\nThe reusable `dev-pr-auto-merge.yml` supports three explicit rollout modes:\n\n- `off` preserves the previous exact-head admission controller;\n- `shadow` qualifies the source and emits a read-only queue submission plan;\n- `required` persists the submission, selects a provisional Warrant, runs or\n reuses semantic native proof under heartbeat, atomically qualifies the same\n fence, and refuses GitHub enqueue unless the immutable queue commit, state root, active Warrant, and\n selected candidate all pass exact readback validation. Immediately before\n enqueue, the controller writes and then reads back both the exact-head queue\n admission status and active lease status. Only after those statuses are\n visible at their required states does it reread the pull request head,\n protected base, native merge queue, and current protected Warrant state. The\n final rooted admission transaction binds the frozen base, source head,\n candidate, fencing token, generation, native proof roots, Project Cut proof,\n and both status contexts. Status propagation is retried before enqueue;\n base, head, queue-predecessor, lease, or Warrant drift revokes both statuses\n without attempting enqueue. A previously valid result is not authority after terminal\n closeout. Re-running qualification for the same selected head may regenerate\n timestamped proof bytes, but it retains the immutable active Warrant and its\n originally selected proof instead of rewriting or rejecting that attempt.\n Each candidate also retains the exact successful source workflow run. If a\n controller discovers that another candidate owns the active Warrant, a\n configured consumer workflow is dispatched immediately for that exact PR,\n head, source run, Assignment and Initiative, source identity and patch,\n plan, closure, dependency, toolchain, environment, affected paths, delivery\n class, and priority; the candidate is not left waiting for a patrol cron.\n The shipped Buildchain caller and native template configure this handoff path\n and accept the same complete input contract. A historical phase-less owner\n uses the distinct `legacy-phase-less-active-owner` command path. That path\n carries the exact queue state root observed before its duplicate submission,\n fencing token, generation, PR, head, and source-run binding. The submission\n receipt proves that pre-transition root even though the queue transition\n advances the current state root. The path omits `environment-root`, `native-command`, and\n `native-command-root`, and rejects readback drift. It therefore resumes the\n historical non-native authority without inventing a native command contract\n or upgrading the owner to native proof authority.\n\n The PR-controlled native candidate runs in a distinct GitHub-hosted job with\n no provider write credential in the step or process ancestry. The dependent\n credentialed finalizer runs on another live-readback-proven GitHub-hosted job\n and runner, verifies the content-addressed transfer, then independently rereads\n the PR, protected base, and provider fence before qualification or settlement.\n Detached descendants, including descendants that unset runner tracking, remain\n in the native runner authority domain and cannot enter the fresh finalizer\n domain. Exit zero alone is never treated as provider mutation authority,\n Landing authority, or completed delivery.\n\n Persistent self-hosted runners are intentionally outside this contract. A\n `needs` edge alone does not prove process cleanup or a new authority domain, so\n the finalizer rejects a self-hosted label. Supporting self-hosted execution\n would require separately attested one-job runner destruction and a provider\n readback contract at least as strong as the GitHub-hosted boundary.\n\n Required-mode admission also performs a latest-base Project Cut immediately\n before enqueue. If the protected base advanced, the controller reclassifies\n the exact attributed delta against the rooted native proof. Only a disjoint,\n fully attributed move may reuse that proof; overlap, unknown attribution,\n missing composition, or merge conflict fails with a stable pre-enqueue reason.\n The rooted Project Cut receipt binds the frozen and admitted base SHAs,\n GitHub's exact synthetic merge commit and replay tree, and the unchanged PR\n head. A final base/head/queue/Warrant compare-and-swap readback must still\n match that receipt before the enqueue mutation is attempted.\n\n The protected branch ref is the base authority for that compare-and-swap.\n A pull request's `base.sha` may remain an older composition snapshot while\n GitHub reports the pull request as behind, so it is diagnostic rather than a\n substitute for the separately read protected ref and rooted Project Cut.\n\nFor a required native delivery class, the reusable controller rejects a\nmissing or malformed environment root before runtime checkout, candidate\nsubmission, Warrant selection, or native execution. The input remains\nconditionally optional so `off`, `shadow`, and `non-native-fast` callers keep\ntheir documented behavior.\n\nThe controller persists a completed native proof before its final base\nreclassification. A later exact retry can supply that proof and avoid the\nexpensive native command when the rooted delta still proves reuse safe. A\nduplicate dispatch against the same already-qualified Warrant returns the same\nproof and reuse roots plus a rooted qualification replay output without another\nqueue mutation. Both result forms carry\n`landingAuthority: false`: only the live qualified Warrant plus exact-head\nGitHub merge-queue admission can authorize landing.\n\nThe required controller checks the protected base again after native work. A\ndisjoint attributed delta reuses the proof. Overlap or unknown attribution\ntriggers one automatic revalidation on the latest base; continued overlap,\nnative failure, cancellation, semantic head movement, or an unrecoverable merge\nconflict closes the exact fence. The next queued candidate is notified through\nthe `buildchain-dev-delivery-wake` repository event. Its complete semantic\ncandidate is carried under the single `client_payload.candidate` envelope so\nGitHub's ten-property top-level limit cannot discard proof bindings. If\ncancellation prevents cleanup, lease expiry recovers retained queue age and\nmints a new fence.\n\nConsumers should deploy `shadow` first, inspect receipts, then change their\nprotected caller to `required`. Rollback is a reviewed caller change back to\n`off`; it does not delete queue history or reinterpret old receipts. The\nterminal reusable workflow creates the exact Integration Delivery Proof for a\nmerged candidate (or accepts explicit evidence for another terminal outcome),\nthen closes only the current fencing generation. The separate queued\ncancellation reusable workflow cannot close an active generation; it advances\nthe state ref only when the caller's complete terminal binding and expected-old\nroot still match. A delayed `dequeued` event is ignored when GitHub readback\nshows the same exact PR head is already queued again, so an earlier queue event\ncannot close a newer active Warrant generation.\n\nBuildchain uses the same contract for its own protected dev line through\n`buildchain-dev-delivery.yml`. The manual caller requires the exact PR head and\nsemantic source roots, accepts an optional reusable native proof, keeps both\nthe durable public selector and explicit runtime input on `v4-alpha`, selects\n`delivery-warrant-mode: required`, and targets GitHub Merge Queue. It does not\noffer an `off` switch: rollback is a reviewed change to this caller, not an\noperator-time weakening of a specific delivery attempt.\n\n`templates/native-dev-delivery.yml` provides the corresponding protected-dev\nconsumer workflow. It supports both explicit dispatch and the bounded wake\nevent, calls the allowed floating `@v4-alpha` selector, explicitly passes the v4\nruntime ref that locks every delivery job to the same checkout, and keeps the\nnative command in the consumer repository rather than inventing\nprovider-specific shards. Both callers explicitly bind the queue-admission\nand active-lease status contexts so write/readback fencing uses the same exact\nnames. The reusable workflow defaults the explicit runtime input to\n`v4-alpha`; an empty input or any v3 selector fails before the first runtime\ncheckout.\n\nThis mechanism schedules protected delivery only. It does not serialize local\ndevelopment, source-only checks, unrelated channels, release publication, or\nrunner provisioning. It never grants authority to enable cloud runner\ncampaigns."
|
|
2254
|
+
"markdown": "---\nstatus: accepted\nperiod: ongoing\ntheme: dev-delivery-warrant\ndoc_type: technical-reference\nsource_level: local-files\nconfidence: high\nsensitivity: public\nevidence_grade: A\nreview_state: self-reviewed\nlast_reviewed: 2026-08-17\nai_provenance:\n model_family: GPT-5\n product: Codex\n generated_at: 2026-08-11\n invisible_context: not asserted\n---\n\n# Dev Delivery Warrant Queue\n\nBuildchain's Dev Delivery Warrant Queue gives a qualified slow pull request a\ndurable, non-preemptive delivery turn without replacing GitHub Merge Queue as\nthe final protected-ref authority.\n\nThe queue is stored on a dedicated Git ref below\n`buildchain/dev-delivery-warrant/`. Every update creates a child Git commit and\nadvances the ref without force. The transition receipt binds the expected old\nstate root; a competing controller receives a visible non-fast-forward failure\ninstead of a second authority claim.\n\n## Contract\n\nA submission binds the repository, protected dev line, pull request, semantic\nsource identity, exact source head, native Assignment and Initiative roots,\nsource patch or tree intent, reusable Source Qualification Proof, plan,\naffected closure, dependencies, toolchain, delivery class, priority, attempts,\nand retained enqueue time.\n\nSelection is deterministic FIFO plus aging with bounded priority. Priority may\nreorder queued work, but it cannot preempt the active Warrant. Exactly one\ncandidate receives a `provisional` leased Warrant containing a fencing token,\nlease generation, expected-old state root, expiry, and the complete exact\nsource binding. It reserves the next protected-dev landing before expensive\nnative shards start, but it is not GitHub Merge Queue admission authority.\nHeartbeat extends only that generation. Native proof success atomically\nupgrades the same token and generation to `qualified`; only then may enqueue\nbegin. Expiry fences further mutations by the old token, but it does not prove\nthat the old native process stopped. The active Warrant therefore remains in\nplace until bounded termination is proven by rooted terminal evidence. Only\nthat exact fenced settlement may clear the holder and permit successor\nselection.\n\nA terminal event may cancel a candidate before selection without minting a\nWarrant. This transition is limited to an exact non-active queued candidate and\nbinds its candidate root, pull request, recorded source head, event-observed\nsource head, terminal event action, evidence root, and expected-old queue root.\nAn active candidate still requires its current fencing token and lease\ngeneration. Exact duplicate cancellation evidence is a visible no-op; identity,\nstate, event, or evidence drift fails closed.\n\nThe reusable terminal controller classifies authoritative completion,\ncancellation, supersession, native failure, and transient dequeue separately.\n`dequeued` retains only a provisional Warrant whose native worker may still be\nrunning: a fresh holder continues with the same generation and token, while an\nexpired holder waits for proof that its fenced worker stopped. A qualified or\nhistorical phase-less holder has no unproven native worker to fence, so its exact\ndequeue closes atomically and persists the rooted queued-successor wake. Queued\nwork may also settle as dequeued because it never started native execution. The\ncontroller uses one `settle` operation for active, queued, already-terminal,\nand never-admitted pull requests. An active Warrant still requires its exact\nfence and evidence. A matching queued cancellation is persisted normally. A\nduplicate terminal event replays the persisted wake, while a pull request that\nnever entered Warrant authority returns a rooted explicit no-op instead of\nfailing the workflow or inventing queue state.\n\nThe supported priority classes are `ordinary`, `expedited`, and `emergency`.\nThe queue does not infer an emergency: callers must choose it explicitly under\ntheir reviewed policy. Delivery classes are `non-native-fast`,\n`native-proof-required`, `cross-platform`, and `release`.\n\n## CI lane change budget\n\n`architecture/ci-lane-change-budget.json` pins the exact protected-Dev cut\nthat predates lane-budget enforcement. `scripts/check-ci-lane-change-budget.mjs`\ncompares the current workflow job set with that cut on every repository check.\nLegacy jobs remain readable without invented metadata, while every newly added\njob fails closed until its exact `<workflow>#<job>` lane declares:\n\n- merge or non-merge authority class;\n- trigger class;\n- concurrency scope and `cancel-in-progress` behavior;\n- expected runner-minutes per run;\n- cancellation/settlement behavior; and\n- merge-critical SLO impact, expected contribution, metric, and rationale.\n\nThe guard is repository policy only. It does not become another required\nGitHub status, acquire merge-queue authority, or relax Delivery Warrant,\nexact-head, approval, required-check, and protected-ref enforcement. A removed\nlane must also remove its declaration, so stale budget records cannot conceal\nworkflow drift.\n\nA release-blocker candidate may additionally carry a rooted priority claim\ncreated from a settled Release Train dual landing. The claim binds the exact\nAssignment, Initiative, repair, prior and successor cuts, candidate generation,\ncut candidate, Dev head, semantic patch, both landing evidence roots, and\npublication gate. Only a claim whose repository, protected base, Work roots,\nhead, patch, and claim root match the queued candidate enters the blocker lane.\nThat lane outranks not-yet-leased ordinary work, but never preempts or rewrites\nan active Warrant; unrelated, conflicted, mismatched, or fabricated claims fail\nclosed before selection.\n\n## Three proof authorities\n\nSource Qualification Proof is created from the cheap source-acceptance gate. It\nbinds the semantic source, exact source head and patch/tree intent, plan,\naffected closure, dependencies, toolchain, covered paths, and exact acceptance\nevidence. Ready state and approval are established before provisional\nselection.\n\nNative Qualification Proof is separate. Its v4 form binds semantic source and patch,\nplan, affected closure, dependency graph, toolchain, the exact execution\nenvironment contract, covered paths, native shard evidence, the exact dev\nbase used by the native composition, and the v3 native heartbeat-run receipt.\nThat receipt exposes and roots the exact repository, protected base, source\nhead, qualified base, toolchain, and environment binding established before\nprocess spawn. The proof carries the exact receipt bytes as well as repeating\nthe binding and receipt roots in its shard evidence. Public verification\nrecomputes those bytes and requires a successful outcome, positive heartbeat\ncount, exact command root, ordered start/completion/qualification timestamps,\nand the complete execution binding; caller-computed roots without the receipt\nbytes are not a v4 proof. Before reuse, the consumer roots the\ncomplete attributed Dev delta, including both sides of every rename, then\nclassifies it:\n\n- unchanged semantic roots plus an unrelated fully attributed base delta reuse\n native qualification and run only a cheap Project Cut replay. GitHub's `behind`\n state is accepted only when a rooted replay proof binds the exact current\n protected base, unchanged PR head and source patch, replay tree, required\n context roots, and a qualified `project.cut.merge-queue-admission/v1`\n receipt;\n- an overlapping delta reruns affected native shards or the full native plan;\n- an unknown or truncated graph, ambiguous rename, missing attribution, or\n changed source, plan, closure, dependency, toolchain, or environment root\n fails closed to full native qualification.\n\nHistorical Native Qualification Proof v1, v2, and v3 values remain readable,\nbut they cannot be reused because they do not carry the current v4 exact native\nexecution evidence. They fail closed to explicit native revalidation and\nproduce a v4 proof.\n\nThe reuse decision binds the exact old and current Dev heads, normalized changed\npaths and rename pairs in `baseDeltaRoot`. This makes local and hosted replay of\nthe same inputs byte-deterministic. Generated outputs that participate in the\naffected closure must be listed in `affected-paths-json`; a delta touching one\nof those surfaces is overlap, not a documentation-only advance.\n\nIntegration Delivery Proof is separate and cannot be cached across candidates.\nIt binds the exact current dev base, replay tree, GitHub `merge_group` head and\ntree, active Warrant fencing generation, Source Qualification Proof root, and\nfinal required-context roots. GitHub's exact merge-group checks remain the\nfinal integration authority.\n\n## CLI\n\nQueue commands are dry-run by default:\n\n```sh\nbuildchain dev warrant submit --repository owner/repository \\\n --branch dev/v4/v4.0 --pull-request 123 --source-head <sha> \\\n --assignment-root <root> --initiative-root <root> \\\n --source-identity-root <root> --source-patch-root <root> \\\n --source-proof-root <root> --plan-root <root> --closure-root <root> \\\n --dependency-root <root> --toolchain-root <root> \\\n --environment-root <root> \\\n --delivery-class native-proof-required\n\nbuildchain dev warrant select --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\n\nbuildchain dev proof native --branch dev/v4/v4.0 \\\n --source-head <sha> --qualified-base <sha> \\\n --environment-root <root> \\\n --native-execution-receipt native-heartbeat-run.json \\\n --affected-paths-json '[\"packages/native\"]' ...\n\nbuildchain dev proof classify-native --source-proof native-proof.json \\\n --current-base <sha> --graph-known true --attribution-complete true \\\n --changed-paths-json '[]' --renames-json '[]' ...\n\nbuildchain dev warrant qualify --repository owner/repository \\\n --branch dev/v4/v4.0 --fencing-token <root> --lease-generation 1 \\\n --native-proof native-proof.json \\\n --native-reuse-decision native-reuse-decision.json --execute\n\nbuildchain dev warrant cancel-queued --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> --pull-request 123 \\\n --expected-source-head <queued-sha> --observed-source-head <event-sha> \\\n --expected-old <queue-root> --event-action closed --outcome cancelled \\\n --evidence-root <terminal-event-root> --execute\n```\n\n`heartbeat`, `qualify`, `recover`, `close`, `settle`, `cancel-queued`, and `observe` use the same durable authority.\nWarrant-scoped mutations require the exact fencing token and lease generation.\n`close` also requires a rooted terminal evidence object.\n\nLegacy v3 queues that predate the native command contract can be observed but\ncannot enter ordinary mutation paths. If every live legacy candidate has an\nexact completed failed hosted run with zero nonterminal jobs, an operator may\natomically terminalize that complete live set:\n\n```sh\nbuildchain dev warrant recover-legacy-terminal \\\n --repository owner/repository --branch dev/v4/v4.0 \\\n --expected-old sha256:<current-state-root> \\\n --legacy-terminal-recovery legacy-terminal-recovery.json --execute\n```\n\nThe request must cover every live legacy native candidate exactly once and\nbind each stored candidate, source workflow run, terminal provider result, and\ncontent-addressed evidence object. Each evidence object carries the exact\nprovider job identities, attempts, conclusions, and completion timestamps; all\njobs must be terminal and at least one must have failed. The transition writes\none expected-old state update and requires the resulting queue to pass the\ncurrent strict native-proof contract. The recovery cannot qualify, merge,\nrequeue, or partially advance a legacy authority state.\n\nOn the v4 line, `observe` also has an explicit `--read-mode v4` candidate. It requires retained exact semantic-diff qualification and source binding, invokes the effect-disabled Rust projection, retains parity evidence, and returns the existing observation shape. The default and rollback mode remains `v3`; mutation commands ignore the read switch. See [`v4-delivery-warrant-read-candidate.md`](v4-delivery-warrant-read-candidate.md).\n\nExpensive native commands must run through `dev-delivery-native-run.mjs` (or an\nequivalent exact consumer). Before spawn it validates the environment and\nexecution roots and traverses the complete Linux `/proc` ancestry. An unreadable\nprocess environment or status is a failure, as is any variable name containing a\ngeneric auth, credential, key, password, secret, or token segment. The child\nstill receives only the fixed process-basics allowlist. The command root,\nexact execution binding and root, successful outcome, child start and completion\ntimes, and heartbeat count are included in the native receipt. The controller\nkeeps retained-fence heartbeats across the direct child lifetime and requires a\nfinal successful heartbeat after child exit; process-group termination on fence\nloss remains fail-closed runtime behavior rather than a claimed receipt field.\n\nThe reusable workflow does not run that controller in a credentialed job. A\nGitHub-hosted `native-execution` job has read-only checkout permission, no\nprovider write credential in the candidate step or its ancestry, and cannot\nqualify, settle, enqueue, or renew provider state. It copies only rooted proof\nand Warrant bytes into a dedicated staging directory and uploads that closed set.\nThe success artifact contains exactly its transfer manifest, Warrant, native\nresult, native proof, and reuse decision; the failed-native artifact contains\nexactly its transfer manifest, Warrant, canonical rooted failure, and\nprovider-settlement binding. Recursive verification rejects missing or extra\nentries, duplicate or case-colliding paths, traversal, symlinks, directories,\nother non-regular entries, non-canonical failure or manifest JSON bytes, byte\ndrift, and mutation between the first and second recursive membership\nsnapshots. A\ndependent GitHub-hosted finalizer downloads those bytes and uses live\nActions job readback to prove different positive job ids, different runner\nidentities, a matching run attempt, and strict native-completion-before-finalizer\nordering. It recomputes the canonical failure root and binds that exact root,\ntransfer root, native job, Warrant state and fence into the live provider\nboundary. Failure settlement consumes those verified coordinates directly; it\ndoes not synthesize a second failure. The boundary also roots a live open-PR\nhead and protected-ref readback. The trusted finalizer uses its provider credential only for\nthose GET readbacks until the byte transfer, runner boundary, and semantic native\nproof have passed independent verification. It then rereads the live PR head,\nprotected base, and Warrant fence before qualifying or settling. A missing or\ncorrupt artifact, unreadable `/proc`, same job or runner, invalid timestamp,\nself-hosted label, stale PR/base/fence, or readback mismatch fails closed. Native\nexit zero is only evidence input.\n\nProof commands create, verify, classify, and compose the two proof layers:\n\n```sh\nbuildchain dev proof source ...\nbuildchain dev proof classify --source-proof source-proof.json ...\nbuildchain dev proof replay ...\nbuildchain dev proof replay-proof \\\n --qualification-receipt project-cut-admission.json ...\nbuildchain dev proof integration --warrant-result warrant.json ...\n```\n\n## Opt-in bounded qualification and exclusive landing\n\nBuildchain also defines an explicit production opt-in that turns successful\nshadow evidence into a separate v2 authority state. It does not widen or\nreinterpret the v1 Warrant queue. The accepted\n[`Qualification Lease and Landing Warrant ADR`](dev-delivery-qualification-landing-adr.md)\nand `contracts/dev-delivery-authority-v2.schema.json` are authoritative.\n\nIn `bounded-qualification-landing` mode, a configured number of exact\nQualification Leases may coexist. Each lease carries\n`authority = qualification-only` and `mergeGroupAdmission = false`. Completing\nqualification records evidence and releases that lease. Qualified candidates\nthen wait for the one `Landing Warrant`, which alone carries\n`authority = merge-group-admission` and may be checked for `merge_group`\nadmission.\n\nConcurrency is granted only across disjoint rooted `qualificationDomains`.\nOverlap and unknown domains are held behind the active safety boundary with an\nexplicit content-rooted reason. `maxLandingOvertakes` prevents a slow older\ncandidate from being bypassed indefinitely, while `maxQualificationAttempts`\nturns repeated heartbeat loss into a rooted terminal failure. Every release\nreturns a deterministic rooted wake instruction; an exact duplicate release or\nrecovery is a state-root-preserving no-op.\n\nAn expired qualification-only lease may release its bounded compute slot. An\nexpired Landing Warrant does not release exclusive provider authority by time\nalone: recovery retains it and requires exact provider-stop or terminal\nsettlement evidence for the same token and generation before another landing\ncandidate can be selected. Expired cleanup invokes a separate independent\nprovider terminal verifier after candidate exit. Its rooted readback must match\nthe exact repository, protected base, authority state root, candidate, pull\nrequest, source head, Landing token and generation, provider run and job, and a\nfresh observation for that Warrant. Caller assertions, forged roots, wrong\nbindings, nonterminal states, and stale observations cannot release the slot.\nThe verifier reads the immutable historical run-attempt endpoint. A later rerun\nor synchronized PR head cannot rewrite the admitted attempt or prevent its\nterminal settlement; current PR identity and protected base still must match.\nThe reader rejects an empty run conclusion, nonterminal run or job state,\nunsupported job conclusion, or pull-request state outside `open|closed` before\nit can seal product-owned cleanup evidence.\n\nThe public two-phase workflow keeps heartbeat authority in a fourth,\nGitHub-hosted job on a runner domain distinct from admission, native execution,\nevidence sealing, and finalization. Each successful heartbeat records the exact\nexpected-old and next authority state roots plus its receipt root. The\ncredentialless native job holds only its immutable admission binding; the\nhosted coordinator alone renews durable state. After heartbeat loss it records\nthe exact current attempt but never invokes GitHub's run-scoped cancellation\nAPI, so a successor rerun cannot be cancelled through a stale coordinate. All boundary jobs must prove the exact\n`GitHub Actions` hosted runner group and reject `self-hosted`. The finalizer\nrereads the provider job set and live authority state, rejects missing\nor reordered receipt continuity, and requires the live state root to equal the\nreceipt's latest root before it can qualify, settle, or land.\n\nA terminal native failure retains the complete provider chain through every\nwrite-normalize-observe-remutate cycle: `transferRoot`,\n`finalizerBoundaryRoot`, `nativeJobId`, `sealJobId`, the exact admitted\n`providerAttempt`, and, when expiry cleanup was required, the independent\n`providerTerminalReadbackRoot`.\n\nBuildchain's tracked self-delivery caller invokes\n`kungfu-systems/buildchain/.github/workflows/dev-pr-auto-merge.yml@v4-alpha`.\nThe durable selector remains the floating alpha channel, the repository keeps\nmatching `.buildchain/contract-lock.json` (`v4`) and\n`.buildchain/alpha-contract-lock.json` (`v4-alpha`), and a train runtime may be\nselected only through the trusted, non-persistent `workflow_dispatch` input.\nNo candidate SHA or train ref is persisted in the caller.\n\nOnly complete `verified-native-qualification` evidence can mint a new Landing\nWarrant. Migrated `legacy-compatibility-only` evidence may preserve an exact\nalready-active historical Landing fence, but it cannot create a successor\nLanding or acquire native proof authority.\n\nThe public command family is explicit:\n\n```sh\nbuildchain dev authority migrate --repository owner/repository \\\n --branch dev/v4/v4.0 --execute --json\nbuildchain dev authority submit --repository owner/repository \\\n --branch dev/v4/v4.0 --environment-root <root> \\\n --qualification-domains '[\"<root>\"]' ... --execute\nbuildchain dev authority lease-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 --execute\nbuildchain dev authority complete-qualification --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --evidence-root <qualification-root> --execute\nbuildchain dev authority lease-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority heartbeat-landing --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --provider-attempt admitted-provider-attempt.json --execute\nbuildchain dev authority recover --repository owner/repository \\\n --branch dev/v4/v4.0 --execute\nbuildchain dev authority admit-merge-group --repository owner/repository \\\n --branch dev/v4/v4.0 --candidate-id <root> \\\n --authority-token <root> --authority-generation 1 \\\n --merge-group-head <sha>\n```\n\nTerminal settlement releases either authority immediately from exact evidence;\nit does not wait for TTL. Exact duplicate settlement is a state-root-preserving\nno-op. The default `buildchain dev warrant` commands, v1 state bytes, and\nsingle-flight behavior do not change while this mode is off.\n\nMigration also accepts the historical non-native v1 form whose active Warrant\npredates the `phase` field. It preserves that exact fence as Landing authority\nand records a schema-safe `legacy-compatibility-only` qualification carrying the\nexact legacy state root, token, generation, source proof, and phase. Fields that\nv1 never established remain explicitly null, including the phase-less\nqualification time and every native proof field. A migrated qualified v1\nWarrant retains its historical proof roots as compatibility facts, but\n`nativeProofAuthority` remains false because migration cannot reconstruct the\nv2 execution binding or qualification contract. Neither form can claim new\nnative proof or reuse authority. Phase-less native candidates remain invalid.\n\n## Workflow rollout and rollback\n\nThe reusable `dev-pr-auto-merge.yml` supports three explicit rollout modes:\n\n- `off` preserves the previous exact-head admission controller;\n- `shadow` qualifies the source and emits a read-only queue submission plan;\n- `required` persists the submission, selects a provisional Warrant, runs or\n reuses semantic native proof under heartbeat, atomically qualifies the same\n fence, and refuses GitHub enqueue unless the immutable queue commit, state root, active Warrant, and\n selected candidate all pass exact readback validation. Immediately before\n enqueue, the controller writes and then reads back both the exact-head queue\n admission status and active lease status. Only after those statuses are\n visible at their required states does it reread the pull request head,\n protected base, native merge queue, and current protected Warrant state. The\n final rooted admission transaction binds the frozen base, source head,\n candidate, fencing token, generation, native proof roots, Project Cut proof,\n and both status contexts. Status propagation is retried before enqueue;\n base, head, queue-predecessor, lease, or Warrant drift revokes both statuses\n without attempting enqueue. A previously valid result is not authority after terminal\n closeout. Re-running qualification for the same selected head may regenerate\n timestamped proof bytes, but it retains the immutable active Warrant and its\n originally selected proof instead of rewriting or rejecting that attempt.\n Each candidate also retains the exact successful source workflow run. If a\n controller discovers that another candidate owns the active Warrant, a\n configured consumer workflow is dispatched immediately for that exact PR,\n head, source run, Assignment and Initiative, source identity and patch,\n plan, closure, dependency, toolchain, environment, affected paths, delivery\n class, and priority; the candidate is not left waiting for a patrol cron.\n The shipped Buildchain caller and native template configure this handoff path\n and accept the same complete input contract. A historical phase-less owner\n uses the distinct `legacy-phase-less-active-owner` command path. That path\n carries the exact queue state root observed before its duplicate submission,\n fencing token, generation, PR, head, and source-run binding. The submission\n receipt proves that pre-transition root even though the queue transition\n advances the current state root. The path omits `environment-root`, `native-command`, and\n `native-command-root`, and rejects readback drift. It therefore resumes the\n historical non-native authority without inventing a native command contract\n or upgrading the owner to native proof authority.\n\n The PR-controlled native candidate runs in a distinct GitHub-hosted job with\n no provider write credential in the step or process ancestry. The dependent\n credentialed finalizer runs on another live-readback-proven GitHub-hosted job\n and runner, verifies the content-addressed transfer, then independently rereads\n the PR, protected base, and provider fence before qualification or settlement.\n Detached descendants, including descendants that unset runner tracking, remain\n in the native runner authority domain and cannot enter the fresh finalizer\n domain. Exit zero alone is never treated as provider mutation authority,\n Landing authority, or completed delivery.\n\n Persistent self-hosted runners are intentionally outside this contract. A\n `needs` edge alone does not prove process cleanup or a new authority domain, so\n the finalizer rejects a self-hosted label. Supporting self-hosted execution\n would require separately attested one-job runner destruction and a provider\n readback contract at least as strong as the GitHub-hosted boundary.\n\n Required-mode admission also performs a latest-base Project Cut immediately\n before enqueue. If the protected base advanced, the controller reclassifies\n the exact attributed delta against the rooted native proof. Only a disjoint,\n fully attributed move may reuse that proof; overlap, unknown attribution,\n missing composition, or merge conflict fails with a stable pre-enqueue reason.\n The rooted Project Cut receipt binds the frozen and admitted base SHAs,\n GitHub's exact synthetic merge commit and replay tree, and the unchanged PR\n head. A final base/head/queue/Warrant compare-and-swap readback must still\n match that receipt before the enqueue mutation is attempted.\n\n The protected branch ref is the base authority for that compare-and-swap.\n A pull request's `base.sha` may remain an older composition snapshot while\n GitHub reports the pull request as behind, so it is diagnostic rather than a\n substitute for the separately read protected ref and rooted Project Cut.\n\nFor a required native delivery class, the reusable controller rejects a\nmissing or malformed environment root before runtime checkout, candidate\nsubmission, Warrant selection, or native execution. The input remains\nconditionally optional so `off`, `shadow`, and `non-native-fast` callers keep\ntheir documented behavior.\n\nThe controller persists a completed native proof before its final base\nreclassification. A later exact retry can supply that proof and avoid the\nexpensive native command when the rooted delta still proves reuse safe. A\nduplicate dispatch against the same already-qualified Warrant returns the same\nproof and reuse roots plus a rooted qualification replay output without another\nqueue mutation. Both result forms carry\n`landingAuthority: false`: only the live qualified Warrant plus exact-head\nGitHub merge-queue admission can authorize landing.\n\nThe required controller checks the protected base again after native work. A\ndisjoint attributed delta reuses the proof. Overlap or unknown attribution\ntriggers one automatic revalidation on the latest base; continued overlap,\nnative failure, cancellation, semantic head movement, or an unrecoverable merge\nconflict closes the exact fence. The next queued candidate is notified through\nthe `buildchain-dev-delivery-wake` repository event. Its complete semantic\ncandidate is carried under the single `client_payload.candidate` envelope so\nGitHub's ten-property top-level limit cannot discard proof bindings. If\ncancellation prevents cleanup, lease expiry recovers retained queue age and\nmints a new fence.\n\nConsumers should deploy `shadow` first, inspect receipts, then change their\nprotected caller to `required`. Rollback is a reviewed caller change back to\n`off`; it does not delete queue history or reinterpret old receipts. The\nterminal reusable workflow creates the exact Integration Delivery Proof for a\nmerged candidate (or accepts explicit evidence for another terminal outcome),\nthen closes only the current fencing generation. The separate queued\ncancellation reusable workflow cannot close an active generation; it advances\nthe state ref only when the caller's complete terminal binding and expected-old\nroot still match. A delayed `dequeued` event is ignored when GitHub readback\nshows the same exact PR head is already queued again, so an earlier queue event\ncannot close a newer active Warrant generation.\n\nBuildchain uses the same contract for its own protected dev line through\n`buildchain-dev-delivery.yml`. The manual caller requires the exact PR head and\nsemantic source roots, accepts an optional reusable native proof, keeps both\nthe durable public selector and explicit runtime input on `v4-alpha`, selects\n`delivery-warrant-mode: required`, and targets GitHub Merge Queue. It does not\noffer an `off` switch: rollback is a reviewed change to this caller, not an\noperator-time weakening of a specific delivery attempt.\n\n`templates/native-dev-delivery.yml` provides the corresponding protected-dev\nconsumer workflow. It supports both explicit dispatch and the bounded wake\nevent, calls the allowed floating `@v4-alpha` selector, explicitly passes the v4\nruntime ref that locks every delivery job to the same checkout, and keeps the\nnative command in the consumer repository rather than inventing\nprovider-specific shards. Both callers explicitly bind the queue-admission\nand active-lease status contexts so write/readback fencing uses the same exact\nnames. The reusable workflow defaults the explicit runtime input to\n`v4-alpha`; an empty input or any v3 selector fails before the first runtime\ncheckout.\n\nThis mechanism schedules protected delivery only. It does not serialize local\ndevelopment, source-only checks, unrelated channels, release publication, or\nrunner provisioning. It never grants authority to enable cloud runner\ncampaigns."
|
|
2255
2255
|
},
|
|
2256
2256
|
{
|
|
2257
2257
|
"id": "manual:dev-qualification-patrol",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"workflowCount": 77,
|
|
8
8
|
"actionCount": 8,
|
|
9
9
|
"sitePageCount": 84,
|
|
10
|
-
"docCommandRefCount":
|
|
10
|
+
"docCommandRefCount": 1050,
|
|
11
11
|
"failureCount": 0
|
|
12
12
|
},
|
|
13
13
|
"enumerated": {
|
|
@@ -4999,6 +4999,11 @@
|
|
|
4999
4999
|
"path": "docs/dev-delivery-warrant.md",
|
|
5000
5000
|
"command": "buildchain dev warrant cancel-queued"
|
|
5001
5001
|
},
|
|
5002
|
+
{
|
|
5003
|
+
"id": "dev",
|
|
5004
|
+
"path": "docs/dev-delivery-warrant.md",
|
|
5005
|
+
"command": "buildchain dev warrant recover-legacy-terminal"
|
|
5006
|
+
},
|
|
5002
5007
|
{
|
|
5003
5008
|
"id": "dev",
|
|
5004
5009
|
"path": "docs/dev-delivery-warrant.md",
|
|
@@ -8911,8 +8916,8 @@
|
|
|
8911
8916
|
"workflowRegistryPath": "dist/site/workflow-registry.json",
|
|
8912
8917
|
"pageRegistryPath": "dist/site/page-registry.json",
|
|
8913
8918
|
"cliRegistryDigest": "fbc23073bbae240489a2f826b2c26daadc58e704050c5f8df366509f5c5a1c3e",
|
|
8914
|
-
"workflowRegistryDigest": "
|
|
8915
|
-
"pageRegistryDigest": "
|
|
8919
|
+
"workflowRegistryDigest": "48dcf0d6e798d64f8cb0acb2c7e6af7782b8332f9a254a83512abf9d8e31a49f",
|
|
8920
|
+
"pageRegistryDigest": "620d7dd295b0ed42c046ebea1b2cfb97b69f9e10a0c4f5cb0b796e7e0f1219d1"
|
|
8916
8921
|
},
|
|
8917
8922
|
"comparison": {
|
|
8918
8923
|
"missingCliRegistry": [],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"contract": "kungfu-buildchain-publication-release-registry",
|
|
4
|
-
"generatedAt": "2026-08-28T20:
|
|
5
|
-
"publishedAt": "2026-08-28T20:
|
|
4
|
+
"generatedAt": "2026-08-28T20:30:35.956Z",
|
|
5
|
+
"publishedAt": "2026-08-28T20:30:35.956Z",
|
|
6
6
|
"reproducible": true,
|
|
7
7
|
"timestampPolicy": "ci-injected",
|
|
8
8
|
"deterministicInputs": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"declared Buildchain surface manifest contract"
|
|
20
20
|
],
|
|
21
21
|
"sourceDateEpoch": "0",
|
|
22
|
-
"sourceRevision": "
|
|
22
|
+
"sourceRevision": "3881f9dea6fa750ce5e561fc86419a163ca19b90",
|
|
23
23
|
"timestampPolicyDetails": {
|
|
24
24
|
"contract": "kungfu-buildchain-surface-timestamp-policy",
|
|
25
25
|
"timestampFields": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"package": {
|
|
34
34
|
"name": "@kungfu-tech/buildchain",
|
|
35
|
-
"version": "4.0.
|
|
35
|
+
"version": "4.0.2-alpha.0",
|
|
36
36
|
"versionSource": "package.json#version"
|
|
37
37
|
},
|
|
38
38
|
"sourceKind": "package-site-bundle",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"contract": "kungfu-buildchain-site-manifest",
|
|
4
|
-
"generatedAt": "2026-08-28T20:
|
|
5
|
-
"publishedAt": "2026-08-28T20:
|
|
4
|
+
"generatedAt": "2026-08-28T20:30:35.956Z",
|
|
5
|
+
"publishedAt": "2026-08-28T20:30:35.956Z",
|
|
6
6
|
"reproducible": true,
|
|
7
7
|
"timestampPolicy": "ci-injected",
|
|
8
8
|
"deterministicInputs": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"declared Buildchain surface manifest contract"
|
|
20
20
|
],
|
|
21
21
|
"sourceDateEpoch": "0",
|
|
22
|
-
"sourceRevision": "
|
|
22
|
+
"sourceRevision": "3881f9dea6fa750ce5e561fc86419a163ca19b90",
|
|
23
23
|
"timestampPolicyDetails": {
|
|
24
24
|
"contract": "kungfu-buildchain-surface-timestamp-policy",
|
|
25
25
|
"timestampFields": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"package": {
|
|
39
39
|
"name": "@kungfu-tech/buildchain",
|
|
40
|
-
"version": "4.0.
|
|
40
|
+
"version": "4.0.2-alpha.0",
|
|
41
41
|
"versionSource": "package.json#version"
|
|
42
42
|
},
|
|
43
43
|
"entrypoint": "buildchain-site.json",
|
|
@@ -2039,7 +2039,7 @@
|
|
|
2039
2039
|
"status": "preview",
|
|
2040
2040
|
"owner": "buildchain-workflows",
|
|
2041
2041
|
"maturity": "preview",
|
|
2042
|
-
"introducedVersion": "4.0.
|
|
2042
|
+
"introducedVersion": "4.0.2-alpha.0",
|
|
2043
2043
|
"compatibilityPromise": "preserved-through-the-v3-major-line",
|
|
2044
2044
|
"deprecationReplacement": "",
|
|
2045
2045
|
"sunsetCondition": "explicit-breaking-change-review-in-a-future-major-line",
|
|
@@ -2060,7 +2060,7 @@
|
|
|
2060
2060
|
"status": "preview",
|
|
2061
2061
|
"owner": "buildchain-workflows",
|
|
2062
2062
|
"maturity": "preview",
|
|
2063
|
-
"introducedVersion": "4.0.
|
|
2063
|
+
"introducedVersion": "4.0.2-alpha.0",
|
|
2064
2064
|
"compatibilityPromise": "preserved-through-the-v3-major-line",
|
|
2065
2065
|
"deprecationReplacement": "",
|
|
2066
2066
|
"sunsetCondition": "explicit-breaking-change-review-in-a-future-major-line",
|
|
@@ -2081,7 +2081,7 @@
|
|
|
2081
2081
|
"status": "preview",
|
|
2082
2082
|
"owner": "buildchain-workflows",
|
|
2083
2083
|
"maturity": "preview",
|
|
2084
|
-
"introducedVersion": "4.0.
|
|
2084
|
+
"introducedVersion": "4.0.2-alpha.0",
|
|
2085
2085
|
"compatibilityPromise": "preserved-through-the-v3-major-line",
|
|
2086
2086
|
"deprecationReplacement": "",
|
|
2087
2087
|
"sunsetCondition": "explicit-breaking-change-review-in-a-future-major-line",
|
|
@@ -2131,7 +2131,7 @@
|
|
|
2131
2131
|
"status": "preview",
|
|
2132
2132
|
"owner": "buildchain-workflows",
|
|
2133
2133
|
"maturity": "preview",
|
|
2134
|
-
"introducedVersion": "4.0.
|
|
2134
|
+
"introducedVersion": "4.0.2-alpha.0",
|
|
2135
2135
|
"compatibilityPromise": "preserved-through-the-v3-major-line",
|
|
2136
2136
|
"deprecationReplacement": "",
|
|
2137
2137
|
"sunsetCondition": "explicit-breaking-change-review-in-a-future-major-line",
|
|
@@ -203,6 +203,27 @@ buildchain dev warrant cancel-queued --repository owner/repository \
|
|
|
203
203
|
Warrant-scoped mutations require the exact fencing token and lease generation.
|
|
204
204
|
`close` also requires a rooted terminal evidence object.
|
|
205
205
|
|
|
206
|
+
Legacy v3 queues that predate the native command contract can be observed but
|
|
207
|
+
cannot enter ordinary mutation paths. If every live legacy candidate has an
|
|
208
|
+
exact completed failed hosted run with zero nonterminal jobs, an operator may
|
|
209
|
+
atomically terminalize that complete live set:
|
|
210
|
+
|
|
211
|
+
```sh
|
|
212
|
+
buildchain dev warrant recover-legacy-terminal \
|
|
213
|
+
--repository owner/repository --branch dev/v4/v4.0 \
|
|
214
|
+
--expected-old sha256:<current-state-root> \
|
|
215
|
+
--legacy-terminal-recovery legacy-terminal-recovery.json --execute
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The request must cover every live legacy native candidate exactly once and
|
|
219
|
+
bind each stored candidate, source workflow run, terminal provider result, and
|
|
220
|
+
content-addressed evidence object. Each evidence object carries the exact
|
|
221
|
+
provider job identities, attempts, conclusions, and completion timestamps; all
|
|
222
|
+
jobs must be terminal and at least one must have failed. The transition writes
|
|
223
|
+
one expected-old state update and requires the resulting queue to pass the
|
|
224
|
+
current strict native-proof contract. The recovery cannot qualify, merge,
|
|
225
|
+
requeue, or partially advance a legacy authority state.
|
|
226
|
+
|
|
206
227
|
On the v4 line, `observe` also has an explicit `--read-mode v4` candidate. It requires retained exact semantic-diff qualification and source binding, invokes the effect-disabled Rust projection, retains parity evidence, and returns the existing observation shape. The default and rollback mode remains `v3`; mutation commands ignore the read switch. See [`v4-delivery-warrant-read-candidate.md`](v4-delivery-warrant-read-candidate.md).
|
|
207
228
|
|
|
208
229
|
Expensive native commands must run through `dev-delivery-native-run.mjs` (or an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungfu-tech/buildchain",
|
|
3
|
-
"version": "4.0.
|
|
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",
|
|
@@ -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
|
+
}
|
|
@@ -33,11 +33,8 @@ function terminalEvidenceOptions(rest, environment) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
const [command = "", ...rest] = args;
|
|
36
|
+
function authorityStateOptions(rest, environment) {
|
|
38
37
|
return {
|
|
39
|
-
command,
|
|
40
|
-
repository: flag(rest, "repository", environment.GITHUB_REPOSITORY),
|
|
41
38
|
branch: flag(
|
|
42
39
|
rest,
|
|
43
40
|
"branch",
|
|
@@ -53,6 +50,20 @@ export function devDeliveryCliOptions(args = [], environment = process.env) {
|
|
|
53
50
|
"expected-old",
|
|
54
51
|
environment.BUILDCHAIN_DEV_DELIVERY_EXPECTED_OLD,
|
|
55
52
|
),
|
|
53
|
+
legacyTerminalRecoveryPath: flag(
|
|
54
|
+
rest,
|
|
55
|
+
"legacy-terminal-recovery",
|
|
56
|
+
environment.BUILDCHAIN_DEV_DELIVERY_LEGACY_TERMINAL_RECOVERY,
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function devDeliveryCliOptions(args = [], environment = process.env) {
|
|
62
|
+
const [command = "", ...rest] = args;
|
|
63
|
+
return {
|
|
64
|
+
command,
|
|
65
|
+
repository: flag(rest, "repository", environment.GITHUB_REPOSITORY),
|
|
66
|
+
...authorityStateOptions(rest, environment),
|
|
56
67
|
pullRequestNumber: flag(
|
|
57
68
|
rest,
|
|
58
69
|
"pull-request",
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
settleDevDeliveryTerminalEvent,
|
|
16
16
|
submitDevDeliveryCandidate,
|
|
17
17
|
} from "../packages/core/dev-delivery-warrant.js";
|
|
18
|
+
import { recoverLegacyTerminalDevDeliveryQueue } from "../packages/core/dev-delivery-warrant-legacy-recovery.js";
|
|
18
19
|
import { runV4DeliveryWarrantReadCandidate } from "../packages/core/v4-delivery-warrant-read-candidate.js";
|
|
19
20
|
|
|
20
21
|
import { GitHubDevDeliveryStore } from "./dev-delivery-warrant-store.mjs";
|
|
@@ -80,7 +81,9 @@ function reconcileTerminalEvidenceCommand(queue, options) {
|
|
|
80
81
|
|
|
81
82
|
function requireTerminalEvidenceCas(options) {
|
|
82
83
|
if (
|
|
83
|
-
|
|
84
|
+
["reconcile-terminal-evidence", "recover-legacy-terminal"].includes(
|
|
85
|
+
options.command,
|
|
86
|
+
) &&
|
|
84
87
|
options.execute &&
|
|
85
88
|
!options.expectedOldStateRoot
|
|
86
89
|
) {
|
|
@@ -267,6 +270,13 @@ function transitionFor(command, queue, options) {
|
|
|
267
270
|
}
|
|
268
271
|
if (command === "recover")
|
|
269
272
|
return recoverExpiredDevDeliveryWarrant(queue, { now: options.now });
|
|
273
|
+
if (command === "recover-legacy-terminal") {
|
|
274
|
+
return recoverLegacyTerminalDevDeliveryQueue(
|
|
275
|
+
queue,
|
|
276
|
+
jsonFile(options.legacyTerminalRecoveryPath, "legacy terminal recovery"),
|
|
277
|
+
{ now: options.now },
|
|
278
|
+
);
|
|
279
|
+
}
|
|
270
280
|
if (command === "close") {
|
|
271
281
|
return closeDevDeliveryWarrant(queue, warrantIdentity(queue, options), {
|
|
272
282
|
outcome: options.outcome,
|
|
@@ -416,7 +426,9 @@ export async function runDevDeliveryCommand(optionsInput = {}, clientInput) {
|
|
|
416
426
|
stateRef: options.stateRef,
|
|
417
427
|
protectedBase: options.branch,
|
|
418
428
|
now: options.now,
|
|
419
|
-
allowLegacyV3Readback:
|
|
429
|
+
allowLegacyV3Readback: ["observe", "recover-legacy-terminal"].includes(
|
|
430
|
+
options.command,
|
|
431
|
+
),
|
|
420
432
|
});
|
|
421
433
|
if (
|
|
422
434
|
options.expectedOldStateRoot &&
|
|
@@ -496,7 +508,7 @@ export async function runDevDeliveryCommand(optionsInput = {}, clientInput) {
|
|
|
496
508
|
}
|
|
497
509
|
|
|
498
510
|
function usage() {
|
|
499
|
-
return "Usage:\n buildchain dev warrant <submit|select|heartbeat|qualify|recover|close|settle|reconcile-terminal-evidence|cancel-queued|observe> --repository owner/repo --branch dev/vN/vN.M [--execute] [--output FILE] [--json]\n\nRead candidate:\n observe --read-mode v4 --read-qualification FILE --read-qualification-root sha256:... --read-typescript-revision SHA --read-rust-revision SHA --read-validator-version TOKEN [--read-evidence-output FILE]\n";
|
|
511
|
+
return "Usage:\n buildchain dev warrant <submit|select|heartbeat|qualify|recover|recover-legacy-terminal|close|settle|reconcile-terminal-evidence|cancel-queued|observe> --repository owner/repo --branch dev/vN/vN.M [--execute] [--output FILE] [--json]\n\nLegacy terminal recovery:\n recover-legacy-terminal --expected-old sha256:... --legacy-terminal-recovery FILE [--execute]\n\nRead candidate:\n observe --read-mode v4 --read-qualification FILE --read-qualification-root sha256:... --read-typescript-revision SHA --read-rust-revision SHA --read-validator-version TOKEN [--read-evidence-output FILE]\n";
|
|
500
512
|
}
|
|
501
513
|
|
|
502
514
|
async function main() {
|
|
@@ -513,6 +525,7 @@ async function main() {
|
|
|
513
525
|
"heartbeat",
|
|
514
526
|
"qualify",
|
|
515
527
|
"recover",
|
|
528
|
+
"recover-legacy-terminal",
|
|
516
529
|
"close",
|
|
517
530
|
"settle",
|
|
518
531
|
"reconcile-terminal-evidence",
|