@kungfu-tech/buildchain 3.0.9-alpha.1 → 3.0.9-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/actions/promote-buildchain-ref/README.md +4 -0
  2. package/bin/buildchain.mjs +9 -1
  3. package/bin/internal/trust-release-release-handlers.mjs +1 -0
  4. package/contracts/dev-delivery-authority-v2.schema.json +253 -0
  5. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +47 -0
  6. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +47 -0
  7. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +40 -0
  8. package/contracts/next-development-request-v1.schema.json +66 -0
  9. package/contracts/next-development-transition-v1.schema.json +292 -0
  10. package/dist/site/agent-index.json +1 -0
  11. package/dist/site/artifact-schemas.json +2 -0
  12. package/dist/site/buildchain-contract.json +92 -27
  13. package/dist/site/buildchain-site.json +351 -38
  14. package/dist/site/capability-registry.json +7 -6
  15. package/dist/site/cli-registry.json +43 -3
  16. package/dist/site/controller-registry.json +6 -2
  17. package/dist/site/kfd-claims.json +223 -12
  18. package/dist/site/kfd-upstream-aggregate.json +9 -9
  19. package/dist/site/manual-registry.json +23 -7
  20. package/dist/site/node-api-registry.json +7926 -4533
  21. package/dist/site/page-registry.json +332 -27
  22. package/dist/site/public-surface-audit.json +359 -11
  23. package/dist/site/publication-registry.json +4 -4
  24. package/dist/site/release-passport-check-manifest.json +1 -0
  25. package/dist/site/release-provenance.json +14 -0
  26. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +442 -0
  27. package/dist/site/schemas/release-passport-v1.schema.json +3 -0
  28. package/dist/site/site-manifest.json +19 -11
  29. package/dist/site/workflow-registry.json +21 -10
  30. package/docs/MAP.md +5 -2
  31. package/docs/adopter-delivery-gate.md +106 -0
  32. package/docs/aws-us-elastic-runner-burst-plane.md +30 -3
  33. package/docs/cli-reference.md +202 -15
  34. package/docs/dev-alpha-candidate-patrol.md +8 -0
  35. package/docs/dev-delivery-qualification-landing-adr.md +137 -0
  36. package/docs/dev-delivery-warrant.md +149 -22
  37. package/docs/kfd-support.md +7 -2
  38. package/docs/next-development-transition.md +119 -0
  39. package/docs/node-api-reference.md +402 -204
  40. package/docs/release-governance.md +10 -7
  41. package/docs/release-passport.md +18 -2
  42. package/docs/versioning.md +4 -1
  43. package/package.json +23 -6
  44. package/packages/core/README.md +25 -0
  45. package/packages/core/adopter-delivery-gate.js +576 -0
  46. package/packages/core/adopter-delivery-json.js +66 -0
  47. package/packages/core/adopter-delivery-passport.js +259 -0
  48. package/packages/core/adopter-delivery-vectors.js +158 -0
  49. package/packages/core/adopter-delivery-vectors.json +77 -0
  50. package/packages/core/artifact-verification-envelope.js +5 -5
  51. package/packages/core/buildchain-agent-manuals.js +1 -0
  52. package/packages/core/buildchain-channel-identity.js +2 -3
  53. package/packages/core/buildchain-compatibility-proof.js +22 -0
  54. package/packages/core/buildchain-delivery-bootstrap.js +240 -0
  55. package/packages/core/buildchain-delivery-infrastructure.js +164 -0
  56. package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
  57. package/packages/core/channel-candidate.js +8 -0
  58. package/packages/core/channel-promotion-baseline.js +52 -0
  59. package/packages/core/dev-alpha-candidate-selection.js +10 -2
  60. package/packages/core/dev-delivery-authority.js +996 -0
  61. package/packages/core/dev-delivery-native-proof.js +418 -0
  62. package/packages/core/dev-delivery-warrant-settlement.js +67 -20
  63. package/packages/core/dev-delivery-warrant.js +129 -46
  64. package/packages/core/kfd-adopter-category-driver.js +167 -0
  65. package/packages/core/kfd-adopter-manifest.js +49 -50
  66. package/packages/core/legacy-kfd-adopter-driver.js +167 -0
  67. package/packages/core/next-development-candidate-reservation.js +186 -0
  68. package/packages/core/next-development-controller.js +726 -0
  69. package/packages/core/next-development-projection.js +288 -0
  70. package/packages/core/next-development-transition.js +738 -0
  71. package/packages/core/paper-agent-entry.js +7 -4
  72. package/packages/core/paper.js +14 -7
  73. package/packages/core/published-delivery-authority.js +247 -0
  74. package/packages/core/release-passport-contract.js +10 -6
  75. package/packages/core/release-passport.js +37 -13
  76. package/scripts/aws-macos-jit-controller-core.mjs +239 -4
  77. package/scripts/aws-macos-jit-controller.mjs +198 -2
  78. package/scripts/aws-macos-jit-instance-rehydrate.mjs +260 -0
  79. package/scripts/aws-macos-jit-source-rebind.mjs +235 -14
  80. package/scripts/aws-macos-jit.mjs +12 -0
  81. package/scripts/buildchain-cli-help.mjs +10 -2
  82. package/scripts/check-internal-architecture.mjs +1 -0
  83. package/scripts/check-inventory.mjs +12 -1
  84. package/scripts/dev-alpha-candidate-patrol.mjs +22 -1
  85. package/scripts/dev-delivery-authority.mjs +368 -0
  86. package/scripts/dev-delivery-native-run.mjs +235 -0
  87. package/scripts/dev-delivery-proof.mjs +64 -2
  88. package/scripts/dev-delivery-two-phase-resume.mjs +90 -0
  89. package/scripts/dev-delivery-two-phase.mjs +577 -0
  90. package/scripts/dev-delivery-warrant.mjs +48 -6
  91. package/scripts/dev-pr-delivery-warrant.mjs +19 -14
  92. package/scripts/generate-buildchain-kfd-witnesses.mjs +2 -2
  93. package/scripts/generate-channel-build-workflow.mjs +4 -0
  94. package/scripts/generate-next-development-guidance.mjs +49 -0
  95. package/scripts/generate-site-bundle.mjs +8 -3
  96. package/scripts/init-repo.mjs +135 -62
  97. package/scripts/next-development-self-dogfood-harness.mjs +409 -0
  98. package/scripts/next-development-self-dogfood.mjs +532 -0
  99. package/scripts/next-development-transition.mjs +47 -0
  100. package/scripts/release-candidate-tail-reseal.mjs +426 -0
  101. package/scripts/seal-artifact-signing-requests.mjs +7 -4
  102. package/scripts/site-capability-metadata.mjs +25 -1
  103. package/scripts/stable-candidate-qualification.mjs +7 -7
  104. package/scripts/workflow-call-contract.mjs +1 -1
  105. package/templates/native-dev-delivery.yml +86 -0
