@kungfu-tech/buildchain 4.0.0 → 4.0.1-alpha.10

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 (228) hide show
  1. package/AGENTS.md +13 -5
  2. package/actions/promote-buildchain-ref/README.md +11 -6
  3. package/actions/release-tail/README.md +8 -0
  4. package/architecture/ci-lane-change-budget.json +187 -0
  5. package/architecture/decisions/0002-next-development-transition.md +101 -0
  6. package/architecture/decisions/0003-two-phase-delivery-warrant.md +152 -0
  7. package/architecture/internal-capabilities.json +219 -7
  8. package/architecture/maintainability-policy.json +246 -29
  9. package/architecture/release-tail-contract-inventory.json +5 -2
  10. package/architecture/v3-core-mechanism-inventory.json +91 -0
  11. package/architecture/v4-adopter-delivery-parity.json +32 -5
  12. package/architecture/v4-capability-state-machine-manifest.json +73 -0
  13. package/architecture/v4-compatibility-facts-parity.json +77 -0
  14. package/architecture/v4-delivery-authority-parity.json +250 -0
  15. package/architecture/v4-delivery-warrant-shadow-fixtures.json +41 -9
  16. package/architecture/v4-floating-consumer-policy.json +81 -0
  17. package/architecture/v4-floating-consumer-policy.md +32 -0
  18. package/architecture/v4-next-development-parity.json +192 -0
  19. package/architecture/v4-publication-rehearsal-parity.json +84 -0
  20. package/architecture/v4-release-train-parity.json +1 -0
  21. package/architecture/v4-runtime-ref-resume-authority.json +64 -0
  22. package/architecture/v4-stage-capsule-qualification.json +2 -2
  23. package/architecture/v4-tail-reseal-parity.json +150 -0
  24. package/bin/buildchain.mjs +32 -3
  25. package/bin/internal/adopter-delivery-cli.mjs +70 -0
  26. package/bin/internal/command-registry.mjs +3 -0
  27. package/bin/internal/compatibility-facts-cli.mjs +101 -0
  28. package/bin/internal/trust-release-release-handlers.mjs +5 -0
  29. package/contracts/dev-delivery-authority-v2.schema.json +662 -0
  30. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +47 -0
  31. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +47 -0
  32. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +40 -0
  33. package/contracts/fixtures/v4-adopter-delivery-v1/archive-template.json +19 -0
  34. package/contracts/fixtures/v4-adopter-delivery-v1/bootstrap-positive.json +93 -0
  35. package/contracts/fixtures/v4-adopter-delivery-v1/gate-positive.json +29 -0
  36. package/contracts/fixtures/v4-adopter-delivery-v1/gate-unknown-selector.json +26 -0
  37. package/contracts/fixtures/v4-adopter-delivery-v1/offline-vectors.json +50 -0
  38. package/contracts/fixtures/v4-compatibility-facts-v1/shared.json +1129 -0
  39. package/contracts/fixtures/v4-floating-consumer-policy-v1/cases.json +59 -0
  40. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/artifacts/product.bin +1 -0
  41. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/config/buildchain.toml +5 -0
  42. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/release-activation.json +1 -0
  43. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/signed-channel.json +1 -0
  44. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/evidence/qualification.json +1 -0
  45. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/candidate.json +5 -0
  46. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/release-passport.json +1 -0
  47. package/contracts/fixtures/v4-publication-rehearsal-v1/capsule.json +707 -0
  48. package/contracts/fixtures/v4-publication-rehearsal-v1/offline-vectors.json +27 -0
  49. package/contracts/fixtures/v4-runtime-ref-resume-authority-v1/scenario.json +15 -0
  50. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +229 -0
  51. package/contracts/next-development-request-v1.schema.json +66 -0
  52. package/contracts/next-development-transition-v1.schema.json +292 -0
  53. package/contracts/v4-adopter-delivery-v1.schema.json +81 -0
  54. package/contracts/v4-compatibility-facts-v1.schema.json +230 -0
  55. package/contracts/v4-floating-consumer-policy-receipt-v1.schema.json +107 -0
  56. package/contracts/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
  57. package/contracts/v4-runtime-ref-resume-authority-v1.schema.json +235 -0
  58. package/contracts/v4-tail-reseal-v1.schema.json +276 -0
  59. package/dist/site/agent-index.json +5 -0
  60. package/dist/site/artifact-schemas.json +10 -0
  61. package/dist/site/buildchain-contract.json +1562 -44
  62. package/dist/site/buildchain-site.json +684 -42
  63. package/dist/site/capability-registry.json +17 -14
  64. package/dist/site/cli-registry.json +205 -3
  65. package/dist/site/controller-registry.json +62 -6
  66. package/dist/site/kfd-claims.json +551 -22
  67. package/dist/site/kfd-upstream-aggregate.json +1 -1
  68. package/dist/site/manual-registry.json +55 -9
  69. package/dist/site/node-api-registry.json +15247 -8690
  70. package/dist/site/page-registry.json +647 -29
  71. package/dist/site/public-surface-audit.json +876 -55
  72. package/dist/site/publication-authority-registry.json +44 -8
  73. package/dist/site/publication-registry.json +4 -4
  74. package/dist/site/release-provenance.json +26 -0
  75. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +662 -0
  76. package/dist/site/schemas/release-tail-capabilities-v1.schema.json +199 -0
  77. package/dist/site/schemas/v4-adopter-delivery-v1.schema.json +81 -0
  78. package/dist/site/schemas/v4-compatibility-facts-v1.schema.json +230 -0
  79. package/dist/site/schemas/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
  80. package/dist/site/site-manifest.json +37 -13
  81. package/dist/site/workflow-registry.json +200 -22
  82. package/docs/MAP.md +10 -2
  83. package/docs/cli-reference.md +404 -13
  84. package/docs/cli.md +8 -0
  85. package/docs/dev-alpha-candidate-patrol.md +8 -0
  86. package/docs/dev-delivery-qualification-landing-adr.md +251 -0
  87. package/docs/dev-delivery-warrant.md +361 -30
  88. package/docs/lifecycle-protocol.md +41 -0
  89. package/docs/next-development-transition.md +118 -0
  90. package/docs/node-api-reference.md +748 -322
  91. package/docs/release-tail-provider-plane.md +30 -0
  92. package/docs/reusable-build-surface.md +41 -0
  93. package/docs/runtime-train-validation.md +10 -0
  94. package/docs/v4-adopter-delivery.md +133 -0
  95. package/docs/v4-compatibility-facts.md +91 -0
  96. package/docs/v4-publication-rehearsal.md +130 -0
  97. package/docs/v4-runtime-ref-resume-authority.md +69 -0
  98. package/docs/v4-tail-reseal.md +73 -0
  99. package/docs/versioning.md +4 -2
  100. package/package.json +36 -6
  101. package/packages/core/adopter-delivery-passport.js +259 -0
  102. package/packages/core/adopter-delivery-vectors.js +158 -0
  103. package/packages/core/adopter-delivery-vectors.json +77 -0
  104. package/packages/core/artifact-signing.js +61 -0
  105. package/packages/core/buildchain-agent-manuals.js +3 -0
  106. package/packages/core/buildchain-compatibility-authority.js +336 -0
  107. package/packages/core/buildchain-compatibility-fact.js +394 -0
  108. package/packages/core/buildchain-compatibility-facts.json +217 -0
  109. package/packages/core/buildchain-compatibility-proof.js +566 -0
  110. package/packages/core/buildchain-config.js +150 -1
  111. package/packages/core/buildchain-contract.js +96 -143
  112. package/packages/core/buildchain-delivery-bootstrap.js +240 -0
  113. package/packages/core/buildchain-delivery-infrastructure.js +164 -0
  114. package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
  115. package/packages/core/buildchain-publication-authority.js +1 -0
  116. package/packages/core/channel-candidate.js +8 -0
  117. package/packages/core/channel-promotion-baseline.js +55 -0
  118. package/packages/core/ci-lane-change-budget.js +247 -0
  119. package/packages/core/dev-alpha-candidate-selection.js +10 -2
  120. package/packages/core/dev-delivery-authority-candidate.js +270 -0
  121. package/packages/core/dev-delivery-authority-evidence.js +146 -0
  122. package/packages/core/dev-delivery-authority-landing.js +461 -0
  123. package/packages/core/dev-delivery-authority-observation.js +48 -0
  124. package/packages/core/dev-delivery-authority-qualification.js +591 -0
  125. package/packages/core/dev-delivery-authority-settlement.js +213 -0
  126. package/packages/core/dev-delivery-authority-state.js +583 -0
  127. package/packages/core/dev-delivery-candidate-identity.js +13 -0
  128. package/packages/core/dev-delivery-contract-surface.js +76 -0
  129. package/packages/core/dev-delivery-execution-failure.js +133 -0
  130. package/packages/core/dev-delivery-execution-transfer.js +592 -0
  131. package/packages/core/dev-delivery-landing-admission-core.js +119 -0
  132. package/packages/core/dev-delivery-landing-readback.js +598 -0
  133. package/packages/core/dev-delivery-landing-terminal-evidence.js +271 -0
  134. package/packages/core/dev-delivery-landing-testing-port.js +6 -0
  135. package/packages/core/dev-delivery-native-execution.js +110 -0
  136. package/packages/core/dev-delivery-native-proof.js +562 -0
  137. package/packages/core/dev-delivery-process-boundary.js +563 -0
  138. package/packages/core/dev-delivery-proof.js +37 -3
  139. package/packages/core/dev-delivery-provider-attempt.js +127 -0
  140. package/packages/core/dev-delivery-provider-heartbeat.js +382 -0
  141. package/packages/core/dev-delivery-warrant-cancellation.js +1 -0
  142. package/packages/core/dev-delivery-warrant-qualification.js +145 -0
  143. package/packages/core/dev-delivery-warrant-settlement.js +237 -36
  144. package/packages/core/dev-delivery-warrant-state.js +587 -0
  145. package/packages/core/dev-delivery-warrant.js +328 -370
  146. package/packages/core/github-governance-authority.js +1 -0
  147. package/packages/core/index.js +7 -0
  148. package/packages/core/kungfu-temporal-fact.js +557 -0
  149. package/packages/core/legacy-kfd-adopter-driver.js +167 -0
  150. package/packages/core/next-development-candidate-reservation.js +186 -0
  151. package/packages/core/next-development-controller.js +728 -0
  152. package/packages/core/next-development-projection.js +287 -0
  153. package/packages/core/next-development-transition.js +738 -0
  154. package/packages/core/paper-agent-entry.js +11 -5
  155. package/packages/core/paper.js +16 -5
  156. package/packages/core/publication-authority.js +5 -5
  157. package/packages/core/published-delivery-authority.js +266 -0
  158. package/packages/core/release-candidate-recovery.js +66 -11
  159. package/packages/core/release-candidate.js +79 -19
  160. package/packages/core/release-passport.js +271 -38
  161. package/packages/core/v4-adopter-delivery-parity.js +3 -3
  162. package/packages/core/v4-adopter-delivery.js +359 -0
  163. package/packages/core/v4-canonical-contracts.js +5 -0
  164. package/packages/core/v4-delivery-warrant-read-candidate.js +10 -3
  165. package/packages/core/v4-floating-consumer-evidence.js +338 -0
  166. package/packages/core/v4-floating-consumer-policy.js +569 -0
  167. package/packages/core/v4-floating-consumer-release-passport.js +153 -0
  168. package/packages/core/v4-publication-rehearsal-capsule.js +468 -0
  169. package/packages/core/v4-publication-rehearsal-provider-bindings.js +212 -0
  170. package/packages/core/v4-publication-rehearsal.js +481 -0
  171. package/packages/core/v4-runtime-ref-resume-authority.js +625 -0
  172. package/packages/core/v4-runtime-selector-persistence.js +228 -0
  173. package/packages/core/v4-tail-reseal-contract.js +26 -0
  174. package/packages/core/v4-tail-reseal-github.js +178 -0
  175. package/packages/core/v4-tail-reseal-receipt.js +225 -0
  176. package/packages/core/v4-tail-reseal.js +594 -0
  177. package/packages/core/workflow-yaml-contract.js +72 -2
  178. package/scripts/audit-publication-control-plane.mjs +31 -31
  179. package/scripts/buildchain-cli-help.mjs +41 -2
  180. package/scripts/check-ci-lane-change-budget.mjs +100 -0
  181. package/scripts/check-inventory.mjs +14 -3
  182. package/scripts/check-v4-floating-consumer-policy-contract.mjs +217 -0
  183. package/scripts/check-v4-public-dogfood-contract.mjs +6 -11
  184. package/scripts/dev-alpha-candidate-patrol.mjs +22 -1
  185. package/scripts/dev-delivery-authority-command-adapters.mjs +206 -0
  186. package/scripts/dev-delivery-authority-provider.mjs +28 -0
  187. package/scripts/dev-delivery-authority.mjs +490 -0
  188. package/scripts/dev-delivery-native-run.mjs +177 -0
  189. package/scripts/dev-delivery-process-boundary.mjs +260 -0
  190. package/scripts/dev-delivery-proof.mjs +67 -2
  191. package/scripts/dev-delivery-provider-heartbeat.mjs +215 -0
  192. package/scripts/dev-delivery-source-proof-replay.mjs +153 -0
  193. package/scripts/dev-delivery-source-proof-reuse.mjs +547 -0
  194. package/scripts/dev-delivery-two-phase-resume.mjs +345 -0
  195. package/scripts/dev-delivery-two-phase.mjs +573 -0
  196. package/scripts/dev-delivery-warrant-options.mjs +266 -0
  197. package/scripts/dev-delivery-warrant-store.mjs +231 -0
  198. package/scripts/dev-delivery-warrant.mjs +232 -194
  199. package/scripts/dev-pr-auto-merge.mjs +37 -48
  200. package/scripts/dev-pr-delivery-warrant.mjs +216 -2
  201. package/scripts/dev-pr-prequeue-guard.mjs +399 -0
  202. package/scripts/dev-qualification-patrol.mjs +9 -9
  203. package/scripts/dispatch-artifact-signing-authority.mjs +1 -1
  204. package/scripts/ensure-github-release.mjs +3 -3
  205. package/scripts/generate-channel-build-workflow.mjs +3 -0
  206. package/scripts/generate-channel-promotion-workflow.mjs +114 -14
  207. package/scripts/generate-next-development-guidance.mjs +49 -0
  208. package/scripts/generate-release-candidate-passport.mjs +192 -32
  209. package/scripts/generate-site-bundle.mjs +69 -4
  210. package/scripts/init-repo.mjs +26 -4
  211. package/scripts/inspect-artifact-signing-requests.mjs +6 -0
  212. package/scripts/next-development-self-dogfood-harness.mjs +460 -0
  213. package/scripts/next-development-self-dogfood.mjs +597 -0
  214. package/scripts/next-development-transition.mjs +47 -0
  215. package/scripts/npm-publish-transaction.mjs +103 -91
  216. package/scripts/promotion-channel-router.mjs +4 -4
  217. package/scripts/release-candidate-anchor-provenance.mjs +99 -0
  218. package/scripts/release-tail.mjs +51 -3
  219. package/scripts/release-train-self-dogfood.mjs +94 -92
  220. package/scripts/resume-from-candidate-run.mjs +565 -41
  221. package/scripts/seal-artifact-signing-requests.mjs +6 -0
  222. package/scripts/site-capability-metadata.mjs +43 -0
  223. package/scripts/stable-candidate-qualification.mjs +9 -10
  224. package/scripts/v4-consumer-policy.mjs +231 -0
  225. package/scripts/v4-publication-rehearsal-fixture.mjs +144 -0
  226. package/scripts/v4-tail-reseal-macos-rehearsal.mjs +134 -0
  227. package/scripts/v4-tail-reseal.mjs +416 -0
  228. package/templates/native-dev-delivery.yml +143 -0
