@kungfu-tech/buildchain 3.0.9-alpha.10 → 3.0.9-alpha.12

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 (31) hide show
  1. package/actions/promote-buildchain-ref/README.md +4 -0
  2. package/bin/internal/trust-release-release-handlers.mjs +1 -0
  3. package/dist/site/buildchain-contract.json +211 -26
  4. package/dist/site/buildchain-site.json +30 -15
  5. package/dist/site/capability-registry.json +1 -1
  6. package/dist/site/cli-registry.json +2 -1
  7. package/dist/site/controller-registry.json +6 -2
  8. package/dist/site/kfd-claims.json +34 -7
  9. package/dist/site/kfd-upstream-aggregate.json +1 -1
  10. package/dist/site/manual-registry.json +3 -3
  11. package/dist/site/node-api-registry.json +276 -24
  12. package/dist/site/page-registry.json +23 -8
  13. package/dist/site/public-surface-audit.json +9 -6
  14. package/dist/site/publication-registry.json +4 -4
  15. package/dist/site/release-provenance.json +2 -0
  16. package/dist/site/site-manifest.json +7 -7
  17. package/dist/site/workflow-registry.json +10 -7
  18. package/docs/cli-reference.md +2 -2
  19. package/docs/node-api-reference.md +61 -40
  20. package/docs/release-passport.md +10 -0
  21. package/package.json +3 -1
  22. package/packages/core/buildchain-compatibility-proof.js +66 -0
  23. package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
  24. package/packages/core/dev-delivery-warrant.js +1 -0
  25. package/packages/core/published-delivery-authority.js +247 -0
  26. package/packages/core/release-passport.js +8 -1
  27. package/scripts/buildchain-cli-help.mjs +1 -0
  28. package/scripts/check-inventory.mjs +1 -1
  29. package/scripts/dev-delivery-warrant.mjs +1 -1
  30. package/scripts/site-capability-metadata.mjs +2 -0
  31. package/scripts/workflow-call-contract.mjs +1 -1