@@ -0,0 +1,137 @@
1
+ ---
2
+ status: accepted
3
+ period: ongoing
4
+ theme: dev-delivery-qualification-landing-authority
5
+ doc_type: architecture-decision-record
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: self-reviewed
11
+ last_reviewed: 2026-08-12
12
+ ---
13
+
14
+ # ADR: Qualification Leases and the exclusive Landing Warrant
15
+
16
+ ## Decision
17
+
18
+ Buildchain has two explicit protected-dev authority modes:
19
+
20
+ 1. `single-flight-warrant` is the default and continues to use the
21
+ `kungfu-buildchain-dev-delivery-warrant-queue` v1 state and
22
+ `buildchain dev warrant` commands unchanged.
23
+ 2. `bounded-qualification-landing` is opt-in and uses the
24
+ `kungfu-buildchain-dev-delivery-authority` v2 state. It may issue up to the
25
+ configured number of Qualification Leases, but it may issue exactly one
26
+ Landing Warrant.
27
+
28
+ The modes use different contracts, state refs, and CLI command families. There
29
+ is no implicit reinterpretation of a v1 Warrant. A consumer turns the new mode
30
+ on only by explicitly migrating the exact current v1 state and deploying the
31
+ v2 controller against the dedicated
32
+ `buildchain/dev-delivery-authority/<dev-line>` state ref.
33
+
34
+ Migration preserves the immutable v1 `stateRoot`, candidate identity, source
35
+ and proof roots, fencing token, generation, and lease times in a rooted
36
+ migration receipt. An active provisional Warrant becomes a
37
+ qualification-only lease and remains unable to admit `merge_group`; an active
38
+ qualified Warrant becomes the one exclusive Landing Warrant. The migration is
39
+ one-shot: a v2 state is never accepted as v1 input, and source/evidence bytes
40
+ are not regenerated. The legacy ref remains immutable rollback evidence.
41
+
42
+ ## Authority invariants
43
+
44
+ A Qualification Lease carries:
45
+
46
+ - `authority = qualification-only`;
47
+ - `mergeGroupAdmission = false`;
48
+ - one exact candidate id, token, generation, issue time, and expiry; and
49
+ - a place in a list bounded by `policy.maxQualificationLeases`.
50
+
51
+ It authorizes expensive qualification work only. It cannot authorize GitHub
52
+ `merge_group`, cannot be upgraded in place to landing authority, and is removed
53
+ when qualification evidence is recorded. Each new candidate declares a sorted
54
+ set of rooted `qualificationDomains`. Candidates with disjoint sets may hold
55
+ leases concurrently. An overlapping set is serialized; an empty set is treated
56
+ as unknown and therefore conflicts with every active candidate. The scheduler
57
+ returns a content-rooted reason for either refusal.
58
+
59
+ The Landing Warrant carries:
60
+
61
+ - `authority = merge-group-admission`;
62
+ - `mergeGroupAdmission = true`;
63
+ - one exact qualified candidate id, token, generation, issue time, and expiry;
64
+ and
65
+ - the only non-null `landingWarrant` slot in the durable state.
66
+
67
+ Only `admitDevDeliveryMergeGroup` and `buildchain dev authority
68
+ admit-merge-group` consume Landing authority. They bind the exact current state
69
+ root, candidate, protected base, source head, merge-group head, token, and
70
+ generation. A Qualification Lease fails closed at this boundary.
71
+
72
+ The state normalizer rejects a lease beyond the configured bound, duplicate
73
+ Qualification Leases for one candidate, a candidate holding qualification and
74
+ Landing authority together, a Landing Warrant without its exact landing
75
+ candidate, and any state-root drift. Git expected-old, non-force ref advancement
76
+ continues to serialize durable mutations. These checks retain the existing
77
+ two-phase safety rule: source/native qualification is evidence, while the
78
+ exclusive final authority is candidate- and integration-specific.
79
+
80
+ ## Bounded scheduler and recovery
81
+
82
+ Landing selection is FIFO among candidates that have completed qualification.
83
+ When a later candidate receives a Landing Warrant, each older nonterminal
84
+ candidate consumes one durable overtake from its
85
+ `policy.maxLandingOvertakes` budget. Once an older candidate reaches that
86
+ bound, later candidates cannot receive a Warrant. The older candidate receives
87
+ the next landing priority after qualification, or reaches a rooted terminal
88
+ failure after `policy.maxQualificationAttempts` heartbeat expiries. This makes
89
+ the bound independent of controller restart frequency or later arrival rate;
90
+ setting it to zero enforces strict FIFO landing priority.
91
+
92
+ Qualification Leases and Landing Warrants both support fenced heartbeats. A
93
+ missed heartbeat is recovered at expiry; recovery releases capacity and emits
94
+ a deterministic content-rooted wake instruction for the next domain-eligible
95
+ qualification candidates and the next fair landing candidate. Completion,
96
+ cancellation, terminal failure, dequeue, and already-merged settlement emit the
97
+ same wake shape. Exact duplicate heartbeats, recovery, and terminal events are
98
+ state-root-preserving no-ops. Competing controllers still commit through one
99
+ expected-old, non-force ref update, so only one transition can become durable.
100
+
101
+ ## Terminal settlement
102
+
103
+ Terminal provider evidence is authoritative cleanup input. A matching merged,
104
+ failed, dequeued, or cancelled candidate releases its Qualification Lease or
105
+ Landing Warrant in the same expected-old state transition, even when the lease
106
+ TTL has not expired. An active authority requires its exact token and
107
+ generation for that transition. Repeating the same outcome and evidence is a
108
+ root-preserving no-op; outcome or evidence drift fails closed. A terminal event
109
+ for a candidate that never entered the state is also an explicit no-op.
110
+
111
+ TTL recovery remains crash recovery, not the normal terminal cleanup path.
112
+
113
+ ## Public contract
114
+
115
+ - Machine schema:
116
+ [`contracts/dev-delivery-authority-v2.schema.json`](../contracts/dev-delivery-authority-v2.schema.json),
117
+ packaged as `dist/site/schemas/dev-delivery-authority-v2.schema.json`.
118
+ - Node API: `@kungfu-tech/buildchain/dev-delivery-authority` exports the v2
119
+ state, migration, lease, heartbeat, recovery, Landing, admission,
120
+ observation, and settlement functions. `@kungfu-tech/buildchain/dev-delivery-warrant`
121
+ remains byte- and behavior-compatible for v1 consumers.
122
+ - CLI: `buildchain dev authority
123
+ <migrate|submit|lease-qualification|heartbeat-qualification|complete-qualification|lease-landing|heartbeat-landing|recover|admit-merge-group|settle|observe>`.
124
+ - Generated references: [`cli-reference.md`](cli-reference.md) and
125
+ [`node-api-reference.md`](node-api-reference.md).
126
+
127
+ All mutations are plan-only unless `--execute` is supplied. Merge-group
128
+ admission is always a read-only authority check; it never mutates GitHub Merge
129
+ Queue itself.
130
+
131
+ ## Consequences
132
+
133
+ Qualification throughput can increase without increasing the number of
134
+ candidates permitted to land. Consumers retain the byte- and behavior-compatible
135
+ single-flight default until they deliberately deploy the v2 mode. The tradeoff
136
+ is a second state contract and controller family; Buildchain keeps that
137
+ separation explicit so a rollout cannot silently weaken Warrant semantics.
@@ -1,5 +1,5 @@
1
1
  ---