@@ -0,0 +1,359 @@
1
+ import {
2
+ adopterDeliveryGateDigest,
3
+ createAdopterDeliveryGate,
4
+ createGitCommitArtifactProfile,
5
+ createPackageArtifactProfile,
6
+ defineAdopterProtocolDriver,
7
+ ADOPTER_PROTOCOL_DRIVER_INTERFACE,
8
+ } from "./adopter-delivery-gate.js";
9
+ import { qualifyBuildchainDeliveryInfrastructureBootstrap } from "./buildchain-delivery-bootstrap.js";
10
+ import { createKfdAdopterCategoryProtocolDriver } from "./kfd-adopter-category-driver.js";
11
+ import { createLegacyKfdAdopterProtocolDriver } from "./legacy-kfd-adopter-driver.js";
12
+ import { loadPublishedBuildchainDeliveryAuthority } from "./published-delivery-authority.js";
13
+
14
+ export const V4_ADOPTER_DELIVERY_CONTRACT =
15
+ "kungfu-buildchain-v4-adopter-delivery/v1";
16
+ export const V4_ADOPTER_DELIVERY_READBACK_CONTRACT =
17
+ "kungfu-buildchain-v4-adopter-delivery-readback/v1";
18
+ export const V4_ADOPTER_DELIVERY_BOOTSTRAP_LINEAGE_CONTRACT =
19
+ "kungfu-buildchain-v4-adopter-delivery-bootstrap-lineage/v1";
20
+ export const V4_ADOPTER_DELIVERY_SOURCE = Object.freeze({
21
+ branch: "dev/v3/v3.0",
22
+ commit: "6b96bdad8d9f8ccf9275f27d9370a226a9c78465",
23
+ vectorSuiteRoot:
24
+ "sha256:c978707556406ffda4ef4192032332c01c2da1cebb6ad8c4f0edfc65d5cef0c7",
25
+ kfdPackage: "@kungfu-tech/kfd@1.0.0-alpha.65",
26
+ targetBranch: "dev/v4/v4.0",
27
+ initialTargetBase: "e5611377efc03178f8687d99968cfdfa3ce2825b",
28
+ targetBase: "e0342713c7447960c13bd73377282b2e93f4853d",
29
+ });
30
+ export const V4_ADOPTER_DELIVERY_ARCHIVE_AUTHORITY = Object.freeze({
31
+ buildchain: Object.freeze({
32
+ name: "@kungfu-tech/buildchain",
33
+ version: "3.0.9-alpha.16",
34
+ archiveRoot:
35
+ "sha256:3f425e2c77d11f0bee8eb9aa2448566bca7a9d14672a7e528ced3e505b3f14a3",
36
+ artifactRoot:
37
+ "sha256:3f425e2c77d11f0bee8eb9aa2448566bca7a9d14672a7e528ced3e505b3f14a3",
38
+ }),
39
+ kfd: Object.freeze({
40
+ name: "@kungfu-tech/kfd",
41
+ version: "1.0.0-alpha.65",
42
+ archiveRoot:
43
+ "sha256:c4dbd3f954910236d7f0823ea6887f4151e43b871df526ccdd599123421bced2",
44
+ artifactRoot:
45
+ "sha256:c0781bcaf191a58561ae32ee2fbedabbb48ed50b5725c356fbd83704089637f8",
46
+ }),
47
+ authorityRoot:
48
+ "sha256:9ba0cc6042b189ce749d01003617b57bcd03ea6ecf40e96d19e8ecbbfa347134",
49
+ });
50
+
51
+ const ROOT = /^sha256:[0-9a-f]{64}$/u;
52
+ const SHA = /^[0-9a-f]{40}$/u;
53
+ const BUILTIN_DRIVER_SELECTORS = Object.freeze({
54
+ "json-assertion": "buildchain.adopter/json-assertion@1.0.0",
55
+ "kfd-category": "kfd.adopter-category/instance-manifest@1.0.0",
56
+ "legacy-kfd": "buildchain.kfd-adopter/legacy-support-matrix@1.0.0",
57
+ });
58
+ const BUILTIN_PROFILE_SELECTORS = Object.freeze({
59
+ "git-commit": "buildchain.artifact/git-commit@1.0.0",
60
+ package: "buildchain.artifact/package@1.0.0",
61
+ });
62
+
63
+ function exactKeys(value, keys, label) {
64
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
65
+ throw new TypeError(`${label} must be an object`);
66
+ }
67
+ const actual = Object.keys(value).sort();
68
+ const expected = [...keys].sort();
69
+ if (
70
+ actual.length !== expected.length ||
71
+ actual.some((entry, index) => entry !== expected[index])
72
+ ) {
73
+ throw new TypeError(`${label} has an unsupported field set`);
74
+ }
75
+ return structuredClone(value);
76
+ }
77
+
78
+ function definitionKey(value) {
79
+ return `${value.id}@${value.version}`;
80
+ }
81
+
82
+ function resolveSelector(selector, table, definitions, label) {
83
+ const expected = table[selector];
84
+ if (!expected) throw new RangeError(`unknown ${label} selector: ${selector}`);
85
+ const selected = definitions.find(
86
+ (entry) => definitionKey(entry) === expected,
87
+ );
88
+ if (!selected)
89
+ throw new Error(
90
+ `${label} selector is not backed by an exact implementation`,
91
+ );
92
+ return selected;
93
+ }
94
+
95
+ export function createJsonAssertionAdopterProtocolDriver() {
96
+ return defineAdopterProtocolDriver({
97
+ interface: ADOPTER_PROTOCOL_DRIVER_INTERFACE,
98
+ id: "buildchain.adopter/json-assertion",
99
+ version: "1.0.0",
100
+ verify({ request }) {
101
+ const declaration = request.declaration;
102
+ const exact =
103
+ declaration &&
104
+ typeof declaration === "object" &&
105
+ !Array.isArray(declaration) &&
106
+ Object.keys(declaration).length === 1 &&
107
+ typeof declaration.valid === "boolean";
108
+ const valid = exact && declaration.valid === true;
109
+ const issues = valid
110
+ ? []
111
+ : [
112
+ {
113
+ code: "delivery-json-assertion-rejected",
114
+ path: "/declaration",
115
+ message:
116
+ "JSON assertion declarations must contain only valid: true.",
117
+ },
118
+ ];
119
+ const report = {
120
+ schemaVersion: 1,
121
+ contract: "kungfu-buildchain-json-assertion-driver-report/v1",
122
+ valid,
123
+ declaration: structuredClone(declaration),
124
+ qualifying: false,
125
+ selfCertified: false,
126
+ releaseAuthorized: false,
127
+ };
128
+ return {
129
+ valid,
130
+ report,
131
+ reportRoot: adopterDeliveryGateDigest(report),
132
+ issues,
133
+ };
134
+ },
135
+ });
136
+ }
137
+
138
+ export function createV4AdopterDeliveryRuntime({
139
+ drivers = [],
140
+ artifactProfiles = [],
141
+ } = {}) {
142
+ const allDrivers = [
143
+ createJsonAssertionAdopterProtocolDriver(),
144
+ createKfdAdopterCategoryProtocolDriver(),
145
+ createLegacyKfdAdopterProtocolDriver(),
146
+ ...drivers,
147
+ ];
148
+ const allProfiles = [
149
+ createGitCommitArtifactProfile(),
150
+ createPackageArtifactProfile(),
151
+ ...artifactProfiles,
152
+ ];
153
+ return Object.freeze({
154
+ drivers: Object.freeze(allDrivers),
155
+ artifactProfiles: Object.freeze(allProfiles),
156
+ evaluate({
157
+ request,
158
+ context = {},
159
+ driverSelector,
160
+ artifactProfileSelector,
161
+ } = {}) {
162
+ const driver = resolveSelector(
163
+ driverSelector,
164
+ BUILTIN_DRIVER_SELECTORS,
165
+ allDrivers,
166
+ "driver",
167
+ );
168
+ const profile = resolveSelector(
169
+ artifactProfileSelector,
170
+ BUILTIN_PROFILE_SELECTORS,
171
+ allProfiles,
172
+ "artifact profile",
173
+ );
174
+ if (definitionKey(driver) !== definitionKey(request?.protocol ?? {})) {
175
+ throw new Error(
176
+ "driver selector does not match the exact request protocol",
177
+ );
178
+ }
179
+ if (
180
+ definitionKey(profile) !== definitionKey(request?.artifactProfile ?? {})
181
+ ) {
182
+ throw new Error(
183
+ "artifact profile selector does not match the exact request profile",
184
+ );
185
+ }
186
+ return createAdopterDeliveryGate({
187
+ drivers: [driver],
188
+ artifactProfiles: [profile],
189
+ }).evaluate(structuredClone(request), structuredClone(context));
190
+ },
191
+ });
192
+ }
193
+
194
+ export function runV4AdopterDeliveryGate(input, options = {}) {
195
+ const normalized = exactKeys(
196
+ input,
197
+ [
198
+ "schemaVersion",
199
+ "contract",
200
+ "driverSelector",
201
+ "artifactProfileSelector",
202
+ "request",
203
+ "context",
204
+ ],
205
+ "v4 adopter delivery input",
206
+ );
207
+ if (
208
+ normalized.schemaVersion !== 1 ||
209
+ normalized.contract !== V4_ADOPTER_DELIVERY_CONTRACT
210
+ ) {
211
+ throw new Error("v4 adopter delivery contract or version is unsupported");
212
+ }
213
+ const gateResult =
214
+ createV4AdopterDeliveryRuntime(options).evaluate(normalized);
215
+ const result = {
216
+ schemaVersion: 1,
217
+ contract: V4_ADOPTER_DELIVERY_READBACK_CONTRACT,
218
+ sourceAuthority: structuredClone(V4_ADOPTER_DELIVERY_SOURCE),
219
+ selection: {
220
+ driver: normalized.driverSelector,
221
+ artifactProfile: normalized.artifactProfileSelector,
222
+ },
223
+ gateResult,
224
+ qualifying: false,
225
+ selfCertified: false,
226
+ releaseAuthorized: false,
227
+ finalAuthority: "selected-public-driver-plus-exact-consumer-readback",
228
+ };
229
+ result.deliveryRoot = adopterDeliveryGateDigest(result);
230
+ return result;
231
+ }
232
+
233
+ export function verifyV4AdopterDeliveryReadback(
234
+ { input, readback } = {},
235
+ options = {},
236
+ ) {
237
+ if (!readback || !ROOT.test(readback.deliveryRoot ?? "")) {
238
+ throw new Error("exact adopter delivery readback is required");
239
+ }
240
+ const observed = runV4AdopterDeliveryGate(input, options);
241
+ if (
242
+ observed.deliveryRoot !== readback.deliveryRoot ||
243
+ adopterDeliveryGateDigest(observed) !== adopterDeliveryGateDigest(readback)
244
+ ) {
245
+ throw new Error(
246
+ "adopter delivery readback does not match exact recomputation",
247
+ );
248
+ }
249
+ return observed;
250
+ }
251
+
252
+ export function qualifyV4AdopterDeliveryBootstrap({ input, lineage } = {}) {
253
+ const normalizedLineage = exactKeys(
254
+ lineage,
255
+ [
256
+ "schemaVersion",
257
+ "contract",
258
+ "sourceAuthorityCommit",
259
+ "targetBaseCommit",
260
+ "authorityArchiveRoot",
261
+ ],
262
+ "bootstrap lineage",
263
+ );
264
+ if (
265
+ normalizedLineage.schemaVersion !== 1 ||
266
+ normalizedLineage.contract !==
267
+ V4_ADOPTER_DELIVERY_BOOTSTRAP_LINEAGE_CONTRACT ||
268
+ normalizedLineage.sourceAuthorityCommit !==
269
+ V4_ADOPTER_DELIVERY_SOURCE.commit ||
270
+ normalizedLineage.targetBaseCommit !==
271
+ V4_ADOPTER_DELIVERY_SOURCE.targetBase ||
272
+ !SHA.test(normalizedLineage.sourceAuthorityCommit) ||
273
+ !SHA.test(normalizedLineage.targetBaseCommit) ||
274
+ !ROOT.test(normalizedLineage.authorityArchiveRoot ?? "") ||
275
+ normalizedLineage.authorityArchiveRoot !== input?.authority?.packageRoot
276
+ ) {
277
+ throw new Error(
278
+ "bootstrap lineage does not bind the exact v3 authority and v4 base",
279
+ );
280
+ }
281
+ const bootstrap = qualifyBuildchainDeliveryInfrastructureBootstrap(input);
282
+ const result = {
283
+ schemaVersion: 1,
284
+ contract: "kungfu-buildchain-v4-adopter-delivery-bootstrap/v1",
285
+ sourceAuthority: structuredClone(V4_ADOPTER_DELIVERY_SOURCE),
286
+ lineage: normalizedLineage,
287
+ bootstrap,
288
+ qualifying: false,
289
+ selfCertified: false,
290
+ releaseAuthorized: false,
291
+ };
292
+ result.resultRoot = adopterDeliveryGateDigest(result);
293
+ return result;
294
+ }
295
+
296
+ export async function loadV4PublishedAdopterDeliveryAuthority({
297
+ packages,
298
+ expectedAuthorityRoot,
299
+ } = {}) {
300
+ const request = assertV4PublishedAdopterDeliveryRequest({
301
+ packages,
302
+ expectedAuthorityRoot,
303
+ });
304
+ const authority = await loadPublishedBuildchainDeliveryAuthority(
305
+ request.packages,
306
+ );
307
+ if (authority.authorityRoot !== expectedAuthorityRoot) {
308
+ await authority.dispose();
309
+ throw new Error("published archive authority readback root does not match");
310
+ }
311
+ return authority;
312
+ }
313
+
314
+ export function assertV4PublishedAdopterDeliveryRequest({
315
+ packages,
316
+ expectedAuthorityRoot,
317
+ } = {}) {
318
+ if (
319
+ !ROOT.test(expectedAuthorityRoot ?? "") ||
320
+ expectedAuthorityRoot !==
321
+ V4_ADOPTER_DELIVERY_ARCHIVE_AUTHORITY.authorityRoot
322
+ ) {
323
+ throw new Error(
324
+ "exact published archive authority readback root is required",
325
+ );
326
+ }
327
+ const normalizedPackages = exactKeys(
328
+ packages,
329
+ ["buildchain", "kfd"],
330
+ "published archive packages",
331
+ );
332
+ for (const key of ["buildchain", "kfd"]) {
333
+ const declaration = exactKeys(
334
+ normalizedPackages[key],
335
+ ["name", "version", "archivePath", "archiveRoot", "artifactRoot"],
336
+ `${key} archive identity`,
337
+ );
338
+ const expected = V4_ADOPTER_DELIVERY_ARCHIVE_AUTHORITY[key];
339
+ if (
340
+ typeof declaration.archivePath !== "string" ||
341
+ declaration.archivePath.length === 0 ||
342
+ declaration.name !== expected.name ||
343
+ declaration.version !== expected.version ||
344
+ declaration.archiveRoot !== expected.archiveRoot ||
345
+ declaration.artifactRoot !== expected.artifactRoot
346
+ ) {
347
+ throw new Error(`${key} archive identity is not the exact v3 authority`);
348
+ }
349
+ }
350
+ return {
351
+ packages: normalizedPackages,
352
+ expectedAuthorityRoot,
353
+ };
354
+ }
355
+
356
+ export const V4_ADOPTER_DELIVERY_SELECTORS = Object.freeze({
357
+ drivers: BUILTIN_DRIVER_SELECTORS,
358
+ artifactProfiles: BUILTIN_PROFILE_SELECTORS,
359
+ });
@@ -56,6 +56,11 @@ const ROOT_DOMAINS = new Set([
56
56
  "stable-publication-fence",
57
57
  "partial-mutation-recovery-checkpoint",
58
58
  "partial-mutation-recovery-plan",
59
+ "tail-reseal-plan",
60
+ "tail-reseal-admission",
61
+ "tail-reseal-artifact-files",
62
+ "tail-reseal-receipt",
63
+ "release-candidate-passport",
59
64
  ]);
