@kungfu-tech/buildchain 3.0.9-alpha.9 → 4.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/AGENTS.md +39 -0
  2. package/README.md +17 -13
  3. package/actions/promote-buildchain-ref/README.md +0 -10
  4. package/actions/release-tail/README.md +6 -10
  5. package/architecture/internal-capabilities.json +502 -0
  6. package/architecture/maintainability-baseline.json +59 -0
  7. package/architecture/maintainability-policy.json +1384 -0
  8. package/architecture/release-tail-contract-inventory.json +587 -0
  9. package/architecture/v3-core-mechanism-inventory.json +1043 -0
  10. package/architecture/v3-core-mechanism-inventory.md +67 -0
  11. package/architecture/v4-adopter-delivery-parity.json +47 -0
  12. package/architecture/v4-architecture-constitution.md +210 -0
  13. package/architecture/v4-bootstrap-authority.json +56 -0
  14. package/architecture/v4-canonical-contract-fixtures.json +105 -0
  15. package/architecture/v4-capability-state-machine-manifest.json +480 -0
  16. package/architecture/v4-capability-state-machine-manifest.schema.json +202 -0
  17. package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.json +830 -0
  18. package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.md +223 -0
  19. package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.schema.json +318 -0
  20. package/architecture/v4-delivery-warrant-shadow-fixtures.json +227 -0
  21. package/architecture/v4-delivery-warrant-shadow-fixtures.schema.json +67 -0
  22. package/architecture/v4-exception-ledger.json +5 -0
  23. package/architecture/v4-exception-ledger.schema.json +56 -0
  24. package/architecture/v4-partial-mutation-recovery-qualification.json +65 -0
  25. package/architecture/v4-platform-stage-checkpoints.json +97 -0
  26. package/architecture/v4-provider-operation-journal-contract.json +113 -0
  27. package/architecture/v4-release-activation-shadow-domain.json +61 -0
  28. package/architecture/v4-release-train-parity.json +68 -0
  29. package/architecture/v4-rust-libnode-bridge-evaluation.json +107 -0
  30. package/architecture/v4-rust-libnode-bridge-spike.md +85 -0
  31. package/architecture/v4-stable-publication-fence.json +66 -0
  32. package/architecture/v4-stage-capsule-contract.json +90 -0
  33. package/architecture/v4-stage-capsule-qualification.json +99 -0
  34. package/architecture/v4-stage-capsule-resume-planner.json +52 -0
  35. package/architecture/v4-stage-capsule-store-contract.json +72 -0
  36. package/bin/buildchain.mjs +15 -10
  37. package/contracts/auditable-demo-scenario-v1.schema.json +1 -1
  38. package/contracts/buildchain-v2-residuals-v1.json +2 -2
  39. package/contracts/fixtures/v4-delivery-warrant-trace-v1/golden.json +158 -0
  40. package/contracts/fixtures/v4-delivery-warrant-trace-v1/property.json +380 -0
  41. package/contracts/fixtures/v4-delivery-warrant-trace-v1/replay.json +163 -0
  42. package/contracts/fixtures/v4-partial-mutation-recovery-v1/shared.json +155 -0
  43. package/contracts/fixtures/v4-provider-operation-journal-v1/shared.json +457 -0
  44. package/contracts/fixtures/v4-provider-readback-idempotency-v1/shared.json +682 -0
  45. package/contracts/fixtures/v4-release-activation-shadow-v1/shared.json +53 -0
  46. package/contracts/fixtures/v4-stable-publication-fence-v1/shared.json +56 -0
  47. package/contracts/fixtures/v4-stage-capsule-resume-v1/late-platform-failure.json +176 -0
  48. package/contracts/fixtures/v4-stage-capsule-store-v1/shared.json +132 -0
  49. package/contracts/fixtures/v4-stage-capsule-v1/shared.json +111 -0
  50. package/contracts/v4-canonical-contracts-v1.schema.json +182 -0
  51. package/contracts/v4-delivery-warrant-semantic-diff-report-v1.schema.json +284 -0
  52. package/contracts/v4-delivery-warrant-trace-v1.schema.json +215 -0
  53. package/contracts/v4-host-contract-v1.schema.json +135 -0
  54. package/contracts/v4-partial-mutation-recovery-v1.schema.json +168 -0
  55. package/contracts/v4-provider-operation-journal-v1.schema.json +381 -0
  56. package/contracts/v4-release-activation-shadow-v1.schema.json +186 -0
  57. package/contracts/v4-stable-publication-fence-v1.schema.json +125 -0
  58. package/contracts/v4-stage-capsule-resume-v1.schema.json +225 -0
  59. package/contracts/v4-stage-capsule-store-v1.schema.json +154 -0
  60. package/contracts/v4-stage-capsule-v1.schema.json +178 -0
  61. package/crates/buildchain-v4-bridge/Cargo.lock +213 -0
  62. package/crates/buildchain-v4-bridge/Cargo.toml +12 -0
  63. package/crates/buildchain-v4-bridge/src/main.rs +495 -0
  64. package/dist/site/agent-index.json +0 -4
  65. package/dist/site/artifact-schemas.json +0 -8
  66. package/dist/site/buildchain-contract.json +103 -397
  67. package/dist/site/buildchain-site.json +302 -386
  68. package/dist/site/capability-registry.json +9 -11
  69. package/dist/site/cli-registry.json +8 -53
  70. package/dist/site/controller-registry.json +48 -8
  71. package/dist/site/kfd-claims.json +129 -167
  72. package/dist/site/kfd-upstream-aggregate.json +9 -9
  73. package/dist/site/manual-registry.json +18 -49
  74. package/dist/site/node-api-registry.json +4345 -7345
  75. package/dist/site/page-registry.json +278 -346
  76. package/dist/site/public-surface-audit.json +85 -404
  77. package/dist/site/publication-authority-registry.json +11 -1
  78. package/dist/site/publication-registry.json +4 -4
  79. package/dist/site/release-provenance.json +3 -9
  80. package/dist/site/schemas/kfd-support-projection-v1.schema.json +106 -0
  81. package/dist/site/site-manifest.json +22 -38
  82. package/dist/site/workflow-registry.json +78 -35
  83. package/docs/MAP.md +8 -5
  84. package/docs/auditable-demo.md +2 -2
  85. package/docs/aws-us-elastic-runner-burst-plane.md +7 -59
  86. package/docs/cli-reference.md +15 -213
  87. package/docs/cli.md +14 -14
  88. package/docs/dev-alpha-candidate-patrol.md +3 -11
  89. package/docs/dev-delivery-warrant.md +29 -194
  90. package/docs/engineering-housekeeper.md +12 -4
  91. package/docs/getting-started.md +1 -1
  92. package/docs/install.md +5 -5
  93. package/docs/kfd-support.md +2 -7
  94. package/docs/lifecycle-protocol.md +2 -4
  95. package/docs/node-api-reference.md +414 -554
  96. package/docs/release-flow.md +31 -31
  97. package/docs/release-governance.md +16 -28
  98. package/docs/release-passport.md +2 -15
  99. package/docs/release-tail-contract.md +13 -6
  100. package/docs/release-tail-provider-plane.md +13 -19
  101. package/docs/release-train.md +4 -4
  102. package/docs/reusable-build-surface.md +14 -27
  103. package/docs/site-bundle-contract.md +1 -5
  104. package/docs/stable-candidate-patrol.md +7 -7
  105. package/docs/v4-canonical-contracts.md +92 -0
  106. package/docs/v4-delivery-warrant-read-candidate.md +73 -0
  107. package/docs/v4-delivery-warrant-semantic-diff.md +75 -0
  108. package/docs/v4-production-release.md +63 -0
  109. package/docs/v4-stage-capsule.md +193 -0
  110. package/docs/versioning.md +3 -5
  111. package/package.json +19 -19
  112. package/packages/core/adopter-delivery-gate.js +576 -0
  113. package/packages/core/adopter-delivery-json.js +66 -0
  114. package/packages/core/artifact-signing.js +0 -61
  115. package/packages/core/artifact-verification-envelope.js +5 -5
  116. package/packages/core/build-facts.js +12 -4
  117. package/packages/core/buildchain-agent-manuals.js +0 -2
  118. package/packages/core/buildchain-channel-identity.js +3 -2
  119. package/packages/core/buildchain-config.js +4 -69
  120. package/packages/core/buildchain-contract.js +232 -46
  121. package/packages/core/buildchain-kfd-claims.js +1 -1
  122. package/packages/core/channel-candidate.js +0 -8
  123. package/packages/core/channel-promotion-baseline.js +0 -52
  124. package/packages/core/controller-evidence.js +3 -4
  125. package/packages/core/dev-alpha-candidate-selection.js +2 -10
  126. package/packages/core/dev-delivery-warrant-cancellation.js +0 -1
  127. package/packages/core/dev-delivery-warrant-settlement.js +20 -67
  128. package/packages/core/dev-delivery-warrant.js +50 -138
  129. package/packages/core/diagnostics.js +3 -8
  130. package/packages/core/github-governance-authority.js +3 -1
  131. package/packages/core/kfd-adopter-category-driver.js +167 -0
  132. package/packages/core/kfd-adopter-manifest.js +47 -46
  133. package/packages/core/kfd-gate.js +15 -45
  134. package/packages/core/paper-agent-entry.js +7 -16
  135. package/packages/core/paper-fleet.js +2 -2
  136. package/packages/core/paper-repository.js +2 -3
  137. package/packages/core/paper-scaffold-content.js +2 -23
  138. package/packages/core/paper.js +11 -43
  139. package/packages/core/publication-reproducibility.js +4 -4
  140. package/packages/core/release-line-bootstrap.js +21 -8
  141. package/packages/core/release-passport-contract.js +5 -5
  142. package/packages/core/release-passport.js +20 -131
  143. package/packages/core/self-dogfood-version.js +48 -35
  144. package/packages/core/spawn-command.js +232 -8
  145. package/packages/core/v4-adopter-delivery-parity.js +219 -0
  146. package/packages/core/v4-canonical-contracts.js +284 -0
  147. package/packages/core/v4-delivery-warrant-fixture-runner.js +371 -0
  148. package/packages/core/v4-delivery-warrant-read-candidate.js +279 -0
  149. package/packages/core/v4-delivery-warrant-semantic-diff-gate.js +352 -0
  150. package/packages/core/v4-delivery-warrant-shadow-adapter.js +447 -0
  151. package/packages/core/v4-partial-mutation-recovery-qualification.js +395 -0
  152. package/packages/core/v4-platform-stage-checkpoints.js +471 -0
  153. package/packages/core/v4-provider-operation-journal.js +531 -0
  154. package/packages/core/v4-provider-readback-idempotency.js +394 -0
  155. package/packages/core/v4-release-activation-shadow.js +519 -0
  156. package/packages/core/v4-stable-publication-fence.js +357 -0
  157. package/packages/core/v4-stage-capsule-local-store.js +426 -0
  158. package/packages/core/v4-stage-capsule-qualification-campaign.js +512 -0
  159. package/packages/core/v4-stage-capsule-qualification.js +456 -0
  160. package/packages/core/v4-stage-capsule-resume-planner.js +397 -0
  161. package/packages/core/v4-stage-capsule-store.js +401 -0
  162. package/packages/core/v4-stage-capsule.js +319 -0
  163. package/scripts/assemble-self-publication-admission.mjs +1 -1
  164. package/scripts/audit-publication-control-plane.mjs +5 -5
  165. package/scripts/auditable-demo-bundle-verification.mjs +3 -2
  166. package/scripts/auditable-demo-platform.mjs +2 -2
  167. package/scripts/auditable-demo-renditions.mjs +1 -1
  168. package/scripts/auditable-demo.mjs +2 -2
  169. package/scripts/aws-macos-jit-controller-core.mjs +13 -346
  170. package/scripts/aws-macos-jit-controller-runtime.mjs +2 -210
  171. package/scripts/aws-macos-jit-controller.mjs +37 -275
  172. package/scripts/aws-macos-jit-core.mjs +3 -41
  173. package/scripts/aws-macos-jit.mjs +0 -12
  174. package/scripts/aws-windows-jit-campaign.mjs +2 -2
  175. package/scripts/aws-windows-jit-controller-core.mjs +1 -1
  176. package/scripts/aws-windows-jit-controller.mjs +3 -3
  177. package/scripts/build-contract-core.mjs +3 -8
  178. package/scripts/build-standalone-binary.mjs +3 -14
  179. package/scripts/buildchain-channel-router.mjs +4 -0
  180. package/scripts/buildchain-cli-help.mjs +7 -16
  181. package/scripts/buildchain-contract-lock.mjs +0 -6
  182. package/scripts/check-action-bundles.mjs +3 -4
  183. package/scripts/check-internal-architecture.mjs +7 -6
  184. package/scripts/check-inventory.mjs +30 -25
  185. package/scripts/check-v4-public-dogfood-contract.mjs +270 -0
  186. package/scripts/create-release-bundle.mjs +8 -4
  187. package/scripts/dev-alpha-candidate-patrol.mjs +1 -22
  188. package/scripts/dev-delivery-proof.mjs +2 -64
  189. package/scripts/dev-delivery-warrant.mjs +61 -86
  190. package/scripts/dev-pr-auto-merge.mjs +4 -30
  191. package/scripts/dev-pr-delivery-warrant.mjs +0 -55
  192. package/scripts/dispatch-artifact-signing-authority.mjs +7 -4
  193. package/scripts/generate-buildchain-kfd-witnesses.mjs +94 -88
  194. package/scripts/generate-channel-build-workflow.mjs +54 -24
  195. package/scripts/generate-channel-promotion-workflow.mjs +15 -6
  196. package/scripts/generate-site-bundle.mjs +8 -27
  197. package/scripts/git-fetch-process-tree.mjs +34 -1
  198. package/scripts/init-repo.mjs +64 -159
  199. package/scripts/inspect-artifact-signing-requests.mjs +0 -6
  200. package/scripts/locked-source-checkout.mjs +3 -4
  201. package/scripts/maintainability-metrics.mjs +8 -2
  202. package/scripts/npm-publish-dry-run.mjs +2 -2
  203. package/scripts/npm-publish-transaction.mjs +2 -2
  204. package/scripts/publication-commit-evidence.mjs +23 -69
  205. package/scripts/release-candidate-resolver.mjs +11 -17
  206. package/scripts/release-tail.mjs +3 -49
  207. package/scripts/resume-from-candidate-run.mjs +9 -123
  208. package/scripts/run-lifecycle-core.mjs +12 -13
  209. package/scripts/seal-artifact-signing-requests.mjs +17 -21
  210. package/scripts/site-capability-metadata.mjs +3 -20
  211. package/scripts/stable-candidate-qualification.mjs +10 -10
  212. package/scripts/v4-architecture.mjs +12 -2
  213. package/scripts/v4-bridge-bootstrap.mjs +141 -0
  214. package/scripts/v4-bridge-evidence.mjs +141 -0
  215. package/scripts/v4-host-adapter.mjs +182 -0
  216. package/scripts/v4-platform-stage-checkpoint-rehearsal.mjs +207 -0
  217. package/scripts/v4-stage-capsule-qualification.mjs +528 -0
  218. package/scripts/v4-stage-capsule-resume-rehearsal.mjs +57 -0
  219. package/scripts/v4-warrant-shadow-plan.mjs +601 -0
  220. package/scripts/verify-golden-path.mjs +5 -5
  221. package/scripts/web-surface-cloudfront-rewrite.mjs +15 -15
  222. package/scripts/web-surface-core.mjs +2 -8
  223. package/scripts/workflow-call-contract.mjs +5 -184
  224. package/contracts/dev-delivery-authority-v2.schema.json +0 -253
  225. package/contracts/fixtures/kfd-adopter-release-v1/kfd-4-perspective.json +0 -16
  226. package/contracts/fixtures/kfd-adopter-release-v1/kfd-4-replay.json +0 -57
  227. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +0 -47
  228. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +0 -47
  229. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +0 -40
  230. package/contracts/next-development-request-v1.schema.json +0 -66
  231. package/contracts/next-development-transition-v1.schema.json +0 -292
  232. package/contracts/publication-rehearsal-capsule-v1.schema.json +0 -173
  233. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +0 -442
  234. package/dist/site/schemas/publication-rehearsal-capsule-v1.schema.json +0 -269
  235. package/dist/site/schemas/release-tail-capabilities-v1.schema.json +0 -353
  236. package/dist/site/schemas/release-tail-provider-bindings-v1.schema.json +0 -94
  237. package/docs/dev-delivery-qualification-landing-adr.md +0 -137
  238. package/docs/next-development-transition.md +0 -119
  239. package/docs/publication-rehearsal.md +0 -94
  240. package/packages/core/buildchain-compatibility-proof.js +0 -631
  241. package/packages/core/dev-delivery-authority.js +0 -996
  242. package/packages/core/dev-delivery-native-proof.js +0 -418
  243. package/packages/core/dev-delivery-warrant-shadow.js +0 -502
  244. package/packages/core/next-development-candidate-reservation.js +0 -186
  245. package/packages/core/next-development-controller.js +0 -726
  246. package/packages/core/next-development-projection.js +0 -288
  247. package/packages/core/next-development-transition.js +0 -738
  248. package/packages/core/publication-rehearsal-projection.js +0 -173
  249. package/packages/core/publication-rehearsal-runtime.js +0 -921
  250. package/scripts/aws-macos-jit-instance-rehydrate.mjs +0 -260
  251. package/scripts/aws-macos-jit-source-rebind.mjs +0 -724
  252. package/scripts/dev-delivery-authority.mjs +0 -368
  253. package/scripts/dev-delivery-native-run.mjs +0 -235
  254. package/scripts/dev-delivery-two-phase-resume.mjs +0 -90
  255. package/scripts/dev-delivery-two-phase.mjs +0 -577
  256. package/scripts/generate-next-development-guidance.mjs +0 -49
  257. package/scripts/materialize-self-release-candidate-version.mjs +0 -137
  258. package/scripts/next-development-self-dogfood-harness.mjs +0 -409
  259. package/scripts/next-development-self-dogfood.mjs +0 -532
  260. package/scripts/next-development-transition.mjs +0 -47
  261. package/scripts/release-candidate-tail-reseal.mjs +0 -426
  262. package/templates/native-dev-delivery.yml +0 -86