2
- status: draft
2
+ status: accepted
3
3
  period: ongoing
4
4
  theme: dev-delivery-warrant
5
5
  doc_type: technical-reference
@@ -7,7 +7,7 @@ source_level: local-files
7
7
  confidence: high
8
8
  sensitivity: public
9
9
  evidence_grade: A
10
- review_state: unreviewed
10
+ review_state: self-reviewed
11
11
  last_reviewed: 2026-08-11
12
12
  ai_provenance:
13
13
  model_family: GPT-5
@@ -38,10 +38,17 @@ and retained enqueue time.
38
38
 
39
39
  Selection is deterministic FIFO plus aging with bounded priority. Priority may
40
40
  reorder queued work, but it cannot preempt the active Warrant. Exactly one
41
- candidate receives a leased Warrant containing a fencing token, lease
42
- generation, expected-old state root, expiry, and the complete exact source
43
- binding. Heartbeat extends only that generation. Expiry recovery rejects the
44
- old token, retains queue age, and returns the candidate to selection.
41
+ candidate receives a `provisional` leased Warrant containing a fencing token,
42
+ lease generation, expected-old state root, expiry, and the complete exact
43
+ source binding. It reserves the next protected-dev landing before expensive
44
+ native shards start, but it is not GitHub Merge Queue admission authority.
45
+ Heartbeat extends only that generation. Native proof success atomically
46
+ upgrades the same token and generation to `qualified`; only then may enqueue
47
+ begin. Expiry fences further mutations by the old token, but it does not prove
48
+ that the old native process stopped. The active Warrant therefore remains in
49
+ place until bounded termination is proven by rooted terminal evidence. Only
50
+ that exact fenced settlement may clear the holder and permit successor
51
+ selection.
45
52
 
