@kungfu-tech/buildchain 4.0.1-alpha.2 → 4.0.1-alpha.21

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 (203) hide show
  1. package/actions/release-tail/README.md +8 -0
  2. package/architecture/ci-lane-change-budget.json +187 -0
  3. package/architecture/decisions/0002-next-development-transition.md +101 -0
  4. package/architecture/decisions/0003-two-phase-delivery-warrant.md +152 -0
  5. package/architecture/internal-capabilities.json +211 -8
  6. package/architecture/maintainability-policy.json +113 -28
  7. package/architecture/release-tail-contract-inventory.json +5 -2
  8. package/architecture/v3-core-mechanism-inventory.json +91 -0
  9. package/architecture/v4-adopter-delivery-parity.json +32 -5
  10. package/architecture/v4-capability-state-machine-manifest.json +73 -0
  11. package/architecture/v4-compatibility-facts-parity.json +77 -0
  12. package/architecture/v4-delivery-authority-parity.json +250 -0
  13. package/architecture/v4-delivery-warrant-shadow-fixtures.json +41 -9
  14. package/architecture/v4-floating-consumer-policy.json +6 -0
  15. package/architecture/v4-next-development-parity.json +192 -0
  16. package/architecture/v4-publication-rehearsal-parity.json +84 -0
  17. package/architecture/v4-release-train-parity.json +1 -0
  18. package/architecture/v4-tail-reseal-parity.json +150 -0
  19. package/bin/buildchain.mjs +32 -3
  20. package/bin/internal/adopter-delivery-cli.mjs +70 -0
  21. package/bin/internal/command-registry.mjs +3 -0
  22. package/bin/internal/compatibility-facts-cli.mjs +101 -0
  23. package/contracts/dev-delivery-authority-v2.schema.json +662 -0
  24. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +47 -0
  25. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +47 -0
  26. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +40 -0
  27. package/contracts/fixtures/v4-adopter-delivery-v1/archive-template.json +19 -0
  28. package/contracts/fixtures/v4-adopter-delivery-v1/bootstrap-positive.json +93 -0
  29. package/contracts/fixtures/v4-adopter-delivery-v1/gate-positive.json +29 -0
  30. package/contracts/fixtures/v4-adopter-delivery-v1/gate-unknown-selector.json +26 -0
  31. package/contracts/fixtures/v4-adopter-delivery-v1/offline-vectors.json +50 -0
  32. package/contracts/fixtures/v4-compatibility-facts-v1/shared.json +1129 -0
  33. package/contracts/fixtures/v4-floating-consumer-policy-v1/cases.json +7 -1
  34. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/artifacts/product.bin +1 -0
  35. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/config/buildchain.toml +5 -0
  36. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/release-activation.json +1 -0
  37. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/signed-channel.json +1 -0
  38. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/evidence/qualification.json +1 -0
  39. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/candidate.json +5 -0
  40. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/release-passport.json +1 -0
  41. package/contracts/fixtures/v4-publication-rehearsal-v1/capsule.json +707 -0
  42. package/contracts/fixtures/v4-publication-rehearsal-v1/offline-vectors.json +27 -0
  43. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +229 -0
  44. package/contracts/next-development-request-v1.schema.json +66 -0
  45. package/contracts/next-development-transition-v1.schema.json +292 -0
  46. package/contracts/v4-adopter-delivery-v1.schema.json +81 -0
  47. package/contracts/v4-compatibility-facts-v1.schema.json +230 -0
  48. package/contracts/v4-floating-consumer-policy-receipt-v1.schema.json +4 -2
  49. package/contracts/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
  50. package/contracts/v4-tail-reseal-v1.schema.json +276 -0
  51. package/dist/site/agent-index.json +5 -0
  52. package/dist/site/artifact-schemas.json +10 -0
  53. package/dist/site/buildchain-contract.json +1475 -27
  54. package/dist/site/buildchain-site.json +627 -31
  55. package/dist/site/capability-registry.json +17 -14
  56. package/dist/site/cli-registry.json +205 -3
  57. package/dist/site/kfd-claims.json +490 -16
  58. package/dist/site/kfd-upstream-aggregate.json +1 -1
  59. package/dist/site/manual-registry.json +52 -6
  60. package/dist/site/node-api-registry.json +14736 -8851
  61. package/dist/site/page-registry.json +593 -21
  62. package/dist/site/public-surface-audit.json +837 -48
  63. package/dist/site/publication-authority-registry.json +44 -8
  64. package/dist/site/publication-registry.json +4 -4
  65. package/dist/site/release-provenance.json +24 -0
  66. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +662 -0
  67. package/dist/site/schemas/release-tail-capabilities-v1.schema.json +199 -0
  68. package/dist/site/schemas/v4-adopter-delivery-v1.schema.json +81 -0
  69. package/dist/site/schemas/v4-compatibility-facts-v1.schema.json +230 -0
  70. package/dist/site/schemas/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
  71. package/dist/site/site-manifest.json +34 -10
  72. package/dist/site/workflow-registry.json +160 -10
  73. package/docs/MAP.md +8 -2
  74. package/docs/cli-reference.md +404 -13
  75. package/docs/cli.md +8 -0
  76. package/docs/dev-alpha-candidate-patrol.md +8 -0
  77. package/docs/dev-delivery-qualification-landing-adr.md +251 -0
  78. package/docs/dev-delivery-warrant.md +351 -38
  79. package/docs/next-development-transition.md +118 -0
  80. package/docs/node-api-reference.md +646 -293
  81. package/docs/release-tail-provider-plane.md +30 -0
  82. package/docs/v4-adopter-delivery.md +133 -0
  83. package/docs/v4-compatibility-facts.md +91 -0
  84. package/docs/v4-publication-rehearsal.md +130 -0
  85. package/docs/v4-tail-reseal.md +73 -0
  86. package/docs/versioning.md +4 -3
  87. package/package.json +34 -6
  88. package/packages/core/adopter-delivery-passport.js +259 -0
  89. package/packages/core/adopter-delivery-vectors.js +158 -0
  90. package/packages/core/adopter-delivery-vectors.json +77 -0
  91. package/packages/core/buildchain-agent-manuals.js +3 -0
  92. package/packages/core/buildchain-compatibility-authority.js +336 -0
  93. package/packages/core/buildchain-compatibility-fact.js +394 -0
  94. package/packages/core/buildchain-compatibility-facts.json +217 -0
  95. package/packages/core/buildchain-compatibility-proof.js +566 -0
  96. package/packages/core/buildchain-config.js +84 -0
  97. package/packages/core/buildchain-contract.js +96 -143
  98. package/packages/core/buildchain-delivery-bootstrap.js +240 -0
  99. package/packages/core/buildchain-delivery-infrastructure.js +164 -0
  100. package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
  101. package/packages/core/buildchain-publication-authority.js +1 -0
  102. package/packages/core/channel-candidate.js +8 -0
  103. package/packages/core/channel-promotion-baseline.js +55 -0
  104. package/packages/core/ci-lane-change-budget.js +247 -0
  105. package/packages/core/dev-alpha-candidate-selection.js +10 -2
  106. package/packages/core/dev-delivery-authority-candidate.js +270 -0
  107. package/packages/core/dev-delivery-authority-evidence.js +146 -0
  108. package/packages/core/dev-delivery-authority-landing.js +461 -0
  109. package/packages/core/dev-delivery-authority-observation.js +48 -0
  110. package/packages/core/dev-delivery-authority-qualification.js +591 -0
  111. package/packages/core/dev-delivery-authority-settlement.js +213 -0
  112. package/packages/core/dev-delivery-authority-state.js +583 -0
  113. package/packages/core/dev-delivery-candidate-identity.js +13 -0
  114. package/packages/core/dev-delivery-contract-surface.js +76 -0
  115. package/packages/core/dev-delivery-execution-failure.js +133 -0
  116. package/packages/core/dev-delivery-execution-transfer.js +592 -0
  117. package/packages/core/dev-delivery-landing-admission-core.js +119 -0
  118. package/packages/core/dev-delivery-landing-readback.js +598 -0
  119. package/packages/core/dev-delivery-landing-terminal-evidence.js +271 -0
  120. package/packages/core/dev-delivery-landing-testing-port.js +6 -0
  121. package/packages/core/dev-delivery-native-execution.js +110 -0
  122. package/packages/core/dev-delivery-native-proof.js +562 -0
  123. package/packages/core/dev-delivery-process-boundary.js +563 -0
  124. package/packages/core/dev-delivery-provider-attempt.js +127 -0
  125. package/packages/core/dev-delivery-provider-heartbeat.js +382 -0
  126. package/packages/core/dev-delivery-warrant-cancellation.js +1 -0
  127. package/packages/core/dev-delivery-warrant-qualification.js +145 -0
  128. package/packages/core/dev-delivery-warrant-settlement.js +237 -36
  129. package/packages/core/dev-delivery-warrant-state.js +587 -0
  130. package/packages/core/dev-delivery-warrant.js +328 -370
  131. package/packages/core/github-governance-authority.js +1 -0
  132. package/packages/core/index.js +5 -0
  133. package/packages/core/kungfu-temporal-fact.js +557 -0
  134. package/packages/core/legacy-kfd-adopter-driver.js +167 -0
  135. package/packages/core/next-development-candidate-reservation.js +186 -0
  136. package/packages/core/next-development-controller.js +728 -0
  137. package/packages/core/next-development-projection.js +287 -0
  138. package/packages/core/next-development-transition.js +738 -0
  139. package/packages/core/paper-agent-entry.js +11 -5
  140. package/packages/core/paper.js +16 -5
  141. package/packages/core/published-delivery-authority.js +266 -0
  142. package/packages/core/release-candidate-recovery.js +70 -15
  143. package/packages/core/release-candidate.js +2 -2
  144. package/packages/core/release-passport.js +36 -9
  145. package/packages/core/v4-adopter-delivery-parity.js +3 -3
  146. package/packages/core/v4-adopter-delivery.js +359 -0
  147. package/packages/core/v4-canonical-contracts.js +5 -0
  148. package/packages/core/v4-delivery-warrant-read-candidate.js +10 -3
  149. package/packages/core/v4-floating-consumer-evidence.js +18 -4
  150. package/packages/core/v4-floating-consumer-policy.js +143 -20
  151. package/packages/core/v4-floating-consumer-release-passport.js +32 -5
  152. package/packages/core/v4-publication-rehearsal-capsule.js +468 -0
  153. package/packages/core/v4-publication-rehearsal-provider-bindings.js +212 -0
  154. package/packages/core/v4-publication-rehearsal.js +481 -0
  155. package/packages/core/v4-tail-reseal-contract.js +26 -0
  156. package/packages/core/v4-tail-reseal-github.js +178 -0
  157. package/packages/core/v4-tail-reseal-receipt.js +225 -0
  158. package/packages/core/v4-tail-reseal.js +594 -0
  159. package/packages/core/workflow-yaml-contract.js +24 -2
  160. package/scripts/buildchain-cli-help.mjs +41 -2
  161. package/scripts/check-ci-lane-change-budget.mjs +100 -0
  162. package/scripts/check-inventory.mjs +14 -3
  163. package/scripts/check-v4-floating-consumer-policy-contract.mjs +23 -4
  164. package/scripts/dev-alpha-candidate-patrol.mjs +22 -1
  165. package/scripts/dev-delivery-authority-command-adapters.mjs +206 -0
  166. package/scripts/dev-delivery-authority-provider.mjs +28 -0
  167. package/scripts/dev-delivery-authority.mjs +490 -0
  168. package/scripts/dev-delivery-native-run.mjs +177 -0
  169. package/scripts/dev-delivery-process-boundary.mjs +260 -0
  170. package/scripts/dev-delivery-proof.mjs +67 -2
  171. package/scripts/dev-delivery-provider-heartbeat.mjs +215 -0
  172. package/scripts/dev-delivery-source-proof-replay.mjs +153 -0
  173. package/scripts/dev-delivery-source-proof-reuse.mjs +13 -97
  174. package/scripts/dev-delivery-two-phase-resume.mjs +345 -0
  175. package/scripts/dev-delivery-two-phase.mjs +573 -0
  176. package/scripts/dev-delivery-warrant-options.mjs +266 -0
  177. package/scripts/dev-delivery-warrant-store.mjs +231 -0
  178. package/scripts/dev-delivery-warrant.mjs +232 -194
  179. package/scripts/dev-pr-auto-merge.mjs +1 -1
  180. package/scripts/dev-pr-delivery-warrant.mjs +11 -0
  181. package/scripts/dev-qualification-patrol.mjs +9 -9
  182. package/scripts/dispatch-artifact-signing-authority.mjs +1 -1
  183. package/scripts/generate-channel-promotion-workflow.mjs +2 -2
  184. package/scripts/generate-next-development-guidance.mjs +49 -0
  185. package/scripts/generate-release-candidate-passport.mjs +152 -0
  186. package/scripts/generate-site-bundle.mjs +69 -4
  187. package/scripts/init-repo.mjs +22 -4
  188. package/scripts/next-development-self-dogfood-harness.mjs +460 -0
  189. package/scripts/next-development-self-dogfood.mjs +597 -0
  190. package/scripts/next-development-transition.mjs +47 -0
  191. package/scripts/npm-publish-transaction.mjs +2 -2
  192. package/scripts/promotion-channel-router.mjs +4 -4
  193. package/scripts/release-candidate-anchor-provenance.mjs +99 -0
  194. package/scripts/release-tail.mjs +51 -3
  195. package/scripts/release-train-self-dogfood.mjs +94 -92
  196. package/scripts/resume-from-candidate-run.mjs +557 -30
  197. package/scripts/site-capability-metadata.mjs +41 -0
  198. package/scripts/stable-candidate-qualification.mjs +9 -10
  199. package/scripts/v4-consumer-policy.mjs +5 -5
  200. package/scripts/v4-publication-rehearsal-fixture.mjs +144 -0
  201. package/scripts/v4-tail-reseal-macos-rehearsal.mjs +134 -0
  202. package/scripts/v4-tail-reseal.mjs +416 -0
  203. package/templates/native-dev-delivery.yml +143 -0