@@ -18,7 +18,7 @@ ai_provenance:
18
18
 
19
19
  # Release Flow Diagrams
20
20
 
21
- This document describes the Buildchain v3 branch, tag, and version-state flow.
21
+ This document describes the Buildchain v4 branch, tag, and version-state flow.
22
22
  See [Release governance](release-governance.md) for the design rationale.
23
23
 
24
24
  ## Architecture
@@ -64,16 +64,16 @@ for the versioned policy and evidence contract.
64
64
 
65
65
  | Ref kind | Example | Mutability | Purpose |
66
66
  | --- | --- | --- | --- |
67
- | Development branch | `dev/v3/v3.0` | moves | next source state for a minor line |
68
- | Alpha branch | `alpha/v3/v3.0` | moves | latest test state for a minor line |
69
- | Release branch | `release/v3/v3.0` | moves | latest production state for a minor line |
67
+ | Development branch | `dev/v4/v4.0` | moves | next source state for a minor line |
68
+ | Alpha branch | `alpha/v4/v4.0` | moves | latest test state for a minor line |
69
+ | Release branch | `release/v4/v4.0` | moves | latest production state for a minor line |
70
70
  | Major gate branch | `publish-gate/major` | moves | reviewed administrator gate for publishing the next major |
71
- | Exact alpha tag | `v3.0.3-alpha.0` | immutable | audit ref for one tested prerelease |
72
- | Exact release tag | `v3.0.2` | immutable | audit ref for one production release |
73
- | Floating alpha tag | `v3.0-alpha` | moves | latest test channel for a minor line |
74
- | Floating major alpha tag | `v3-alpha` | moves | latest test channel on the highest published alpha minor for a major line |
75
- | Floating minor tag | `v3.0` | moves | latest production patch on a minor line |
76
- | Floating major tag | `v3` | moves | selected stable major entrypoint |
71
+ | Exact alpha tag | `v4.0.3-alpha.0` | immutable | audit ref for one tested prerelease |
72
+ | Exact release tag | `v4.0.2` | immutable | audit ref for one production release |
73
+ | Floating alpha tag | `v4.0-alpha` | moves | latest test channel for a minor line |
74
+ | Floating major alpha tag | `v4-alpha` | moves | latest test channel on the highest published alpha minor for a major line |
75
+ | Floating minor tag | `v4.0` | moves | latest production patch on a minor line |
76
+ | Floating major tag | `v4` | moves | selected stable major entrypoint |
77
77
 
