@kungfu-tech/buildchain 3.0.6 → 3.0.7-alpha.1

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 (103) hide show
  1. package/README.md +4 -2
  2. package/actions/promote-buildchain-ref/README.md +10 -0
  3. package/actions/release-tail/README.md +17 -0
  4. package/bin/buildchain.mjs +11 -0
  5. package/bin/internal/command-registry.mjs +2 -0
  6. package/contracts/auditable-demo-scenario-v1.schema.json +1 -1
  7. package/contracts/engineering-housekeeper-v1.schema.json +143 -0
  8. package/contracts/fixtures/engineering-housekeeper-v1/cases.json +68 -0
  9. package/contracts/fixtures/release-tail-capabilities-v1/kungfu-alpha.json +273 -0
  10. package/contracts/publication-rehearsal-capsule-v1.schema.json +173 -0
  11. package/contracts/release-tail-capabilities-v1.schema.json +199 -0
  12. package/contracts/release-tail-provider-bindings-v1.schema.json +56 -0
  13. package/dist/site/agent-index.json +3 -0
  14. package/dist/site/artifact-schemas.json +6 -0
  15. package/dist/site/buildchain-contract.json +42 -27
  16. package/dist/site/buildchain-site.json +384 -33
  17. package/dist/site/capability-registry.json +15 -12
  18. package/dist/site/cli-registry.json +102 -0
  19. package/dist/site/controller-registry.json +19 -3
  20. package/dist/site/kfd-claims.json +359 -17
  21. package/dist/site/kfd-upstream-aggregate.json +1 -1
  22. package/dist/site/manual-registry.json +53 -7
  23. package/dist/site/node-api-registry.json +5882 -3605
  24. package/dist/site/page-registry.json +348 -21
  25. package/dist/site/public-surface-audit.json +396 -16
  26. package/dist/site/publication-authority-registry.json +106 -1
  27. package/dist/site/publication-registry.json +4 -4
  28. package/dist/site/release-provenance.json +7 -0
  29. package/dist/site/schemas/publication-rehearsal-capsule-v1.schema.json +269 -0
  30. package/dist/site/schemas/release-tail-capabilities-v1.schema.json +353 -0
  31. package/dist/site/schemas/release-tail-provider-bindings-v1.schema.json +94 -0
  32. package/dist/site/site-manifest.json +35 -11
  33. package/dist/site/workflow-registry.json +204 -10
  34. package/docs/MAP.md +6 -2
  35. package/docs/auditable-demo.md +2 -2
  36. package/docs/cli-reference.md +136 -0
  37. package/docs/dev-delivery-warrant.md +49 -4
  38. package/docs/engineering-housekeeper.md +138 -0
  39. package/docs/lifecycle-protocol.md +4 -2
  40. package/docs/node-api-reference.md +495 -281
  41. package/docs/publication-rehearsal.md +94 -0
  42. package/docs/release-governance.md +17 -2
  43. package/docs/release-tail-contract.md +160 -0
  44. package/docs/release-tail-provider-plane.md +120 -0
  45. package/docs/reusable-build-surface.md +11 -0
  46. package/package.json +11 -3
  47. package/packages/core/artifact-signing.js +61 -0
  48. package/packages/core/buildchain-agent-manuals.js +3 -0
  49. package/packages/core/buildchain-config.js +66 -6
  50. package/packages/core/buildchain-kfd-claims.js +1 -1
  51. package/packages/core/buildchain-publication-authority.js +5 -0
  52. package/packages/core/controller-evidence.js +2 -1
  53. package/packages/core/dev-delivery-warrant-cancellation.js +1 -0
  54. package/packages/core/dev-delivery-warrant-shadow.js +502 -0
  55. package/packages/core/dev-delivery-warrant.js +15 -6
  56. package/packages/core/diagnostics.js +8 -3
  57. package/packages/core/engineering-housekeeper-github-client.js +222 -0
  58. package/packages/core/engineering-housekeeper-github.js +501 -0
  59. package/packages/core/engineering-housekeeper.js +259 -0
  60. package/packages/core/index.js +42 -0
  61. package/packages/core/kfd-gate.js +45 -15
  62. package/packages/core/paper-agent-entry.js +11 -5
  63. package/packages/core/paper-repository.js +1 -0
  64. package/packages/core/paper-scaffold-content.js +21 -0
  65. package/packages/core/paper.js +28 -2
  66. package/packages/core/publication-rehearsal-projection.js +173 -0
  67. package/packages/core/publication-rehearsal-runtime.js +921 -0
  68. package/packages/core/release-passport.js +130 -20
  69. package/packages/core/release-tail-compatibility.js +60 -0
  70. package/packages/core/release-tail-provider-adapters.js +461 -0
  71. package/packages/core/release-tail-provider-plane.js +1228 -0
  72. package/scripts/assemble-publication-artifact-admission.mjs +1 -1
  73. package/scripts/assemble-self-publication-admission.mjs +2 -2
  74. package/scripts/audit-publication-control-plane.mjs +1 -1
  75. package/scripts/auditable-demo-bundle-verification.mjs +2 -3
  76. package/scripts/auditable-demo-platform.mjs +2 -2
  77. package/scripts/auditable-demo-renditions.mjs +1 -1
  78. package/scripts/auditable-demo.mjs +2 -2
  79. package/scripts/build-contract-core.mjs +8 -3
  80. package/scripts/build-standalone-binary.mjs +14 -3
  81. package/scripts/buildchain-cli-help.mjs +13 -0
  82. package/scripts/check-core-mechanism-inventory.mjs +347 -0
  83. package/scripts/check-inventory.mjs +10 -8
  84. package/scripts/check-maintainability.mjs +9 -2
  85. package/scripts/check-release-tail-contract.mjs +435 -0
  86. package/scripts/dev-delivery-warrant.mjs +31 -4
  87. package/scripts/dev-pr-auto-merge.mjs +30 -4
  88. package/scripts/dev-pr-delivery-warrant.mjs +50 -0
  89. package/scripts/engineering-housekeeper-workflow.mjs +394 -0
  90. package/scripts/generate-channel-promotion-workflow.mjs +10 -8
  91. package/scripts/generate-site-bundle.mjs +47 -4
  92. package/scripts/init-repo.mjs +26 -2
  93. package/scripts/inspect-artifact-signing-requests.mjs +6 -0
  94. package/scripts/materialize-self-release-candidate-version.mjs +137 -0
  95. package/scripts/publication-commit-evidence.mjs +69 -23
  96. package/scripts/release-candidate-resolver.mjs +16 -10
  97. package/scripts/release-tail.mjs +159 -0
  98. package/scripts/resume-from-candidate-run.mjs +123 -9
  99. package/scripts/seal-artifact-signing-requests.mjs +6 -0
  100. package/scripts/site-capability-metadata.mjs +13 -0
  101. package/scripts/v4-architecture.mjs +600 -0
  102. package/scripts/web-surface-core.mjs +8 -2
  103. package/scripts/workflow-call-contract.mjs +184 -5
