@kungfu-tech/buildchain 4.0.1-alpha.9 → 4.0.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 (98) hide show
  1. package/README.md +9 -6
  2. package/actions/v4-release-candidate-promote/README.md +3 -0
  3. package/architecture/agent-change-map.md +1015 -0
  4. package/architecture/ci-lane-change-budget.json +70 -1
  5. package/architecture/decisions/0004-v4-declarative-release-tail.md +47 -0
  6. package/architecture/internal-capabilities.json +156 -11
  7. package/architecture/maintainability-debt.json +3229 -0
  8. package/architecture/maintainability-policy.json +480 -129
  9. package/architecture/v3-core-mechanism-inventory.json +4 -3
  10. package/architecture/v3-v4-capability-closure.md +59 -0
  11. package/architecture/v3-v4-live-capability-inventory.json +102404 -0
  12. package/architecture/v4-cross-platform-adopter-qualification.json +52 -0
  13. package/architecture/v4-delivery-warrant-shadow-fixtures.json +3 -3
  14. package/architecture/v4-runtime-semantic-closure.json +710 -0
  15. package/bin/internal/trust-release-release-handlers.mjs +5 -0
  16. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
  17. package/contracts/v4-publication-qualification-v1.schema.json +51 -0
  18. package/dist/site/agent-index.json +1 -0
  19. package/dist/site/artifact-schemas.json +2 -0
  20. package/dist/site/buildchain-contract.json +123 -32
  21. package/dist/site/buildchain-site.json +96 -28
  22. package/dist/site/capability-registry.json +6 -6
  23. package/dist/site/cli-registry.json +5 -2
  24. package/dist/site/controller-registry.json +41 -5
  25. package/dist/site/kfd-claims.json +170 -21
  26. package/dist/site/kfd-upstream-aggregate.json +1 -1
  27. package/dist/site/manual-registry.json +6 -6
  28. package/dist/site/node-api-registry.json +1474 -215
  29. package/dist/site/page-registry.json +85 -17
  30. package/dist/site/public-surface-audit.json +85 -20
  31. package/dist/site/publication-authority-registry.json +28 -1
  32. package/dist/site/publication-registry.json +4 -4
  33. package/dist/site/release-provenance.json +5 -0
  34. package/dist/site/schemas/v4-publication-qualification-v1.schema.json +51 -0
  35. package/dist/site/site-manifest.json +10 -10
  36. package/dist/site/workflow-registry.json +94 -18
  37. package/docs/MAP.md +1 -1
  38. package/docs/cli-reference.md +4 -4
  39. package/docs/dev-delivery-warrant.md +12 -9
  40. package/docs/node-api-reference.md +291 -206
  41. package/docs/publish-transaction.md +11 -4
  42. package/docs/release-candidate.md +7 -0
  43. package/docs/v4-adopter-delivery.md +23 -4
  44. package/docs/v4-declarative-release-tail-migration.md +43 -0
  45. package/package.json +8 -3
  46. package/packages/core/adopter-delivery-passport.js +36 -0
  47. package/packages/core/buildchain-contract.js +31 -1
  48. package/packages/core/buildchain-publication-authority.js +1 -0
  49. package/packages/core/dev-delivery-warrant-settlement.js +239 -3
  50. package/packages/core/dev-delivery-warrant-state.js +15 -2
  51. package/packages/core/dev-delivery-warrant.js +21 -4
  52. package/packages/core/github-governance-authority.js +4 -4
  53. package/packages/core/index.js +1 -0
  54. package/packages/core/paper-scaffold-content.js +401 -0
  55. package/packages/core/paper.js +12 -378
  56. package/packages/core/publication-control-plane-audit.js +135 -111
  57. package/packages/core/publication-rehearsal-projection.js +104 -0
  58. package/packages/core/publication-rehearsal-runtime.js +190 -0
  59. package/packages/core/release-candidate-recovery.js +6 -5
  60. package/packages/core/release-passport.js +82 -184
  61. package/packages/core/v4-cross-platform-adopter-qualification.js +343 -0
  62. package/packages/core/v4-floating-consumer-policy.js +3 -2
  63. package/packages/core/v4-floating-consumer-release-passport.js +134 -15
  64. package/packages/core/v4-publication-qualification.js +222 -0
  65. package/scripts/artifact-signing-controller-core.mjs +1 -1
  66. package/scripts/audit-publication-control-plane.mjs +17 -17
  67. package/scripts/buildchain-cli-help.mjs +3 -0
  68. package/scripts/check-internal-architecture.mjs +23 -3
  69. package/scripts/check-inventory.mjs +23 -5
  70. package/scripts/check-maintainability.mjs +145 -4
  71. package/scripts/check-project-cut-merge-queue-admission.mjs +87 -0
  72. package/scripts/check-v3-v4-capability-inventory.mjs +574 -0
  73. package/scripts/check-v4-floating-consumer-policy-contract.mjs +10 -3
  74. package/scripts/check-v4-runtime-semantic-closure.mjs +266 -0
  75. package/scripts/dev-delivery-warrant-options.mjs +27 -11
  76. package/scripts/dev-delivery-warrant.mjs +45 -5
  77. package/scripts/dev-pr-auto-merge.mjs +25 -11
  78. package/scripts/dev-pr-delivery-warrant.mjs +44 -0
  79. package/scripts/dev-pr-prequeue-guard.mjs +0 -18
  80. package/scripts/dispatch-artifact-signing-authority.mjs +1 -1
  81. package/scripts/generate-agent-change-map.mjs +118 -0
  82. package/scripts/generate-release-candidate-passport.mjs +26 -1
  83. package/scripts/generate-site-bundle.mjs +6 -0
  84. package/scripts/maintainability-domain-metrics.mjs +237 -0
  85. package/scripts/maintainability-governance.mjs +473 -0
  86. package/scripts/maintainability-metrics.mjs +28 -6
  87. package/scripts/project-cut-merge-queue-admission.mjs +394 -0
  88. package/scripts/promotion-routing-evidence.mjs +35 -6
  89. package/scripts/release-candidate-resolver.mjs +44 -0
  90. package/scripts/release-line-policy.mjs +25 -15
  91. package/scripts/release-tail.mjs +19 -2
  92. package/scripts/resume-from-candidate-run.mjs +106 -103
  93. package/scripts/run-lifecycle-core.mjs +341 -376
  94. package/scripts/site-capability-metadata.mjs +4 -0
  95. package/scripts/stable-candidate-qualification.mjs +9 -10
  96. package/scripts/v3-v4-capability-catalog.mjs +439 -0
  97. package/scripts/v4-cross-platform-adopter-qualification.mjs +228 -0
  98. package/scripts/v4-declarative-promotion-admission.mjs +42 -0
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+
7
+ import {
8
+ createV4CrossPlatformAdopterReport,
9
+ qualifyV4CrossPlatformAdopters,
10
+ summarizeV3V4CapabilityInventory,
11
+ } from "../packages/core/v4-cross-platform-adopter-qualification.js";
12
+
13
+ function flag(name, fallback = "") {
14
+ const index = process.argv.indexOf(`--${name}`);
15
+ return index === -1 ? fallback : process.argv[index + 1] || fallback;
16
+ }
17
+
18
+ function required(name) {
19
+ const value = flag(name);
20
+ if (!value) throw new Error(`--${name} is required`);
21
+ return value;
22
+ }
23
+
24
+ function repeated(name) {
25
+ const values = [];
26
+ for (let index = 0; index < process.argv.length; index += 1) {
27
+ if (process.argv[index] === `--${name}` && process.argv[index + 1])
28
+ values.push(process.argv[++index]);
29
+ }
30
+ return values;
31
+ }
32
+
33
+ function readJson(file) {
34
+ return JSON.parse(fs.readFileSync(file, "utf8"));
35
+ }
36
+
37
+ function writeJson(file, value) {
38
+ fs.mkdirSync(path.dirname(file), { recursive: true });
39
+ fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
40
+ }
41
+
42
+ function run(command, args, options = {}) {
43
+ const completed = spawnSync(command, args, {
44
+ encoding: "utf8",
45
+ ...options,
46
+ });
47
+ if (completed.error) throw completed.error;
48
+ return completed;
49
+ }
50
+
51
+ function expectPass(result, label) {
52
+ if (result.status !== 0)
53
+ throw new Error(
54
+ `${label} failed with ${result.status}: ${(result.stderr || "").trim()}`,
55
+ );
56
+ }
57
+
58
+ function resolveInput(consumerRoot, value) {
59
+ return path.isAbsolute(value) ? value : path.join(consumerRoot, value);
60
+ }
61
+
62
+ function runPlatform() {
63
+ const runtimeRoot = path.resolve(required("runtime-root"));
64
+ const consumerRoot = path.resolve(flag("consumer-root", process.cwd()));
65
+ const output = path.resolve(required("output"));
66
+ const workRoot = path.dirname(output);
67
+ const input = resolveInput(consumerRoot, required("input"));
68
+ const bootstrap = resolveInput(consumerRoot, required("bootstrap"));
69
+ const cli = path.join(runtimeRoot, "bin/buildchain.mjs");
70
+ const command = (subcommand, args) =>
71
+ run(process.execPath, [cli, "adopter-delivery", subcommand, ...args], {
72
+ cwd: consumerRoot,
73
+ env: process.env,
74
+ });
75
+
76
+ const inventory = readJson(
77
+ path.join(runtimeRoot, "architecture/v3-v4-live-capability-inventory.json"),
78
+ );
79
+ const inventoryEvidence = summarizeV3V4CapabilityInventory(inventory);
80
+ fs.mkdirSync(workRoot, { recursive: true });
81
+ const initialPath = path.join(workRoot, "initial-readback.json");
82
+ const retryPath = path.join(workRoot, "retry-readback.json");
83
+ const terminalPath = path.join(workRoot, "terminal-readback.json");
84
+ const tamperedPath = path.join(workRoot, "tampered-readback.json");
85
+ const bootstrapPath = path.join(workRoot, "bootstrap.json");
86
+
87
+ expectPass(
88
+ command("run", ["--input", input, "--output", initialPath]),
89
+ "initial public adopter delivery",
90
+ );
91
+ const initial = readJson(initialPath);
92
+ const tampered = structuredClone(initial);
93
+ tampered.gateResult.artifact.root = `sha256:${"f".repeat(64)}`;
94
+ writeJson(tamperedPath, tampered);
95
+ const rejected = command("verify", [
96
+ "--input",
97
+ input,
98
+ "--readback",
99
+ tamperedPath,
100
+ ]);
101
+ if (rejected.status === 0)
102
+ throw new Error("tampered public readback was not rejected");
103
+ expectPass(
104
+ command("run", ["--input", input, "--output", retryPath]),
105
+ "retry public adopter delivery",
106
+ );
107
+ const retry = readJson(retryPath);
108
+ expectPass(
109
+ command("verify", [
110
+ "--input",
111
+ input,
112
+ "--readback",
113
+ retryPath,
114
+ "--output",
115
+ terminalPath,
116
+ ]),
117
+ "terminal public adopter delivery readback",
118
+ );
119
+ const terminal = readJson(terminalPath);
120
+ expectPass(
121
+ command("bootstrap", ["--input", bootstrap, "--output", bootstrapPath]),
122
+ "public N-1 bootstrap",
123
+ );
124
+ const bootstrapEvidence = readJson(bootstrapPath);
125
+ const neutralDriver = run(
126
+ process.execPath,
127
+ [
128
+ "--test",
129
+ path.join(
130
+ runtimeRoot,
131
+ "tests/non-kfd-specification-driver-clean-room.test.mjs",
132
+ ),
133
+ ],
134
+ { cwd: runtimeRoot, env: process.env },
135
+ );
136
+ expectPass(neutralDriver, "independent protocol-neutral driver");
137
+
138
+ const report = createV4CrossPlatformAdopterReport({
139
+ platform: required("platform"),
140
+ consumer: required("consumer"),
141
+ sourceBinding: {
142
+ runtimeSha: required("runtime-sha"),
143
+ consumerSha: required("consumer-sha"),
144
+ inventoryRoot: inventoryEvidence.inventoryRoot,
145
+ sourceCuts: inventoryEvidence.sourceCuts,
146
+ },
147
+ capabilityMatrix: {
148
+ capabilityCount: inventoryEvidence.summary.capabilityCount,
149
+ categoryCounts: inventoryEvidence.summary.categoryCounts,
150
+ dispositionCounts: inventoryEvidence.summary.dispositionCounts,
151
+ categories: inventoryEvidence.categories,
152
+ },
153
+ execution: {
154
+ initialRun: {
155
+ status: "passed",
156
+ readbackRoot: initial.deliveryRoot,
157
+ },
158
+ tamperFailure: {
159
+ status: "failed-as-required",
160
+ exitCode: rejected.status ?? 1,
161
+ },
162
+ retryRun: {
163
+ status: "passed",
164
+ readbackRoot: retry.deliveryRoot,
165
+ },
166
+ terminalVerify: {
167
+ status: "passed",
168
+ readbackRoot: terminal.deliveryRoot,
169
+ },
170
+ bootstrap: {
171
+ status: "passed",
172
+ resultRoot: bootstrapEvidence.resultRoot,
173
+ },
174
+ neutralDriver: {
175
+ id: "ledger-specification-driver",
176
+ status: "passed",
177
+ kfdDependencyPresent: false,
178
+ },
179
+ },
180
+ authority: {
181
+ productionWrites: false,
182
+ providerEffects: false,
183
+ releaseEffects: false,
184
+ stablePublication: false,
185
+ },
186
+ });
187
+ writeJson(output, report);
188
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
189
+ }
190
+
191
+ function collectReports(root) {
192
+ const reports = [];
193
+ const visit = (directory) => {
194
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
195
+ const target = path.join(directory, entry.name);
196
+ if (entry.isDirectory()) visit(target);
197
+ else if (entry.isFile() && entry.name.endsWith(".json")) {
198
+ const candidate = readJson(target);
199
+ if (
200
+ candidate?.contract ===
201
+ "kungfu-buildchain-v4-cross-platform-adopter-report/v1"
202
+ )
203
+ reports.push(candidate);
204
+ }
205
+ }
206
+ };
207
+ visit(root);
208
+ return reports;
209
+ }
210
+
211
+ function aggregate() {
212
+ const reportsRoot = path.resolve(required("reports-root"));
213
+ const qualification = qualifyV4CrossPlatformAdopters({
214
+ reports: collectReports(reportsRoot),
215
+ consumers: repeated("consumer"),
216
+ });
217
+ const output = flag("output");
218
+ if (output) writeJson(path.resolve(output), qualification);
219
+ process.stdout.write(`${JSON.stringify(qualification, null, 2)}\n`);
220
+ }
221
+
222
+ const mode = process.argv[2] || "";
223
+ if (mode === "run") runPlatform();
224
+ else if (mode === "aggregate") aggregate();
225
+ else
226
+ throw new Error(
227
+ "usage: v4-cross-platform-adopter-qualification.mjs <run|aggregate> ...",
228
+ );
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import { pathToFileURL } from "node:url";
3
+
4
+ import { assertV4DeclarativePromotionInputs } from "../packages/core/v4-publication-qualification.js";
5
+
6
+ export function admitV4DeclarativePromotion({
7
+ inputs,
8
+ runtimeRef,
9
+ declarative,
10
+ }) {
11
+ if (!/^v4(?:$|[-./])/u.test(String(runtimeRef || ""))) {
12
+ return Object.freeze({ mode: "legacy", admitted: true });
13
+ }
14
+ if (declarative !== true) {
15
+ const error = new Error(
16
+ "Buildchain v4 release-candidate-promote requires declarative-release-tail=true",
17
+ );
18
+ error.code = "v4-declarative-release-tail-required";
19
+ throw error;
20
+ }
21
+ assertV4DeclarativePromotionInputs(inputs);
22
+ return Object.freeze({ mode: "v4-declarative", admitted: true });
23
+ }
24
+
25
+ if (
26
+ process.argv[1] &&
27
+ import.meta.url === pathToFileURL(process.argv[1]).href
28
+ ) {
29
+ try {
30
+ const result = admitV4DeclarativePromotion({
31
+ inputs: JSON.parse(process.env.BUILDCHAIN_PROMOTION_INPUTS_JSON || "{}"),
32
+ runtimeRef: process.env.BUILDCHAIN_RUNTIME_REF,
33
+ declarative: process.env.BUILDCHAIN_DECLARATIVE_RELEASE_TAIL === "true",
34
+ });
35
+ process.stdout.write(`${JSON.stringify(result)}\n`);
36
+ } catch (error) {
37
+ process.stderr.write(
38
+ `v4-declarative-promotion-admission: ${error.code || "rejected"}: ${error.message}\n`,
39
+ );
40
+ process.exitCode = 1;
41
+ }
42
+ }