78
78
  ## Ref Protection Contract
79
79
 
@@ -87,20 +87,20 @@ refs/tags/v*.*.*
87
87
  ```
88
88
 
89
89
  Do not apply immutable-tag rulesets to every `refs/tags/v*` ref. Buildchain
90
- must be able to update floating channel tags such as `v3`, `v3.0`, `v3.0-alpha`,
91
- and `v3-alpha` after the exact tag and publish evidence are valid. A ruleset that
90
+ must be able to update floating channel tags such as `v4`, `v4.0`, `v4.0-alpha`,
91
+ and `v4-alpha` after the exact tag and publish evidence are valid. A ruleset that
92
92
  matches all `v*` tags also matches floating tags, so release finalization can
93
93
  fail with GitHub protected-ref errors even though the exact release tag and
94
94
  published artifacts are already durable.
95
95
 
96
96
  The intended governance split is:
97
97
 
98
- - exact tags such as `v3.0.2` and `v3.0.3-alpha.0` are immutable audit refs;
98
+ - exact tags such as `v4.0.2` and `v4.0.3-alpha.0` are immutable audit refs;
99
99
  - for publish transactions, the exact tag points to the transaction
100
100
  `source_sha`, matching package-registry source metadata such as npm
101
101
  `gitHead`; generated version-state commits remain on protected branches and
102
102
  floating channel refs;
103
- - floating tags such as `v3`, `v3.0`, `v3.0-alpha`, and `v3-alpha` are mutable channel refs
103
+ - floating tags such as `v4`, `v4.0`, `v4.0-alpha`, and `v4-alpha` are mutable channel refs
104
104
  owned by the Buildchain promotion token;
105
105
  - protected branches still require reviewed channel PRs before Buildchain can
106
106
  move any exact or floating release refs.
@@ -116,17 +116,17 @@ The workflow is backed by the CLI command:
116
116
 
117
117
  ```bash