@@ -38,6 +38,7 @@ import {
38
38
  isV4PromotionRouting,
39
39
  releasePassportCertificationVerificationOptions,
40
40
  requireV4ConsumerPolicyCertification,
41
+ resolveV4ConsumerPolicyCertificationIdentity,
41
42
  } from "./v4-floating-consumer-release-passport.js";
42
43
  import {
43
44
  verifyV4RuntimeAuthorizationReceipt,
@@ -439,11 +440,17 @@ function mergeAuthoritativePassportBase(passport, basePassport = undefined, { re
439
440
  kfd3: basePassport.evidence?.kfd3 || passport.evidence?.kfd3 || "",
440
441
  },
441
442
  };
442
- for (const key of ["versionImpact", "surfaceImpacts"]) {
443
- if (basePassport[key] !== undefined) {
444
- merged[key] = basePassport[key];
445
- }
446
- }
443
+ for (const key of [
444
+ "versionImpact",
445
+ "surfaceImpacts",
446
+ "promotionRouting",
447
+ "v4ConsumerPolicy",
448
+ "v4RuntimeResume",
449
+ "transaction",
450
+ "trustedPublishing",
451
+ "distTagPromotion",
452
+ ])
453
+ if (basePassport[key] !== undefined) merged[key] = basePassport[key];
447
454
  if (basePassport.controllerReceipts !== undefined) {
448
455
  merged.controllerReceipts = basePassport.controllerReceipts;
449
456
  }
@@ -1106,17 +1113,25 @@ function normalizePromotionEvidence({
1106
1113
  release = {},
1107
1114
  v4ConsumerPolicyCertification: certification,
1108
1115
  v4ConsumerPolicyCertificationRoot: certificationRoot,
1116
+ v4RuntimeResumeEvidence,
1109
1117
  repository,
1110
1118
  sourceSha,
1111
1119
  cwd,
1112
1120
  }) {
1113
1121
  const routing = normalizePromotionRouting(release.promotionRouting);
1122
+ const identity = resolveV4ConsumerPolicyCertificationIdentity({
1123
+ release: { ...release, certification },
1124
+ routing,
1125
+ runtimeResume: v4RuntimeResumeEvidence,
1126
+ sourceSha,
1127
+ });
1114
1128
  return {
1115
1129
  routing,
1116
1130
  consumerPolicy: requireV4ConsumerPolicyCertification({
1117
1131
  value: certification,
1118
1132
  repository,
1119
- sourceSha,
1133
+ sourceSha: identity.sourceSha,
1134
+ runtimeSha: identity.runtimeSha,
1120
1135
  routing,
1121
1136
  cwd,
1122
1137
  certificationRoot,
@@ -1162,6 +1177,18 @@ function normalizeV4RuntimeResumeEvidence(value, expected = {}) {
1162
1177
  };
1163
1178
  }
1164
1179
 
1180
+ function v4RuntimeResumeSourceSha(release, fallback = "") {
1181
+ const builtSourceSha = releaseField(
1182
+ release || {},
1183
+ "builtSourceSha",
1184
+ "built_source_sha",
1185
+ );
1186
+ return release?.treeEquivalent === true && builtSourceSha
1187
+ ? builtSourceSha
1188
+ : fallback;
1189
+ }
1190
+
1191
+
1165
1192
  function prepareBuildEvidence({
1166
1193
  buildSummary,
1167
1194
  buildFacts,
@@ -1317,7 +1344,7 @@ export function createReleasePassport(options = {}) {
1317
1344
  const { promotion, buildEvidence } = preparePromotionBuild(options);
1318
1345
  const normalizedV4RuntimeResume = normalizeV4RuntimeResumeEvidence(v4RuntimeResumeEvidence, {
1319
1346
  repository,
1320
- sourceSha,
1347
+ sourceSha: v4RuntimeResumeSourceSha(release, sourceSha),
1321
1348
  resumeRuntimeSha: promotion.routing?.runtime?.resolvedSha || "",
1322
1349
  consumerPolicyReceiptRoot: promotion.consumerPolicy?.certification?.receiptRoot || "",
1323
1350
  });
@@ -2302,7 +2329,7 @@ function validateV4RuntimeResumePassportSection({ passport, issues }) {
2302
2329
  receipt: evidence.authorization,
2303
2330
  receiptRoot: evidence.authorizationRoot,
2304
2331
  repository: passport?.product?.repository || "",
2305
- sourceSha: passport?.release?.sourceSha || "",
2332
+ sourceSha: v4RuntimeResumeSourceSha(passport?.release, passport?.release?.sourceSha || ""),
2306
2333
  runtimeSha: passport?.promotionRouting?.runtime?.resolvedSha || "",
2307
2334
  consumerPolicyReceiptRoot,
2308
2335
  });
@@ -2313,7 +2340,7 @@ function validateV4RuntimeResumePassportSection({ passport, issues }) {
2313
2340
  lineage: evidence.lineage,
2314
2341
  lineageRoot: evidence.lineageRoot,
2315
2342
  repository: passport?.product?.repository || "",
2316
- sourceSha: passport?.release?.sourceSha || "",
2343
+ sourceSha: v4RuntimeResumeSourceSha(passport?.release, passport?.release?.sourceSha || ""),
2317
2344
  resumeRuntimeSha: passport?.promotionRouting?.runtime?.resolvedSha || "",
2318
2345
  consumerPolicyReceiptRoot,
2319
2346
  });
@@ -31,10 +31,10 @@ const root = path.resolve(
31
31
  );
32
32
 
33
33
  export const V4_ADOPTER_DELIVERY_PARITY_SOURCE = Object.freeze({
34
- v3Commit: "c3f58d76391c1c6ceddfc900a68e91c7ab82a575",
34
+ v3Commit: "6b96bdad8d9f8ccf9275f27d9370a226a9c78465",
35
35
  vectorSuiteRoot:
36
- "sha256:cf329805d928a9883cbafbdfdf21ef66c6a0889ed8dfe14356b4e0d25d6738f9",
37
- kfdPackage: "@kungfu-tech/kfd@1.0.0-alpha.62",
36
+ "sha256:c978707556406ffda4ef4192032332c01c2da1cebb6ad8c4f0edfc65d5cef0c7",
37
+ kfdPackage: "@kungfu-tech/kfd@1.0.0-alpha.65",
38
38
  });
39
39
 
40
40
  function clone(value) {
@@ -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",
@@ -8,6 +8,12 @@ export const V4_FLOATING_CONSUMER_CERTIFICATION =
8
8
  "kungfu-buildchain-v4-floating-consumer-certification/v1";
9
9
 
10
10
  const SHA256_ROOT = /^sha256:[0-9a-f]{64}$/u;
11
+ const ALPHA_RECOVERY_BOOTSTRAP = Object.freeze({
12
+ repository: "kungfu-systems/buildchain",
13
+ sourcePath: ".github/workflows/buildchain-ref-promotion-recovery.yml",
14
+ workflow: ".github/workflows/.release-candidate-promote.yml",
15
+ selector: "alpha/v4/v4.0",
16
+ });
11
17
 
12
18
  function stableJson(value) {
13
19
  if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
@@ -109,15 +115,23 @@ function verifyAuthorityFields(value, expected, check, label) {
109
115
  }
110
116
 
111
117
  function verifyFloatingSelector(value, check, label) {
118
+ const bootstrap =
119
+ value?.caller?.repository === ALPHA_RECOVERY_BOOTSTRAP.repository &&
120
+ value?.invocation?.sourcePath === ALPHA_RECOVERY_BOOTSTRAP.sourcePath &&
121
+ value?.invocation?.workflow === ALPHA_RECOVERY_BOOTSTRAP.workflow &&
122
+ value?.invocation?.visibleSelector === ALPHA_RECOVERY_BOOTSTRAP.selector &&
123
+ value?.invocation?.selectorClass === "protected-bootstrap" &&
124
+ value?.invocation?.channel === "alpha";
112
125
  check(
113
- value?.invocation?.selectorClass === "floating",
126
+ value?.invocation?.selectorClass === "floating" || bootstrap,
114
127
  "selector-class-invalid",
115
- `${label} must bind a floating selector`,
128
+ `${label} must bind a floating selector or the bounded protected alpha recovery bootstrap`,
116
129
  );
117
130
  check(
118
- ["v4", "v4-alpha"].includes(value?.invocation?.visibleSelector),
131
+ ["v4", "v4-alpha"].includes(value?.invocation?.visibleSelector) ||
132
+ bootstrap,
119
133
  "selector-invalid",
120
- `${label} selector must be v4 or v4-alpha`,
134
+ `${label} selector must be v4, v4-alpha, or the bounded protected alpha recovery bootstrap`,
121
135
  );
122
136
  }
123
137