46
53
  A terminal event may cancel a candidate before selection without minting a
47
54
  Warrant. This transition is limited to an exact non-active queued candidate and
@@ -51,7 +58,12 @@ An active candidate still requires its current fencing token and lease
51
58
  generation. Exact duplicate cancellation evidence is a visible no-op; identity,
52
59
  state, event, or evidence drift fails closed.
53
60
 
54
- The reusable terminal controller uses one `settle` operation for active,
61
+ The reusable terminal controller classifies authoritative completion,
62
+ cancellation, supersession, native failure, and transient dequeue separately.
63
+ `dequeued` alone never clears an active Warrant: a fresh holder continues with
64
+ the same generation and token, while an expired holder waits for proof that its
65
+ fenced worker stopped. Queued work may still settle as dequeued because it never
66
+ started native execution. The controller uses one `settle` operation for active,
55
67
  queued, already-terminal, and never-admitted pull requests. An active Warrant
56
68
  still requires its exact fence and evidence. A matching queued cancellation is
57
69
  persisted normally. A duplicate terminal event or a pull request that never
@@ -73,23 +85,37 @@ That lane outranks not-yet-leased ordinary work, but never preempts or rewrites
73
85
  an active Warrant; unrelated, conflicted, mismatched, or fabricated claims fail
74
86
  closed before selection.
75
87
 
76
- ## Split proof authority
88
+ ## Three proof authorities
77
89
 
78
- Source Qualification Proof is independent of the moving dev base. It binds the
79
- semantic source, exact source head and patch/tree intent, plan, affected
80
- closure, dependencies, toolchain, covered paths, and shard evidence.
90
+ Source Qualification Proof is created from the cheap source-acceptance gate. It
91
+ binds the semantic source, exact source head and patch/tree intent, plan,
92
+ affected closure, dependencies, toolchain, covered paths, and exact acceptance
93
+ evidence. Ready state and approval are established before provisional
94
+ selection.
81
95
 
82
- Before reuse, the consumer classifies the dev delta:
96
+ Native Qualification Proof is separate. It binds semantic source and patch,
97
+ plan, affected closure, dependency graph, toolchain, the exact execution
98
+ environment contract, covered paths, native shard evidence, and the exact dev
99
+ base used by the native composition. Before reuse, the consumer roots the
100
+ complete attributed Dev delta, including both sides of every rename, then
101
+ classifies it:
83
102
 
84
- - unchanged roots plus an unrelated attributed delta reuse source
85
- qualification and run only a cheap Project Cut replay. GitHub's `behind`
103
+ - unchanged semantic roots plus an unrelated fully attributed base delta reuse
104
+ native qualification and run only a cheap Project Cut replay. GitHub's `behind`
86
105
  state is accepted only when a rooted replay proof binds the exact current