118
118
  buildchain release line open \
119
- --major 3 \
119
+ --major 4 \
120
120
  --minor 1 \
121
- --source-ref release/v3/v3.0 \
121
+ --source-ref release/v4/v4.0 \
122
122
  --json
123
123
  ```
124
124
 
125
125
  When the workflow is run with `apply=true`, Buildchain:
126
126
 
127
- - writes the initial version-state commit, such as `3.1.0-alpha.0`;
128
- - creates `dev/v3/v3.1` from that commit;
129
- - creates `alpha/v3/v3.1` and `release/v3/v3.1` from the selected source ref;
127
+ - writes the initial version-state commit, such as `4.1.0-alpha.0`;
128
+ - creates `dev/v4/v4.1` from that commit;
129
+ - creates `alpha/v4/v4.1` and `release/v4/v4.1` from the selected source ref;
130
130
  - applies branch protection with one approving review and the configured
131
131
  required status check; dev starts strict, while alpha and release also require
132
132
  the pair-specific `verify` aggregate without a source-up-to-date ancestry loop;
@@ -134,7 +134,7 @@ When the workflow is run with `apply=true`, Buildchain:
134
134
  the exact queue parameters and bypass actors from the current default dev
135
135
  branch when the policy is `inherit` or absent;
136
136
  - switches the repository default branch to the new dev line when requested;
137
- - opens the first `dev/v3/v3.1 -> alpha/v3/v3.1` channel PR when requested.
137
+ - opens the first `dev/v4/v4.1 -> alpha/v4/v4.1` channel PR when requested.
138
138
 
139
139
  This makes minor-line creation a single audited operation. The channel PR still
140
140
  goes through the normal verify/review/promotion path before an alpha is
@@ -251,26 +251,26 @@ The same minor line can loop through this state machine many times.
251
251
 
252
252
  ## Version Examples
253
253
 
254
- Assume `v3.0.2-alpha.1` has been tested and a maintainer merges
255
- `alpha/v3/v3.0 -> release/v3/v3.0`.
254
+ Assume `v4.0.2-alpha.1` has been tested and a maintainer merges
255
+ `alpha/v4/v4.0 -> release/v4/v4.0`.
256
256
 
257
257
  Buildchain should produce:
258
258
 
259
259
  ```text
260
- v3.0.2 exact production tag
261
- v3.0 floating minor tag
262
- v3 floating major tag when v3.0 is the selected major line
263
- release/v3/v3.0 production channel branch
260
+ v4.0.2 exact production tag
261
+ v4.0 floating minor tag
262
+ v4 floating major tag when v4.0 is the selected major line
263
+ release/v4/v4.0 production channel branch
264
264
  ```
265
265
 
266
266
  It should also prepare:
267
267
 
268
268
  ```text