@@ -4,13 +4,170 @@ import path from "node:path";
4
4
  import { execFileSync } from "node:child_process";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import { evaluateWorkflowCallContract } from "../packages/core/workflow-call-contract.js";
7
+ import { parseWorkflowDocument } from "../packages/core/workflow-yaml-contract.js";
8
+
9
+ export const SELF_RELEASE_REF = "769b221bad7a6b9104afad4c2628d9dca396ab0f";
10
+ export const SELF_RELEASE_PUBLIC_WORKFLOW = `kungfu-systems/buildchain/.github/workflows/release-candidate-promote.yml@${SELF_RELEASE_REF}`;
11
+
12
+ function parityFailure(message) {
13
+ throw new Error(`self-release route parity: ${message}`);
14
+ }
15
+
16
+ function literal(job, name) {
17
+ const value = job?.with?.[name];
18
+ if (!value || value.kind === "expression") {
19
+ parityFailure(`${job?.id || "<missing>"}.${name} must be a literal`);
20
+ }
21
+ return value.value;
22
+ }
23
+
24
+ export function selfReleaseRouteIdentity(workflowText, jobId = "promote") {
25
+ const job = parseWorkflowDocument(workflowText).callJobs.find(
26
+ (entry) => entry.id === jobId,
27
+ );
28
+ if (!job) parityFailure(`reusable workflow job is missing: ${jobId}`);
29
+ if (
30
+ job.uses.startsWith("./") ||
31
+ job.uses.includes("/.release-candidate-promote.yml@")
32
+ ) {
33
+ parityFailure(
34
+ `authoritative caller uses an internal or checkout-relative route: ${job.uses}`,
35
+ );
36
+ }
37
+ if (job.uses !== SELF_RELEASE_PUBLIC_WORKFLOW) {
38
+ parityFailure(
39
+ `caller uses ${job.uses}, expected ${SELF_RELEASE_PUBLIC_WORKFLOW}`,
40
+ );
41
+ }
42
+ if (literal(job, "buildchain-ref") !== SELF_RELEASE_REF) {
43
+ parityFailure("caller runtime ref differs from the public workflow ref");
44
+ }
45
+ if (literal(job, "declarative-release-tail") !== true) {
46
+ parityFailure(
47
+ "caller does not require the declarative release-tail provider plane",
48
+ );
49
+ }
50
+ return {
51
+ publicWorkflow: job.uses,
52
+ runtimeRef: SELF_RELEASE_REF,
53
+ declarationContract: "kungfu-buildchain-release-tail-capabilities/v1",
54
+ declarationCompiler:
55
+ "packages/core/release-tail-provider-plane.js#compileReleaseTailDeclaration",
56
+ transaction:
57
+ "packages/core/release-tail-provider-plane.js#executeReleaseTailTransaction",
58
+ providerAdapter:
59
+ "packages/core/release-tail-provider-adapters.js#createGitHubReleaseAssetsAdapter",
60
+ receiptValidator:
61
+ "packages/core/release-tail-provider-plane.js#validateReleaseTailTransaction",
62
+ };
63
+ }
64
+
65
+ export function assertSelfReleaseRouteParity({
66
+ selfWorkflowText,
67
+ consumerWorkflowText,
68
+ routing,
69
+ publicWorkflowText,
70
+ advancedWorkflowText,
71
+ actionText,
72
+ providerPlanText,
73
+ } = {}) {
74
+ const self = selfReleaseRouteIdentity(selfWorkflowText);
75
+ const consumer = selfReleaseRouteIdentity(consumerWorkflowText);
76
+ if (JSON.stringify(self) !== JSON.stringify(consumer)) {
77
+ parityFailure(
78
+ "Buildchain self-release and representative consumer identities differ",
79
+ );
80
+ }
81
+ const alphaShellRef = routing?.alpha?.callRef;
82
+ if (alphaShellRef !== "train/v3/v3.0/consumer-equivalent-self-dogfood") {
83
+ parityFailure(
84
+ "alpha workflow shell does not resolve through the self-dogfood train",
85
+ );
86
+ }
87
+ for (const required of [
88
+ "uses: kungfu-systems/buildchain/.github/workflows/.release-candidate-promote.yml@train/v3/v3.0/consumer-equivalent-self-dogfood",
89
+ "declarative-release-tail: ${{ inputs.declarative-release-tail }}",
90
+ ]) {
91
+ if (!publicWorkflowText.includes(required)) {
92
+ parityFailure(`public router is missing: ${required}`);
93
+ }
94
+ }
95
+ for (const required of [
96
+ "declarative-release-tail:",
97
+ "declarative-release-tail: ${{ inputs.declarative-release-tail }}",
98
+ "release-tail-transaction-root:",
99
+ ]) {
100
+ if (!advancedWorkflowText.includes(required)) {
101
+ parityFailure(`advanced workflow shell is missing: ${required}`);
102
+ }
103
+ }
104
+ for (const required of [
105
+ "executeReleaseTailTransaction",
106
+ "createGitHubReleaseAssetsAdapter",
107
+ "publishDeclarativeGitHubReleaseEvidence",
108
+ ]) {
109
+ if (!actionText.includes(required)) {
110
+ parityFailure(
111
+ `promotion action is missing provider-plane identity: ${required}`,
112
+ );
113
+ }
114
+ }
115
+ for (const required of [
116
+ "compileReleaseTailDeclaration",
117
+ "githubReleaseAssetsTargetRoot",
118
+ "createDeclarativeGitHubReleasePlan",
119
+ ]) {
120
+ if (!providerPlanText.includes(required)) {
121
+ parityFailure(`declarative GitHub Release plan is missing: ${required}`);
122
+ }
123
+ }
124
+ return {
125
+ schema: "kungfu.buildchain.self-release-route-parity/v1",
126
+ ok: true,
127
+ self,
128
+ consumer,
129
+ workflowShellRef: routing.alpha.callRef,
130
+ };
131
+ }
132
+
133
+ export function checkSelfReleaseRouteParity({ root, observed = {} } = {}) {
134
+ const read = (relative) => fs.readFileSync(path.join(root, relative), "utf8");
135
+ const report = assertSelfReleaseRouteParity({
136
+ selfWorkflowText: read(".github/workflows/buildchain-ref-promotion.yml"),
137
+ consumerWorkflowText: read(
138
+ "tests/fixtures/self-release-route/external-consumer.yml",
139
+ ),
140
+ routing: JSON.parse(read(".buildchain/promotion-shell-routing.json")),
141
+ publicWorkflowText: read(".github/workflows/release-candidate-promote.yml"),
142
+ advancedWorkflowText: read(
143
+ ".github/workflows/.release-candidate-promote.yml",
144
+ ),
145
+ actionText: `${read("actions/promote-buildchain-ref/index.js")}\n${read("actions/promote-buildchain-ref/github-release.js")}`,
146
+ providerPlanText: read("actions/promote-buildchain-ref/github-release.js"),
147
+ });
148
+ const rootPattern = /^sha256:[0-9a-f]{64}$/u;
149
+ const shaPattern = /^[0-9a-f]{40}$/u;
150
+ for (const [name, value] of Object.entries(observed)) {
151
+ if (!value) continue;
152
+ const valid =
153
+ name === "runtimeSha" ? shaPattern.test(value) : rootPattern.test(value);
154
+ if (!valid)
155
+ parityFailure(`observed ${name} is not an exact rooted identity`);
156
+ }
157
+ return { ...report, observed };
158
+ }
7
159
 
