@kungfu-tech/buildchain 4.0.2-alpha.9 → 4.0.2
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.
- package/AGENTS.md +10 -1
- package/CONTRIBUTING.md +24 -0
- package/README.md +2 -2
- package/actions/promote-buildchain-ref/README.md +1 -1
- package/actions/v4-release-candidate-promote/README.md +28 -0
- package/architecture/agent-change-map.md +64 -7
- package/architecture/ci-lane-change-budget.json +366 -0
- package/architecture/internal-capabilities.json +53 -8
- package/architecture/maintainability-debt.json +147 -93
- package/architecture/maintainability-policy.json +32 -28
- package/architecture/release-tail-contract-inventory.json +6 -6
- package/architecture/v4-architecture-constitution.md +23 -20
- package/architecture/v4-cross-platform-adopter-qualification.json +1 -1
- package/architecture/v4-delivery-authority-parity.json +2 -2
- package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.json +1 -1
- package/architecture/v4-floating-consumer-policy.json +2 -2
- package/architecture/v4-next-development-parity.json +5 -5
- package/architecture/v4-partial-mutation-recovery-qualification.json +4 -1
- package/architecture/v4-platform-stage-checkpoints.json +1 -1
- package/architecture/v4-provider-operation-journal-contract.json +5 -2
- package/architecture/v4-publication-facade-patches.json +64 -0
- package/architecture/v4-release-activation-shadow-domain.json +5 -2
- package/architecture/v4-release-topology.json +74 -39
- package/architecture/v4-rust-wasm-production-authority.json +58 -0
- package/architecture/v4-stable-publication-fence.json +5 -2
- package/architecture/v4-stage-capsule-qualification.json +2 -2
- package/architecture/v4-tail-reseal-parity.json +8 -6
- package/architecture/v4-universal-workflow-bootstrap.json +171 -0
- package/architecture/v4-universal-workflow-fault-campaign.json +72 -0
- package/architecture/v4-universal-workflow-train-admission.json +40 -0
- package/architecture/workflow-taxonomy.json +1451 -0
- package/bin/buildchain.mjs +7 -7
- package/contracts/buildchain-v2-residuals-v1.json +57 -48
- package/contracts/dev-delivery-authority-v2.schema.json +16 -2
- package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
- package/contracts/v4-canonical-contracts-v1.schema.json +1 -0
- package/dist/site/buildchain-contract.json +93 -48
- package/dist/site/buildchain-site.json +222 -69
- package/dist/site/capability-registry.json +4 -4
- package/dist/site/controller-registry.json +50 -13
- package/dist/site/kfd-claims.json +2585 -1000
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +13 -13
- package/dist/site/node-api-registry.json +120 -115
- package/dist/site/page-registry.json +204 -51
- package/dist/site/public-surface-audit.json +3205 -1219
- package/dist/site/publication-authority-registry.json +1124 -362
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/schemas/dev-delivery-authority-v2.schema.json +16 -2
- package/dist/site/site-manifest.json +17 -17
- package/dist/site/workflow-registry.json +5061 -1659
- package/docs/MAP.md +1 -0
- package/docs/auditable-demo.md +1 -1
- package/docs/cli.md +21 -8
- package/docs/dev-delivery-warrant.md +1 -1
- package/docs/engineering-housekeeper.md +3 -3
- package/docs/kfd-support.md +26 -2
- package/docs/next-development-transition.md +2 -2
- package/docs/node-api-reference.md +190 -190
- package/docs/publication-authority.md +2 -2
- package/docs/release-candidate.md +3 -3
- package/docs/release-flow.md +67 -19
- package/docs/release-governance.md +8 -8
- package/docs/release-passport.md +27 -2
- package/docs/reusable-build-surface.md +16 -0
- package/docs/v4-adopter-delivery.md +2 -2
- package/docs/v4-production-release.md +71 -8
- package/docs/v4-rust-wasm-production-authority.md +58 -0
- package/docs/v4-stage-capsule.md +2 -2
- package/docs/v4-tail-reseal.md +1 -1
- package/docs/workflow-catalog.md +154 -0
- package/docs/workflow-path-migration.md +109 -0
- package/package.json +10 -6
- package/packages/core/artifact-verification-envelope.js +5 -5
- package/packages/core/buildchain-contract.js +1 -1
- package/packages/core/buildchain-kfd-claims.js +2 -2
- package/packages/core/buildchain-publication-authority.js +42 -26
- package/packages/core/buildchain-v4-domain.wasm +0 -0
- package/packages/core/ci-lane-change-budget.js +14 -1
- package/packages/core/controller-evidence.js +4 -1
- package/packages/core/dev-delivery-candidate-identity.js +40 -6
- package/packages/core/dev-delivery-warrant-state.js +3 -4
- package/packages/core/dev-delivery-warrant.js +12 -2
- package/packages/core/github-governance-authority.js +4 -4
- package/packages/core/kfd-adopter-manifest.js +46 -47
- package/packages/core/next-development-projection.js +2 -2
- package/packages/core/paper-agent-entry.js +30 -4
- package/packages/core/paper-fleet.js +1 -1
- package/packages/core/paper-runtime-channels.js +348 -0
- package/packages/core/paper-scaffold-content.js +10 -0
- package/packages/core/paper.js +37 -71
- package/packages/core/release-line-dry-run.js +1 -1
- package/packages/core/release-passport-contract.js +5 -5
- package/packages/core/release-passport.js +5 -4
- package/packages/core/release-tail-provider-plane.js +68 -1048
- package/packages/core/v4-canonical-contracts.js +10 -75
- package/packages/core/v4-domain-wasm-artifact.js +7 -0
- package/packages/core/v4-domain-wasm.js +216 -0
- package/packages/core/v4-floating-consumer-evidence.js +1 -1
- package/packages/core/v4-floating-consumer-policy.js +1 -1
- package/packages/core/v4-partial-mutation-recovery-qualification.js +9 -386
- package/packages/core/v4-product-publication.js +19 -349
- package/packages/core/v4-protected-publication-source.js +19 -21
- package/packages/core/v4-provider-operation-journal.js +18 -487
- package/packages/core/v4-provider-readback-idempotency.js +12 -97
- package/packages/core/v4-release-activation-shadow.js +13 -500
- package/packages/core/v4-release-invocation.js +28 -389
- package/packages/core/v4-stable-publication-fence.js +13 -342
- package/packages/core/v4-universal-workflow-bootstrap.js +586 -0
- package/scripts/binary-publication-evidence.mjs +135 -0
- package/scripts/build-contract-core.mjs +1 -14
- package/scripts/build-v4-domain-wasm.mjs +189 -0
- package/scripts/check-action-bundles.mjs +12 -2
- package/scripts/check-ci-lane-change-budget.mjs +4 -1
- package/scripts/check-core-mechanism-inventory.mjs +4 -3
- package/scripts/check-inventory.mjs +35 -44
- package/scripts/check-maintainability.mjs +16 -113
- package/scripts/check-v4-floating-consumer-policy-contract.mjs +2 -2
- package/scripts/check-v4-public-dogfood-contract.mjs +22 -9
- package/scripts/check-v4-release-topology.mjs +90 -33
- package/scripts/check-v4-runtime-semantic-closure.mjs +4 -1
- package/scripts/check-v4-universal-workflow-bootstrap.mjs +266 -0
- package/scripts/check-workflow-taxonomy.mjs +6 -0
- package/scripts/copy-v4-domain-wasm.mjs +14 -0
- package/scripts/dev-delivery-authority-command-adapters.mjs +1 -1
- package/scripts/dev-delivery-authority.mjs +8 -8
- package/scripts/dev-delivery-source-proof-reuse.mjs +2 -1
- package/scripts/dev-delivery-warrant-options.mjs +14 -9
- package/scripts/dev-delivery-warrant-store.mjs +73 -7
- package/scripts/dev-delivery-warrant-transition.mjs +109 -0
- package/scripts/dev-delivery-warrant.mjs +76 -99
- package/scripts/dev-pr-auto-merge.mjs +15 -15
- package/scripts/generate-channel-build-workflow.mjs +7 -2
- package/scripts/generate-channel-promotion-workflow.mjs +7 -5
- package/scripts/generate-site-bundle.mjs +11 -11
- package/scripts/generate-v4-universal-workflow-facades.mjs +458 -0
- package/scripts/generate-workflow-taxonomy.mjs +25 -0
- package/scripts/github-output.mjs +31 -0
- package/scripts/maintainability-metrics.mjs +16 -5
- package/scripts/maintainability-public-surface.mjs +115 -0
- package/scripts/next-development-review.mjs +307 -0
- package/scripts/paper-work-fleet-cli.mjs +2 -0
- package/scripts/release-asset-client.mjs +91 -0
- package/scripts/release-candidate-resolver.mjs +9 -9
- package/scripts/source-verification-evidence.mjs +344 -0
- package/scripts/stable-candidate-qualification.mjs +1 -1
- package/scripts/universal-facade-maintainability.mjs +82 -0
- package/scripts/v4-product-publication-intent.mjs +13 -6
- package/scripts/v4-publication-settlement.mjs +211 -0
- package/scripts/v4-universal-workflow-backflow.mjs +212 -0
- package/scripts/v4-universal-workflow-engine.mjs +618 -0
- package/scripts/v4-universal-workflow-self-dogfood.mjs +205 -0
- package/scripts/verify-version-state-delta.mjs +173 -0
- package/scripts/workflow-taxonomy.mjs +507 -0
- package/templates/native-dev-delivery.yml +4 -7
- package/templates/universal-buildchain-bootstrap-recovery.yml +282 -0
- package/templates/universal-buildchain-bootstrap.yml +28 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
import { currentWorkflowPath, writeWorkflowSource, rewriteRepositoryWorkflowPaths } from "./workflow-taxonomy.mjs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
const contractPath = path.join(
|
|
10
|
+
root,
|
|
11
|
+
"architecture/v4-universal-workflow-bootstrap.json",
|
|
12
|
+
);
|
|
13
|
+
const contract = JSON.parse(fs.readFileSync(contractPath, "utf8"));
|
|
14
|
+
const laneBudgetPath = path.join(
|
|
15
|
+
root,
|
|
16
|
+
"architecture/ci-lane-change-budget.json",
|
|
17
|
+
);
|
|
18
|
+
const recoveryTemplatePath = path.join(
|
|
19
|
+
root,
|
|
20
|
+
contract.bootstrap.consumerRecoveryTemplate,
|
|
21
|
+
);
|
|
22
|
+
const recoveryWorkflowPath = path.join(
|
|
23
|
+
root,
|
|
24
|
+
contract.bootstrap.consumerRecoveryWorkflow,
|
|
25
|
+
);
|
|
26
|
+
const universalInput = ` universal-request-json:
|
|
27
|
+
description: "Versioned exact-candidate request envelope; empty preserves the compatibility path"
|
|
28
|
+
default: ""
|
|
29
|
+
required: false
|
|
30
|
+
type: string
|
|
31
|
+
`;
|
|
32
|
+
const bootstrapJob = ` universal-bootstrap:
|
|
33
|
+
name: Universal exact-candidate execution
|
|
34
|
+
if: \${{ inputs.universal-request-json != '' }}
|
|
35
|
+
uses: ./.github/workflows/bootstrap.yml
|
|
36
|
+
with:
|
|
37
|
+
request-json: \${{ inputs.universal-request-json }}
|
|
38
|
+
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
function fail(message) {
|
|
42
|
+
throw new Error(message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function activeFacadePaths() {
|
|
46
|
+
const retired = new Set(contract.retiredWorkflowSurfaces || []);
|
|
47
|
+
return contract.inventoryWorkflows.filter(
|
|
48
|
+
(relative) =>
|
|
49
|
+
relative !== contract.bootstrap.publicWorkflow &&
|
|
50
|
+
relative !== contract.bootstrap.consumerRecoveryWorkflow &&
|
|
51
|
+
!retired.has(relative),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function sourceRevision() {
|
|
56
|
+
const revision = contract.migration.facadeSourceRevision;
|
|
57
|
+
if (!/^[0-9a-f]{40}$/u.test(revision || ""))
|
|
58
|
+
fail("migration.facadeSourceRevision must be an exact commit");
|
|
59
|
+
return revision;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function materializeSourceRevision() {
|
|
63
|
+
const revision = sourceRevision();
|
|
64
|
+
try {
|
|
65
|
+
execFileSync("git", ["cat-file", "-e", `${revision}^{commit}`], {
|
|
66
|
+
cwd: root,
|
|
67
|
+
stdio: "ignore",
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
} catch {}
|
|
71
|
+
try {
|
|
72
|
+
execFileSync(
|
|
73
|
+
"git",
|
|
74
|
+
["fetch", "--no-tags", "--depth=1", "origin", revision],
|
|
75
|
+
{ cwd: root, stdio: "pipe" },
|
|
76
|
+
);
|
|
77
|
+
execFileSync("git", ["cat-file", "-e", `${revision}^{commit}`], {
|
|
78
|
+
cwd: root,
|
|
79
|
+
stdio: "ignore",
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const detail = String(error?.stderr || error?.message || error).trim();
|
|
83
|
+
fail(
|
|
84
|
+
`facade source revision ${revision} is unavailable and could not be hydrated from origin${detail ? `: ${detail}` : ""}`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function frozenFacadeSource(relative) {
|
|
90
|
+
return execFileSync("git", ["show", `${sourceRevision()}:${relative}`], {
|
|
91
|
+
cwd: root,
|
|
92
|
+
encoding: "utf8",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const mutableFacades = new Set([
|
|
97
|
+
...(contract.migration.channelGeneratedFacades || []),
|
|
98
|
+
".github/workflows/dev-pr-auto-merge.yml",
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
function isMutableFacade(relative) {
|
|
102
|
+
return mutableFacades.has(relative);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function addUniversalInput(source, relative) {
|
|
106
|
+
if (source.includes(" universal-request-json:\n")) return source;
|
|
107
|
+
const workflowCall = source.match(/^(\s*)workflow_call:\s*$/mu);
|
|
108
|
+
if (!workflowCall) fail(`${relative} has no workflow_call mapping`);
|
|
109
|
+
const callIndent = workflowCall[1];
|
|
110
|
+
const inputHeader = `${callIndent} inputs:\n`;
|
|
111
|
+
const callEnd = workflowCall.index + workflowCall[0].length;
|
|
112
|
+
if (source.slice(callEnd + 1).startsWith(inputHeader)) {
|
|
113
|
+
const insertion = callEnd + 1 + inputHeader.length;
|
|
114
|
+
return `${source.slice(0, insertion)}${universalInput}${source.slice(insertion)}`;
|
|
115
|
+
}
|
|
116
|
+
return `${source.slice(0, callEnd + 1)}\n${inputHeader}${universalInput}${source.slice(callEnd + 1)}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function conditionExpression(source, relative, jobId) {
|
|
120
|
+
const child = source.match(/^(\s+)[A-Za-z0-9_-]+:/mu);
|
|
121
|
+
const indent = child?.[1] || " ";
|
|
122
|
+
const match = source.match(new RegExp(`^${indent}if:\\s*(.*)$`, "mu"));
|
|
123
|
+
if (!match)
|
|
124
|
+
return `${indent}if: \${{ inputs.universal-request-json == '' }}\n`;
|
|
125
|
+
const suffix = match[1].trim();
|
|
126
|
+
if (suffix === ">-" || suffix === "|") {
|
|
127
|
+
const start = match.index + match[0].length + 1;
|
|
128
|
+
const tail = source.slice(start);
|
|
129
|
+
const endMatch = tail.match(/^ [A-Za-z0-9_-]+:/mu);
|
|
130
|
+
const end = endMatch ? start + endMatch.index : source.length;
|
|
131
|
+
const raw = source.slice(start, end).trim();
|
|
132
|
+
const inner = raw
|
|
133
|
+
.replace(/^\$\{\{\s*/u, "")
|
|
134
|
+
.replace(/\s*\}\}$/u, "")
|
|
135
|
+
.split("\n")
|
|
136
|
+
.map((line) => line.trim())
|
|
137
|
+
.filter(Boolean)
|
|
138
|
+
.join("\n ");
|
|
139
|
+
if (!inner) fail(`${relative}#${jobId} has an empty multiline if`);
|
|
140
|
+
return {
|
|
141
|
+
start: match.index,
|
|
142
|
+
end,
|
|
143
|
+
value: `${indent}if: >-\n${indent} \${{\n${indent} inputs.universal-request-json == '' &&\n${indent} (\n${indent} ${inner}\n${indent} )\n${indent} }}\n`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const inner = suffix.startsWith("${{")
|
|
147
|
+
? suffix.replace(/^\$\{\{\s*/u, "").replace(/\s*\}\}$/u, "")
|
|
148
|
+
: suffix;
|
|
149
|
+
return {
|
|
150
|
+
start: match.index,
|
|
151
|
+
end:
|
|
152
|
+
match.index +
|
|
153
|
+
match[0].length +
|
|
154
|
+
(source[match.index + match[0].length] === "\n" ? 1 : 0),
|
|
155
|
+
value: `${indent}if: \${{ inputs.universal-request-json == '' && (${inner}) }}\n`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function guardCompatibilityJobs(source, relative) {
|
|
160
|
+
const jobs = source.match(/^jobs:\s*$/mu);
|
|
161
|
+
if (!jobs) fail(`${relative} has no jobs mapping`);
|
|
162
|
+
const bodyStart = jobs.index + jobs[0].length + 1;
|
|
163
|
+
const body = source.slice(bodyStart);
|
|
164
|
+
const headers = [...body.matchAll(/^ ([A-Za-z0-9_-]+):\s*$/gmu)];
|
|
165
|
+
if (headers.length === 0) fail(`${relative} has no jobs`);
|
|
166
|
+
let rewritten = body;
|
|
167
|
+
for (let index = headers.length - 1; index >= 0; index -= 1) {
|
|
168
|
+
const header = headers[index];
|
|
169
|
+
if (header[1] === "universal-bootstrap") continue;
|
|
170
|
+
const start = header.index + header[0].length + 1;
|
|
171
|
+
const end = headers[index + 1]?.index ?? body.length;
|
|
172
|
+
const job = body.slice(start, end);
|
|
173
|
+
if (job.includes("inputs.universal-request-json == ''")) continue;
|
|
174
|
+
const condition = conditionExpression(job, relative, header[1]);
|
|
175
|
+
if (typeof condition === "string") {
|
|
176
|
+
rewritten = `${rewritten.slice(0, start)}${condition}${rewritten.slice(start)}`;
|
|
177
|
+
} else {
|
|
178
|
+
rewritten = `${rewritten.slice(0, start + condition.start)}${condition.value}${rewritten.slice(start + condition.end)}`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const withGuards = `${source.slice(0, bodyStart)}${rewritten}`;
|
|
182
|
+
return withGuards.includes(" universal-bootstrap:\n")
|
|
183
|
+
? withGuards
|
|
184
|
+
: `${withGuards.slice(0, bodyStart)}${bootstrapJob}${withGuards.slice(bodyStart)}`;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function addRuntimeBootstrapDependencies(source, relative) {
|
|
188
|
+
if (
|
|
189
|
+
relative !== ".github/workflows/.build.yml" ||
|
|
190
|
+
source.includes(
|
|
191
|
+
".buildchain/workflow-shell/scripts/github-output.mjs\n",
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
return source;
|
|
195
|
+
const anchor =
|
|
196
|
+
" .buildchain/workflow-shell/scripts/build-contract-core.mjs\n";
|
|
197
|
+
return source.replace(
|
|
198
|
+
anchor,
|
|
199
|
+
`${anchor} .buildchain/workflow-shell/scripts/github-output.mjs\n`,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function applyPublicationFacadePatches(source, relative) {
|
|
204
|
+
const document = JSON.parse(fs.readFileSync(path.join(root,
|
|
205
|
+
"architecture/v4-publication-facade-patches.json"), "utf8"));
|
|
206
|
+
const patch = document.facades.find(entry => entry.workflow === relative);
|
|
207
|
+
if (!patch) return source;
|
|
208
|
+
const digest = value => crypto.createHash("sha256").update(value).digest("hex");
|
|
209
|
+
if (digest(source) === patch.afterSha256) return source;
|
|
210
|
+
if (digest(source) !== patch.beforeSha256) fail(`${relative}: publication facade source drift`);
|
|
211
|
+
for (const { before, after } of patch.replacements) {
|
|
212
|
+
if (source.split(before).length !== 2) fail(`${relative}: ambiguous publication patch`);
|
|
213
|
+
source = source.replace(before, () => after);
|
|
214
|
+
}
|
|
215
|
+
if (digest(source) !== patch.afterSha256) fail(`${relative}: publication facade result drift`);
|
|
216
|
+
return source;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function migrateV4UniversalWorkflowFacade(source, relative) {
|
|
220
|
+
return rewriteRepositoryWorkflowPaths(root, applyPublicationFacadePatches(guardCompatibilityJobs(
|
|
221
|
+
addUniversalInput(addRuntimeBootstrapDependencies(source, relative), relative),
|
|
222
|
+
relative,
|
|
223
|
+
), relative));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function verify(source, relative) {
|
|
227
|
+
for (const snippet of [
|
|
228
|
+
" universal-request-json:\n",
|
|
229
|
+
" universal-bootstrap:\n",
|
|
230
|
+
"uses: ./.github/workflows/bootstrap.yml",
|
|
231
|
+
]) {
|
|
232
|
+
if (!source.includes(snippet))
|
|
233
|
+
fail(`${relative} is missing ${snippet.trim()}`);
|
|
234
|
+
}
|
|
235
|
+
const jobs = source.slice(source.search(/^jobs:\s*$/mu));
|
|
236
|
+
const headers = [...jobs.matchAll(/^ ([A-Za-z0-9_-]+):\s*$/gmu)];
|
|
237
|
+
for (let index = 0; index < headers.length; index += 1) {
|
|
238
|
+
const header = headers[index];
|
|
239
|
+
if (header[1] === "universal-bootstrap") continue;
|
|
240
|
+
const end = headers[index + 1]?.index ?? jobs.length;
|
|
241
|
+
const block = jobs.slice(header.index, end);
|
|
242
|
+
if (!block.includes("inputs.universal-request-json == ''"))
|
|
243
|
+
fail(`${relative}#${header[1]} can overlap universal execution`);
|
|
244
|
+
}
|
|
245
|
+
if (!isMutableFacade(relative)) {
|
|
246
|
+
const expected = migrateV4UniversalWorkflowFacade(
|
|
247
|
+
frozenFacadeSource(relative),
|
|
248
|
+
relative,
|
|
249
|
+
);
|
|
250
|
+
if (source !== expected)
|
|
251
|
+
fail(
|
|
252
|
+
`${relative} differs from the exact generated facade rooted at ${sourceRevision()}`,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function laneBudget({ laneId, authorityClass, triggerClass, minutes, metric }) {
|
|
258
|
+
return {
|
|
259
|
+
laneId,
|
|
260
|
+
authorityClass,
|
|
261
|
+
triggerClass,
|
|
262
|
+
concurrencyPolicy: { mode: "none", cancelInProgress: false },
|
|
263
|
+
expectedRunnerMinutes: minutes,
|
|
264
|
+
cancellationBehavior: "finish-started",
|
|
265
|
+
sloImpact: {
|
|
266
|
+
mergeCritical: false,
|
|
267
|
+
metric,
|
|
268
|
+
expectedContributionSeconds: 0,
|
|
269
|
+
rationale:
|
|
270
|
+
"The opt-in universal path preserves the default compatibility lane and executes only an exact admitted runtime.",
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function updateLaneBudgets() {
|
|
276
|
+
const policy = JSON.parse(fs.readFileSync(laneBudgetPath, "utf8"));
|
|
277
|
+
const mixed = new Set([
|
|
278
|
+
".github/workflows/release-governance-reconcile.yml",
|
|
279
|
+
".github/workflows/v4-adopter-delivery.yml",
|
|
280
|
+
]);
|
|
281
|
+
const facadeLanes = activeFacadePaths().map(
|
|
282
|
+
(relative) => `${relative}#universal-bootstrap`,
|
|
283
|
+
);
|
|
284
|
+
policy.declarationFamilies = [
|
|
285
|
+
{
|
|
286
|
+
...laneBudget({
|
|
287
|
+
laneId: "",
|
|
288
|
+
authorityClass: "governed-delegation",
|
|
289
|
+
triggerClass: "reusable",
|
|
290
|
+
minutes: 60,
|
|
291
|
+
metric: "opt-in exact-candidate execution latency",
|
|
292
|
+
}),
|
|
293
|
+
laneIds: facadeLanes.filter(
|
|
294
|
+
(laneId) => !mixed.has(laneId.split("#", 1)[0]),
|
|
295
|
+
),
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
...laneBudget({
|
|
299
|
+
laneId: "",
|
|
300
|
+
authorityClass: "governed-delegation",
|
|
301
|
+
triggerClass: "mixed",
|
|
302
|
+
minutes: 60,
|
|
303
|
+
metric: "mixed-trigger exact-candidate execution latency",
|
|
304
|
+
}),
|
|
305
|
+
laneIds: facadeLanes.filter((laneId) =>
|
|
306
|
+
mixed.has(laneId.split("#", 1)[0]),
|
|
307
|
+
),
|
|
308
|
+
},
|
|
309
|
+
].map(({ laneId: _laneId, ...family }) => family);
|
|
310
|
+
const universalLaneIds = new Set([
|
|
311
|
+
".github/workflows/bootstrap.yml#admit",
|
|
312
|
+
".github/workflows/bootstrap.yml#execute",
|
|
313
|
+
".github/workflows/bootstrap.yml#settle",
|
|
314
|
+
".github/workflows/universal-bootstrap-recovery.yml#recovery-admit",
|
|
315
|
+
".github/workflows/universal-bootstrap-recovery.yml#recovery-execute",
|
|
316
|
+
".github/workflows/universal-bootstrap-recovery.yml#recovery-settle",
|
|
317
|
+
".github/workflows/universal-bootstrap-dogfood.yml#public-bootstrap",
|
|
318
|
+
".github/workflows/universal-bootstrap-dogfood.yml#prepare",
|
|
319
|
+
".github/workflows/universal-bootstrap-dogfood.yml#primary-conformance",
|
|
320
|
+
".github/workflows/universal-bootstrap-dogfood.yml#recovery-conformance",
|
|
321
|
+
".github/workflows/universal-bootstrap-dogfood.yml#primary-alpha",
|
|
322
|
+
".github/workflows/universal-bootstrap-dogfood.yml#recovery-alpha",
|
|
323
|
+
".github/workflows/universal-bootstrap-dogfood.yml#primary-stable",
|
|
324
|
+
".github/workflows/universal-bootstrap-dogfood.yml#recovery-stable",
|
|
325
|
+
".github/workflows/universal-bootstrap-dogfood.yml#reconcile",
|
|
326
|
+
]);
|
|
327
|
+
policy.declarations = policy.declarations.filter(
|
|
328
|
+
({ laneId }) => !universalLaneIds.has(laneId),
|
|
329
|
+
);
|
|
330
|
+
policy.declarations.push(
|
|
331
|
+
laneBudget({
|
|
332
|
+
laneId: ".github/workflows/bootstrap.yml#admit",
|
|
333
|
+
authorityClass: "evidence",
|
|
334
|
+
triggerClass: "reusable",
|
|
335
|
+
minutes: 10,
|
|
336
|
+
metric: "exact-candidate admission latency",
|
|
337
|
+
}),
|
|
338
|
+
laneBudget({
|
|
339
|
+
laneId: ".github/workflows/bootstrap.yml#execute",
|
|
340
|
+
authorityClass: "governed-delegation",
|
|
341
|
+
triggerClass: "reusable",
|
|
342
|
+
minutes: 60,
|
|
343
|
+
metric: "exact-candidate execution latency",
|
|
344
|
+
}),
|
|
345
|
+
laneBudget({
|
|
346
|
+
laneId: ".github/workflows/bootstrap.yml#settle",
|
|
347
|
+
authorityClass: "evidence",
|
|
348
|
+
triggerClass: "reusable",
|
|
349
|
+
minutes: 10,
|
|
350
|
+
metric: "universal terminal settlement latency",
|
|
351
|
+
}),
|
|
352
|
+
laneBudget({
|
|
353
|
+
laneId:
|
|
354
|
+
".github/workflows/universal-bootstrap-recovery.yml#recovery-admit",
|
|
355
|
+
authorityClass: "evidence",
|
|
356
|
+
triggerClass: "reusable",
|
|
357
|
+
minutes: 10,
|
|
358
|
+
metric: "consumer-owned exact-candidate admission latency",
|
|
359
|
+
}),
|
|
360
|
+
laneBudget({
|
|
361
|
+
laneId:
|
|
362
|
+
".github/workflows/universal-bootstrap-recovery.yml#recovery-execute",
|
|
363
|
+
authorityClass: "governed-delegation",
|
|
364
|
+
triggerClass: "reusable",
|
|
365
|
+
minutes: 60,
|
|
366
|
+
metric: "consumer-owned exact-candidate execution latency",
|
|
367
|
+
}),
|
|
368
|
+
laneBudget({
|
|
369
|
+
laneId:
|
|
370
|
+
".github/workflows/universal-bootstrap-recovery.yml#recovery-settle",
|
|
371
|
+
authorityClass: "evidence",
|
|
372
|
+
triggerClass: "reusable",
|
|
373
|
+
minutes: 10,
|
|
374
|
+
metric: "consumer-owned terminal settlement latency",
|
|
375
|
+
}),
|
|
376
|
+
laneBudget({
|
|
377
|
+
laneId: ".github/workflows/universal-bootstrap-dogfood.yml#prepare",
|
|
378
|
+
authorityClass: "evidence",
|
|
379
|
+
triggerClass: "mixed",
|
|
380
|
+
minutes: 10,
|
|
381
|
+
metric: "Train-first self-dogfood admission latency",
|
|
382
|
+
}),
|
|
383
|
+
...[
|
|
384
|
+
"primary-conformance",
|
|
385
|
+
"recovery-conformance",
|
|
386
|
+
"primary-alpha",
|
|
387
|
+
"recovery-alpha",
|
|
388
|
+
"primary-stable",
|
|
389
|
+
"recovery-stable",
|
|
390
|
+
].map((job) =>
|
|
391
|
+
laneBudget({
|
|
392
|
+
laneId: `.github/workflows/universal-bootstrap-dogfood.yml#${job}`,
|
|
393
|
+
authorityClass: "governed-delegation",
|
|
394
|
+
triggerClass: "mixed",
|
|
395
|
+
minutes: 60,
|
|
396
|
+
metric: "Train-first exact-candidate self-dogfood latency",
|
|
397
|
+
}),
|
|
398
|
+
),
|
|
399
|
+
laneBudget({
|
|
400
|
+
laneId: ".github/workflows/universal-bootstrap-dogfood.yml#reconcile",
|
|
401
|
+
authorityClass: "evidence",
|
|
402
|
+
triggerClass: "mixed",
|
|
403
|
+
minutes: 10,
|
|
404
|
+
metric: "primary and recovery equivalence latency",
|
|
405
|
+
}),
|
|
406
|
+
);
|
|
407
|
+
fs.writeFileSync(laneBudgetPath, `${JSON.stringify(policy, null, 2)}\n`);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function main() {
|
|
411
|
+
const check = process.argv.includes("--check");
|
|
412
|
+
const fresh = process.argv.includes("--fresh");
|
|
413
|
+
materializeSourceRevision();
|
|
414
|
+
if (check) {
|
|
415
|
+
if (
|
|
416
|
+
fs.readFileSync(recoveryWorkflowPath, "utf8") !==
|
|
417
|
+
fs.readFileSync(recoveryTemplatePath, "utf8")
|
|
418
|
+
)
|
|
419
|
+
fail(
|
|
420
|
+
"consumer recovery workflow differs from its pre-positioned template",
|
|
421
|
+
);
|
|
422
|
+
} else {
|
|
423
|
+
writeWorkflowSource(
|
|
424
|
+
root, path.relative(root, recoveryWorkflowPath),
|
|
425
|
+
fs.readFileSync(recoveryTemplatePath, "utf8"),
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
for (const relative of activeFacadePaths()) {
|
|
429
|
+
const current = currentWorkflowPath(root, relative);
|
|
430
|
+
const target = path.join(root, current);
|
|
431
|
+
const source = fresh
|
|
432
|
+
? frozenFacadeSource(relative)
|
|
433
|
+
: fs.readFileSync(target, "utf8");
|
|
434
|
+
if (check) verify(source, relative);
|
|
435
|
+
else
|
|
436
|
+
writeWorkflowSource(
|
|
437
|
+
root, current,
|
|
438
|
+
migrateV4UniversalWorkflowFacade(source, relative),
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
if (!check) {
|
|
442
|
+
contract.bootstrapGovernedWorkflows = [
|
|
443
|
+
contract.bootstrap.publicWorkflow,
|
|
444
|
+
...activeFacadePaths(),
|
|
445
|
+
].sort();
|
|
446
|
+
contract.migration.compatibilityFacades = "generated-dual-path";
|
|
447
|
+
fs.writeFileSync(contractPath, `${JSON.stringify(contract, null, 2)}\n`);
|
|
448
|
+
updateLaneBudgets();
|
|
449
|
+
process.stdout.write(
|
|
450
|
+
`${JSON.stringify({ migrated: activeFacadePaths().length })}\n`,
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const isMain =
|
|
456
|
+
process.argv[1] &&
|
|
457
|
+
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
458
|
+
if (isMain) main();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import {
|
|
5
|
+
readWorkflowTaxonomy,
|
|
6
|
+
renderWorkflowCatalog,
|
|
7
|
+
TAXONOMY_DOC,
|
|
8
|
+
workflowPath,
|
|
9
|
+
writeWorkflowSource,
|
|
10
|
+
} from "./workflow-taxonomy.mjs";
|
|
11
|
+
|
|
12
|
+
const root = process.cwd();
|
|
13
|
+
const policy = readWorkflowTaxonomy(root);
|
|
14
|
+
if (!policy) throw new Error("workflow taxonomy is missing");
|
|
15
|
+
for (const entry of policy.entries) {
|
|
16
|
+
writeWorkflowSource(
|
|
17
|
+
root,
|
|
18
|
+
workflowPath(entry),
|
|
19
|
+
fs.readFileSync(path.join(root, workflowPath(entry)), "utf8"),
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
fs.writeFileSync(path.join(root, TAXONOMY_DOC), renderWorkflowCatalog(policy));
|
|
23
|
+
process.stdout.write(
|
|
24
|
+
`Generated ${policy.entries.length} canonical workflow declarations and their exact compatibility projections.\n`,
|
|
25
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
|
|
4
|
+
function githubOutputRecord(key, value) {
|
|
5
|
+
const normalized = String(value ?? "");
|
|
6
|
+
if (!/[\r\n]/u.test(normalized)) return `${key}=${normalized}\n`;
|
|
7
|
+
const valueLines = normalized.split(/\r\n|\r|\n/u);
|
|
8
|
+
let delimiter = `BUILDCHAIN_OUTPUT_${crypto
|
|
9
|
+
.createHash("sha256")
|
|
10
|
+
.update(`${key}\0${normalized}`)
|
|
11
|
+
.digest("hex")}`;
|
|
12
|
+
while (valueLines.includes(delimiter)) delimiter += "_";
|
|
13
|
+
const separator = normalized.endsWith("\n") ? "" : "\n";
|
|
14
|
+
return `${key}<<${delimiter}\n${normalized}${separator}${delimiter}\n`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function writeGitHubOutputs(outputs) {
|
|
18
|
+
const outputPath = process.env.GITHUB_OUTPUT;
|
|
19
|
+
if (!outputPath) {
|
|
20
|
+
for (const [key, value] of Object.entries(outputs)) {
|
|
21
|
+
console.log(`${key}=${value}`);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
fs.appendFileSync(
|
|
26
|
+
outputPath,
|
|
27
|
+
Object.entries(outputs)
|
|
28
|
+
.map(([key, value]) => githubOutputRecord(key, value))
|
|
29
|
+
.join(""),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { projectWorkflowIdentities } from "./workflow-taxonomy.mjs";
|
|
2
3
|
|
|
3
4
|
import fs from "node:fs";
|
|
4
5
|
import path from "node:path";
|
|
@@ -280,10 +281,17 @@ function collectMaintainabilityMetrics({
|
|
|
280
281
|
analyzeJavaScript(file, readTrackedFile(root, file, revision)),
|
|
281
282
|
]),
|
|
282
283
|
);
|
|
284
|
+
const physicalWorkflows = workflowFiles.map((file) => ({
|
|
285
|
+
path: file,
|
|
286
|
+
text: readTrackedFile(root, file, revision),
|
|
287
|
+
}));
|
|
288
|
+
const logicalWorkflows = revision
|
|
289
|
+
? physicalWorkflows
|
|
290
|
+
: projectWorkflowIdentities(root, physicalWorkflows);
|
|
283
291
|
const workflowMetrics = Object.fromEntries(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
analyzeWorkflow(
|
|
292
|
+
logicalWorkflows.map((entry) => [
|
|
293
|
+
entry.path,
|
|
294
|
+
analyzeWorkflow(entry.path, entry.text),
|
|
287
295
|
]),
|
|
288
296
|
);
|
|
289
297
|
const sumLines = (entries) =>
|
|
@@ -316,8 +324,11 @@ function collectMaintainabilityMetrics({
|
|
|
316
324
|
),
|
|
317
325
|
testFiles: testFiles.length,
|
|
318
326
|
testLines: sumLines(testFiles),
|
|
319
|
-
workflowFiles:
|
|
320
|
-
workflowLines:
|
|
327
|
+
workflowFiles: logicalWorkflows.length,
|
|
328
|
+
workflowLines: logicalWorkflows.reduce(
|
|
329
|
+
(total, entry) => total + lineCount(entry.text),
|
|
330
|
+
0,
|
|
331
|
+
),
|
|
321
332
|
documentationFiles: documentationFiles.length,
|
|
322
333
|
documentationLines: sumLines(documentationFiles),
|
|
323
334
|
generatedFiles: generatedFiles.length,
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
isGeneratedFacadePublicTransition,
|
|
6
|
+
loadUniversalFacadeMigration,
|
|
7
|
+
} from "./universal-facade-maintainability.mjs";
|
|
8
|
+
|
|
9
|
+
function readJson(root, file) {
|
|
10
|
+
return JSON.parse(fs.readFileSync(path.join(root, file), "utf8"));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function readJsonAtRevision(root, revision, file) {
|
|
14
|
+
return JSON.parse(
|
|
15
|
+
execFileSync("git", ["show", `${revision}:${file}`], {
|
|
16
|
+
cwd: root,
|
|
17
|
+
encoding: "utf8",
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function publicSurfaceContract(entry, kind) {
|
|
23
|
+
if (kind === "cli") return { id: entry.id, usage: entry.usage };
|
|
24
|
+
if (kind === "node")
|
|
25
|
+
return {
|
|
26
|
+
export: entry.export,
|
|
27
|
+
specifier: entry.specifier,
|
|
28
|
+
target: entry.target,
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
id: entry.id,
|
|
32
|
+
path: entry.path,
|
|
33
|
+
reusable: entry.reusable,
|
|
34
|
+
inputs: entry.inputs || [],
|
|
35
|
+
secrets: entry.secrets || [],
|
|
36
|
+
outputs: entry.outputs || [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function evaluatePublicSurface({
|
|
41
|
+
root,
|
|
42
|
+
revision,
|
|
43
|
+
policy,
|
|
44
|
+
migration = loadUniversalFacadeMigration(root),
|
|
45
|
+
}) {
|
|
46
|
+
const issues = [];
|
|
47
|
+
const capabilityGroups = new Set(
|
|
48
|
+
readJson(root, "dist/site/capability-registry.json").groups.map(
|
|
49
|
+
(entry) => entry.id,
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
const definitions = [
|
|
53
|
+
["dist/site/cli-registry.json", "commands", "cli", "id"],
|
|
54
|
+
["dist/site/node-api-registry.json", "exports", "node", "export"],
|
|
55
|
+
["dist/site/workflow-registry.json", "workflows", "workflow", "id"],
|
|
56
|
+
["dist/site/workflow-registry.json", "actions", "action", "id"],
|
|
57
|
+
];
|
|
58
|
+
for (const [file, collection, kind, key] of definitions) {
|
|
59
|
+
const current = readJson(root, file)[collection] || [];
|
|
60
|
+
const baseline = readJsonAtRevision(root, revision, file)[collection] || [];
|
|
61
|
+
const previousByKey = new Map(baseline.map((entry) => [entry[key], entry]));
|
|
62
|
+
for (const entry of current) {
|
|
63
|
+
const label = `${kind}:${entry[key]}`;
|
|
64
|
+
for (const field of policy.publicSurfacePolicy.requiredLifecycleFields) {
|
|
65
|
+
if (
|
|
66
|
+
!Object.prototype.hasOwnProperty.call(entry, field) ||
|
|
67
|
+
typeof entry[field] !== "string"
|
|
68
|
+
)
|
|
69
|
+
issues.push(`${label}: lifecycle field ${field} is missing`);
|
|
70
|
+
}
|
|
71
|
+
if (!capabilityGroups.has(entry.capabilityGroup))
|
|
72
|
+
issues.push(
|
|
73
|
+
`${label}: capability group ${entry.capabilityGroup || "<empty>"} is not registered`,
|
|
74
|
+
);
|
|
75
|
+
const previous = previousByKey.get(entry[key]);
|
|
76
|
+
const currentContract = publicSurfaceContract(entry, kind);
|
|
77
|
+
if (
|
|
78
|
+
previous &&
|
|
79
|
+
JSON.stringify(currentContract) !==
|
|
80
|
+
JSON.stringify(publicSurfaceContract(previous, kind))
|
|
81
|
+
) {
|
|
82
|
+
const approval = policy.approvedPublicSurfaceTransitions?.[label];
|
|
83
|
+
const approvedContract =
|
|
84
|
+
approval?.fromRevision === revision &&
|
|
85
|
+
String(approval?.rationale || "").trim()
|
|
86
|
+
? approval.contract
|
|
87
|
+
: null;
|
|
88
|
+
const generated = isGeneratedFacadePublicTransition({
|
|
89
|
+
entry,
|
|
90
|
+
kind,
|
|
91
|
+
migration,
|
|
92
|
+
baseContract:
|
|
93
|
+
approvedContract || publicSurfaceContract(previous, kind),
|
|
94
|
+
currentContract,
|
|
95
|
+
});
|
|
96
|
+
if (
|
|
97
|
+
!generated &&
|
|
98
|
+
(!approvedContract ||
|
|
99
|
+
JSON.stringify(approvedContract) !==
|
|
100
|
+
JSON.stringify(currentContract))
|
|
101
|
+
)
|
|
102
|
+
issues.push(
|
|
103
|
+
`${label}: existing public contract drifted from ${revision}`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (!previous && !entry.nonDuplicationRationale)
|
|
107
|
+
issues.push(
|
|
108
|
+
`${label}: new public surface requires a non-duplication rationale`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return issues;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { evaluatePublicSurface, publicSurfaceContract };
|