269
- v3.0.3-alpha.0 exact next alpha tag
270
- v3.0-alpha floating alpha tag
271
- v3-alpha floating major alpha tag when v3.0 is the highest published alpha minor
272
- alpha/v3/v3.0 alpha channel branch
273
- dev/v3/v3.0 development channel branch
269
+ v4.0.3-alpha.0 exact next alpha tag
270
+ v4.0-alpha floating alpha tag
271
+ v4-alpha floating major alpha tag when v4.0 is the highest published alpha minor
272
+ alpha/v4/v4.0 alpha channel branch
273
+ dev/v4/v4.0 development channel branch
274
274
  ```
275
275
 
276
276
  This is expected behavior. A production release closes one patch and opens the
@@ -263,11 +263,9 @@ semantics and fail-closed verification requirements.
263
263
  The authority verifies the complete result set on GitHub-hosted infrastructure
264
264
  before delivery. The consumer controller also performs final result verification,
265
265
  exact-byte import, manifest recomputation, and deterministic-artifact replacement
266
- on a GitHub-hosted lane. macOS results finalize on a GitHub-hosted macOS runner so
267
- the consumer lifecycle can perform native post-sign checks before publication;
268
- other platforms retain the GitHub-hosted Ubuntu control lane. Self-hosted build
269
- runners do not download authority result payloads, and aggregate/release evidence
270
- fails closed until this finalization succeeds.
266
+ on a GitHub-hosted lane. Self-hosted build runners do not download authority
267
+ result payloads, and aggregate/release evidence fails closed until this
268
+ finalization succeeds.
271
269
 
272
270
  The central `buildchain-artifact-signing` environment reuses the established
273
271
  macOS Credential Island names (`BUILDCHAIN_MACOS_CERTIFICATE_*`,
@@ -493,11 +491,10 @@ GitHub Merge Queue does not by itself decide which candidate may spend a long
493
491
  native proof before enqueue. Repositories with that workload use the
494
492
  [Dev Delivery Warrant Queue](dev-delivery-warrant.md) as the durable,
495
493
  FIFO-aging scheduling and fencing authority before native queue admission. A
496
- provisional Warrant reserves the landing order before native shards, while only
497
- its atomic qualified upgrade can authorize enqueue. Later candidates remain
498
- visibly queued and continue source/CI work; GitHub still owns the exact
499
- `merge_group` proof and final ref mutation. Workflow concurrency remains only a
500
- process critical section and is not fairness or ownership authority.
494
+ selected Warrant owns one complete delivery attempt and later candidates remain
495
+ visibly queued; GitHub still owns the exact `merge_group` proof and final ref
496
+ mutation. Workflow concurrency remains only a process critical section and is
497
+ not fairness or ownership authority.
501
498
 
502
499
  Every required workflow must handle both `pull_request` and `merge_group`
503
500
  before the queue is enabled. Queue runs do not provide
@@ -613,12 +610,6 @@ The reusable caller supports `off`, read-only `shadow`, and fail-closed
613
610
  `required` rollout modes. GitHub Merge Queue remains the final protected-ref
614
611
  authority in every mode.
615
612
 
616
- Bounded-concurrency experiments use the separate effect-disabled Warrant
617
- shadow planner. It may evaluate at most two fully bound lanes from one exact
618
- observation, but it cannot mint a second production Warrant or mutate GitHub.
619
- Its aggregate threshold decision is qualification evidence for a later rollout
620
- change, not authority to change the live single-flight policy.
621
-
622
613
  The canonical consumer required check context is `check / check`, matching the
623
614
  reusable workflow call plus its `check` job. Buildchain's own `Verify` workflow
624
615
  emits the repository-local context `check`, so Buildchain self-promotion,
@@ -726,13 +717,13 @@ status to failure, while the merge group must still produce its own final check.
726
717
  that want a stable day-to-day operations contract, Buildchain also exposes a
727
718
  patrol workflow family:
728
719
 
729
- | Workflow | Intended cadence | Default intent |
730
- | ------------------------------------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------ |
731
- | `.github/workflows/patrol-daily.yml` | daily | lightweight inspection plus ready dev PR maintenance |
732
- | `.github/workflows/patrol-weekly.yml` | weekly | release-state, passport, gate, and stale-state health checks as they are added |
733
- | `.github/workflows/patrol-monthly.yml` | monthly | governance, permission, branch-protection, and workflow drift checks as they are added |
734
- | `.github/workflows/patrol-observed-evidence.yml` | caller-selected schedule | validated immutable observation plus atomic last-known-good publication; no per-refresh PR |
735
- | `.github/workflows/stable-candidate-patrol.yml` | repository-selected release window | qualify immutable alpha candidates and open the exact source-lock stable PR |
720
+ | Workflow | Intended cadence | Default intent |
721
+ | --- | --- | --- |
722
+ | `.github/workflows/patrol-daily.yml` | daily | lightweight inspection plus ready dev PR maintenance |
723
+ | `.github/workflows/patrol-weekly.yml` | weekly | release-state, passport, gate, and stale-state health checks as they are added |
724
+ | `.github/workflows/patrol-monthly.yml` | monthly | governance, permission, branch-protection, and workflow drift checks as they are added |
725
+ | `.github/workflows/patrol-observed-evidence.yml` | caller-selected schedule | validated immutable observation plus atomic last-known-good publication; no per-refresh PR |
726
+ | `.github/workflows/stable-candidate-patrol.yml` | repository-selected release window | qualify immutable alpha candidates and open the exact source-lock stable PR |
736
727
 
737
728
  The cadence names describe patrol intensity, not release cadence:
738
729
 
@@ -834,11 +825,8 @@ declare version-state files and lifecycle commands without pretending every
834
825
  project is a Node workspace. Supported version files include JSON, TOML, and
835
826
  regex-based files such as `CMakeLists.txt` or `conanfile.py`.
836
827
 
837
- The promotion action consumes `version.files`, optional
838
- `version.derived_files`, and `lifecycle.verify`. Semver and anchored/manual
839
- repositories may both declare lifecycle-regenerated tracked outputs as derived
840
- files; anchored/manual repositories additionally bind them into their committed
841
- version witnesses.
828
+ The promotion action consumes `version.files`, optional anchored/manual
829
+ `version.derived_files`, and `lifecycle.verify`.
842
830
  The verify stage runs after generated version-state changes are applied locally
843
831
  and before any release refs move. If `verification-command` is passed directly
844
832
  to the action, that explicit command overrides `lifecycle.verify`.
@@ -313,13 +313,6 @@ fails closed if any claim is missing source bindings, machine evidence, hashes,
313
313
  artifact coordinates, verification result, audit boundary, responsibility, or
314
314
  residual risk.
315
315
 
316
- The same self-promotion boundary extends the Buildchain-owned KFD witness
317
- generator against the transaction's exact source SHA. It produces the standard
318
- full-cut adopter manifest, the non-qualifying KFD-4/5/7 product gates, and the
319
- one-way legacy projection before the final passport is collected. An explicitly
320
- supplied adopter manifest still takes precedence; an omitted self-release
321
- manifest no longer silently produces a KFD-1/2/3-only passport.
322
-
323
316
  ### KFD-3 collaboration-interface release gate
324
317
 
325
318
  KFD-3 asks a different release question than KFD-1. KFD-1 proves that named
@@ -410,14 +403,8 @@ Pass the standard full-cut declaration with `--kfd-adopter-manifest-json`
410
403
  together with three `--kfd-product-gate-json` arguments for KFD-4, KFD-5, and
411
404
  KFD-7. The collector invokes the verifier from the exact installed
412
405
  `@kungfu-tech/kfd` package, binds the package artifact, registry and verifier
413
- roots, the collector's exact product repository and source, the
414
- manifest/report/bundle witness roots, and the existing product-gate roots. A
415
- non-Buildchain adopter is accepted only when its manifest identity, artifact
416
- coordinate, and all three product-gate repositories match the collector's
417
- `--repository` value. The lower-level Node API exposes the same boundary as
418
- `expectedAdopterId`, `expectedSourceRepository`, and `expectedSourceSha`, while
419
- omitted identity/repository values retain the Buildchain self-release default.
420
- It emits `kfd-adopter-manifest.json`,
406
+ roots, the exact Buildchain source, the manifest/report/bundle witness roots,
407
+ and the existing product-gate roots. It emits `kfd-adopter-manifest.json`,
421
408
  `kfd-adopter-manifest-gate.json`, and a legacy `kfd-support.json` projection.
422
409
  The release passport and `artifact-evidence.json` carry the same rooted
423
410
  `kfdAdopter` binding.
@@ -7,21 +7,21 @@ source_level: local-files
7
7
  confidence: high
8
8
  sensitivity: public
9
9
  evidence_grade: A
10
- review_state: unreviewed
11
- last_reviewed: 2026-08-07
10
+ review_state: self-reviewed
11
+ last_reviewed: 2026-08-13
12
12
  ai_provenance:
13
13
  model_family: GPT-5
14
14
  product: Codex
15
15
  generated_at: 2026-08-07
16
- visible_context: Buildchain dev/v3/v3.0 release workflows, promotion Action, transaction and activation code, local exact-head managed-consumer callers, and the Kungfu alpha release-tail implementation.
16
+ visible_context: Buildchain dev/v3/v3.0 release workflows, the v4 capability manifest and architecture constitution, promotion Action, transaction and activation code, local exact-head managed-consumer callers, and the Kungfu alpha release-tail implementation.
17
17
  invisible_context_boundary: Did not read credentials, private logs, signed URLs, provider state, or unpublished release assets.
18
18
  ---
19
19
 
20
20
  # Declarative release-tail contract
21
21
 
22
- Buildchain v3 currently lets a consumer repository provide shell commands at
23
- several points around publication. Those hooks made early adoption possible,
24
- but they also let a consumer redefine the final release transaction. The
22
+ Buildchain's v3 compatibility line lets a consumer repository provide shell
23
+ commands at several points around publication. Those hooks made early adoption
24
+ possible, but they also let a consumer redefine the final release transaction. The
25
25
  machine authority for the current inventory is
26
26
  [`architecture/release-tail-contract-inventory.json`](../architecture/release-tail-contract-inventory.json).
27
27
  The declaration schema is
@@ -33,6 +33,13 @@ implementation is documented in
33
33
  provider plane does not itself cut over a consumer, run a release, or
34
34
  reinterpret an already published release.
35
35
 
36
+ The v4 line carries this contract as its production release-tail boundary. The
37
+ v4 capability manifest names `typescript-v4` as the sole writer and marks the
38
+ legacy v3 writer retired. Deterministic v4 journal, activation, stable-fence,
39
+ recovery, provider readback, rollback, and N-1 qualification contracts gate
40
+ every provider mutation; the retained v3 release ref is rollback evidence, not
41
+ an active fallback writer.
42
+
36
43
  ## Current executable surfaces
37
44
 
38
45
  The reverse scan classifies 27 workflow, Action, config, and CLI coordinates
@@ -28,15 +28,15 @@ The frozen boundary and migration inventory remain in
28
28
  ## Public entry points
29
29
 
30
30
  - Node: `@kungfu-tech/buildchain/release-tail-provider-plane`,
31
- `release-tail-provider-adapters`, `release-tail-compatibility`, and
32
- `publication-rehearsal-runtime`.
33
- - CLI: `buildchain release-tail plan|init|status|verify|compat|rehearse`.
31
+ `release-tail-provider-adapters`, and `release-tail-compatibility`.
32
+ - CLI: `buildchain release-tail plan|init|status|verify|compat`.
34
33
  - Action: `kungfu-systems/buildchain/actions/release-tail@<exact-ref>`.
35
34
  - reusable workflow: `kungfu-systems/buildchain/.github/workflows/release-tail.yml@<exact-ref>`.
36
35
 
37
- The CLI and Action both invoke the public publication rehearsal runtime over
38
- the same core transaction implementation. The Action is a thin provider
39
- transport wrapper; callers cannot inject an execution command or runner state.
36
+ The Action is the provider-executing entry point. The CLI compiles, initializes,
37
+ inspects, verifies, and diagnoses bounded v3 compatibility using the same core
38
+ transaction format. The reusable workflow checks out an exact Buildchain ref
39
+ and invokes the packaged Action; callers cannot inject an execution command.
40
40
 
41
41
  ## Inputs and secrets
42
42
 
@@ -82,12 +82,9 @@ buildchain release-tail init --declaration release-tail.json --state .buildchain
82
82
  buildchain release-tail verify --state .buildchain/release-tail/state.json
83
83
  ```