87
106
  protected base, unchanged PR head and source patch, replay tree, required
88
107
  context roots, and a qualified `project.cut.merge-queue-admission/v1`
89
108
  receipt;
90
- - an overlapping delta reruns the affected source shards;
91
- - an unknown graph or changed source, plan, closure, dependency, or toolchain
92
- root fails closed to full source qualification.
109
+ - an overlapping delta reruns affected native shards or the full native plan;
110
+ - an unknown or truncated graph, ambiguous rename, missing attribution, or
111
+ changed source, plan, closure, dependency, toolchain, or environment root
112
+ fails closed to full native qualification.
113
+
114
+ The reuse decision binds the exact old and current Dev heads, normalized changed
115
+ paths and rename pairs in `baseDeltaRoot`. This makes local and hosted replay of
116
+ the same inputs byte-deterministic. Generated outputs that participate in the
117
+ affected closure must be listed in `affected-paths-json`; a delta touching one
118
+ of those surfaces is overlap, not a documentation-only advance.
93
119
 
94
120
  Integration Delivery Proof is separate and cannot be cached across candidates.
95
121
  It binds the exact current dev base, replay tree, GitHub `merge_group` head and
@@ -113,6 +139,19 @@ buildchain dev warrant submit --repository owner/repository \
113
139
  buildchain dev warrant select --repository owner/repository \
114
140
  --branch dev/v4/v4.0 --execute
115
141
 
142
+ buildchain dev proof native --branch dev/v4/v4.0 \
143
+ --qualified-base <sha> --environment-root <root> \
144
+ --affected-paths-json '["packages/native"]' ...
145
+
146
+ buildchain dev proof classify-native --source-proof native-proof.json \
147
+ --current-base <sha> --graph-known true --attribution-complete true \
148
+ --changed-paths-json '[]' --renames-json '[]' ...
149
+
150
+ buildchain dev warrant qualify --repository owner/repository \
151
+ --branch dev/v4/v4.0 --fencing-token <root> --lease-generation 1 \
152
+ --native-proof native-proof.json \
153
+ --native-reuse-decision native-reuse-decision.json --execute
154
+
116
155
  buildchain dev warrant cancel-queued --repository owner/repository \
117
156
  --branch dev/v4/v4.0 --candidate-id <root> --pull-request 123 \
118
157
  --expected-source-head <queued-sha> --observed-source-head <event-sha> \
@@ -120,10 +159,17 @@ buildchain dev warrant cancel-queued --repository owner/repository \
120
159
  --evidence-root <terminal-event-root> --execute
121
160
  ```
122
161
 
123
- `heartbeat`, `recover`, `close`, `settle`, `cancel-queued`, and `observe` use the same durable authority.
162
+ `heartbeat`, `qualify`, `recover`, `close`, `settle`, `cancel-queued`, and `observe` use the same durable authority.
124
163
  Warrant-scoped mutations require the exact fencing token and lease generation.
125
164
  `close` also requires a rooted terminal evidence object.
126
165
 
166
+ Expensive native commands must run through `dev-delivery-native-run.mjs` (or an
167
+ equivalent exact consumer). It performs an exact fenced heartbeat before spawn,
168
+ renews throughout the complete child lifetime, performs a final renewal before
169
+ accepting success, and terminates the process group on heartbeat or fencing
170
+ failure. Missing, stale, expired, or mismatched Warrant state therefore blocks
171
+ native spawn instead of becoming qualification evidence.
172
+
127
173
  Proof commands create, verify, classify, and compose the two proof layers:
128
174
 
129
175
  ```sh
@@ -137,7 +183,7 @@ buildchain dev proof integration --warrant-result warrant.json ...
137
183
 
138
184
  ## Bounded-concurrency shadow qualification
139
185
 
140
- The production queue remains single-flight. A separate effect-disabled shadow
186
+ The default production queue remains single-flight. A separate effect-disabled shadow
141
187
  planner can replay the same deterministic candidate order with a bound of one
142
188
  or two lanes. It does not issue, renew, supersede, close, or persist a Warrant;
143
189
  it cannot enqueue a pull request; and its output explicitly carries no
@@ -168,14 +214,71 @@ additional runner cost, ambiguity, and false positives. A `proceed` result is
168
214
  only evidence for a separate reviewed rollout decision; it never changes the
169
215
  live Warrant schema, queue state, merge-queue policy, or protected branch.
170
216
 
