@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
@@ -501,16 +501,16 @@ export function createGitHubDevQualificationClient({
501
501
  sourceBranch,
502
502
  { activeOnly = false } = {},
503
503
  ) {
504
- const query = sourceBranch
505
- ? `?branch=${encodeURIComponent(sourceBranch)}`
506
- : "";
507
- const runs = await paged(
508
- `/repos/${owner}/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs${query}`,
509
- "workflow_runs",
504
+ const query = sourceBranch ? `branch=${encodeRef(sourceBranch)}&` : "";
505
+ const runs = await Promise.all(
506
+ [...(activeOnly ? ACTIVE_STATUSES : [""])].map((status) =>
507
+ paged(
508
+ `/repos/${owner}/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs?${query}${status ? `status=${status}` : ""}`,
509
+ "workflow_runs",
510
+ ),
511
+ ),
510
512
  );
511
- return activeOnly
512
- ? runs.filter((run) => ACTIVE_STATUSES.has(text(run.status)))
513
- : runs;
513
+ return runs.flat();
514
514
  },
515
515
  async listRunJobs(runId, runAttempt) {
516
516
  return paged(
@@ -24,7 +24,7 @@ const AUTHORITY_WORKFLOW = "artifact-signing-authority.yml";
24
24
 
25
25
  export function resolveAuthorityDispatchRef(value) {
26
26
  const ref = required(value, "authority ref");
27
- return /^[0-9a-f]{40}$/u.test(ref)
27
+ return /^[0-9a-f]{40}$/u.test(ref) || /^v\d+(?:\.\d+)?(?:-alpha)?$/u.test(ref)
28
28
  ? DEFAULT_ARTIFACT_SIGNING_AUTHORITY_REF
29
29
  : ref;
30
30
  }
@@ -159,8 +159,8 @@ function validateWorkflowRoute(name, route, expectedLogicalRef) {
159
159
  if (!/^\.github\/workflows\/[.a-z0-9-]+\.ya?ml$/.test(route.workflowPath || "")) {
160
160
  throw new Error(`promotion shell ${name} workflowPath must name a reusable workflow`);
161
161
  }
162
- if (!/^(?:v[0-9]+(?:-alpha)?|train\/[A-Za-z0-9._+\/-]+|[0-9a-f]{40})$/.test(route.callRef || "")) {
163
- throw new Error(`promotion shell ${name} callRef must be an official channel ref, trusted train, or exact SHA`);
162
+ if (!/^(?:v[0-9]+(?:-alpha)?|(?:train|alpha|release)\/[A-Za-z0-9._+\/-]+|[0-9a-f]{40})$/.test(route.callRef || "")) {
163
+ throw new Error(`promotion shell ${name} callRef must be an official tag, protected channel ref, trusted train, or exact SHA`);
164
164
  }
165
165
  if (typeof route.forwardInternalInputs !== "boolean") {
166
166
  throw new Error(`promotion shell ${name} forwardInternalInputs must be boolean`);
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+
7
+ import { nextDevelopmentManual } from "../packages/core/next-development-projection.js";
8
+
9
+ export const NEXT_DEVELOPMENT_MANUAL_PATH =
10
+ "docs/next-development-transition.md";
11
+
12
+ export function generateNextDevelopmentGuidance({
13
+ cwd = process.cwd(),
14
+ check = false,
15
+ } = {}) {
16
+ const target = path.resolve(cwd, NEXT_DEVELOPMENT_MANUAL_PATH);
17
+ const expected = nextDevelopmentManual();
18
+ const current = fs.existsSync(target) ? fs.readFileSync(target, "utf8") : "";
19
+ if (check) {
20
+ if (current !== expected) {
21
+ throw new Error(
22
+ `${NEXT_DEVELOPMENT_MANUAL_PATH} drifted from its contract source`,
23
+ );
24
+ }
25
+ return { ok: true, changed: false, path: NEXT_DEVELOPMENT_MANUAL_PATH };
26
+ }
27
+ fs.mkdirSync(path.dirname(target), { recursive: true });
28
+ if (current !== expected) fs.writeFileSync(target, expected);
29
+ return {
30
+ ok: true,
31
+ changed: current !== expected,
32
+ path: NEXT_DEVELOPMENT_MANUAL_PATH,
33
+ };
34
+ }
35
+
36
+ if (
37
+ process.argv[1] &&
38
+ import.meta.url === pathToFileURL(process.argv[1]).href
39
+ ) {
40
+ try {
41
+ const result = generateNextDevelopmentGuidance({
42
+ check: process.argv.includes("--check"),
43
+ });
44
+ process.stdout.write(`${JSON.stringify(result)}\n`);
45
+ } catch (error) {
46
+ process.stderr.write(`next-development guidance: ${error.message}\n`);
47
+ process.exitCode = 1;
48
+ }
49
+ }
@@ -5,11 +5,160 @@ import { execFileSync } from "node:child_process";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import { createReleaseCandidatePassport, validateReleaseCandidatePassport } from "../packages/core/release-candidate.js";
7
7
  import { scanV4FloatingConsumerPolicy, v4ConsumerPolicyScannerRoot } from "../packages/core/v4-floating-consumer-policy.js";
8
+ import { v4ContentRoot } from "../packages/core/v4-canonical-contracts.js";
9
+ import { V4_STAGE_CAPSULE_CONTRACT, V4_STAGE_CAPSULE_IDENTITY_CONTRACT, v4StageCapsuleIdentityRoot, v4StageCapsuleRoot, validateV4StageCapsule } from "../packages/core/v4-stage-capsule.js";
10
+ import { v4RuntimeResumeDocumentRoot } from "../packages/core/v4-runtime-ref-resume-authority.js";
8
11
  import { writeGitHubOutputs } from "./build-contract-core.mjs";
9
12
 
10
13
  const env = (name, fallback = "") => process.env[name] || fallback;
11
14
  const readJsonFile = (filePath) => JSON.parse(fs.readFileSync(filePath, "utf8"));
12
15
 
16
+ export function createReleaseCandidateStageCapsules({
17
+ passport,
18
+ buildSummary,
19
+ coordinates,
20
+ }) {
21
+ if (!passport.consumerPolicy?.receiptRoot) return undefined;
22
+ if (
23
+ coordinates.repository !== passport.repository ||
24
+ String(coordinates.runId) !== String(passport.workflow.runId) ||
25
+ String(coordinates.runAttempt) !== String(passport.workflow.runAttempt) ||
26
+ coordinates.sourceSha !== passport.source.headSha
27
+ ) {
28
+ throw new Error(
29
+ "Stage Capsule coordinate set does not bind the candidate run",
30
+ );
31
+ }
32
+ const coordinateByPlatform = new Map(
33
+ coordinates.artifacts.map((entry) => [entry.platformId, entry]),
34
+ );
35
+ const qualificationRoot = passport.controllerReceipts?.[0]?.receiptDigest;
36
+ const entries = passport.platformMatrix
37
+ .map((platform) => {
38
+ const coordinate = coordinateByPlatform.get(platform.platformId);
39
+ if (!coordinate || coordinate.name !== platform.artifactName) {
40
+ throw new Error(
41
+ `Stage Capsule coordinate missing for ${platform.platformId}`,
42
+ );
43
+ }
44
+ const manifest = readJsonFile(platform.manifestPath);
45
+ const identity = {
46
+ schema: V4_STAGE_CAPSULE_IDENTITY_CONTRACT,
47
+ sourceRoot: v4ContentRoot("candidate-identity", passport.source),
48
+ platform: platform.platformId,
49
+ platformRoot: v4ContentRoot("candidate-identity", manifest.platform),
50
+ stage: "verify",
51
+ toolchainRoots: [],
52
+ runtimeRoot: v4ContentRoot("candidate-identity", {
53
+ sha: passport.buildchain.sha,
54
+ }),
55
+ policyRoot: passport.consumerPolicy.receiptRoot,
56
+ declaredInputs: [
57
+ {
58
+ name: "release-candidate",
59
+ root: `sha256:${passport.candidateHash}`,
60
+ },
61
+ ],
62
+ transformationRoot: v4ContentRoot("candidate-identity", {
63
+ lifecycle: manifest.lifecycle,
64
+ summary: platform.summary,
65
+ }),
66
+ outputManifestRoot: v4ContentRoot(
67
+ "stage-capsule-artifact-manifest",
68
+ { artifact: coordinate, manifest },
69
+ ),
70
+ qualificationRoot,
71
+ observationRoots: [
72
+ {
73
+ name: "provider-coordinate",
74
+ root: v4ContentRoot("provider-readback-sample", coordinate),
75
+ },
76
+ ],
77
+ };
78
+ const capsule = {
79
+ schema: V4_STAGE_CAPSULE_CONTRACT,
80
+ writerAuthority: "typescript-v3",
81
+ rustAuthority: "validation-only",
82
+ identity,
83
+ identityRoot: v4StageCapsuleIdentityRoot(identity),
84
+ retentionPromise: {
85
+ class: "github-artifact",
86
+ retainUntil: coordinate.expiresAt,
87
+ },
88
+ capsuleRoot: `sha256:${"0".repeat(64)}`,
89
+ };
90
+ capsule.capsuleRoot = v4StageCapsuleRoot(capsule);
91
+ validateV4StageCapsule(capsule);
92
+ return {
93
+ platform: platform.platformId,
94
+ artifactName: coordinate.name,
95
+ artifactDigest: coordinate.digest,
96
+ artifact: coordinate,
97
+ capsule,
98
+ };
99
+ })
100
+ .sort((left, right) => left.platform.localeCompare(right.platform));
101
+ const body = {
102
+ schemaVersion: 1,
103
+ contract: "kungfu-buildchain-v4-release-candidate-stage-capsules/v1",
104
+ status: "sealed",
105
+ repository: passport.repository,
106
+ buildAttempt: {
107
+ id: `github-run:${passport.workflow.runId}:attempt:${passport.workflow.runAttempt}`,
108
+ runtimeSha: passport.buildchain.sha,
109
+ },
110
+ source: {
111
+ sha: passport.source.headSha,
112
+ treeSha: passport.source.treeHash,
113
+ },
114
+ consumerPolicyReceiptRoot: passport.consumerPolicy.receiptRoot,
115
+ capsules: entries,
116
+ };
117
+ return { ...body, root: v4RuntimeResumeDocumentRoot(body) };
118
+ }
119
+
120
+ function writeReleaseCandidateStageCapsules({
121
+ passport,
122
+ buildSummary,
123
+ outputPath,
124
+ }) {
125
+ const coordinatesPath = path.resolve(
126
+ env(
127
+ "BUILDCHAIN_ARTIFACT_COORDINATES_PATH",
128
+ ".buildchain/artifacts/artifact-coordinates.json",
129
+ ),
130
+ );
131
+ if (!fs.existsSync(coordinatesPath)) {
132
+ if (passport.consumerPolicy?.receiptRoot) {
133
+ throw new Error(
134
+ "v4 release candidate Stage Capsules require exact artifact coordinates",
135
+ );
136
+ }
137
+ return { path: "", root: "" };
138
+ }
139
+ const stageCapsules = createReleaseCandidateStageCapsules({
140
+ passport,
141
+ buildSummary,
142
+ coordinates: readJsonFile(coordinatesPath),
143
+ });
144
+ if (!stageCapsules) return { path: "", root: "" };
145
+ const stageCapsulesPath = path.join(
146
+ path.dirname(outputPath),
147
+ "release-candidate-stage-capsules.json",
148
+ );
149
+ fs.writeFileSync(
150
+ stageCapsulesPath,
151
+ `${JSON.stringify(stageCapsules, null, 2)}\n`,
152
+ );
153
+ return {
154
+ path: path
155
+ .relative(process.cwd(), stageCapsulesPath)
156
+ .split(path.sep)
157
+ .join("/"),
158
+ root: stageCapsules.root,
159
+ };
160
+ }
161
+
13
162
  export function resolveLegacyConsumerPolicyReceipt(options = {}) {
14
163
  if (options.json) return { receipt: JSON.parse(options.json), receiptRoot: options.receiptRoot };
15
164
  if (options.repository !== "kungfu-systems/buildchain" || options.targetChannel !== "alpha" || options.workflowShellRef !== "v4-alpha" || options.runtimeOverride !== true) return undefined;
@@ -80,6 +229,7 @@ export function generateReleaseCandidatePassportCli() {
80
229
  if (!validation.ok) throw new Error(`release candidate passport invalid: ${validation.errors.join("; ")}`);
81
230
  fs.mkdirSync(path.dirname(outputPath), { recursive: true });
82
231
  fs.writeFileSync(outputPath, `${JSON.stringify(passport, null, 2)}\n`);
232
+ const stageCapsules = writeReleaseCandidateStageCapsules({ passport, buildSummary, outputPath });
83
233
  writeGitHubOutputs({
84
234
  "release-candidate-passport-path": path.relative(process.cwd(), outputPath).split(path.sep).join("/"),
85
235
  "release-candidate-passport-json": JSON.stringify({
@@ -94,6 +244,8 @@ export function generateReleaseCandidatePassportCli() {
94
244
  consumerPolicy: passport.consumerPolicy,
95
245
  controllerReceipts: passport.controllerReceipts || [],
96
246
  }),
247
+ "release-candidate-stage-capsules-path": stageCapsules.path,
248
+ "release-candidate-stage-capsules-root": stageCapsules.root,
97
249
  });
98
250
  return passport;
99
251
  }
@@ -46,6 +46,31 @@ import {
46
46
  const SITE_BUNDLE_CONTRACT = "kungfu-buildchain-site-bundle";
47
47
  const PUBLICATION_RELEASE_REGISTRY_CONTRACT = "kungfu-buildchain-publication-release-registry";
48
48
  const README_PATH = "README.md";
49
+ const DEV_DELIVERY_AUTHORITY_SCHEMA =
50
+ "schemas/dev-delivery-authority-v2.schema.json";
51
+ const DEV_DELIVERY_AUTHORITY_SCHEMA_SOURCE =
52
+ "contracts/dev-delivery-authority-v2.schema.json";
53
+ const V4_COMPATIBILITY_FACTS_SCHEMA =
54
+ "schemas/v4-compatibility-facts-v1.schema.json";
55
+ const V4_COMPATIBILITY_FACTS_SCHEMA_SOURCE =
56
+ "contracts/v4-compatibility-facts-v1.schema.json";
57
+ const V4_PUBLICATION_REHEARSAL_SCHEMA =
58
+ "schemas/v4-publication-rehearsal-capsule-v1.schema.json";
59
+ const V4_PUBLICATION_REHEARSAL_SCHEMA_SOURCE =
60
+ "contracts/v4-publication-rehearsal-capsule-v1.schema.json";
61
+ const V4_ADOPTER_DELIVERY_SCHEMA =
62
+ "schemas/v4-adopter-delivery-v1.schema.json";
63
+ const V4_ADOPTER_DELIVERY_SCHEMA_SOURCE =
64
+ "contracts/v4-adopter-delivery-v1.schema.json";
65
+ const RELEASE_TAIL_CAPABILITIES_SCHEMA =
66
+ "schemas/release-tail-capabilities-v1.schema.json";
67
+ const RELEASE_TAIL_CAPABILITIES_SCHEMA_SOURCE =
68
+ "contracts/release-tail-capabilities-v1.schema.json";
69
+ const PUBLICATION_REHEARSAL_SITE_SCHEMAS = [
70
+ V4_PUBLICATION_REHEARSAL_SCHEMA,
71
+ V4_ADOPTER_DELIVERY_SCHEMA,
72
+ RELEASE_TAIL_CAPABILITIES_SCHEMA,
73
+ ];
49
74
  const root = path.resolve(import.meta.dirname, "..");
50
75
  const outputDir = path.join(root, "dist", "site");
51
76
  const requireFromHere = createRequire(import.meta.url);
@@ -73,6 +98,21 @@ function stableJson(value) {
73
98
  return `${JSON.stringify(value, null, 2)}\n`;
74
99
  }
75
100
 
101
+ function siteFileBytes(name, value) {
102
+ if (name === DEV_DELIVERY_AUTHORITY_SCHEMA) return readText(DEV_DELIVERY_AUTHORITY_SCHEMA_SOURCE);
103
+ if (name === V4_COMPATIBILITY_FACTS_SCHEMA) return readText(V4_COMPATIBILITY_FACTS_SCHEMA_SOURCE);
104
+ if (name === V4_PUBLICATION_REHEARSAL_SCHEMA) return readText(V4_PUBLICATION_REHEARSAL_SCHEMA_SOURCE);
105
+ if (name === V4_ADOPTER_DELIVERY_SCHEMA) return readText(V4_ADOPTER_DELIVERY_SCHEMA_SOURCE);
106
+ if (name === RELEASE_TAIL_CAPABILITIES_SCHEMA) return readText(RELEASE_TAIL_CAPABILITIES_SCHEMA_SOURCE);
107
+ return stableJson(value);
108
+ }
109
+
110
+ function writeSiteFile(name, value) {
111
+ const filePath = path.join(outputDir, name);
112
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
113
+ fs.writeFileSync(filePath, siteFileBytes(name, value));
114
+ }
115
+
76
116
  function env(name) {
77
117
  return String(process.env[name] || "").trim();
78
118
  }
@@ -367,13 +407,16 @@ const manualMetaById = new Map(Object.entries({
367
407
  "release-activation-transaction": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "preview", order: 125 },
368
408
  "release-candidate": { capabilityGroup: "reusable-build", audience: ["release-operator", "consumer"], maturity: "stable", order: 130 },
369
409
  "release-train": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 132 },
410
+ "next-development-transition": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 133 },
370
411
  "stable-candidate-patrol": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer"], maturity: "preview", order: 135 },
371
412
  "dev-qualification-patrol": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 136 },
372
413
  "dev-alpha-candidate-patrol": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 137 },
373
414
  "v4-canonical-contracts": { capabilityGroup: "governance-versioning", audience: ["developer", "maintainer", "agent"], maturity: "preview", order: 138 },
415
+ "v4-compatibility-facts": { capabilityGroup: "governance-versioning", audience: ["developer", "maintainer", "agent"], maturity: "preview", order: 139 },
374
416
  "observed-evidence-patrol": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 140 },
375
417
  "engineering-housekeeper": { capabilityGroup: "governance-versioning", audience: ["maintainer", "consumer", "agent"], maturity: "preview", order: 145 },
376
418
  "reusable-build-surface": { capabilityGroup: "reusable-build", audience: ["consumer", "release-operator"], maturity: "stable", order: 200 },
419
+ "v4-adopter-delivery": { capabilityGroup: "reusable-build", audience: ["consumer", "developer", "agent"], maturity: "preview", order: 205 },
377
420
  "lifecycle-protocol": { capabilityGroup: "reusable-build", audience: ["consumer", "developer"], maturity: "stable", order: 210 },
378
421
  "runtime-train-validation": { capabilityGroup: "governance-versioning", audience: ["maintainer", "consumer"], maturity: "stable", order: 220 },
379
422
  "kfd-support": { capabilityGroup: "kfd-trust", audience: ["agent", "maintainer"], maturity: "stable", order: 300 },
@@ -737,6 +780,7 @@ function buildSiteBundle() {
737
780
  "docs/reusable-build-surface.md",
738
781
  "docs/release-candidate.md",
739
782
  "docs/release-train.md",
783
+ "docs/next-development-transition.md",
740
784
  "docs/stable-candidate-patrol.md",
741
785
  "docs/dev-qualification-patrol.md",
742
786
  "docs/dev-alpha-candidate-patrol.md",
@@ -931,6 +975,9 @@ function buildSiteBundle() {
931
975
  "schemas/release-passport-v1.schema.json",
932
976
  "schemas/kfd-agent-hub-adoption.schema.json",
933
977
  "schemas/kfd-product-gate-input-v1.schema.json",
978
+ "schemas/dev-delivery-authority-v2.schema.json",
979
+ "schemas/v4-compatibility-facts-v1.schema.json",
980
+ ...PUBLICATION_REHEARSAL_SITE_SCHEMAS,
934
981
  "kfd-support.json",
935
982
  "artifact-evidence.json",
936
983
  "product-mechanism.json",
@@ -965,6 +1012,9 @@ function buildSiteBundle() {
965
1012
  "schemas/release-passport-v1.schema.json",
966
1013
  "schemas/kfd-agent-hub-adoption.schema.json",
967
1014
  "schemas/kfd-product-gate-input-v1.schema.json",
1015
+ "schemas/dev-delivery-authority-v2.schema.json",
1016
+ "schemas/v4-compatibility-facts-v1.schema.json",
1017
+ ...PUBLICATION_REHEARSAL_SITE_SCHEMAS,
968
1018
  "buildchain-contract.json",
969
1019
  "kfd-claims.json",
970
1020
  "product-mechanism.json",
@@ -1095,6 +1145,9 @@ function buildSiteBundle() {
1095
1145
  "schemas/release-passport-v1.schema.json",
1096
1146
  "schemas/kfd-agent-hub-adoption.schema.json",
1097
1147
  "schemas/kfd-product-gate-input-v1.schema.json",
1148
+ "schemas/dev-delivery-authority-v2.schema.json",
1149
+ "schemas/v4-compatibility-facts-v1.schema.json",
1150
+ ...PUBLICATION_REHEARSAL_SITE_SCHEMAS,
1098
1151
  "buildchain-contract.json",
1099
1152
  "kfd-upstream-aggregate.json",
1100
1153
  "kfd-claims.json",
@@ -1269,6 +1322,18 @@ function buildSiteBundle() {
1269
1322
  "schemas/release-passport-v1.schema.json": RELEASE_PASSPORT_SCHEMA,
1270
1323
  "schemas/kfd-agent-hub-adoption.schema.json": KFD_AGENT_HUB_ADOPTION_SCHEMA,
1271
1324
  "schemas/kfd-product-gate-input-v1.schema.json": KFD_PRODUCT_GATE_INPUT_SCHEMA,
1325
+ [DEV_DELIVERY_AUTHORITY_SCHEMA]: readJson(
1326
+ DEV_DELIVERY_AUTHORITY_SCHEMA_SOURCE,
1327
+ ),
1328
+ [V4_COMPATIBILITY_FACTS_SCHEMA]: readJson(
1329
+ V4_COMPATIBILITY_FACTS_SCHEMA_SOURCE,
1330
+ ),
1331
+ ...Object.fromEntries(
1332
+ PUBLICATION_REHEARSAL_SITE_SCHEMAS.map((name) => [
1333
+ name,
1334
+ JSON.parse(siteFileBytes(name)),
1335
+ ]),
1336
+ ),
1272
1337
  "badge-endpoint-registry.json": badgeEndpointRegistry,
1273
1338
  "publication-registry.json": publicationRegistry,
1274
1339
  "buildchain-contract.json": createBuildchainContractWorld({ root, controllerRegistry }),
@@ -1288,7 +1353,7 @@ export function writeSiteBundle({ check = false } = {}) {
1288
1353
  const mismatches = [];
1289
1354
  for (const [name, value] of Object.entries(files)) {
1290
1355
  const filePath = path.join(outputDir, name);
1291
- const next = stableJson(value);
1356
+ const next = siteFileBytes(name, value);
1292
1357
  if (check) {
1293
1358
  if (existingJson(filePath) !== next) {
1294
1359
  mismatches.push(path.relative(root, filePath));
@@ -1301,11 +1366,11 @@ export function writeSiteBundle({ check = false } = {}) {
1301
1366
  if (!check) {
1302
1367
  for (let iteration = 0; iteration < 5; iteration += 1) {
1303
1368
  for (const [name, value] of Object.entries(files)) {
1304
- writeJson(path.join(outputDir, name), value);
1369
+ writeSiteFile(name, value);
1305
1370
  }
1306
1371
  const nextFiles = buildSiteBundle();
1307
1372
  const stable = Object.entries(nextFiles).every(([name, value]) => (
1308
- existingJson(path.join(outputDir, name)) === stableJson(value)
1373
+ existingJson(path.join(outputDir, name)) === siteFileBytes(name, value)
1309
1374
  ));
1310
1375
  files = nextFiles;
1311
1376
  if (stable) {
@@ -1316,7 +1381,7 @@ export function writeSiteBundle({ check = false } = {}) {
1316
1381
  }
1317
1382
  }
1318
1383
  for (const [name, value] of Object.entries(files)) {
1319
- writeJson(path.join(outputDir, name), value);
1384
+ writeSiteFile(name, value);
1320
1385
  }
1321
1386
  }
1322
1387
  return {
@@ -4,6 +4,11 @@ import path from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { BUILDCHAIN_CONFIG_PATH } from "../packages/core/buildchain-layout.js";
6
6
  import { detectPackageManager, assertPackageManager } from "../packages/core/package-manager.js";
7
+ import {
8
+ appendNextDevelopmentToml,
9
+ mergeNextDevelopmentAgentInstructions,
10
+ nextDevelopmentWorkflowHeader,
11
+ } from "../packages/core/next-development-projection.js";
7
12
 
8
13
  const BUILDCHAIN_WORKFLOW_REF = "kungfu-systems/buildchain/.github/workflows/.build.yml@v4";
9
14
  const DEFAULT_PUBLICATION_LATEX_IMAGE = "ghcr.io/kungfu-systems/build-images/latex-pdf-builder";
@@ -327,7 +332,7 @@ function workflowArtifactPaths(type) {
327
332
  }
328
333
 
329
334
  function publicationWorkflowYaml() {
330
- return `# Commit both .buildchain/contract-lock.json and .buildchain/alpha-contract-lock.json.
335
+ return `${nextDevelopmentWorkflowHeader()}# Commit both .buildchain/contract-lock.json and .buildchain/alpha-contract-lock.json.
331
336
  # Persist only @v4 or @v4-alpha; pass temporary train/SHA runtimes through workflow_dispatch.
332
337
  name: Build
333
338
 
@@ -361,7 +366,7 @@ jobs:
361
366
  }
362
367
 
363
368
  function workflowYaml({ type, runnerPreset, artifactName }) {
364
- return `# Buildchain v4 lifecycle checkpoints are governed by architecture/v4-platform-stage-checkpoints.json.
369
+ return `${nextDevelopmentWorkflowHeader()}# Buildchain v4 lifecycle checkpoints are governed by architecture/v4-platform-stage-checkpoints.json.
365
370
  # Do not add undeclared runner-only inputs, outputs, environment, or provider effects.
366
371
  # Commit both .buildchain/contract-lock.json and .buildchain/alpha-contract-lock.json.
367
372
  # Persist only @v4 or @v4-alpha; pass temporary train/SHA runtimes through workflow_dispatch.
@@ -407,6 +412,13 @@ function writeIfAllowed(filePath, content, { force }) {
407
412
  return filePath;
408
413
  }
409
414
 
415
+ function writeManagedAgentEntry(filePath, current) {
416
+ const content = mergeNextDevelopmentAgentInstructions(current);
417
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
418
+ fs.writeFileSync(filePath, content);
419
+ return filePath;
420
+ }
421
+
410
422
  export function initBuildchainRepo({
411
423
  cwd = process.cwd(),
412
424
  type = "package",
@@ -417,7 +429,7 @@ export function initBuildchainRepo({
417
429
  } = {}) {
418
430
  const resolvedCwd = path.resolve(cwd);
419
431
  const manager = detectOrDefaultPackageManager(resolvedCwd, packageManager);
420
- const toml = (() => {
432
+ const toml = appendNextDevelopmentToml((() => {
421
433
  if (type === "package") {
422
434
  return packageToml(resolvedCwd, manager);
423
435
  }
@@ -437,7 +449,12 @@ export function initBuildchainRepo({
437
449
  return anchoredPackageToml(resolvedCwd, manager);
438
450
  }
439
451
  throw new Error("init --type must be one of package, native, web-surface, infra-contract, publication-artifact, or anchored-package");
440
- })();
452
+ })());
453
+
454
+ const agentsPath = path.join(resolvedCwd, "AGENTS.md");
455
+ const currentAgents = fs.existsSync(agentsPath)
456
+ ? fs.readFileSync(agentsPath, "utf8")
457
+ : "";
441
458
 
442
459
  const written = [
443
460
  writeIfAllowed(path.join(resolvedCwd, BUILDCHAIN_CONFIG_PATH), toml, { force }),
@@ -452,6 +469,7 @@ export function initBuildchainRepo({
452
469
  }),
453
470
  { force },
454
471
  ),
472
+ writeManagedAgentEntry(agentsPath, currentAgents),
455
473
  ];
456
474
 
457
475
  if (type === "anchored-package" && !fs.existsSync(path.join(resolvedCwd, "release.json"))) {