84
84
 
85
- For complete local release semantics, use the exact capsule command in
86
- [`publication-rehearsal.md`](publication-rehearsal.md). Simulation and replay
87
- exercise planning, validation, transaction, retry, and evidence without
88
- claiming external provider truth. Provider execution belongs in the Action or
89
- reusable workflow so token handling and transport capabilities remain explicit.
90
- Retain the state and rehearsal evidence artifacts.
85
+ Provider execution belongs in the Action or reusable workflow so token handling
86
+ and provider permissions remain explicit. Retain the state artifact: it is the
87
+ resume boundary and evidence source, not a disposable log.
91
88
 
92
89
  ## Buildchain self-dogfood route
93
90
 
@@ -95,15 +92,12 @@ Buildchain self-release calls the same public reusable workflow coordinate as a
95
92
  consumer:
96
93
 
97
94
  ```text
98
- kungfu-systems/buildchain/.github/workflows/release-candidate-promote.yml@769b221bad7a6b9104afad4c2628d9dca396ab0f
95
+ kungfu-systems/buildchain/.github/workflows/release-candidate-promote.yml@train/v3/v3.0/consumer-equivalent-self-dogfood
99
96
  ```
100
97
 
101
- The caller pins the public router and runtime to the same exact implementation
102
- SHA. Its internal alpha shell remains on the named train, so automatic
103
- `workflow_run` publication uses the immutable-router path without a manual
104
- runtime override. For alpha self-release, the promotion Action materializes the
105
- sealed GitHub Release asset declaration, executes it through this provider
106
- plane, and retains the
98
+ The public router resolves the workflow shell and runtime to exact SHAs. For
99
+ alpha self-release, the promotion Action materializes the sealed GitHub Release
100
+ asset declaration, executes it through this provider plane, and retains the
107
101
  declaration root, transaction root, state root, receipt roots, controller
108
102
  receipt, and route-parity evidence. The legacy GitHub Release helper is not a
109
103
  fallback when `declarative-release-tail` is enabled; a provider or readback
@@ -13,13 +13,13 @@ ai_provenance:
13
13
  model_family: GPT-5
14
14
  product: Codex
15
15
  generated_at: 2026-08-11
16
- visible_context: Buildchain v3 release candidate, recovery, Dev to Alpha Candidate Patrol, rooted blocker repair, Warrant, publication transaction, and release governance sources.
16
+ visible_context: Buildchain v4 parity of the v3 release candidate, recovery, Dev to Alpha Candidate Patrol, rooted blocker repair, Warrant, publication transaction, and release governance sources.
17
17
  invisible_context_boundary: Live provider state and credentials were not read.
18
18
  ---
19
19
 
20
20
  # Release Train and Release Cut
21
21
 
22
- Buildchain v3 exposes a pure, provider-neutral Release Train contract for
22
+ Buildchain v4 exposes the same pure, provider-neutral Release Train contract proven on v3 for
23
23
  retaining one authorized Alpha candidate while the development branch keeps
24
24
  moving. The contract does not select a candidate, write a Git ref, open a pull
25
25
  request, publish a package, or replace any existing provider gate. Controllers
@@ -92,7 +92,7 @@ and records a Dev landing with the same patch root. A landed but different Dev
92
92
  patch produces a rooted `cut-dev-patch-root-mismatch` gate rather than
93
93
  publication authority.
94
94
 
95
- Buildchain v3 Candidate Patrol resolves the open managed candidate's persisted
95
+ Buildchain v4 Candidate Patrol resolves the open managed candidate's persisted
96
96
  train before it considers a new qualified development head. It reads back the
97
97
  candidate ref and tree, Alpha base, and exact Buildchain runtime. Matching
98
98
  coordinates resume the frozen candidate; a newer development head becomes a
@@ -102,7 +102,7 @@ enumerated `superseded` transition is reported as superseded.
102
102
 
103
103
  ## Buildchain self-dogfood campaign
104
104
 
105
- Buildchain qualifies the complete v3 mechanism with
105
+ Buildchain qualifies the complete v4 parity mechanism with
106
106
  `scripts/release-train-self-dogfood.mjs`. The campaign composes one frozen
107
107
  Release Cut, moving-dev observation, deterministic failed build, successor
108
108
  repair, cut/dev patch-root settlement, publication gate, and bounded Delivery
@@ -354,8 +354,7 @@ ref is not blind trust. Each released Buildchain ref carries a package-owned
354
354
  runtime contract world in `dist/site/buildchain-contract.json`. Consumers may
355
355
  keep a small lock file, `.buildchain/contract-lock.json`, recording the
356
356
  Buildchain ref, resolved SHA, contract digest, compatibility digest, accepted
357
- major line, compatibility proof registry root, per-surface proof roots, and the
358
- compatibility policy they reviewed.
357
+ major line, and compatibility policy they reviewed.
359
358
 
360
359
  The reusable build trust gate checks this lock before any heavy matrix job:
361
360
 
@@ -372,14 +371,6 @@ promise changes, or the major line changes. Additive changes such as optional
372
371
  inputs, optional outputs, diagnostics, or documentation updates continue under
373
372
  the default `major-compatible` policy.
374
373
 
