@kungfu-tech/buildchain 4.1.3-alpha.5 → 4.1.3-alpha.6

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 (78) hide show
  1. package/AGENTS.md +41 -75
  2. package/CONTRIBUTING.md +19 -26
  3. package/architecture/agent-change-map.md +7 -12
  4. package/architecture/capability-state-machine-manifest.json +1 -4
  5. package/architecture/ci-lane-change-budget.json +35 -1026
  6. package/architecture/core-mechanisms.json +3 -6
  7. package/architecture/internal-capabilities.json +1 -5
  8. package/architecture/maintainability-debt.json +43 -36
  9. package/architecture/maintainability-policy.json +8 -8
  10. package/architecture/minimal-consumer-migration.json +80 -1977
  11. package/architecture/platform-stage-checkpoints.json +31 -7
  12. package/architecture/release-topology.json +64 -84
  13. package/architecture/stage-capsule-qualification.json +3 -1
  14. package/architecture/universal-workflow-bootstrap.json +3 -1
  15. package/architecture/universal-workflow-capability-policy.json +4 -4
  16. package/architecture/universal-workflow-fault-campaign.json +3 -1
  17. package/architecture/workflow-taxonomy.json +24 -341
  18. package/dist/site/buildchain-contract.json +13 -67
  19. package/dist/site/buildchain-site.json +28 -23
  20. package/dist/site/capability-registry.json +2 -2
  21. package/dist/site/controller-registry.json +1 -47
  22. package/dist/site/kfd-claims.json +78 -448
  23. package/dist/site/kfd-upstream-aggregate.json +1 -1
  24. package/dist/site/manual-registry.json +3 -3
  25. package/dist/site/node-api-registry.json +24 -24
  26. package/dist/site/page-registry.json +21 -16
  27. package/dist/site/public-surface-audit.json +31 -347
  28. package/dist/site/publication-authority-registry.json +51 -511
  29. package/dist/site/publication-registry.json +4 -4
  30. package/dist/site/site-manifest.json +7 -7
  31. package/dist/site/workflow-registry.json +259 -1126
  32. package/docs/code-organization.md +9 -6
  33. package/docs/node-api-reference.md +57 -57
  34. package/docs/release-governance.md +10 -12
  35. package/docs/runtime-entry.md +10 -3
  36. package/docs/runtime-train-validation.md +39 -11
  37. package/docs/stable-candidate-patrol.md +6 -5
  38. package/docs/workflow-catalog.md +3 -32
  39. package/package.json +1 -1
  40. package/packages/core/adoption/buildchain-kfd-claims.js +7 -7
  41. package/packages/core/dev-delivery/dev-delivery-provider-heartbeat.js +18 -15
  42. package/packages/core/dev-delivery/native/actions.js +2 -0
  43. package/packages/core/dev-delivery/native/process-entry.js +19 -0
  44. package/packages/core/dev-delivery/queue/landing-action.js +49 -1
  45. package/packages/core/dev-delivery/warrant/failure-settlement.js +8 -6
  46. package/packages/core/dev-delivery/warrant/service.js +7 -0
  47. package/packages/core/governance/buildchain-publication-authority.js +2 -23
  48. package/packages/core/governance/github-governance-authority.js +1 -0
  49. package/packages/core/observability/controller-evidence.js +0 -8
  50. package/packages/core/providers/github/pipeline-entry-runs.js +8 -1
  51. package/packages/core/providers/github/pipeline-events.js +79 -0
  52. package/packages/core/publication/pipeline/pack.js +31 -8
  53. package/packages/core/workflow/pipeline/actions.js +0 -23
  54. package/packages/core/workflow/pipeline/build-evidence.js +123 -5
  55. package/packages/core/workflow/pipeline/build-result.js +1 -0
  56. package/packages/core/workflow/pipeline/channel-control.js +25 -4
  57. package/packages/core/workflow/pipeline/controller.js +9 -1
  58. package/packages/core/workflow/pipeline/delivery-control.js +54 -9
  59. package/packages/core/workflow/pipeline/delivery-observation.js +16 -10
  60. package/packages/core/workflow/pipeline/group-control.js +1 -0
  61. package/packages/core/workflow/pipeline/guard-build.js +37 -0
  62. package/packages/core/workflow/pipeline/guard.js +4 -2
  63. package/packages/core/workflow/pipeline/host.js +23 -1
  64. package/packages/core/workflow/pipeline/integration-status.js +113 -0
  65. package/packages/core/workflow/pipeline/record-action.js +27 -0
  66. package/packages/core/workflow/pipeline/recorder-status.js +69 -0
  67. package/packages/core/workflow/workflow-taxonomy.mjs +67 -47
  68. package/scripts/check-inventory.mjs +7 -70
  69. package/scripts/check-pipeline-publication-topology.mjs +2 -0
  70. package/scripts/check-public-dogfood-contract.mjs +38 -51
  71. package/scripts/check-release-topology.mjs +8 -7
  72. package/scripts/check-self-consumer-contract.mjs +133 -0
  73. package/scripts/check-universal-workflow-bootstrap.mjs +4 -6
  74. package/scripts/generate-minimal-consumer-contract.mjs +1 -1
  75. package/scripts/inventory/binary.mjs +9 -19
  76. package/scripts/inventory/promotion.mjs +2 -13
  77. package/scripts/prepare-product-toolchain.mjs +10 -0
  78. package/scripts/verify-product-platform.mjs +65 -0