8
160
  function usage() {
9
- return `usage: node scripts/workflow-call-contract.mjs check \\
161
+ return `usage:
162
+ node scripts/workflow-call-contract.mjs check \\
10
163
  --caller-workflow <path> --job <id> --caller-repository <owner/repo> \\
11
164
  --callee-root <checkout> --callee-workflow <path> --callee-repository <owner/repo> \\
12
165
  --trusted-event <event[:type]> [--trusted-event ...] \\
13
- [--expected-contract-root sha256:...] [--allow-dirty] [--output <path>]`;
166
+ [--expected-contract-root sha256:...] [--allow-dirty] [--output <path>]
167
+ node scripts/workflow-call-contract.mjs self-release-parity \\
168
+ [--root <checkout>] [--runtime-sha <sha>] [--contract-root <root>] \\
169
+ [--release-tail-declaration-root <root>] [--release-tail-transaction-root <root>] \\
170
+ [--release-tail-state-root <root>] [--output <path>]`;
14
171
  }
15
172
 
16
173
  function parseArgs(argv) {
@@ -21,7 +178,7 @@ function parseArgs(argv) {
21
178
  options.allowDirty = true;
22
179
  continue;
23
180
  }
24
- if (!arg.startsWith("--") || !argv[index + 1])
181
+ if (!arg.startsWith("--") || index + 1 >= argv.length)
25
182
  throw new Error(`invalid argument: ${arg}`);
26
183
  const value = argv[index + 1];
27
184
  index += 1;
@@ -67,7 +224,9 @@ export function checkWorkflowCall(options) {
67
224
  "--untracked-files=no",
68
225
  );
69
226
  if (calleeStatus) {
70
- throw new Error("callee checkout is dirty; exact pinned-ref bytes are required");
227
+ throw new Error(
228
+ "callee checkout is dirty; exact pinned-ref bytes are required",
229
+ );
71
230
  }
72
231
  const callerSha = git(callerRoot, "rev-parse", "HEAD");
73
232
  const callerTree = git(callerRoot, "rev-parse", "HEAD^{tree}");
@@ -103,8 +262,28 @@ export function checkWorkflowCall(options) {
103
262
 
104
263
  function main(argv = process.argv.slice(2)) {
105
264
  const command = argv.shift();
106
- if (command !== "check") throw new Error(usage());
107
265
  const options = parseArgs(argv);
266
+ if (command === "self-release-parity") {
267
+ const root = options.root ? path.resolve(options.root) : process.cwd();
268
+ const report = checkSelfReleaseRouteParity({
269
+ root,
270
+ observed: {
271
+ runtimeSha: options.runtimeSha || "",
272
+ contractRoot: options.contractRoot || "",
273
+ releaseTailDeclarationRoot: options.releaseTailDeclarationRoot || "",
274
+ releaseTailTransactionRoot: options.releaseTailTransactionRoot || "",
275
+ releaseTailStateRoot: options.releaseTailStateRoot || "",
276
+ },
277
+ });
278
+ if (options.output) {
279
+ const output = path.resolve(root, options.output);
280
+ fs.mkdirSync(path.dirname(output), { recursive: true });
281
+ fs.writeFileSync(output, `${JSON.stringify(report, null, 2)}\n`);
282
+ }
283
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
284
+ return;
285
+ }
286
+ if (command !== "check") throw new Error(usage());
108
287
  required(options, [
109
288
  "callerWorkflow",
110
289
  "job",