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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/actions/promote-buildchain-ref/README.md +4 -0
  2. package/bin/buildchain.mjs +9 -1
  3. package/bin/internal/trust-release-release-handlers.mjs +1 -0
  4. package/contracts/dev-delivery-authority-v2.schema.json +253 -0
  5. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +47 -0
  6. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +47 -0
  7. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +40 -0
  8. package/contracts/next-development-request-v1.schema.json +66 -0
  9. package/contracts/next-development-transition-v1.schema.json +292 -0
  10. package/dist/site/agent-index.json +1 -0
  11. package/dist/site/artifact-schemas.json +2 -0
  12. package/dist/site/buildchain-contract.json +92 -27
  13. package/dist/site/buildchain-site.json +351 -38
  14. package/dist/site/capability-registry.json +7 -6
  15. package/dist/site/cli-registry.json +43 -3
  16. package/dist/site/controller-registry.json +6 -2
  17. package/dist/site/kfd-claims.json +223 -12
  18. package/dist/site/kfd-upstream-aggregate.json +9 -9
  19. package/dist/site/manual-registry.json +23 -7
  20. package/dist/site/node-api-registry.json +7926 -4533
  21. package/dist/site/page-registry.json +332 -27
  22. package/dist/site/public-surface-audit.json +359 -11
  23. package/dist/site/publication-registry.json +4 -4
  24. package/dist/site/release-passport-check-manifest.json +1 -0
  25. package/dist/site/release-provenance.json +14 -0
  26. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +442 -0
  27. package/dist/site/schemas/release-passport-v1.schema.json +3 -0
  28. package/dist/site/site-manifest.json +19 -11
  29. package/dist/site/workflow-registry.json +21 -10
  30. package/docs/MAP.md +5 -2
  31. package/docs/adopter-delivery-gate.md +106 -0
  32. package/docs/aws-us-elastic-runner-burst-plane.md +30 -3
  33. package/docs/cli-reference.md +202 -15
  34. package/docs/dev-alpha-candidate-patrol.md +8 -0
  35. package/docs/dev-delivery-qualification-landing-adr.md +137 -0
  36. package/docs/dev-delivery-warrant.md +149 -22
  37. package/docs/kfd-support.md +7 -2
  38. package/docs/next-development-transition.md +119 -0
  39. package/docs/node-api-reference.md +402 -204
  40. package/docs/release-governance.md +10 -7
  41. package/docs/release-passport.md +18 -2
  42. package/docs/versioning.md +4 -1
  43. package/package.json +23 -6
  44. package/packages/core/README.md +25 -0
  45. package/packages/core/adopter-delivery-gate.js +576 -0
  46. package/packages/core/adopter-delivery-json.js +66 -0
  47. package/packages/core/adopter-delivery-passport.js +259 -0
  48. package/packages/core/adopter-delivery-vectors.js +158 -0
  49. package/packages/core/adopter-delivery-vectors.json +77 -0
  50. package/packages/core/artifact-verification-envelope.js +5 -5
  51. package/packages/core/buildchain-agent-manuals.js +1 -0
  52. package/packages/core/buildchain-channel-identity.js +2 -3
  53. package/packages/core/buildchain-compatibility-proof.js +22 -0
  54. package/packages/core/buildchain-delivery-bootstrap.js +240 -0
  55. package/packages/core/buildchain-delivery-infrastructure.js +164 -0
  56. package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
  57. package/packages/core/channel-candidate.js +8 -0
  58. package/packages/core/channel-promotion-baseline.js +52 -0
  59. package/packages/core/dev-alpha-candidate-selection.js +10 -2
  60. package/packages/core/dev-delivery-authority.js +996 -0
  61. package/packages/core/dev-delivery-native-proof.js +418 -0
  62. package/packages/core/dev-delivery-warrant-settlement.js +67 -20
  63. package/packages/core/dev-delivery-warrant.js +129 -46
  64. package/packages/core/kfd-adopter-category-driver.js +167 -0
  65. package/packages/core/kfd-adopter-manifest.js +49 -50
  66. package/packages/core/legacy-kfd-adopter-driver.js +167 -0
  67. package/packages/core/next-development-candidate-reservation.js +186 -0
  68. package/packages/core/next-development-controller.js +726 -0
  69. package/packages/core/next-development-projection.js +288 -0
  70. package/packages/core/next-development-transition.js +738 -0
  71. package/packages/core/paper-agent-entry.js +7 -4
  72. package/packages/core/paper.js +14 -7
  73. package/packages/core/published-delivery-authority.js +247 -0
  74. package/packages/core/release-passport-contract.js +10 -6
  75. package/packages/core/release-passport.js +37 -13
  76. package/scripts/aws-macos-jit-controller-core.mjs +239 -4
  77. package/scripts/aws-macos-jit-controller.mjs +198 -2
  78. package/scripts/aws-macos-jit-instance-rehydrate.mjs +260 -0
  79. package/scripts/aws-macos-jit-source-rebind.mjs +235 -14
  80. package/scripts/aws-macos-jit.mjs +12 -0
  81. package/scripts/buildchain-cli-help.mjs +10 -2
  82. package/scripts/check-internal-architecture.mjs +1 -0
  83. package/scripts/check-inventory.mjs +12 -1
  84. package/scripts/dev-alpha-candidate-patrol.mjs +22 -1
  85. package/scripts/dev-delivery-authority.mjs +368 -0
  86. package/scripts/dev-delivery-native-run.mjs +235 -0
  87. package/scripts/dev-delivery-proof.mjs +64 -2
  88. package/scripts/dev-delivery-two-phase-resume.mjs +90 -0
  89. package/scripts/dev-delivery-two-phase.mjs +577 -0
  90. package/scripts/dev-delivery-warrant.mjs +48 -6
  91. package/scripts/dev-pr-delivery-warrant.mjs +19 -14
  92. package/scripts/generate-buildchain-kfd-witnesses.mjs +2 -2
  93. package/scripts/generate-channel-build-workflow.mjs +4 -0
  94. package/scripts/generate-next-development-guidance.mjs +49 -0
  95. package/scripts/generate-site-bundle.mjs +8 -3
  96. package/scripts/init-repo.mjs +135 -62
  97. package/scripts/next-development-self-dogfood-harness.mjs +409 -0
  98. package/scripts/next-development-self-dogfood.mjs +532 -0
  99. package/scripts/next-development-transition.mjs +47 -0
  100. package/scripts/release-candidate-tail-reseal.mjs +426 -0
  101. package/scripts/seal-artifact-signing-requests.mjs +7 -4
  102. package/scripts/site-capability-metadata.mjs +25 -1
  103. package/scripts/stable-candidate-qualification.mjs +7 -7
  104. package/scripts/workflow-call-contract.mjs +1 -1
  105. package/templates/native-dev-delivery.yml +86 -0