217
+ ## Opt-in bounded qualification and exclusive landing
218
+
219
+ Buildchain also defines an explicit production opt-in that turns successful
220
+ shadow evidence into a separate v2 authority state. It does not widen or
221
+ reinterpret the v1 Warrant queue. The accepted
222
+ [`Qualification Lease and Landing Warrant ADR`](dev-delivery-qualification-landing-adr.md)
223
+ and `contracts/dev-delivery-authority-v2.schema.json` are authoritative.
224
+
225
+ In `bounded-qualification-landing` mode, a configured number of exact
226
+ Qualification Leases may coexist. Each lease carries
227
+ `authority = qualification-only` and `mergeGroupAdmission = false`. Completing
228
+ qualification records evidence and releases that lease. Qualified candidates
229
+ then wait for the one `Landing Warrant`, which alone carries
230
+ `authority = merge-group-admission` and may be checked for `merge_group`
231
+ admission.
232
+
233
+ Concurrency is granted only across disjoint rooted `qualificationDomains`.
234
+ Overlap and unknown domains are held behind the active safety boundary with an
235
+ explicit content-rooted reason. `maxLandingOvertakes` prevents a slow older
236
+ candidate from being bypassed indefinitely, while `maxQualificationAttempts`
237
+ turns repeated heartbeat loss into a rooted terminal failure. Every release
238
+ returns a deterministic rooted wake instruction; an exact duplicate release or
239
+ recovery is a state-root-preserving no-op.
240
+
241
+ The public command family is explicit:
242
+
243
+ ```sh
244
+ buildchain dev authority migrate --repository owner/repository \
245
+ --branch dev/v3/v3.0 --legacy-state v1-queue.json --execute --json
246
+ buildchain dev authority lease-qualification --repository owner/repository \
247
+ --branch dev/v4/v4.0 --execute
248
+ buildchain dev authority heartbeat-qualification --repository owner/repository \
249
+ --branch dev/v4/v4.0 --candidate-id <root> \
250
+ --authority-token <root> --authority-generation 1 --execute
251
+ buildchain dev authority complete-qualification --repository owner/repository \
252
+ --branch dev/v4/v4.0 --candidate-id <root> \
253
+ --authority-token <root> --authority-generation 1 \
254
+ --evidence-root <qualification-root> --execute
255
+ buildchain dev authority lease-landing --repository owner/repository \
256
+ --branch dev/v4/v4.0 --execute
257
+ buildchain dev authority heartbeat-landing --repository owner/repository \
258
+ --branch dev/v4/v4.0 --candidate-id <root> \
259
+ --authority-token <root> --authority-generation 1 --execute
260
+ buildchain dev authority recover --repository owner/repository \
261
+ --branch dev/v4/v4.0 --execute
262
+ buildchain dev authority admit-merge-group --repository owner/repository \
263
+ --branch dev/v4/v4.0 --candidate-id <root> \
264
+ --authority-token <root> --authority-generation 1 \
265
+ --merge-group-head <sha>
266
+ ```
267
+
268
+ Terminal settlement releases either authority immediately from exact evidence;
269
+ it does not wait for TTL. Exact duplicate settlement is a state-root-preserving
270
+ no-op. The default `buildchain dev warrant` commands, v1 state bytes, and
271
+ single-flight behavior do not change while this mode is off.
272
+
171
273
  ## Workflow rollout and rollback
172
274
 
173
275
  The reusable `dev-pr-auto-merge.yml` supports three explicit rollout modes:
174
276
 
175
277
  - `off` preserves the previous exact-head admission controller;
176
278
  - `shadow` qualifies the source and emits a read-only queue submission plan;
177
- - `required` persists the submission, selects the Warrant, and refuses GitHub
178
- enqueue unless the immutable queue commit, state root, active Warrant, and
279
+ - `required` persists the submission, selects a provisional Warrant, runs or
280
+ reuses semantic native proof under heartbeat, atomically qualifies the same
281
+ fence, and refuses GitHub enqueue unless the immutable queue commit, state root, active Warrant, and
179
282
  selected candidate all pass exact readback validation. Immediately before
180
283
  enqueue, the controller also rereads the current protected state ref and
181
284
  verifies the active candidate, fencing token, generation, pull request, and
@@ -188,6 +291,25 @@ The reusable `dev-pr-auto-merge.yml` supports three explicit rollout modes:
188
291
  configured consumer workflow is dispatched immediately for that exact PR,
189
292
  head, and source run; the candidate is not left waiting for a patrol cron.
190
293
 