375
- A changed breaking digest is never accepted because it appears in a handwritten
376
- allowlist. Each historical digest must resolve to exactly one immutable,
377
- directed compatibility proof for the current surface digest. The proof binds
378
- the operation scope, protected authority, exact Git cut, and protected-merge
379
- evidence. The legacy `compatibleBreakingDigests` arrays remain in the site
380
- contract only as deterministic, parity-checked projections of those proofs;
381
- an orphan digest or ambiguous proof fails source acceptance.
382
-
383
374
  ```yaml
384
375
  jobs:
385
376
  build:
@@ -396,12 +387,11 @@ jobs:
396
387
 
397
388
  When compatible drift is detected, the build continues and Buildchain opens or
398
389
  updates a low-priority issue in the consumer repository. The issue records the
399
- old SHA/digest, new SHA/digest, compatibility result, workflow run, exact proof
400
- root, direction, scope, evidence, authority, cut, and rooted verification
401
- receipt. When breaking drift is detected, the same issue path is used, but the
402
- trust gate fails before matrix build or publish work starts. If the workflow
403
- token cannot write issues, Buildchain writes a copyable issue body into the job
404
- summary.
390
+ old SHA/digest, new SHA/digest, compatibility result, workflow run, and the next
391
+ action: review the Buildchain release notes and update the lock. When breaking
392
+ drift is detected, the same issue path is used, but the trust gate fails before
393
+ matrix build or publish work starts. If the workflow token cannot write issues,
394
+ Buildchain writes a copyable issue body into the job summary.
405
395
 
406
396
  The lock is intentionally small. It does not copy the full contract. The full
407
397
  contract remains in the Buildchain ref and package; the consumer records only
@@ -709,17 +699,6 @@ For a declared macOS `archive`, the authority safely extracts the sealed
709
699
  container, signs and verifies every Mach-O payload, signs Mach-O payloads inside
710
700
  embedded Python wheels, rebuilds each affected wheel's PEP 427 `RECORD`, and
711
701
  recreates the original zip or tar.gz before returning the exact final bytes.
712
- Archives whose executable hosts a JIT runtime can additionally request the
713
- Buildchain-owned `entitlements_profile = "jit-executable-v1"` and exact paths,
714
- for example `entitlements_paths = ["product/runtime/python/bin/python3"]`.
715
- Paths are relative to the extracted archive root. The authority
716
- then attaches only `com.apple.security.cs.allow-jit` to the exact executable
717
- Mach-O files sealed in `entitlements_paths`, leaves every other executable and
718
- library without exception entitlements, and records the profile, paths, and
719
- entitled executable count in provider evidence. Consumer-provided entitlement
720
- files and wildcard target paths are unsupported. The profile is valid only for
721
- Apple `archive` requests and fails closed on an unsafe, missing,
722
- non-executable, duplicate, or unsealed target path.
723
702
  Windows `pe` and `binary` artifacts
724
703
  resolve to timestamped native `windows-authenticode`; Windows PE never falls
725
704
  back to a detached signature. Linux and other non-native binary files,
@@ -1408,6 +1387,14 @@ with:
1408
1387
  `self-hosted`; a self-hosted control plane must not be exposed to untrusted fork
1409
1388
  events or arbitrary caller-controlled workflow code.
1410
1389
 
1390
+ Consumers that must verify platform-native properties of the final bytes can
1391
+ set `artifact-finalization-command` and `artifact-finalization-on-platform:
1392
+ true`. Buildchain then imports any signed result (or preserves the declared
1393
+ unsigned artifact), runs the command on the matching GitHub-hosted platform,
1394
+ and reseals the manifest before publishing the final deterministic artifact.
1395
+ Platform-native finalization fails closed for self-hosted runners so signing
1396
+ authority credentials and final bytes stay inside the trusted hosted boundary.
1397
+
1411
1398
  `require-trusted-event` controls access to build runners. It does not override
1412
1399
  the publish gate: pull requests remain non-publishing events.
1413
1400
 
@@ -54,11 +54,7 @@ overview, and fixture guides.
54
54
  `buildchain-contract.json` is the machine-readable Buildchain runtime contract
55
55
  world used by floating-ref contract locks. It records public workflow/action/CLI
56
56
  surfaces, compatibility digests, and audit digests for the files that implement
57
- those surfaces. Its immutable compatibility proofs bind historical breaking
58
- digests to exact target surfaces, operation scopes, protected authority,
59
- evidence, and Git cuts. `compatibleBreakingDigests` and per-surface proof-root
60
- lists are generated projections; site consumers must not edit or reinterpret
61
- them as independent authority.
57
+ those surfaces.
62
58
  `manual-registry.json` enumerates the packaged Markdown manuals with source
63
59
  digests so an agent can find complete operating documentation from the npm
64
60
  artifact. `node-api-registry.json` enumerates public Node import surfaces from
@@ -125,7 +125,7 @@ permissions:
125
125
 
126
126
  jobs:
127
127
  stable:
128
- uses: kungfu-systems/buildchain/.github/workflows/stable-candidate-patrol.yml@v3
128
+ uses: kungfu-systems/buildchain/.github/workflows/stable-candidate-patrol.yml@v4
129
129
  with:
130
130
  release-now: ${{ inputs.release-now }}
131
131
  dry-run: false
@@ -165,15 +165,15 @@ returned a GraphQL error in the response body.
165
165
 
166
166
  ## Exact-source stable promotion
167
167
 
168
- For a selected `3.0.2-alpha.4`, Patrol creates the immutable source branch:
168
+ For a selected `4.0.2-alpha.4`, Patrol creates the immutable source branch:
169
169
 
170
170
  ```text
171
- publish-gate/release/v3/v3.0/3.0.2-alpha.4
171
+ publish-gate/release/v4/v4.0/4.0.2-alpha.4
172
172
  ```
173
173
 
174
- and opens it against `release/v3/v3.0`. This is an existing strict Buildchain
175
- governance path. The PR freezes the qualified candidate even if `v3.0-alpha`
176
- or `alpha/v3/v3.0` has already moved to alpha.5. Normal Verify,
174
+ and opens it against `release/v4/v4.0`. This is an existing strict Buildchain
175
+ governance path. The PR freezes the qualified candidate even if `v4.0-alpha`
176
+ or `alpha/v4/v4.0` has already moved to alpha.5. Normal Verify,
177
177
  release-candidate resolution, source-tree equivalence, publish transaction,
178
178
  passport, registry, tag, and floating-ref checks still run.
179
179
 
@@ -206,7 +206,7 @@ step; the durable authority record remains the candidate ledger entry and PR.
206
206
  The default ledger ref is derived from the release line, for example:
207
207
 
208
208
  ```text