@@ -0,0 +1,426 @@
1
+ #!/usr/bin/env node
2
+ import crypto from "node:crypto";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+
7
+ const CONTRACT = "kungfu-buildchain-release-candidate-tail-reseal/v1";
8
+ const SHA = /^[0-9a-f]{40}$/u;
9
+ const ROOT = /^sha256:[0-9a-f]{64}$/u;
10
+ const REQUIRED_PLATFORMS = ["linux-arm64", "linux-x64", "macos-arm64", "windows-x64"];
11
+ const REQUIRED_SUCCESS_JOBS = [
12
+ "build / Linux ARM64",
13
+ "build / Linux x64",
14
+ "build / macOS ARM64",
15
+ "build / Windows x64",
16
+ "build / Control detached signing Linux ARM64",
17
+ "build / Control detached signing Linux x64",
18
+ "build / Control detached signing macOS ARM64",
19
+ "build / Control detached signing Windows x64",
20
+ "build / Finalize signed artifact Linux ARM64",
21
+ "build / Finalize signed artifact Linux x64",
22
+ "build / Finalize signed artifact Windows x64",
23
+ ];
24
+
25
+ function required(value, label) {
26
+ const result = String(value ?? "").trim();
27
+ if (!result) throw new Error(`${label} is required`);
28
+ return result;
29
+ }
30
+
31
+ function exactSha(value, label) {
32
+ const result = required(value, label);
33
+ if (!SHA.test(result)) throw new Error(`${label} must be an exact lowercase Git SHA`);
34
+ return result;
35
+ }
36
+
37
+ function contentRoot(value, label) {
38
+ const result = required(value, label);
39
+ if (!ROOT.test(result)) throw new Error(`${label} must be a sha256 content root`);
40
+ return result;
41
+ }
42
+
43
+ function integer(value, label) {
44
+ const result = Number(value);
45
+ if (!Number.isSafeInteger(result) || result <= 0) throw new Error(`${label} must be a positive integer`);
46
+ return result;
47
+ }
48
+
49
+ function object(value, label) {
50
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object`);
51
+ return value;
52
+ }
53
+
54
+ function readJson(file, label = file) {
55
+ try {
56
+ return JSON.parse(fs.readFileSync(file, "utf8"));
57
+ } catch (error) {
58
+ throw new Error(`could not read ${label}: ${error.message}`);
59
+ }
60
+ }
61
+
62
+ function writeJson(file, value) {
63
+ fs.mkdirSync(path.dirname(file), { recursive: true });
64
+ fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
65
+ }
66
+
67
+ function sha256Json(value) {
68
+ return `sha256:${crypto.createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
69
+ }
70
+
71
+ function sha256File(file) {
72
+ const hash = crypto.createHash("sha256");
73
+ const descriptor = fs.openSync(file, "r");
74
+ const buffer = Buffer.allocUnsafe(1024 * 1024);
75
+ try {
76
+ for (;;) {
77
+ const count = fs.readSync(descriptor, buffer, 0, buffer.length, null);
78
+ if (count === 0) break;
79
+ hash.update(buffer.subarray(0, count));
80
+ }
81
+ } finally {
82
+ fs.closeSync(descriptor);
83
+ }
84
+ return `sha256:${hash.digest("hex")}`;
85
+ }
86
+
87
+ function appendOutputs(values) {
88
+ const output = process.env.GITHUB_OUTPUT;
89
+ if (!output) return;
90
+ const lines = [];
91
+ for (const [name, value] of Object.entries(values)) {
92
+ const text = String(value ?? "");
93
+ if (text.includes("\n")) {
94
+ const marker = `BUILDCHAIN_${crypto.randomBytes(8).toString("hex")}`;
95
+ lines.push(`${name}<<${marker}\n${text}\n${marker}`);
96
+ } else {
97
+ lines.push(`${name}=${text}`);
98
+ }
99
+ }
100
+ fs.appendFileSync(output, `${lines.join("\n")}\n`);
101
+ }
102
+
103
+ async function githubJson(repository, apiPath, token) {
104
+ const response = await fetch(`https://api.github.com/repos/${repository}${apiPath}`, {
105
+ headers: {
106
+ accept: "application/vnd.github+json",
107
+ authorization: `Bearer ${required(token, "GITHUB_TOKEN")}`,
108
+ "x-github-api-version": "2022-11-28",
109
+ },
110
+ });
111
+ if (!response.ok) throw new Error(`GitHub API ${apiPath} failed: HTTP ${response.status}`);
112
+ return response.json();
113
+ }
114
+
115
+ async function pagedGithubItems(repository, apiPath, key, token) {
116
+ const values = [];
117
+ for (let page = 1; ; page += 1) {
118
+ const separator = apiPath.includes("?") ? "&" : "?";
119
+ const response = await githubJson(repository, `${apiPath}${separator}per_page=100&page=${page}`, token);
120
+ const items = Array.isArray(response?.[key]) ? response[key] : [];
121
+ values.push(...items);
122
+ if (items.length < 100) return values;
123
+ }
124
+ }
125
+
126
+ export function normalizeTailResealRequest(raw) {
127
+ const request = object(raw, "tail reseal request");
128
+ if (request.contract !== CONTRACT) throw new Error(`tail reseal contract must be ${CONTRACT}`);
129
+ const source = object(request.source, "source");
130
+ const target = object(request.target, "target");
131
+ const candidateRuntime = object(request.candidateRuntime, "candidateRuntime");
132
+ const controller = object(request.consumerController, "consumerController");
133
+ const failure = object(request.failure, "failure");
134
+ const authority = object(request.authority, "authority");
135
+ const platforms = Array.isArray(request.platforms) ? request.platforms : [];
136
+ if (platforms.length !== REQUIRED_PLATFORMS.length) throw new Error("tail reseal requires exactly four platform bindings");
137
+ const normalizedPlatforms = platforms.map((entry, index) => {
138
+ const platform = object(entry, `platforms[${index}]`);
139
+ return {
140
+ id: required(platform.id, `platforms[${index}].id`),
141
+ name: required(platform.name, `platforms[${index}].name`),
142
+ runner: required(platform.runner, `platforms[${index}].runner`),
143
+ artifactName: required(platform.artifactName, `platforms[${index}].artifactName`),
144
+ artifactDigest: contentRoot(platform.artifactDigest, `platforms[${index}].artifactDigest`),
145
+ manifestArtifactName: required(platform.manifestArtifactName, `platforms[${index}].manifestArtifactName`),
146
+ manifestArtifactDigest: contentRoot(platform.manifestArtifactDigest, `platforms[${index}].manifestArtifactDigest`),
147
+ artifactPaths: required(platform.artifactPaths, `platforms[${index}].artifactPaths`),
148
+ };
149
+ }).sort((left, right) => left.id.localeCompare(right.id));
150
+ if (JSON.stringify(normalizedPlatforms.map(({ id }) => id)) !== JSON.stringify([...REQUIRED_PLATFORMS].sort())) {
151
+ throw new Error(`tail reseal platforms must be ${REQUIRED_PLATFORMS.join(", ")}`);
152
+ }
153
+ if (new Set(normalizedPlatforms.flatMap((entry) => [entry.artifactName, entry.manifestArtifactName])).size !== 8) {
154
+ throw new Error("tail reseal artifact names must be unique");
155
+ }
156
+ return {
157
+ contract: CONTRACT,
158
+ repository: required(request.repository, "repository"),
159
+ source: {
160
+ runId: integer(source.runId, "source.runId"),
161
+ runAttempt: integer(source.runAttempt, "source.runAttempt"),
162
+ sha: exactSha(source.sha, "source.sha"),
163
+ tree: exactSha(source.tree, "source.tree"),
164
+ workflowFile: required(source.workflowFile, "source.workflowFile").replace(/^\.github\/workflows\//u, ""),
165
+ workflowName: required(source.workflowName, "source.workflowName"),
166
+ },
167
+ target: {
168
+ channel: required(target.channel, "target.channel"),
169
+ ref: required(target.ref, "target.ref").replace(/^refs\/heads\//u, ""),
170
+ baseSha: exactSha(target.baseSha, "target.baseSha"),
171
+ version: required(target.version, "target.version"),
172
+ },
173
+ candidateRuntime: {
174
+ repository: required(candidateRuntime.repository, "candidateRuntime.repository"),
175
+ ref: required(candidateRuntime.ref, "candidateRuntime.ref"),
176
+ sha: exactSha(candidateRuntime.sha, "candidateRuntime.sha"),
177
+ contractDigest: contentRoot(candidateRuntime.contractDigest, "candidateRuntime.contractDigest"),
178
+ },
179
+ consumerController: {
180
+ repository: required(controller.repository, "consumerController.repository"),
181
+ sha: exactSha(controller.sha, "consumerController.sha"),
182
+ tree: exactSha(controller.tree, "consumerController.tree"),
183
+ },
184
+ failure: {
185
+ jobId: integer(failure.jobId, "failure.jobId"),
186
+ jobName: required(failure.jobName, "failure.jobName"),
187
+ stepName: required(failure.stepName, "failure.stepName"),
188
+ },
189
+ authority: {
190
+ repository: required(authority.repository, "authority.repository"),
191
+ runId: integer(authority.runId, "authority.runId"),
192
+ runtimeSha: exactSha(authority.runtimeSha, "authority.runtimeSha"),
193
+ resultArtifact: required(authority.resultArtifact, "authority.resultArtifact"),
194
+ resultArtifactDigest: contentRoot(authority.resultArtifactDigest, "authority.resultArtifactDigest"),
195
+ },
196
+ controllerPlanArtifact: required(request.controllerPlanArtifact, "controllerPlanArtifact"),
197
+ platforms: normalizedPlatforms,
198
+ };
199
+ }
200
+
201
+ function exactArtifact(artifacts, name, digest, label) {
202
+ const matches = artifacts.filter((artifact) => artifact.name === name);
203
+ if (matches.length !== 1) throw new Error(`${label} must resolve to exactly one retained artifact`);
204
+ const artifact = matches[0];
205
+ if (artifact.expired === true) throw new Error(`${label} is expired`);
206
+ if (artifact.digest !== digest) throw new Error(`${label} digest mismatch`);
207
+ return artifact;
208
+ }
209
+
210
+ function validateTailResealEvent({ request, event, repository }) {
211
+ const allowedActions = new Set(["opened", "synchronize", "reopened", "ready_for_review"]);
212
+ if (request.repository !== repository) throw new Error("tail reseal repository differs from the caller repository");
213
+ if (!allowedActions.has(event.action)) {
214
+ throw new Error(`tail reseal requires a pull_request source event, got ${event.action || "<none>"}`);
215
+ }
216
+ if (event.pull_request?.head?.repo?.full_name !== repository) throw new Error("tail reseal rejects fork pull requests");
217
+ if (event.pull_request?.head?.sha !== request.source.sha) throw new Error("tail reseal source SHA differs from the exact PR head");
218
+ if (event.pull_request?.base?.ref !== request.target.ref || event.pull_request?.base?.sha !== request.target.baseSha) {
219
+ throw new Error("tail reseal target ref or frozen base SHA differs from the exact PR event");
220
+ }
221
+ if (request.target.channel !== "alpha" || !/^alpha\/v\d+\/v\d+\.\d+$/u.test(request.target.ref)) {
222
+ throw new Error("tail reseal is limited to an exact Alpha channel");
223
+ }
224
+ if (request.candidateRuntime.repository !== "kungfu-systems/buildchain" || request.candidateRuntime.ref !== "v3-alpha") {
225
+ throw new Error("tail reseal requires the deployed floating v3-alpha candidate contract");
226
+ }
227
+ if (request.consumerController.repository !== repository) throw new Error("tail reseal consumer controller must remain in the caller repository");
228
+ }
229
+
230
+ function validateTailResealRun({ request, run }) {
231
+ const workflowFile = String(run.path || "").split("@")[0].replace(/^\.github\/workflows\//u, "");
232
+ const exactRun =
233
+ Number(run.id) === request.source.runId &&
234
+ Number(run.run_attempt) === request.source.runAttempt &&
235
+ run.event === "workflow_dispatch" &&
236
+ run.status === "completed" &&
237
+ run.conclusion === "failure" &&
238
+ run.head_sha === request.source.sha &&
239
+ workflowFile === request.source.workflowFile &&
240
+ run.name === request.source.workflowName;
241
+ if (!exactRun) throw new Error("tail reseal source run is not the exact retained failed Build run");
242
+ }
243
+
244
+ function validateTailResealJobs({ request, jobs }) {
245
+ const byName = new Map(jobs.map((job) => [job.name, job]));
246
+ for (const name of REQUIRED_SUCCESS_JOBS) {
247
+ if (byName.get(name)?.conclusion !== "success") throw new Error(`tail reseal required source job did not succeed: ${name}`);
248
+ }
249
+ const failedJob = jobs.find((job) => Number(job.id) === request.failure.jobId);
250
+ const failedSteps = (failedJob?.steps || []).filter((step) => step.conclusion === "failure").map((step) => step.name);
251
+ const exactFailure =
252
+ failedJob?.name === request.failure.jobName &&
253
+ failedJob?.conclusion === "failure" &&
254
+ JSON.stringify(failedSteps) === JSON.stringify([request.failure.stepName]);
255
+ if (!exactFailure) throw new Error("tail reseal failure boundary differs from the single allowed macOS finalization step");
256
+ if (request.failure.jobName !== "build / Finalize signed artifact macOS ARM64" || request.failure.stepName !== "Recompute manifest over final signed bytes") {
257
+ throw new Error("tail reseal only accepts the known macOS finalization blocker");
258
+ }
259
+ }
260
+
261
+ function validateTailResealArtifacts({ request, artifacts, authorityRun, authorityArtifacts }) {
262
+ for (const platform of request.platforms) {
263
+ exactArtifact(artifacts, platform.artifactName, platform.artifactDigest, `${platform.id} payload`);
264
+ exactArtifact(artifacts, platform.manifestArtifactName, platform.manifestArtifactDigest, `${platform.id} manifest`);
265
+ }
266
+ const controllerPlan = artifacts.filter((artifact) => artifact.name === request.controllerPlanArtifact);
267
+ if (controllerPlan.length !== 1 || controllerPlan[0].expired === true) throw new Error("tail reseal controller plan artifact is unavailable");
268
+ if (authorityRun.status !== "completed" || authorityRun.conclusion !== "success") throw new Error("tail reseal signing authority run is not successful");
269
+ exactArtifact(authorityArtifacts, request.authority.resultArtifact, request.authority.resultArtifactDigest, "macOS signing authority result");
270
+ }
271
+
272
+ function writeTailResealPlan(request) {
273
+ const output = path.resolve(process.env.BUILDCHAIN_TAIL_RESEAL_REQUEST_PATH || ".buildchain/tail-reseal/request.json");
274
+ writeJson(output, request);
275
+ appendOutputs({
276
+ enabled: "true",
277
+ "request-path": path.relative(process.cwd(), output),
278
+ "request-root": sha256Json(request),
279
+ "platforms-json": JSON.stringify(request.platforms),
280
+ "source-run-id": request.source.runId,
281
+ "source-run-attempt": request.source.runAttempt,
282
+ "source-sha": request.source.sha,
283
+ "source-tree": request.source.tree,
284
+ "target-channel": request.target.channel,
285
+ "target-ref": request.target.ref,
286
+ "target-version": request.target.version,
287
+ "candidate-runtime-ref": request.candidateRuntime.ref,
288
+ "candidate-runtime-sha": request.candidateRuntime.sha,
289
+ "candidate-runtime-contract-digest": request.candidateRuntime.contractDigest,
290
+ "consumer-controller-sha": request.consumerController.sha,
291
+ "authority-run-id": request.authority.runId,
292
+ "authority-result-artifact": request.authority.resultArtifact,
293
+ "controller-plan-artifact": request.controllerPlanArtifact,
294
+ });
295
+ }
296
+
297
+ async function plan() {
298
+ const token = required(process.env.GITHUB_TOKEN, "GITHUB_TOKEN");
299
+ const raw = required(process.env.BUILDCHAIN_TAIL_RESEAL_REQUEST_JSON, "BUILDCHAIN_TAIL_RESEAL_REQUEST_JSON");
300
+ const request = normalizeTailResealRequest(JSON.parse(raw));
301
+ const event = readJson(required(process.env.GITHUB_EVENT_PATH, "GITHUB_EVENT_PATH"), "GitHub event");
302
+ const repository = required(process.env.GITHUB_REPOSITORY, "GITHUB_REPOSITORY");
303
+ validateTailResealEvent({ request, event, repository });
304
+
305
+ const [sourceCommit, controllerCommit, run, jobs, artifacts, authorityRun, authorityArtifacts] = await Promise.all([
306
+ githubJson(repository, `/git/commits/${request.source.sha}`, token),
307
+ githubJson(repository, `/git/commits/${request.consumerController.sha}`, token),
308
+ githubJson(repository, `/actions/runs/${request.source.runId}`, token),
309
+ pagedGithubItems(repository, `/actions/runs/${request.source.runId}/jobs?filter=latest`, "jobs", token),
310
+ pagedGithubItems(repository, `/actions/runs/${request.source.runId}/artifacts`, "artifacts", token),
311
+ githubJson(request.authority.repository, `/actions/runs/${request.authority.runId}`, token),
312
+ pagedGithubItems(request.authority.repository, `/actions/runs/${request.authority.runId}/artifacts`, "artifacts", token),
313
+ ]);
314
+ if (sourceCommit.tree?.sha !== request.source.tree) throw new Error("tail reseal source tree mismatch");
315
+ if (controllerCommit.tree?.sha !== request.consumerController.tree) throw new Error("tail reseal consumer controller tree mismatch");
316
+ validateTailResealRun({ request, run });
317
+ validateTailResealJobs({ request, jobs });
318
+ validateTailResealArtifacts({ request, artifacts, authorityRun, authorityArtifacts });
319
+ writeTailResealPlan(request);
320
+ return request;
321
+ }
322
+
323
+ function locateManifest(root, platformId) {
324
+ const matches = [];
325
+ const visit = (directory) => {
326
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
327
+ const absolute = path.join(directory, entry.name);
328
+ if (entry.isDirectory()) visit(absolute);
329
+ else if (entry.name === "manifest.json") {
330
+ const value = readJson(absolute);
331
+ if (value?.contract === "kungfu-buildchain-artifact" && value?.platform?.id === platformId) matches.push({ absolute, value });
332
+ }
333
+ }
334
+ };
335
+ visit(root);
336
+ if (matches.length !== 1) throw new Error(`expected exactly one ${platformId} platform manifest under ${root}, found ${matches.length}`);
337
+ return matches[0];
338
+ }
339
+
340
+ export function verifyTailResealPlatform() {
341
+ const request = normalizeTailResealRequest(readJson(required(process.env.BUILDCHAIN_TAIL_RESEAL_REQUEST_PATH, "BUILDCHAIN_TAIL_RESEAL_REQUEST_PATH")));
342
+ const platformId = required(process.env.BUILDCHAIN_TAIL_RESEAL_PLATFORM_ID, "BUILDCHAIN_TAIL_RESEAL_PLATFORM_ID");
343
+ const platform = request.platforms.find((entry) => entry.id === platformId);
344
+ if (!platform) throw new Error(`tail reseal request does not bind platform ${platformId}`);
345
+ const root = path.resolve(process.env.BUILDCHAIN_TAIL_RESEAL_ARTIFACT_ROOT || ".");
346
+ const { absolute, value: manifest } = locateManifest(root, platformId);
347
+ if (manifest.artifactName !== platform.artifactName) throw new Error(`${platformId} manifest artifact name mismatch`);
348
+ if (manifest.git?.repository !== request.repository || manifest.git?.sha !== request.source.sha) throw new Error(`${platformId} manifest source mismatch`);
349
+ if (String(manifest.git?.runId || "") !== String(request.source.runId) || String(manifest.git?.runAttempt || "") !== String(request.source.runAttempt)) {
350
+ throw new Error(`${platformId} manifest original run mismatch`);
351
+ }
352
+ const files = Array.isArray(manifest.files) ? manifest.files : [];
353
+ if (files.length === 0) throw new Error(`${platformId} manifest has no files`);
354
+ for (const file of files) {
355
+ const relative = required(file.path || file.name, `${platformId} manifest file path`);
356
+ const absoluteFile = path.resolve(root, relative);
357
+ if (!absoluteFile.startsWith(`${root}${path.sep}`) || !fs.existsSync(absoluteFile) || !fs.statSync(absoluteFile).isFile()) {
358
+ throw new Error(`${platformId} manifest file is missing: ${relative}`);
359
+ }
360
+ if (Number(file.size ?? file.bytes) !== fs.statSync(absoluteFile).size) throw new Error(`${platformId} manifest file size mismatch: ${relative}`);
361
+ const expected = contentRoot(`sha256:${String(file.sha256 || "").replace(/^sha256:/u, "")}`, `${platformId} ${relative} digest`);
362
+ if (sha256File(absoluteFile) !== expected) throw new Error(`${platformId} manifest file digest mismatch: ${relative}`);
363
+ }
364
+ appendOutputs({ "manifest-path": path.relative(process.cwd(), absolute), "manifest-root": sha256File(absolute) });
365
+ return manifest;
366
+ }
367
+
368
+ export function sealTailResealReceipt() {
369
+ const request = normalizeTailResealRequest(readJson(required(process.env.BUILDCHAIN_TAIL_RESEAL_REQUEST_PATH, "BUILDCHAIN_TAIL_RESEAL_REQUEST_PATH")));
370
+ const manifestsRoot = path.resolve(required(process.env.BUILDCHAIN_TAIL_RESEAL_MANIFESTS_ROOT, "BUILDCHAIN_TAIL_RESEAL_MANIFESTS_ROOT"));
371
+ const manifests = request.platforms.map((platform) => {
372
+ const { absolute, value } = locateManifest(manifestsRoot, platform.id);
373
+ if (value.artifactName !== platform.artifactName || value.git?.sha !== request.source.sha) throw new Error(`${platform.id} resealed manifest identity mismatch`);
374
+ return { platformId: platform.id, artifactName: platform.artifactName, manifestRoot: sha256File(absolute) };
375
+ });
376
+ const receipt = {
377
+ contract: CONTRACT,
378
+ action: "reused-tail-reseal",
379
+ repository: request.repository,
380
+ source: request.source,
381
+ target: request.target,
382
+ candidateRuntime: request.candidateRuntime,
383
+ recoveryTooling: {
384
+ ref: required(process.env.BUILDCHAIN_TAIL_RESEAL_TOOLING_REF, "BUILDCHAIN_TAIL_RESEAL_TOOLING_REF"),
385
+ sha: exactSha(process.env.BUILDCHAIN_TAIL_RESEAL_TOOLING_SHA, "BUILDCHAIN_TAIL_RESEAL_TOOLING_SHA"),
386
+ },
387
+ consumerController: request.consumerController,
388
+ originalFailure: request.failure,
389
+ signingAuthority: request.authority,
390
+ artifacts: request.platforms.map(({ id, artifactName, artifactDigest, manifestArtifactName, manifestArtifactDigest }) => ({
391
+ platformId: id,
392
+ artifactName,
393
+ originalArtifactDigest: artifactDigest,
394
+ manifestArtifactName,
395
+ originalManifestArtifactDigest: manifestArtifactDigest,
396
+ })),
397
+ resealedManifests: manifests,
398
+ skippedStages: ["install", "build", "verify", "platform-matrix"],
399
+ rerunStages: ["macos-signing-finalization", "aggregate", "candidate-passport"],
400
+ payloadPolicy: "reuse-exact-platform-bytes-except-authoritative-macos-signing-import",
401
+ currentRun: {
402
+ id: required(process.env.GITHUB_RUN_ID, "GITHUB_RUN_ID"),
403
+ attempt: required(process.env.GITHUB_RUN_ATTEMPT, "GITHUB_RUN_ATTEMPT"),
404
+ },
405
+ };
406
+ receipt.root = sha256Json(receipt);
407
+ const output = path.resolve(process.env.BUILDCHAIN_TAIL_RESEAL_RECEIPT_PATH || ".buildchain/tail-reseal/receipt.json");
408
+ writeJson(output, receipt);
409
+ appendOutputs({ "receipt-path": path.relative(process.cwd(), output), "receipt-root": receipt.root, "receipt-json": JSON.stringify(receipt) });
410
+ return receipt;
411
+ }
412
+
413
+ export async function releaseCandidateTailResealCli(argv = process.argv.slice(2)) {
414
+ const command = argv[0];
415
+ if (command === "plan") return plan();
416
+ if (command === "verify-platform") return verifyTailResealPlatform();
417
+ if (command === "seal") return sealTailResealReceipt();
418
+ throw new Error("usage: release-candidate-tail-reseal.mjs <plan|verify-platform|seal>");
419
+ }
420
+
421
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
422
+ releaseCandidateTailResealCli().catch((error) => {
423
+ console.error(`::error::${String(error.message || error).replace(/\r?\n/gu, "%0A")}`);
424
+ process.exitCode = 1;
425
+ });
426
+ }
@@ -275,16 +275,19 @@ export function sealArtifactSigningRequests({
275
275
  sourceTreeSha = process.env.BUILDCHAIN_SOURCE_TREE_SHA,
276
276
  runtimeSha = process.env.BUILDCHAIN_RUNTIME_SHA,
277
277
  platformId = process.env.BUILDCHAIN_PLATFORM_ID,
278
+ requestsEnabled = process.env.BUILDCHAIN_SIGNING_REQUESTS_ENABLED !== "false",
278
279
  } = {}) {
279
280
  const resolvedWorkspace = path.resolve(workspace);
280
281
  const resolvedCwd = path.resolve(resolvedWorkspace, cwd);
281
282
  assertInside(resolvedWorkspace, resolvedCwd, "signing working directory");
282
283
  const loaded = loadBuildchainConfig(resolvedCwd);
283
284
  const declarations = loaded?.config?.signing?.artifacts || [];
284
- const selected = declarations.filter(
285
- (entry) =>
286
- entry.platforms.length === 0 || entry.platforms.includes(platformId),
287
- );
285
+ const selected = requestsEnabled
286
+ ? declarations.filter(
287
+ (entry) =>
288
+ entry.platforms.length === 0 || entry.platforms.includes(platformId),
289
+ )
290
+ : [];
288
291
  const resolvedOutputRoot = path.resolve(resolvedWorkspace, outputRoot);
289
292
  assertInside(resolvedWorkspace, resolvedOutputRoot, "signing request output");
290
293
  if (selected.length === 0) {
@@ -92,6 +92,17 @@ export function cliCommandMeta(id) {
92
92
  "kfd-upstream-roles": { group: "kfd-trust", purpose: "List Buildchain-managed KFD upstream role values and inference policy." },
93
93
  lifecycle: { group: "reusable-build", purpose: "Run configured lifecycle commands and write deterministic artifact manifests." },
94
94
  dev: { group: "governance-versioning", purpose: "Inspect protected development-channel governance command families." },
95
+ "dev-authority-admit-merge-group": { group: "governance-versioning", purpose: "Verify that one exact candidate holds the exclusive Landing Warrant before merge_group admission." },
96
+ "dev-authority-complete-qualification": { group: "governance-versioning", purpose: "Bind qualification evidence and release one bounded Qualification Lease without granting landing authority." },
97
+ "dev-authority-heartbeat-landing": { group: "governance-versioning", purpose: "Extend the exact fenced Landing Warrant while final landing work remains live." },
98
+ "dev-authority-heartbeat-qualification": { group: "governance-versioning", purpose: "Extend one exact fenced Qualification Lease while qualification work remains live." },
99
+ "dev-authority-lease-landing": { group: "governance-versioning", purpose: "Issue or retain the single exclusive Landing Warrant for a qualified candidate." },
100
+ "dev-authority-lease-qualification": { group: "governance-versioning", purpose: "Issue one qualification-only lease within the configured bounded lane count." },
101
+ "dev-authority-migrate": { group: "governance-versioning", purpose: "Migrate one exact v1 Warrant state into v2 without rewriting candidate or fencing evidence." },
102
+ "dev-authority-observe": { group: "governance-versioning", purpose: "Read bounded Qualification Leases and the exclusive Landing Warrant without mutating authority." },
103
+ "dev-authority-recover": { group: "governance-versioning", purpose: "Recover expired qualification or Landing authority and emit one rooted wake instruction." },
104
+ "dev-authority-settle": { group: "governance-versioning", purpose: "Settle terminal candidate evidence idempotently and release held qualification or Landing authority immediately." },
105
+ "dev-authority-submit": { group: "governance-versioning", purpose: "Submit an exact candidate to the opt-in bounded-qualification authority state." },
95
106
  "dev-proof-classify": { group: "governance-versioning", purpose: "Classify source-qualified candidate changes against a current integration base." },
96
107
  "dev-proof-integration": { group: "governance-versioning", purpose: "Seal final exact integration delivery proof for a warranted candidate." },
97
108
  "dev-proof-replay": { group: "governance-versioning", purpose: "Replay source qualification against a Project Cut without rewriting candidate source." },
@@ -174,7 +185,8 @@ export function nodeApiMeta(exportName) {
174
185
  "./build-facts": { group: "observability-diagnostics", summary: "Git source, version, module output, product artifact, and legacy Kungfu build fact APIs." },
175
186
  "./candidate-timeline": { group: "observability-diagnostics", summary: "Source-bound candidate event normalization, per-attempt critical-path-safe aggregation, and compact reporting APIs." },
176
187
  "./channel-candidate": { group: "governance-versioning", summary: "Exact-source channel candidate decisions, same-SHA workflow evidence validation, and deterministic source-lock reference APIs." },
177
- "./dev-delivery-warrant": { group: "governance-versioning", summary: "Durable fair Dev Delivery Warrant queue, fenced lease, and split source and integration proof APIs." },
188
+ "./dev-delivery-authority": { group: "governance-versioning", summary: "Opt-in bounded Qualification Lease, exclusive Landing Warrant, exact v1 migration, admission, and terminal settlement APIs." },
189
+ "./dev-delivery-warrant": { group: "governance-versioning", summary: "Durable single-flight Warrant queue, fenced lease, and split source and integration proof APIs." },
178
190
  "./cache-evidence": { group: "observability-diagnostics", summary: "Content-addressed cache operation receipts and source/platform-bound evidence-set verification APIs." },
179
191
  "./diagnostics": { group: "observability-diagnostics", summary: "Native diagnostics collection, summarization, cache, compiler, and process-sampler APIs." },
180
192
  "./logging": { group: "observability-diagnostics", summary: "Buildchain JSONL logging, span, summary, and verification APIs." },
@@ -203,6 +215,9 @@ export function nodeApiMeta(exportName) {
203
215
  "./release-candidate": { group: "reusable-build", summary: "PR-stage release-candidate artifact, passport, and promote-only resolver APIs." },
204
216
  "./release-candidate-recovery": { group: "release-passport-trust", summary: "Fail-closed verification and immutable receipts for reusing a successful sealed candidate run without rebuilding product payloads." },
205
217
  "./release-train": { group: "governance-versioning", summary: "Frozen Release Cut identity, rooted Release Train transitions, Dev observations, supersession, replay, and legacy read compatibility APIs." },
218
+ "./next-development-transition": { group: "governance-versioning", summary: "Provider-neutral completed-Alpha preservation and rooted next-development state, version-model, idempotency, and local materialization APIs." },
219
+ "./next-development-controller": { group: "governance-versioning", summary: "Durable completed-Alpha child scheduling, fresh-runner checkpoint resume, latest protected-Dev reconciliation, and exact version-root readback APIs." },
220
+ "./next-development-projection": { group: "governance-versioning", summary: "Canonical generated config, Agent, and manual projections for the next-development transition contract." },
206
221
  "./stable-candidate-ledger": { group: "governance-versioning", summary: "Immutable alpha candidate ledger, qualification, revocation, selection, and exact stable source-lock APIs." },
207
222
  "./release-propagation": { group: "site-and-propagation", summary: "Release propagation graph, plan, and exact upstream lock APIs." },
208
223
  "./release-activation-transaction": { group: "release-passport-trust", summary: "Ordered cross-repository activation, exact receipt-set binding, retry, abort, rollback, and shadow-rehearsal APIs." },
@@ -219,6 +234,15 @@ export function nodeApiMeta(exportName) {
219
234
  "./buildchain-layout": { group: "kfd-trust", summary: "Versioned Buildchain repository-layout discovery contract plus canonical .buildchain path resolution and migration APIs." },
220
235
  "./kfd": { group: "kfd-trust", summary: "Unified KFD standards, schema discovery, KFD-1/KFD-2/KFD-3 grouped APIs, KFD-4 schema discovery, upstream KFD aggregate facts, and Buildchain KFD claim helpers." },
221
236
  "./kfd-adopter-manifest": { group: "kfd-trust", summary: "Exact-cut KFD adopter manifest verification, Buildchain evidence binding, and one-way legacy support-matrix projection APIs." },
237
+ "./adopter-delivery-gate": { group: "release-passport-trust", summary: "Protocol-neutral exact-driver and explicit artifact-profile delivery gate APIs." },
238
+ "./kfd-adopter-category-driver": { group: "kfd-trust", summary: "Thin delivery driver over exact published KFD category profiles and instance verification." },
239
+ "./buildchain-delivery-infrastructure": { group: "kfd-trust", summary: "Buildchain-owned delivery-infrastructure category instance construction and published-KFD verification APIs." },
240
+ "./buildchain-delivery-bootstrap": { group: "release-passport-trust", summary: "Anti-circular protected N-1 bootstrap evidence verification for one exact Buildchain delivery-infrastructure candidate." },
241
+ "./buildchain-delivery-self-dogfood": { group: "release-passport-trust", summary: "Pure exact-package self-dogfood assembly through injected published N-1 Buildchain and KFD abilities." },
242
+ "./published-delivery-authority": { group: "release-passport-trust", summary: "Exact npm archive-byte loading and constrained N-1 delivery authority imports with guaranteed cleanup." },
243
+ "./legacy-kfd-adopter-driver": { group: "kfd-trust", summary: "Explicit one-way legacy standard adopter manifest and support-matrix delivery adapter." },
244
+ "./adopter-delivery-passport": { group: "release-passport-trust", summary: "Exact adopter delivery gate binding and Release Passport evidence verification APIs." },
245
+ "./adopter-delivery-vectors": { group: "release-passport-trust", summary: "Rooted golden, negative, fault, and offline replay vector suite APIs." },
222
246
  "./kfd-adopter-release-binding": { group: "kfd-trust", summary: "Release Passport and artifact-evidence binding for one exact standard adopter manifest closure." },
223
247
  "./kfd-product-gates": { group: "kfd-trust", summary: "Fail-closed KFD-4, KFD-5, and KFD-7 product evidence gates plus non-widening KFD support-matrix release projections." },
224
248
  "./public-surface-audit": { group: "kfd-trust", summary: "Reverse audit APIs for CLI, workflow, action, site page, and documentation command surfaces." },
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { validateHostedSelfDogfoodEvidence } from "./next-development-self-dogfood.mjs";
4
+
3
5
  const DEFAULTS = {
4
6
  buildWorkflowFile: "build-surface-fixture.yml",
5
7
  buildWorkflowName: "Build Surface Fixture",
@@ -48,13 +50,11 @@ export function resolveStableCandidateQualificationCandidate({ eventName, inputC
48
50
  if (text(eventName) !== "workflow_run") {
49
51
  throw new Error(`qualification candidate resolver does not admit event ${eventName || "<empty>"}`);
50
52
  }
51
- const evidence = selfDogfoodEvidence;
52
- if (
53
- evidence?.contract !== "kungfu-buildchain-alpha-self-dogfood"
54
- || evidence?.status !== "passed"
55
- || evidence?.observed?.alpha?.ref !== "v3-alpha"
56
- ) {
57
- throw new Error("self-dogfood evidence is not a passing v3-alpha observation");
53
+ let evidence;
54
+ try {
55
+ evidence = validateHostedSelfDogfoodEvidence(selfDogfoodEvidence);
56
+ } catch (error) {
57
+ throw new Error(`self-dogfood evidence is not a passing rooted v3-alpha observation: ${error.message}`);
58
58
  }
59
59
  const observedSha = optionalSha(evidence.observed.alpha.sha, "observed v3-alpha SHA");
60
60
  const expectedSha = optionalSha(evidence.observed.alpha.expectedSha, "expected v3-alpha SHA");
@@ -6,7 +6,7 @@ import { pathToFileURL } from "node:url";
6
6
  import { evaluateWorkflowCallContract } from "../packages/core/workflow-call-contract.js";
7
7
  import { parseWorkflowDocument } from "../packages/core/workflow-yaml-contract.js";
8
8
 
9
- export const SELF_RELEASE_REF = "769b221bad7a6b9104afad4c2628d9dca396ab0f";
9
+ export const SELF_RELEASE_REF = "15db8a9d7c39f7a649a0e3971af68490356dd9ac";
10
10
  export const SELF_RELEASE_PUBLIC_WORKFLOW = `kungfu-systems/buildchain/.github/workflows/release-candidate-promote.yml@${SELF_RELEASE_REF}`;
11
11
 
12
12
  function parityFailure(message) {
@@ -0,0 +1,86 @@
1
+ name: Protected Dev Delivery
2
+
3
+ on:
4
+ repository_dispatch:
5
+ types: [buildchain-dev-delivery-wake]
6
+ workflow_dispatch:
7
+ inputs:
8
+ target-branch:
9
+ description: "Protected dev/vN/vN.M branch"
10
+ required: true
11
+ expected-pr-number:
12
+ description: "Exact ready and approved PR number"
13
+ required: true
14
+ type: number
15
+ expected-head-sha:
16
+ description: "Exact immutable PR head"
17
+ required: true
18
+ source-identity-root:
19
+ description: "Semantic source identity root"
20
+ required: true
21
+ source-patch-root:
22
+ description: "Semantic patch root"
23
+ required: true
24
+ assignment-root:
25
+ description: "Native Assignment root"
26
+ required: true
27
+ initiative-root:
28
+ description: "Parent Initiative root"
29
+ required: true
30
+ plan-root:
31
+ description: "Native qualification plan root"
32
+ required: true
33
+ closure-root:
34
+ description: "Affected closure root"
35
+ required: true
36
+ dependency-root:
37
+ description: "Dependency graph root"
38
+ required: true
39
+ toolchain-root:
40
+ description: "Native toolchain root"
41
+ required: true
42
+ environment-root:
43
+ description: "Native execution environment contract root"
44
+ required: true
45
+ affected-paths-json:
46
+ description: "JSON array representing the affected closure"
47
+ required: true
48
+ native-proof-json:
49
+ description: "Optional reusable native proof"
50
+ required: false
51
+ default: ""
52
+
53
+ permissions:
54
+ actions: write
55
+ contents: write
56
+ pull-requests: write
57
+ checks: read
58
+ statuses: write
59
+
60
+ jobs:
61
+ deliver:
62
+ uses: kungfu-systems/buildchain/.github/workflows/dev-pr-auto-merge.yml@v3
63
+ with:
64
+ target-branch: ${{ github.event.client_payload.candidate.targetBranch || inputs.target-branch }}
65
+ expected-pr-number: ${{ github.event.client_payload.candidate.pullRequestNumber || inputs.expected-pr-number }}
66
+ expected-head-sha: ${{ github.event.client_payload.candidate.sourceHead || inputs.expected-head-sha }}
67
+ source-workflow-run-id: ${{ github.event.client_payload.candidate.sourceWorkflowRunId || github.run_id }}
68
+ delivery-warrant-mode: required
69
+ assignment-root: ${{ github.event.client_payload.candidate.assignmentRoot || inputs.assignment-root }}
70
+ initiative-root: ${{ github.event.client_payload.candidate.initiativeRoot || inputs.initiative-root }}
71
+ source-identity-root: ${{ github.event.client_payload.candidate.sourceIdentityRoot || inputs.source-identity-root }}
72
+ source-patch-root: ${{ github.event.client_payload.candidate.sourcePatchRoot || inputs.source-patch-root }}
73
+ plan-root: ${{ github.event.client_payload.candidate.planRoot || inputs.plan-root }}
74
+ closure-root: ${{ github.event.client_payload.candidate.closureRoot || inputs.closure-root }}
75
+ dependency-root: ${{ github.event.client_payload.candidate.dependencyRoot || inputs.dependency-root }}
76
+ toolchain-root: ${{ github.event.client_payload.candidate.toolchainRoot || inputs.toolchain-root }}
77
+ environment-root: ${{ github.event.client_payload.candidate.environmentRoot || inputs.environment-root }}
78
+ affected-paths-json: ${{ github.event_name == 'repository_dispatch' && toJSON(github.event.client_payload.candidate.affectedPaths) || inputs.affected-paths-json }}
79
+ native-proof-json: ${{ inputs.native-proof-json || '' }}
80
+ native-command: cmake -S . -B build && cmake --build build --parallel && ctest --test-dir build --output-on-failure
81
+ native-heartbeat-seconds: 300
82
+ delivery-class: native-proof-required
83
+ landing-mode: queue
84
+ dry-run: false
85
+ secrets:
86
+ github-token: ${{ secrets.BUILDCHAIN_PROMOTION_TOKEN }}