@@ -0,0 +1,247 @@
1
+ import { createHash } from "node:crypto";
2
+ import { createReadStream } from "node:fs";
3
+ import { mkdir, mkdtemp, readFile, realpath, rm } from "node:fs/promises";
4
+ import { tmpdir } from "node:os";
5
+ import path from "node:path";
6
+ import { promisify } from "node:util";
7
+ import { pathToFileURL } from "node:url";
8
+ import { execFile } from "node:child_process";
9
+
10
+ import { adopterDeliveryGateDigest } from "./adopter-delivery-gate.js";
11
+
12
+ export const PUBLISHED_DELIVERY_AUTHORITY_CONTRACT =
13
+ "kungfu-buildchain-published-delivery-authority/v1";
14
+
15
+ const execFileAsync = promisify(execFile);
16
+ const ROOT_PATTERN = /^sha256:[0-9a-f]{64}$/;
17
+ const PACKAGES = [
18
+ {
19
+ key: "buildchain",
20
+ name: "@kungfu-tech/buildchain",
21
+ packageRoot: "archive",
22
+ modules: {
23
+ adopterDeliveryGate: "packages/core/adopter-delivery-gate.js",
24
+ bootstrap: "packages/core/buildchain-delivery-bootstrap.js",
25
+ infrastructure: "packages/core/buildchain-delivery-infrastructure.js",
26
+ kfdCategoryDriver: "packages/core/kfd-adopter-category-driver.js",
27
+ },
28
+ },
29
+ {
30
+ key: "kfd",
31
+ name: "@kungfu-tech/kfd",
32
+ packageRoot: "profiles/adopter-conformance/adopters/kfd/manifest.json",
33
+ modules: {},
34
+ },
35
+ ];
36
+
37
+ async function sha256File(file) {
38
+ const hash = createHash("sha256");
39
+ for await (const chunk of createReadStream(file)) hash.update(chunk);
40
+ return `sha256:${hash.digest("hex")}`;
41
+ }
42
+
43
+ function exactDeclaration(value, expectedName, label) {
44
+ if (
45
+ value?.name !== expectedName ||
46
+ typeof value.version !== "string" ||
47
+ value.version.length === 0 ||
48
+ typeof value.archivePath !== "string" ||
49
+ value.archivePath.length === 0 ||
50
+ !ROOT_PATTERN.test(value.archiveRoot ?? "") ||
51
+ !ROOT_PATTERN.test(value.artifactRoot ?? "")
52
+ ) {
53
+ throw new TypeError(`${label} package declaration is incomplete`);
54
+ }
55
+ return structuredClone(value);
56
+ }
57
+
58
+ function safeArchiveEntries(listing, verboseListing, label) {
59
+ const entries = listing.split("\n").filter(Boolean);
60
+ const types = verboseListing.split("\n").filter(Boolean);
61
+ if (entries.length === 0 || entries.length !== types.length) {
62
+ throw new Error(`${label} archive listing is incomplete`);
63
+ }
64
+ for (let index = 0; index < entries.length; index += 1) {
65
+ const entry = entries[index];
66
+ const parts = entry.split("/");
67
+ if (
68
+ parts[0] !== "package" ||
69
+ parts.some((part, partIndex) =>
70
+ partIndex === parts.length - 1 && part === ""
71
+ ? false
72
+ : part === "" || part === "." || part === "..",
73
+ )
74
+ ) {
75
+ throw new Error(`${label} archive contains an unsafe path`);
76
+ }
77
+ if (!["-", "d"].includes(types[index][0])) {
78
+ throw new Error(`${label} archive contains a non-file entry`);
79
+ }
80
+ }
81
+ }
82
+
83
+ async function extractPackage(declaration, destination, definition, label) {
84
+ const observedRoot = await sha256File(declaration.archivePath);
85
+ if (observedRoot !== declaration.archiveRoot) {
86
+ throw new Error(`${label} archive bytes do not match archiveRoot`);
87
+ }
88
+ const [{ stdout: listing }, { stdout: verboseListing }] = await Promise.all([
89
+ execFileAsync("tar", ["-tzf", declaration.archivePath], {
90
+ maxBuffer: 16 * 1024 * 1024,
91
+ }),
92
+ execFileAsync("tar", ["-tvzf", declaration.archivePath], {
93
+ maxBuffer: 16 * 1024 * 1024,
94
+ }),
95
+ ]);
96
+ safeArchiveEntries(listing, verboseListing, label);
97
+ await mkdir(destination, { recursive: true });
98
+ await execFileAsync(
99
+ "tar",
100
+ [
101
+ "-xzf",
102
+ declaration.archivePath,
103
+ "--strip-components",
104
+ "1",
105
+ "-C",
106
+ destination,
107
+ ],
108
+ { maxBuffer: 16 * 1024 * 1024 },
109
+ );
110
+ const packageJsonPath = path.join(destination, "package.json");
111
+ const packageJson = JSON.parse(await readFile(packageJsonPath, "utf8"));
112
+ if (
113
+ packageJson.name !== declaration.name ||
114
+ packageJson.version !== declaration.version
115
+ ) {
116
+ throw new Error(`${label} extracted package identity does not match`);
117
+ }
118
+ if (definition.packageRoot === "archive") {
119
+ if (declaration.artifactRoot !== declaration.archiveRoot) {
120
+ throw new Error(`${label} package artifactRoot must match archiveRoot`);
121
+ }
122
+ } else {
123
+ const packageManifest = JSON.parse(
124
+ await readFile(path.join(destination, definition.packageRoot), "utf8"),
125
+ );
126
+ const packageCut = packageManifest?.kfdCut?.package;
127
+ if (
128
+ packageCut?.name !== declaration.name ||
129
+ packageCut?.version !== declaration.version ||
130
+ packageCut?.artifactRoot !== declaration.artifactRoot
131
+ ) {
132
+ throw new Error(`${label} semantic package identity does not match`);
133
+ }
134
+ }
135
+ const destinationRoot = await realpath(destination);
136
+ if (!destinationRoot.endsWith(path.join(...declaration.name.split("/")))) {
137
+ throw new Error(`${label} extraction escaped its package coordinate`);
138
+ }
139
+ return {
140
+ name: declaration.name,
141
+ version: declaration.version,
142
+ archiveRoot: declaration.archiveRoot,
143
+ artifactRoot: declaration.artifactRoot,
144
+ };
145
+ }
146
+
147
+ async function importAuthorityRuntime(buildchainRoot) {
148
+ const definition = PACKAGES[0];
149
+ const imported = {};
150
+ for (const [key, relativePath] of Object.entries(definition.modules)) {
151
+ imported[key] = await import(
152
+ pathToFileURL(path.join(buildchainRoot, relativePath)).href
153
+ );
154
+ }
155
+ const runtime = {
156
+ createAdopterDeliveryGate:
157
+ imported.adopterDeliveryGate.createAdopterDeliveryGate,
158
+ createPackageArtifactProfile:
159
+ imported.adopterDeliveryGate.createPackageArtifactProfile,
160
+ qualifyBuildchainDeliveryInfrastructureBootstrap:
161
+ imported.bootstrap.qualifyBuildchainDeliveryInfrastructureBootstrap,
162
+ createBuildchainDeliveryInfrastructureInstanceManifest:
163
+ imported.infrastructure
164
+ .createBuildchainDeliveryInfrastructureInstanceManifest,
165
+ verifyBuildchainDeliveryInfrastructureInstance:
166
+ imported.infrastructure.verifyBuildchainDeliveryInfrastructureInstance,
167
+ createKfdAdopterCategoryProtocolDriver:
168
+ imported.kfdCategoryDriver.createKfdAdopterCategoryProtocolDriver,
169
+ };
170
+ for (const [name, implementation] of Object.entries(runtime)) {
171
+ if (typeof implementation !== "function") {
172
+ throw new Error(`published Buildchain authority is missing ${name}`);
173
+ }
174
+ }
175
+ return runtime;
176
+ }
177
+
178
+ export async function loadPublishedBuildchainDeliveryAuthority({
179
+ buildchain,
180
+ kfd,
181
+ } = {}) {
182
+ const declarations = {
183
+ buildchain: exactDeclaration(
184
+ buildchain,
185
+ "@kungfu-tech/buildchain",
186
+ "Buildchain authority",
187
+ ),
188
+ kfd: exactDeclaration(kfd, "@kungfu-tech/kfd", "KFD authority"),
189
+ };
190
+ const temporaryRoot = await mkdtemp(
191
+ path.join(tmpdir(), "buildchain-published-delivery-authority-"),
192
+ );
193
+ let retained = false;
194
+ try {
195
+ const identities = {};
196
+ for (const definition of PACKAGES) {
197
+ identities[definition.key] = await extractPackage(
198
+ declarations[definition.key],
199
+ path.join(temporaryRoot, "node_modules", ...definition.name.split("/")),
200
+ definition,
201
+ `${definition.key} authority`,
202
+ );
203
+ }
204
+ const authorityRuntime = await importAuthorityRuntime(
205
+ path.join(temporaryRoot, "node_modules", ...PACKAGES[0].name.split("/")),
206
+ );
207
+ const authority = {
208
+ schemaVersion: 1,
209
+ contract: PUBLISHED_DELIVERY_AUTHORITY_CONTRACT,
210
+ packages: identities,
211
+ moduleCoordinates: structuredClone(PACKAGES[0].modules),
212
+ qualifying: false,
213
+ selfCertified: false,
214
+ releaseAuthorized: false,
215
+ finalAuthority:
216
+ "caller-bound-public-npm-archive-bytes-and-package-identity",
217
+ };
218
+ authority.authorityRoot = adopterDeliveryGateDigest(authority);
219
+ retained = true;
220
+ return {
221
+ ...authority,
222
+ authorityRuntime,
223
+ temporaryRoot,
224
+ async dispose() {
225
+ await rm(temporaryRoot, { recursive: true, force: true });
226
+ },
227
+ };
228
+ } finally {
229
+ if (!retained) await rm(temporaryRoot, { recursive: true, force: true });
230
+ }
231
+ }
232
+
233
+ export async function withPublishedBuildchainDeliveryAuthority(
234
+ declarations,
235
+ operation,
236
+ ) {
237
+ if (typeof operation !== "function") {
238
+ throw new TypeError("published authority operation must be a function");
239
+ }
240
+ const authority =
241
+ await loadPublishedBuildchainDeliveryAuthority(declarations);
242
+ try {
243
+ return await operation(authority);
244
+ } finally {
245
+ await authority.dispose();
246
+ }
247
+ }
@@ -1533,7 +1533,7 @@ export function collectGitHubReleasePassport({
1533
1533
  kfd2ClaimJsons = [],
1534
1534
  kfd3PrebuildWitnessJsons = [],
1535
1535
  kfd3ArtifactWitnessJsons = [],
1536
- kfd3ArtifactVerifyCommand = "",
1536
+ kfd3ArtifactVerifyCommand = "", adopterDeliveryJson = "",
1537
1537
  kfdAdopterManifestJson = "",
1538
1538
  kfdSupportMatrixJson = "",
1539
1539
  kfdProductGateJsons = [],
@@ -1594,6 +1594,11 @@ export function collectGitHubReleasePassport({
1594
1594
  cwd,
1595
1595
  label: "KFD-3 artifact verify command",
1596
1596
  });
1597
+ const adopterDelivery = parseJsonInput(
1598
+ adopterDeliveryJson,
1599
+ undefined,
1600
+ { cwd, label: "adopterDeliveryJson" },
1601
+ );
1597
1602
  const basePassportMeta = parseJsonInputWithMeta(basePassportJson, undefined, { cwd, label: "basePassportJson" });
1598
1603
  const invariantPassportMetas = (invariantPassportJsons || [])
1599
1604
  .filter(Boolean)
@@ -1684,6 +1689,7 @@ export function collectGitHubReleasePassport({
1684
1689
  tag: resolvedTag,
1685
1690
  sourceSha,
1686
1691
  workflow,
1692
+ adopterDelivery,
1687
1693
  kfdAdopter,
1688
1694
  });
1689
1695
  const bundledPublishEvidencePath = publishEvidenceMeta.value ? "evidence.json" : "";
@@ -1750,6 +1756,7 @@ export function collectGitHubReleasePassport({
1750
1756
  kfd1,
1751
1757
  kfd2Claims: kfd2ClaimMetas.map((meta) => meta.value),
1752
1758
  kfd3,
1759
+ adopterDelivery,
1753
1760
  kfdAdopter,
1754
1761
  kfdAdopterManifestEvidencePath: kfdAdopter ? "kfd-adopter-manifest.json" : "",
1755
1762
  kfdAdopterGateEvidencePath: kfdAdopter ? "kfd-adopter-manifest-gate.json" : "",
@@ -67,6 +67,7 @@ export const BUILDCHAIN_USAGE = `Usage:
67
67
  [--kfd-3-prebuild-witness-json <json-or-path>]...
68
68
  [--kfd-3-artifact-witness-json <json-or-path>]...
69
69
  [--kfd-3-artifact-verify-cmd <command>]
70
+ [--adopter-delivery-json <json-or-path>]
70
71
  [--kfd-adopter-manifest-json <json-or-path>]
71
72
  [--kfd-support-matrix-json <json-or-path>]
72
73
  [--kfd-product-gate-json <json-or-path>]...
@@ -1003,7 +1003,7 @@ for (const forbiddenSnippet of [
1003
1003
  for (const requiredSnippet of [
1004
1004
  "id-token: write",
1005
1005
  "actions: write",
1006
- "uses: kungfu-systems/buildchain/.github/workflows/release-candidate-promote.yml@cc6c32845ab5779009aeb48cc34efe65e229fe30\n",
1006
+ "uses: kungfu-systems/buildchain/.github/workflows/release-candidate-promote.yml@15db8a9d7c39f7a649a0e3971af68490356dd9ac\n",
1007
1007
  "github.event.workflow_run.event == 'push'",
1008
1008
  "!startsWith(github.event.workflow_run.display_title, 'chore(release): prepare v')",
1009
1009
  "!startsWith(github.event.workflow_run.display_title, 'chore(release): release v')",
@@ -423,7 +423,7 @@ export function devDeliveryCliOptions(args = [], environment = process.env) {
423
423
  initiativeRoot: flag(rest, "initiative-root", environment.BUILDCHAIN_DEV_DELIVERY_INITIATIVE_ROOT),
424
424
  sourceIdentityRoot: flag(rest, "source-identity-root", environment.BUILDCHAIN_DEV_DELIVERY_SOURCE_IDENTITY_ROOT),
425
425
  sourcePatchRoot: flag(rest, "source-patch-root", environment.BUILDCHAIN_DEV_DELIVERY_SOURCE_PATCH_ROOT),
426
- sourceProofRoot: flag(rest, "source-proof-root", environment.BUILDCHAIN_DEV_DELIVERY_SOURCE_PROOF_ROOT),
426
+ sourceProofRoot: flag(rest, "source-proof-root", environment.BUILDCHAIN_DEV_DELIVERY_SOURCE_PROOF_ROOT), sourceWorkflowRunId: flag(rest, "source-workflow-run-id", environment.BUILDCHAIN_DEV_DELIVERY_SOURCE_WORKFLOW_RUN_ID),
427
427
  affectedPaths: flag(rest, "affected-paths-json", environment.BUILDCHAIN_DEV_DELIVERY_AFFECTED_PATHS || "[]"),
428
428
  nativeProofPath: flag(rest, "native-proof", environment.BUILDCHAIN_DEV_DELIVERY_NATIVE_PROOF),
429
429
  nativeReuseDecisionPath: flag(rest, "native-reuse-decision", environment.BUILDCHAIN_DEV_DELIVERY_NATIVE_REUSE_DECISION),
@@ -238,6 +238,8 @@ export function nodeApiMeta(exportName) {
238
238
  "./kfd-adopter-category-driver": { group: "kfd-trust", summary: "Thin delivery driver over exact published KFD category profiles and instance verification." },
239
239
  "./buildchain-delivery-infrastructure": { group: "kfd-trust", summary: "Buildchain-owned delivery-infrastructure category instance construction and published-KFD verification APIs." },
240
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." },
241
243
  "./legacy-kfd-adopter-driver": { group: "kfd-trust", summary: "Explicit one-way legacy standard adopter manifest and support-matrix delivery adapter." },
242
244
  "./adopter-delivery-passport": { group: "release-passport-trust", summary: "Exact adopter delivery gate binding and Release Passport evidence verification APIs." },
243
245
  "./adopter-delivery-vectors": { group: "release-passport-trust", summary: "Rooted golden, negative, fault, and offline replay vector suite APIs." },
@@ -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 = "cc6c32845ab5779009aeb48cc34efe65e229fe30";
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) {