294
+ The controller persists a completed native proof before its final base
295
+ reclassification. A later exact retry can supply that proof and avoid the
296
+ expensive native command when the rooted delta still proves reuse safe. A
297
+ duplicate dispatch against the same already-qualified Warrant returns the same
298
+ proof and reuse roots without another queue mutation. Both result forms carry
299
+ `landingAuthority: false`: only the live qualified Warrant plus exact-head
300
+ GitHub merge-queue admission can authorize landing.
301
+
302
+ The required controller checks the protected base again after native work. A
303
+ disjoint attributed delta reuses the proof. Overlap or unknown attribution
304
+ triggers one automatic revalidation on the latest base; continued overlap,
305
+ native failure, cancellation, semantic head movement, or an unrecoverable merge
306
+ conflict closes the exact fence. The next queued candidate is notified through
307
+ the `buildchain-dev-delivery-wake` repository event. Its complete semantic
308
+ candidate is carried under the single `client_payload.candidate` envelope so
309
+ GitHub's ten-property top-level limit cannot discard proof bindings. If
310
+ cancellation prevents cleanup, lease expiry recovers retained queue age and
311
+ mints a new fence.
312
+
191
313
  Consumers should deploy `shadow` first, inspect receipts, then change their
192
314
  protected caller to `required`. Rollback is a reviewed caller change back to
193
315
  `off`; it does not delete queue history or reinterpret old receipts. The
@@ -202,11 +324,16 @@ cannot close a newer active Warrant generation.
202
324
 
203
325
  Buildchain uses the same contract for its own protected dev line through
204
326
  `buildchain-dev-delivery.yml`. The manual caller requires the exact PR head and
205
- all native/source proof roots, pins the runtime to the caller commit, selects
327
+ semantic source roots, accepts an optional reusable native proof, pins the runtime to the caller commit, selects
206
328
  `delivery-warrant-mode: required`, and targets GitHub Merge Queue. It does not
207
329
  offer an `off` switch: rollback is a reviewed change to this caller, not an
208
330
  operator-time weakening of a specific delivery attempt.
209
331
 
332
+ `buildchain init --type native` generates the corresponding protected-dev
333
+ consumer workflow. It supports both explicit dispatch and the bounded wake
334
+ event, uses the same reusable controller, and keeps the native command in the
335
+ consumer repository rather than inventing provider-specific shards.
336
+
210
337
  This mechanism schedules protected delivery only. It does not serialize local
211
338
  development, source-only checks, unrelated channels, release publication, or
212
339
  runner provisioning. It never grants authority to enable cloud runner
@@ -77,8 +77,13 @@ KFD records and evidence by SHA-256. The result uses
77
77
  `buildchain kfd support project` derives a compatibility projection from the
78
78
  standard adopter manifest and its exact passing gate. The adopter manifest is
79
79
  the sole KFD-1..13 declaration authority; the command rejects stale package,
80
- source, witness, registry, verifier-set, and KFD-4/5/7 gate roots. The emitted
81
- matrix is not an independent declaration and cannot widen adopter claims.
80
+ source, witness, registry, verifier-set, and KFD-4/5/7 gate roots. Gate creation
81
+ accepts an explicit `expectedAdopterId`, `expectedSourceRepository`, and
82
+ `expectedSourceSha`; omitting the first two preserves the Buildchain
83
+ self-release default. The gate, every product-gate projection, the legacy
84
+ matrix, Release Passport, and artifact evidence all retain that exact
85
+ adopter/repository/source closure. The emitted matrix is not an independent
86
+ declaration and cannot widen adopter claims.
82
87
 
83
88
  ## KFD-1
84
89
 