@@ -0,0 +1,133 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { parse as yaml } from "yaml";
5
+ import { compileConsumerPlan } from "../packages/core/consumer/contract/plan.js";
6
+ import { consumerWorkflows } from "../packages/core/consumer/contract/entries.js";
7
+ import { workflowPath } from "../packages/core/workflow/workflow-taxonomy.mjs";
8
+
9
+ export const SELF_ENTRY_CHANNEL = "v4-alpha";
10
+ export const SELF_CONFIG_PATH = ".buildchain/minimal-consumer.toml";
11
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
12
+ const PLATFORMS = ["linux-x64", "macos-arm64", "windows-x64"];
13
+
14
+ // Repository policy checks the consumer-facing wiring. Product implementation
15
+ // libraries are separately registered and may not own repository event triggers.
16
+ // This policy supplies no repository identity exception to runtime admission.
17
+ export function checkSelfConsumerContract(root = ROOT) {
18
+ const read = (file) => fs.readFileSync(path.join(root, file), "utf8");
19
+ const fail = (message) => {
20
+ throw new Error(`self-consumer-contract: ${message}`);
21
+ };
22
+ const plan = compileConsumerPlan(read(SELF_CONFIG_PATH));
23
+ if (read(SELF_CONFIG_PATH) !== read(".buildchain/buildchain.toml"))
24
+ fail("transition config must match the canonical product plan");
25
+ const callers = consumerWorkflows(SELF_ENTRY_CHANNEL, SELF_CONFIG_PATH);
26
+ for (const [file, bytes] of Object.entries(callers))
27
+ if (read(file) !== bytes) fail(`${file}: generated caller drift`);
28
+ const taxonomy = JSON.parse(read("architecture/workflow-taxonomy.json"));
29
+ const registered = new Set(taxonomy.entries.map(workflowPath));
30
+ const observed = fs
31
+ .readdirSync(path.join(root, ".github/workflows"))
32
+ .filter((file) => /\.ya?ml$/u.test(file))
33
+ .map((file) => `.github/workflows/${file}`);
34
+ if (
35
+ observed.length !== registered.size ||
36
+ observed.some((file) => !registered.has(file))
37
+ )
38
+ fail("workflow inventory is not closed");
39
+ const self = taxonomy.entries
40
+ .filter((entry) => entry.role === "self")
41
+ .map(workflowPath)
42
+ .sort();
43
+ if (JSON.stringify(self) !== JSON.stringify(Object.keys(callers).sort()))
44
+ fail("self automation must contain exactly the generated caller pair");
45
+ for (const entry of taxonomy.entries.filter(
46
+ (entry) => entry.role !== "self",
47
+ )) {
48
+ const file = workflowPath(entry);
49
+ const document = yaml(read(file));
50
+ if (
51
+ Object.keys(document.on || {}).some(
52
+ (event) => !["workflow_call", "workflow_dispatch"].includes(event),
53
+ )
54
+ )
55
+ fail(`${file}: product library owns a repository event`);
56
+ }
57
+ for (const prefix of ["feature", "fix", "chore", "docs", "ci", "refactor"])
58
+ if (
59
+ !plan.channels.some(
60
+ (route) =>
61
+ route.from === `${prefix}/*` &&
62
+ route.to === "dev/v4/v4.1" &&
63
+ route.operation === "develop",
64
+ )
65
+ )
66
+ fail(`missing protected development route for ${prefix}`);
67
+ for (const platform of PLATFORMS) {
68
+ const verified = plan.products.some(
69
+ (product) =>
70
+ product.platforms.includes(platform) &&
71
+ product.verify.includes("corepack pnpm@11.7.0 run check") &&
72
+ product.verify.includes("node scripts/verify-product-platform.mjs"),
73
+ );
74
+ if (!verified)
75
+ fail(
76
+ `${platform}: full check and platform recovery verification are required`,
77
+ );
78
+ }
79
+ if (
80
+ !plan.products.some(
81
+ (product) =>
82
+ product.type === "npm" &&
83
+ product.targets.some((target) => target.provider === "npm"),
84
+ )
85
+ )
86
+ fail("npm publication is missing");
87
+ for (const platform of PLATFORMS)
88
+ if (
89
+ !plan.products.some(
90
+ (product) =>
91
+ product.type === "binary" &&
92
+ product.platforms.includes(platform) &&
93
+ product.targets.some(
94
+ (target) => target.provider === "github-release",
95
+ ),
96
+ )
97
+ )
98
+ fail(`${platform}: binary release asset is missing`);
99
+ const commands = plan.products.flatMap((product) => [
100
+ ...(product.install || []),
101
+ ...product.build,
102
+ ...product.verify,
103
+ ]);
104
+ if (
105
+ commands.some((command) =>
106
+ /\b(?:npm publish|gh release|buildchain (?:dev warrant|release|promote|recover|publish))\b|request-json|fencingToken/u.test(
107
+ command,
108
+ ),
109
+ )
110
+ )
111
+ fail("product lifecycle contains consumer-owned publication orchestration");
112
+ if (!read(".gitattributes").split("\n").includes("* text=auto eol=lf"))
113
+ fail("cross-platform LF checkout contract is missing");
114
+ return {
115
+ ok: true,
116
+ channel: SELF_ENTRY_CHANNEL,
117
+ callers: Object.keys(callers),
118
+ plan,
119
+ };
120
+ }
121
+
122
+ if (
123
+ process.argv[1] &&
124
+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
125
+ ) {
126
+ const { plan, ...result } = checkSelfConsumerContract();
127
+ console.log(
128
+ JSON.stringify({
129
+ ...result,
130
+ products: plan.products.map((product) => product.id),
131
+ }),
132
+ );
133
+ }
@@ -43,10 +43,8 @@ assert.doesNotMatch(read(contract.bootstrap.publicWorkflow), /admission-policy-j
43
43
  const template = parse(contract.bootstrap.consumerTemplate);
44
44
  assert.equal(template.jobs.bootstrap.uses, "kungfu-systems/buildchain/.github/workflows/public-ops-bootstrap.yml@v4");
45
45
  assert.equal(template.jobs.bootstrap.with["runtime-ref"], "${{ inputs.runtime-ref }}");
46
- const dogfood = parse(contract.bootstrap.selfDogfoodWorkflow);
47
- for (const channel of ["conformance", "alpha", "stable"]) for (const mode of ["primary", "recovery"]) {
48
- const job = dogfood.jobs[`${mode}-${channel}`];
49
- assert.equal(job.uses, "kungfu-systems/buildchain/.github/workflows/public-ops-bootstrap.yml@v4");
50
- assert.equal(job.with["runtime-ref"], mode === "primary" ? "${{ inputs.runtime-ref }}" : "${{ inputs.recovery-runtime-ref }}");
51
- }
46
+ assert.equal(contract.bootstrap.selfDogfoodActive, false);
47
+ assert.equal(fs.existsSync(path.join(root, contract.bootstrap.selfDogfoodWorkflow)), false,
48
+ "The retired bootstrap self controller must not coexist with the minimal pipeline");
49
+ assert.equal(contract.bootstrap.selfDogfoodSupersededBy, ".github/workflows/buildchain.yml");
52
50
  console.log(JSON.stringify({ ok: true, reusableWorkflowCount: reusable.length, runtimeAcquisitionOwners: 1 }));
@@ -143,7 +143,7 @@ output(
143
143
  await format(
144
144
  JSON.stringify({
145
145
  schema: "buildchain.consumer-migration/v1",
146
- stage: "contract-defined; execution-entry-not-yet-published",
146
+ stage: "self-cutover-in-progress; final-release-qualification-pending",
147
147
  workflows: workflowInventory(),
148
148
  consumerSources: consumerSourceInventory(),
149
149
  }),
@@ -1,26 +1,16 @@
1
1
  import assert from "node:assert/strict";
2
+ import { checkSelfConsumerContract } from "../check-self-consumer-contract.mjs";
2
3
  import { inspectWorkflowJob, readWorkflow } from "../workflow-action-graph.mjs";
3
4
 
4
5
  export function assertBinaryInventory(root) {
5
- const file = ".github/workflows/self-build-binary-distribution.yml";
6
- const workflow = readWorkflow(file, root);
7
- assert.equal(workflow.name, "Binary Distribution");
8
- assert.deepEqual(Object.keys(workflow.jobs).filter(id => id !== "execution-runtime"), ["preflight", "binary", "passport", "dispatch-publication"]);
9
- const graphs = Object.keys(workflow.jobs).filter(id => id !== "execution-runtime").map(id => inspectWorkflowJob(file, id, root));
10
- for (const graph of graphs) {
11
- assert.equal(graph.job.permissions.contents, "read");
12
- assert.notEqual(graph.job.permissions["id-token"], "write");
13
- assert.ok(!JSON.stringify(graph.job["runs-on"]).includes("self-hosted"));
14
- for (const step of graph.steps) assert.ok(!/gh release (?:upload|create)/u.test(step.run || ""));
15
- assert.ok(graph.actions.has(`actions/build/binary/${["preflight", "build", "passport", "dispatch-publication"][graphs.indexOf(graph)]}`));
16
- }
17
- const binary = graphs[1];
18
- assert.deepEqual(binary.job.strategy.matrix.include.map(entry => entry.os).sort(), ["macos-latest", "ubuntu-24.04", "windows-2022"]);
19
- const passport = graphs[2];
20
- const executable = passport.modules.get("packages/core/build/binary/distribution.js");
21
- for (const command of ["verifyBuildchainLogEvents", "verifyReleasePassport", "verifyArtifactPassport", "createReleaseEvidenceBundle", "buildchain-log-events", "buildchain-log-summary"])
22
- assert.ok(executable.includes(command), `Binary evidence is missing ${command}`);
23
- assert.ok(passport.actions.has("actions/build/binary/qualify"));
6
+ const { plan } = checkSelfConsumerContract(root);
7
+ assert.deepEqual(plan.products.filter(product => product.type === "binary")
8
+ .flatMap(product => product.platforms).sort(), ["linux-x64", "macos-arm64", "windows-x64"]);
9
+ const build = inspectWorkflowJob(".github/workflows/.release-pipeline-products.yml", "build", root);
10
+ assert.equal(build.job.permissions.contents, "read");
11
+ assert.notEqual(build.job.permissions["id-token"], "write");
12
+ assert.ok(!JSON.stringify(build.job["runs-on"]).includes("self-hosted"));
13
+ for (const step of build.steps) assert.ok(!/gh release (?:upload|create)/u.test(step.run || ""));
24
14
  const publish = inspectWorkflowJob(".github/workflows/.release-binary-assets.yml", "publish", root);
25
15
  assert.equal(publish.workflow.jobs["publication-authority"].uses, "./.github/workflows/.release-authority.yml");
26
16
  assert.ok(publish.job.needs.includes("publication-authority"));
@@ -1,4 +1,5 @@
1
1
  import assert from "node:assert/strict";
2
+ import { checkSelfConsumerContract } from "../check-self-consumer-contract.mjs";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
4
5
  import YAML from "yaml";
@@ -35,19 +36,7 @@ export function assertPromotionInventory(root) {
35
36
  "publish-command",
36
37
  ])
37
38
  assert.ok(!request.properties[key]);
38
- for (const file of [
39
- "self-release-promote",
40
- "self-release-tail-dogfood",
41
- "self-ops-promotion-recovery",
42
- ]) {
43
- const caller = YAML.parse(read(`.github/workflows/${file}.yml`));
44
- const calls = Object.values(caller.jobs).filter(
45
- (job) => job.uses === `kungfu-systems/buildchain/${publicPath}@v4`,
46
- );
47
- assert.equal(calls.length, 1, file);
48
- assert.ok(calls[0].with["request-json"]);
49
- assert.ok(Object.keys(calls[0].with).every(key => ["request-json", "runtime-ref", "contract-lock", "runtime-selection"].includes(key)));
50
- }
39
+ checkSelfConsumerContract(root);
51
40
  const component = ".github/workflows/.release-promote.yml";
52
41
  const expected = {
53
42
  qualify: "promotion/qualify",
@@ -0,0 +1,10 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+
5
+ // Product prerequisites cross command phases through the runner file protocol.
6
+ // An explicit cache works with the credential-isolated Windows environment too.
7
+ fs.appendFileSync(
8
+ process.env.GITHUB_ENV,
9
+ `GOTOOLCHAIN=go1.25.14+auto\nGOCACHE=${path.join(os.tmpdir(), "buildchain-go-cache")}\nGOPATH=${path.join(os.tmpdir(), "buildchain-go")}\n`,
10
+ );
@@ -0,0 +1,65 @@
1
+ import path from "node:path";
2
+ import { execFileSync } from "node:child_process";
3
+ import { verifyStageCapsuleCheckpoints } from "../packages/core/build/stage-capsule/rehearsal/verify.js";
4
+
5
+ const platform = {
6
+ linux: "linux-x64",
7
+ darwin: "macos-arm64",
8
+ win32: "windows-x64",
9
+ }[process.platform];
10
+ if (!platform)
11
+ throw new Error(
12
+ `Unsupported product verification platform: ${process.platform}`,
13
+ );
14
+ const goVersion = execFileSync("go", ["version"], { encoding: "utf8" }).trim();
15
+ const goMatch = /^go version go1\.(\d+)\./u.exec(goVersion);
16
+ if (!goMatch || Number(goMatch[1]) < 25)
17
+ throw new Error(
18
+ `Product verification requires Go 1.25 or newer in major 1: ${goVersion}`,
19
+ );
20
+ const workspace = process.cwd();
21
+ const result = verifyStageCapsuleCheckpoints({
22
+ runtimeRoot: workspace,
23
+ workspace,
24
+ platform,
25
+ environment: process.env,
26
+ });
27
+ if (platform === "linux-x64") {
28
+ // Same immutable image and backbone tests as the retired container CI lane.
29
+ // Supply the selected Node as the hosted container runner did; no credentials.
30
+ const image =
31
+ "ghcr.io/kungfu-systems/build-images/kungfu-verify@sha256:11f0ba64267ce88174a4f73a9bf833ff4e9c59cd16ec3d08a6432a06c2be6fb1";
32
+ execFileSync(
33
+ "docker",
34
+ [
35
+ "run",
36
+ "--rm",
37
+ "--network=none",
38
+ "--cap-drop=ALL",
39
+ "--security-opt=no-new-privileges",
40
+ "--mount",
41
+ `type=bind,source=${path.resolve(workspace)},target=/source,readonly`,
42
+ "--mount",
43
+ `type=bind,source=${process.execPath},target=/toolchain/node,readonly`,
44
+ "--env",
45
+ "PATH=/toolchain:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
46
+ "--workdir",
47
+ "/source",
48
+ image,
49
+ "node",
50
+ "--test",
51
+ "tests/build-orchestration.test.mjs",
52
+ "tests/build-artifact-pipeline.test.mjs",
53
+ "tests/dev-delivery-minimal-request.test.mjs",
54
+ ],
55
+ { stdio: "inherit" },
56
+ );
57
+ }
58
+ console.log(
59
+ JSON.stringify({
60
+ platform,
61
+ checkpoint: result.checkpoint,
62
+ resume: result.resume,
63
+ tail: result.tail,
64
+ }),
65
+ );