60
65
  const FAULT_CLASSES = new Set([
61
66
  "validation",
@@ -100,7 +100,9 @@ export function validateV4DeliveryWarrantReadQualification(
100
100
  }
101
101
 
102
102
  export function projectV3QueueToV4ReadState(queueInput) {
103
- const queue = normalizeDevDeliveryQueue(queueInput);
103
+ const queue = normalizeDevDeliveryQueue(queueInput, {
104
+ allowLegacyV3Readback: true,
105
+ });
104
106
  return {
105
107
  schema: STATE_CONTRACT,
106
108
  generation: queue.generation,
@@ -219,7 +221,9 @@ export async function runV4DeliveryWarrantReadCandidate(
219
221
  });
220
222
  if (typeof retain !== "function")
221
223
  fail("retention-required", "v4 read evidence retention is required");
222
- const queue = normalizeDevDeliveryQueue(queueInput);
224
+ const queue = normalizeDevDeliveryQueue(queueInput, {
225
+ allowLegacyV3Readback: true,
226
+ });
223
227
  const state = projectV3QueueToV4ReadState(queue);
224
228
  const request = createV4DeliveryWarrantReadRequest(state, {
225
229
  requestId,
@@ -235,7 +239,10 @@ export async function runV4DeliveryWarrantReadCandidate(
235
239
  );
236
240
  }
237
241
  const projection = validateProjection(response, request, state);
238
- const observation = observeDevDeliveryQueue(queue, { now: observedAt });
242
+ const observation = observeDevDeliveryQueue(queue, {
243
+ now: observedAt,
244
+ allowLegacyV3Readback: true,
245
+ });
239
246
  const evidence = {
240
247
  schema: V4_DELIVERY_WARRANT_READ_EVIDENCE_CONTRACT,
241
248
  authority: "typescript-v3",