@@ -0,0 +1,119 @@
1
+ ---
2
+ status: preview
3
+ period: ongoing
4
+ theme: next-development-transition
5
+ doc_type: generated-contract-guidance
6
+ source_level: generated-from-node-contract
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: self-reviewed
11
+ last_reviewed: 2026-08-11
12
+ ---
13
+
14
+ # Next-development Transition
15
+
16
+ This document is generated from
17
+ `packages/core/next-development-transition.js` and
18
+ `packages/core/next-development-controller.js` and
19
+ `packages/core/next-development-projection.js`. Edit those sources and run
20
+ `node scripts/generate-next-development-guidance.mjs`; direct edits fail the
21
+ projection drift check.
22
+
23
+ ## Contract
24
+
25
+ - Contract: `kungfu-buildchain-next-development-transition/v1`
26
+ - Durable controller: `kungfu-buildchain-next-development-controller/v1`
27
+ - ADR: [ADR 0002](../architecture/decisions/0002-next-development-transition.md)
28
+ - States: `planned`, `waiting-anchor`, `materialized`, `pr-pending`, `merged`, `verified`
29
+ - Legal version models: `semver/auto` and `anchored/manual`
30
+ - Invariant: A completed Alpha remains successful and its refs remain immutable while the next-development transition is incomplete.
31
+
32
+ An Alpha publication is terminal success independently of this transition.
33
+ The idempotency key is a deterministic hash of the completed-Alpha root,
34
+ repository, legal model, and sorted declared paths. Incomplete Dev preparation
35
+ therefore cannot relabel Alpha N as failed, and replay cannot select a different
36
+ Alpha or path set.
37
+
38
+ ## Durable controller
39
+
40
+ `scheduleNextDevelopmentController` atomically creates one child for the
41
+ repository and completed-Alpha root. Identical wakes reuse it. The store
42
+ boundary requires read, create-if-absent, and compare-and-swap operations; the
43
+ controller root fences every checkpoint. Materialization uses an operation key
44
+ derived from the child, exact current protected Dev SHA, and reviewed target,
45
+ so a fresh runner can recover an already-created commit instead of rebuilding
46
+ the Alpha candidate or depending on the original runner workspace.
47
+
48
+ Before opening the protected version PR, the controller reads Dev again. A
49
+ moved head makes the prepared attempt `superseded`; the following wake
50
+ regenerates only declared version material from that latest SHA. After merge,
51
+ `verified` remains unreachable until protected Dev readback contains the
52
+ prepared commit and its target version, source roots, and derived roots exactly
53
+ match the checkpoint. The executor surface contains no Alpha publication, tag,
54
+ release, or package operation.
55
+
56
+ Alpha finalization no longer treats a non-fast-forward Dev update as successful
57
+ bookkeeping. It requires an exact checkout of the current Dev head, regenerates
58
+ the declared version lifecycle there, and uses a non-force merge or reusable
59
+ protected version PR. Candidate Patrol ignores both the generated preparation
60
+ commit and its two-parent integration commit. Before a later product candidate
61
+ can settle, Patrol reads every prepared version path at the candidate SHA and
62
+ requires the exact reserved blob identities; missing or stale state blocks
63
+ before a Release Cut or heavy candidate build.
64
+
65
+ ## Version models
66
+
67
+ `semver/auto` increments the Alpha sequence on the same semantic patch. For
68
+ example, completed `1.4.2-alpha.7` plans `1.4.2-alpha.8`. It must not accept an anchor or an
69
+ operator-selected target.
70
+
71
+ `anchored/manual` enters `waiting-anchor` until the caller provides both a
72
+ semantic target and the exact digest of the configured anchor manifest. The
73
+ adapter verifies the manifest already present in the checkout; it never invents
74
+ or edits upstream anchor facts. `semver/manual` and `anchored/auto` are
75
+ invalid.
76
+
77
+ ## Hosted self-dogfood and adoption
78
+
79
+ `.github/workflows/buildchain-alpha-self-dogfood.yml` calls the same public
80
+ `build.yml@v3-alpha` router as a consumer. After the hosted build succeeds, one
81
+ runner uses the real version-state adapter and checkpoints an injected transient
82
+ durable-state write failure. A separate runner restores the adapter operation
83
+ without rebuilding Alpha, supersedes it when protected Dev moves, and preserves
84
+ `pr-pending` while the protected PR is delayed. The final artifact roots the
85
+ exact runtime SHA, controller transaction, both legal version-model outcomes,
86
+ and an exact hosted protected Dev readback. Stable qualification recomputes and
87
+ rejects evidence that omits or drifts any of those bindings.
88
+
89
+ Production consumers, including Kungfu, adopt the proved contract through
90
+ `kungfu-systems/buildchain/.github/workflows/build.yml@v3`. The evidence retains
91
+ the exact resolved SHA for audit, but the committed production coordinate is the
92
+ floating major contract rather than an exact-SHA pin.
93
+
94
+ ## Local adapter
95
+
96
+ From a normal Buildchain checkout:
97
+
98
+ ```sh
99
+ node scripts/next-development-transition.mjs materialize --cwd . --input <request.json>
100
+ ```
101
+
102
+ The command prints a rooted plan and performs no write by default. `--write`
103
+ may change only regular, non-symlink source files listed by `version.files`
104
+ in the loaded Buildchain config. The rooted adapter contract separately names
105
+ `version.derived_files` as allowed changes, `version.manifest` as read-only,
106
+ `BUILDCHAIN_VERSION` as the target input, `lifecycle.version-state` as the
107
+ derived-material stage, and `lifecycle.verify` as the truth gate. The
108
+ reference writer fails closed when derived files exist because transaction
109
+ execution is outside this contract slice. It performs no Git operation, ref
110
+ update, network request, provider call, lifecycle command, or anchor edit.
111
+
112
+ Preparing development state creates no tag, Release, public package, or
113
+ candidate. Those public effects remain outside the local adapter contract.
114
+
115
+ The request schema is
116
+ `contracts/next-development-request-v1.schema.json`; the durable record schema
117
+ is `contracts/next-development-transition-v1.schema.json`. Positive and
118
+ negative examples live under
119
+ `contracts/fixtures/next-development-transition-v1/`.