209
- buildchain/candidate-ledger/v3/v3.0
209
+ buildchain/candidate-ledger/v4/v4.0
210
210
  ```
211
211
 
212
212
  It stores `.buildchain/stable-candidate-ledger.json`. Patrol runs are serialized
@@ -0,0 +1,92 @@
1
+ ---
2
+ status: draft
3
+ period: 2026-08-07
4
+ theme: buildchain-v4-canonical-contracts
5
+ doc_type: technical-reference
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: unreviewed
11
+ last_reviewed: 2026-08-07
12
+ ai_provenance:
13
+ model_family: GPT-5
14
+ product: Codex
15
+ generated_at: 2026-08-07
16
+ visible_context: Protected Buildchain v4 architecture, canonical contract implementations, schemas, and cross-language fixtures.
17
+ invisible_context_boundary: Did not inspect credentials, private logs, hidden model state, or unobserved production behavior.
18
+ ---
19
+
20
+ # Buildchain v4 canonical contracts
21
+
22
+ Buildchain v4 uses one provider-free contract layer for deterministic state-machine bytes and roots. TypeScript v3 remains the sole production writer. These contracts introduce no Git ref writer, network or filesystem effect, daemon, database, credential owner, or ambient clock.
23
+
24
+ ## Canonical JSON v1
25
+
26
+ `buildchain-canonical-json/v1` accepts only JSON values. Object keys must be non-empty printable ASCII and are ordered by ascending ASCII code point. Arrays retain input order. Numbers are base-10 integers in the inclusive JavaScript-safe range `-9007199254740991..9007199254740991`; fractions, negative zero, non-finite numbers, and wider integers are rejected. Strings use JSON escaping and UTF-8. The exact output ends with one LF byte.
27
+
28
+ Content roots hash these exact bytes with an explicit domain separator:
29
+
30
+ ```text
31
+ sha256(ASCII(domain) + NUL + canonical-json-bytes)
32
+ ```
33
+
34
+ The only v1 domains are `queue-state`, `candidate-identity`, `fencing-token`, `transition-receipt`, `observation`, `semantic-diff`, and `bootstrap-evidence`. A queue-state root is computed from a value that omits its own `stateRoot` field.
35
+
36
+ ## Explicit clocks and closed envelopes
37
+
38
+ Pure contract code accepts time only as `YYYY-MM-DDTHH:mm:ss.SSSZ`. An adapter samples once and passes the value as data. Missing clocks, offsets, invalid calendar instants, or other precision are rejected.
39
+
40
+ Event, receipt, and typed-fault objects use closed versioned shapes in [`contracts/v4-canonical-contracts-v1.schema.json`](../contracts/v4-canonical-contracts-v1.schema.json). Unknown fields fail. Only a rejected receipt carries a typed fault; accepted and no-op receipts carry `null`.
41
+
42
+ ## Implementations and proof
43
+
44
+ - JavaScript: [`packages/core/v4-canonical-contracts.js`](../packages/core/v4-canonical-contracts.js)
45
+ - Rust: [`crates/buildchain-v4-contracts`](../crates/buildchain-v4-contracts)
46
+ - Shared golden and adversarial cases: [`architecture/v4-canonical-contract-fixtures.json`](../architecture/v4-canonical-contract-fixtures.json)
47
+
48
+ Run the focused proof with:
49
+
50
+ ```sh
51
+ pnpm run check:v4-contracts
52
+ ```
53
+
54
+ The check validates both implementations, compares exact UTF-8 bytes and SHA-256 roots, exercises invalid numbers, keys, clocks, domains, and envelope shapes, and scans the pure libraries for ambient clock or provider imports. Delivery Warrant decide/fold, shadow invocation, provider effects, and production authority remain outside this contract slice.
55
+
56
+ ## Shared Delivery Warrant fixture runner
57
+
58
+ The versioned trace contract in [`contracts/v4-delivery-warrant-trace-v1.schema.json`](../contracts/v4-delivery-warrant-trace-v1.schema.json) is the language-neutral boundary for retained Delivery Warrant fixtures. The JavaScript runner in [`packages/core/v4-delivery-warrant-fixture-runner.js`](../packages/core/v4-delivery-warrant-fixture-runner.js) and the Rust runner in [`crates/buildchain-v4-contracts`](../crates/buildchain-v4-contracts) consume the same UTF-8 fixture bytes and emit the same deterministic semantic projection.
59
+
60
+ Each trace is closed and ordered. It binds the exact prior root, event, action or typed fault, canonical successor bytes and root, generation, fencing counter, ordered declarative effects, provider-neutral observations, and rooted receipt. The runner verifies the full root chain before returning a projection. Malformed JSON, missing or unknown fields, reordered sequences, stale roots, and unsupported contract versions fail closed.
61
+
62
+ The retained public-safe fixtures are:
63
+
64
+ - [`golden.json`](../contracts/fixtures/v4-delivery-warrant-trace-v1/golden.json) for accepted submit/select transitions and ordered effects;
65
+ - [`replay.json`](../contracts/fixtures/v4-delivery-warrant-trace-v1/replay.json) for a stale-fence typed fault and response-loss readback.
66
+
67
+ The runner is not a state-machine implementation and does not sample time, execute effects, access Git/GitHub, or move production authority. TypeScript v3 remains the sole production writer. Later Rust decide/fold and TypeScript shadow adapters supply or consume this contract instead of defining another projection shape.
68
+
69
+ ## TypeScript shadow adapter
70
+
71
+ The adapter in [`packages/core/v4-delivery-warrant-shadow-adapter.js`](../packages/core/v4-delivery-warrant-shadow-adapter.js) runs the existing TypeScript v3 fixture projection first and preserves that exact result as the only authoritative output. When explicitly enabled, it sends the same canonical input bytes to the replaceable Rust host command, requires the effect-disabled host capability, and captures the returned semantic projection only as a non-authoritative observation. Rust never receives effect authority, and success, failure, timeout, cancellation, malformed output, or an unsupported host cannot change the v3 result.
72
+
73
+ Shadow retention accepts only checked-in fixtures or captured replays explicitly marked public-safe. Each returned observation binds the input root, exact TypeScript and Rust source revisions, validator version, capture time, fixed retention deadline, both projections, and sanitized diagnostics. It contains no comparison verdict or cutover signal. The adapter is disabled unless the caller opts in or sets `BUILDCHAIN_V4_WARRANT_SHADOW=enabled`; even then, invalid source bindings or an unsafe retention class skip Rust invocation.
74
+
75
+ ## Pure Rust Delivery Warrant domain
76
+
77
+ The `warrant` module in [`crates/buildchain-v4-contracts`](../crates/buildchain-v4-contracts) implements the protected Delivery Warrant manifest as provider-free typed state, seven event decisions, and a separate fold. It freezes all nine candidate states and all nine primitives from the shadow bootstrap plan. Every decision binds the event's exact `subjectRoot`, takes time only from the validated event envelope, and returns a typed action or fault. Fold produces a canonical successor; the combined transition produces only ordered `persist-successor` and `request-admission` intents plus a rooted receipt. It never executes either intent.
78
+
79
+ Duplicate submission deliberately retains the legacy generation/root mutation for shadow comparability. Manifest aliases remain explicit, waiting and blocked remain valid states without invented public transitions, and response-loss reconciliation is symmetric for every declarative effect. Stale expected-old roots and fences, lease expiry, terminal duplicates, cancellation, response loss, provider conflict, and retry exhaustion are closed typed outcomes. The retry policy permits at most one reread/redecision and then stops.
80
+
81
+ The domain consumes the same retained golden and replay bytes as the shared runner. Focused tests cover deterministic replay, bounded property sequences, duplicate behavior, stale compare-and-set and fencing, lease recovery/reselection, settlement and cancellation idempotence, response loss, provider conflict, and calendar-boundary clock arithmetic. Repository-level architecture tests reject provider and I/O imports, ambient clocks, process execution, hidden writers, and unbounded retry loops. The manifest still names `typescript-v3` as the sole authoritative writer with a zero second-writer budget; this slice adds no shadow routing, effect adapter, read/write cutover, or production authority.
82
+
83
+ ## Read-only state projection
84
+
85
+ The Rust host also accepts `delivery-warrant.state-project` with the dedicated
86
+ `delivery-warrant-state-projection-v1` capability. It decodes and validates the
87
+ closed v4 state, then returns the same state and its canonical `queue-state`
88
+ root. The command has no effect adapter, provider import, store access, or write
89
+ authority. The TypeScript read-candidate adapter binds this projection to a
90
+ previously qualified semantic-diff report and retains parity evidence before
91
+ returning the unchanged v3 observation schema. See
92
+ [`v4-delivery-warrant-read-candidate.md`](v4-delivery-warrant-read-candidate.md).