@kungfu-tech/buildchain 3.0.9-alpha.8 → 4.0.0-alpha.0
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 +39 -0
- package/README.md +17 -13
- package/actions/promote-buildchain-ref/README.md +0 -10
- package/actions/release-tail/README.md +6 -10
- package/architecture/internal-capabilities.json +502 -0
- package/architecture/maintainability-baseline.json +59 -0
- package/architecture/maintainability-policy.json +1384 -0
- package/architecture/release-tail-contract-inventory.json +587 -0
- package/architecture/v3-core-mechanism-inventory.json +1043 -0
- package/architecture/v3-core-mechanism-inventory.md +67 -0
- package/architecture/v4-adopter-delivery-parity.json +47 -0
- package/architecture/v4-architecture-constitution.md +210 -0
- package/architecture/v4-bootstrap-authority.json +56 -0
- package/architecture/v4-canonical-contract-fixtures.json +105 -0
- package/architecture/v4-capability-state-machine-manifest.json +480 -0
- package/architecture/v4-capability-state-machine-manifest.schema.json +202 -0
- package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.json +830 -0
- package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.md +223 -0
- package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.schema.json +318 -0
- package/architecture/v4-delivery-warrant-shadow-fixtures.json +227 -0
- package/architecture/v4-delivery-warrant-shadow-fixtures.schema.json +67 -0
- package/architecture/v4-exception-ledger.json +5 -0
- package/architecture/v4-exception-ledger.schema.json +56 -0
- package/architecture/v4-partial-mutation-recovery-qualification.json +65 -0
- package/architecture/v4-platform-stage-checkpoints.json +97 -0
- package/architecture/v4-provider-operation-journal-contract.json +113 -0
- package/architecture/v4-release-activation-shadow-domain.json +61 -0
- package/architecture/v4-release-train-parity.json +68 -0
- package/architecture/v4-rust-libnode-bridge-evaluation.json +107 -0
- package/architecture/v4-rust-libnode-bridge-spike.md +85 -0
- package/architecture/v4-stable-publication-fence.json +66 -0
- package/architecture/v4-stage-capsule-contract.json +90 -0
- package/architecture/v4-stage-capsule-qualification.json +99 -0
- package/architecture/v4-stage-capsule-resume-planner.json +52 -0
- package/architecture/v4-stage-capsule-store-contract.json +72 -0
- package/bin/buildchain.mjs +15 -6
- package/contracts/auditable-demo-scenario-v1.schema.json +1 -1
- package/contracts/buildchain-v2-residuals-v1.json +2 -2
- package/contracts/fixtures/v4-delivery-warrant-trace-v1/golden.json +158 -0
- package/contracts/fixtures/v4-delivery-warrant-trace-v1/property.json +380 -0
- package/contracts/fixtures/v4-delivery-warrant-trace-v1/replay.json +163 -0
- package/contracts/fixtures/v4-partial-mutation-recovery-v1/shared.json +155 -0
- package/contracts/fixtures/v4-provider-operation-journal-v1/shared.json +457 -0
- package/contracts/fixtures/v4-provider-readback-idempotency-v1/shared.json +682 -0
- package/contracts/fixtures/v4-release-activation-shadow-v1/shared.json +53 -0
- package/contracts/fixtures/v4-stable-publication-fence-v1/shared.json +56 -0
- package/contracts/fixtures/v4-stage-capsule-resume-v1/late-platform-failure.json +176 -0
- package/contracts/fixtures/v4-stage-capsule-store-v1/shared.json +132 -0
- package/contracts/fixtures/v4-stage-capsule-v1/shared.json +111 -0
- package/contracts/v4-canonical-contracts-v1.schema.json +182 -0
- package/contracts/v4-delivery-warrant-semantic-diff-report-v1.schema.json +284 -0
- package/contracts/v4-delivery-warrant-trace-v1.schema.json +215 -0
- package/contracts/v4-host-contract-v1.schema.json +135 -0
- package/contracts/v4-partial-mutation-recovery-v1.schema.json +168 -0
- package/contracts/v4-provider-operation-journal-v1.schema.json +381 -0
- package/contracts/v4-release-activation-shadow-v1.schema.json +186 -0
- package/contracts/v4-stable-publication-fence-v1.schema.json +125 -0
- package/contracts/v4-stage-capsule-resume-v1.schema.json +225 -0
- package/contracts/v4-stage-capsule-store-v1.schema.json +154 -0
- package/contracts/v4-stage-capsule-v1.schema.json +178 -0
- package/crates/buildchain-v4-bridge/Cargo.lock +213 -0
- package/crates/buildchain-v4-bridge/Cargo.toml +12 -0
- package/crates/buildchain-v4-bridge/src/main.rs +495 -0
- package/dist/site/agent-index.json +0 -3
- package/dist/site/artifact-schemas.json +0 -6
- package/dist/site/buildchain-contract.json +103 -397
- package/dist/site/buildchain-site.json +302 -270
- package/dist/site/capability-registry.json +9 -11
- package/dist/site/cli-registry.json +8 -30
- package/dist/site/controller-registry.json +48 -8
- package/dist/site/kfd-claims.json +129 -142
- package/dist/site/kfd-upstream-aggregate.json +9 -9
- package/dist/site/manual-registry.json +18 -49
- package/dist/site/node-api-registry.json +1882 -4118
- package/dist/site/page-registry.json +278 -230
- package/dist/site/public-surface-audit.json +87 -185
- package/dist/site/publication-authority-registry.json +11 -1
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/release-provenance.json +3 -7
- package/dist/site/schemas/kfd-support-projection-v1.schema.json +106 -0
- package/dist/site/site-manifest.json +22 -38
- package/dist/site/workflow-registry.json +80 -35
- package/docs/MAP.md +8 -4
- package/docs/auditable-demo.md +2 -2
- package/docs/aws-us-elastic-runner-burst-plane.md +7 -59
- package/docs/cli-reference.md +15 -92
- package/docs/cli.md +14 -14
- package/docs/dev-alpha-candidate-patrol.md +3 -11
- package/docs/dev-delivery-warrant.md +28 -100
- package/docs/engineering-housekeeper.md +12 -4
- package/docs/getting-started.md +1 -1
- package/docs/install.md +5 -5
- package/docs/kfd-support.md +2 -7
- package/docs/lifecycle-protocol.md +2 -4
- package/docs/node-api-reference.md +414 -523
- package/docs/release-flow.md +31 -31
- package/docs/release-governance.md +16 -28
- package/docs/release-passport.md +2 -15
- package/docs/release-tail-contract.md +13 -6
- package/docs/release-tail-provider-plane.md +13 -19
- package/docs/release-train.md +4 -4
- package/docs/reusable-build-surface.md +14 -27
- package/docs/site-bundle-contract.md +1 -5
- package/docs/stable-candidate-patrol.md +7 -7
- package/docs/v4-canonical-contracts.md +92 -0
- package/docs/v4-delivery-warrant-read-candidate.md +73 -0
- package/docs/v4-delivery-warrant-semantic-diff.md +75 -0
- package/docs/v4-production-release.md +63 -0
- package/docs/v4-stage-capsule.md +193 -0
- package/docs/versioning.md +3 -3
- package/package.json +19 -17
- package/packages/core/adopter-delivery-gate.js +576 -0
- package/packages/core/adopter-delivery-json.js +66 -0
- package/packages/core/artifact-signing.js +0 -61
- package/packages/core/artifact-verification-envelope.js +5 -5
- package/packages/core/build-facts.js +12 -4
- package/packages/core/buildchain-agent-manuals.js +0 -2
- package/packages/core/buildchain-config.js +4 -69
- package/packages/core/buildchain-contract.js +232 -46
- package/packages/core/buildchain-kfd-claims.js +1 -1
- package/packages/core/channel-candidate.js +0 -8
- package/packages/core/channel-promotion-baseline.js +0 -52
- package/packages/core/controller-evidence.js +3 -4
- package/packages/core/dev-alpha-candidate-selection.js +2 -10
- package/packages/core/dev-delivery-warrant-cancellation.js +0 -1
- package/packages/core/dev-delivery-warrant-settlement.js +1 -5
- package/packages/core/dev-delivery-warrant.js +12 -52
- package/packages/core/diagnostics.js +3 -8
- package/packages/core/github-governance-authority.js +3 -1
- package/packages/core/kfd-adopter-category-driver.js +167 -0
- package/packages/core/kfd-adopter-manifest.js +47 -46
- package/packages/core/kfd-gate.js +15 -45
- package/packages/core/paper-agent-entry.js +7 -16
- package/packages/core/paper-fleet.js +2 -2
- package/packages/core/paper-repository.js +2 -3
- package/packages/core/paper-scaffold-content.js +2 -23
- package/packages/core/paper.js +11 -43
- package/packages/core/publication-reproducibility.js +4 -4
- package/packages/core/release-line-bootstrap.js +21 -8
- package/packages/core/release-passport-contract.js +5 -5
- package/packages/core/release-passport.js +20 -131
- package/packages/core/self-dogfood-version.js +48 -35
- package/packages/core/spawn-command.js +232 -8
- package/packages/core/v4-adopter-delivery-parity.js +219 -0
- package/packages/core/v4-canonical-contracts.js +284 -0
- package/packages/core/v4-delivery-warrant-fixture-runner.js +371 -0
- package/packages/core/v4-delivery-warrant-read-candidate.js +279 -0
- package/packages/core/v4-delivery-warrant-semantic-diff-gate.js +352 -0
- package/packages/core/v4-delivery-warrant-shadow-adapter.js +447 -0
- package/packages/core/v4-partial-mutation-recovery-qualification.js +395 -0
- package/packages/core/v4-platform-stage-checkpoints.js +471 -0
- package/packages/core/v4-provider-operation-journal.js +531 -0
- package/packages/core/v4-provider-readback-idempotency.js +394 -0
- package/packages/core/v4-release-activation-shadow.js +519 -0
- package/packages/core/v4-stable-publication-fence.js +357 -0
- package/packages/core/v4-stage-capsule-local-store.js +426 -0
- package/packages/core/v4-stage-capsule-qualification-campaign.js +512 -0
- package/packages/core/v4-stage-capsule-qualification.js +456 -0
- package/packages/core/v4-stage-capsule-resume-planner.js +397 -0
- package/packages/core/v4-stage-capsule-store.js +401 -0
- package/packages/core/v4-stage-capsule.js +319 -0
- package/scripts/assemble-self-publication-admission.mjs +1 -1
- package/scripts/audit-publication-control-plane.mjs +5 -5
- package/scripts/auditable-demo-bundle-verification.mjs +3 -2
- package/scripts/auditable-demo-platform.mjs +2 -2
- package/scripts/auditable-demo-renditions.mjs +1 -1
- package/scripts/auditable-demo.mjs +2 -2
- package/scripts/aws-macos-jit-controller-core.mjs +13 -346
- package/scripts/aws-macos-jit-controller-runtime.mjs +2 -210
- package/scripts/aws-macos-jit-controller.mjs +37 -275
- package/scripts/aws-macos-jit-core.mjs +3 -41
- package/scripts/aws-macos-jit.mjs +0 -12
- package/scripts/aws-windows-jit-campaign.mjs +2 -2
- package/scripts/aws-windows-jit-controller-core.mjs +1 -1
- package/scripts/aws-windows-jit-controller.mjs +3 -3
- package/scripts/build-contract-core.mjs +3 -8
- package/scripts/build-standalone-binary.mjs +3 -14
- package/scripts/buildchain-channel-router.mjs +4 -0
- package/scripts/buildchain-cli-help.mjs +7 -13
- package/scripts/buildchain-contract-lock.mjs +0 -6
- package/scripts/check-action-bundles.mjs +3 -4
- package/scripts/check-internal-architecture.mjs +7 -6
- package/scripts/check-inventory.mjs +30 -25
- package/scripts/check-v4-public-dogfood-contract.mjs +270 -0
- package/scripts/create-release-bundle.mjs +8 -4
- package/scripts/dev-alpha-candidate-patrol.mjs +1 -22
- package/scripts/dev-delivery-proof.mjs +2 -54
- package/scripts/dev-delivery-warrant.mjs +59 -77
- package/scripts/dev-pr-auto-merge.mjs +4 -30
- package/scripts/dev-pr-delivery-warrant.mjs +0 -55
- package/scripts/dispatch-artifact-signing-authority.mjs +7 -4
- package/scripts/generate-buildchain-kfd-witnesses.mjs +94 -88
- package/scripts/generate-channel-build-workflow.mjs +54 -24
- package/scripts/generate-channel-promotion-workflow.mjs +15 -6
- package/scripts/generate-site-bundle.mjs +5 -21
- package/scripts/git-fetch-process-tree.mjs +34 -1
- package/scripts/init-repo.mjs +64 -159
- package/scripts/inspect-artifact-signing-requests.mjs +0 -6
- package/scripts/locked-source-checkout.mjs +3 -4
- package/scripts/maintainability-metrics.mjs +8 -2
- package/scripts/npm-publish-dry-run.mjs +2 -2
- package/scripts/npm-publish-transaction.mjs +2 -2
- package/scripts/publication-commit-evidence.mjs +23 -69
- package/scripts/release-candidate-resolver.mjs +11 -17
- package/scripts/release-tail.mjs +3 -49
- package/scripts/resume-from-candidate-run.mjs +9 -123
- package/scripts/run-lifecycle-core.mjs +12 -13
- package/scripts/seal-artifact-signing-requests.mjs +17 -21
- package/scripts/site-capability-metadata.mjs +2 -7
- package/scripts/stable-candidate-qualification.mjs +10 -10
- package/scripts/v4-architecture.mjs +12 -2
- package/scripts/v4-bridge-bootstrap.mjs +141 -0
- package/scripts/v4-bridge-evidence.mjs +141 -0
- package/scripts/v4-host-adapter.mjs +182 -0
- package/scripts/v4-platform-stage-checkpoint-rehearsal.mjs +207 -0
- package/scripts/v4-stage-capsule-qualification.mjs +528 -0
- package/scripts/v4-stage-capsule-resume-rehearsal.mjs +57 -0
- package/scripts/v4-warrant-shadow-plan.mjs +601 -0
- package/scripts/verify-golden-path.mjs +5 -5
- package/scripts/web-surface-cloudfront-rewrite.mjs +15 -15
- package/scripts/web-surface-core.mjs +2 -8
- package/scripts/workflow-call-contract.mjs +5 -184
- package/contracts/fixtures/kfd-adopter-release-v1/kfd-4-perspective.json +0 -16
- package/contracts/fixtures/kfd-adopter-release-v1/kfd-4-replay.json +0 -57
- package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +0 -47
- package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +0 -47
- package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +0 -40
- package/contracts/next-development-request-v1.schema.json +0 -66
- package/contracts/next-development-transition-v1.schema.json +0 -292
- package/contracts/publication-rehearsal-capsule-v1.schema.json +0 -173
- package/dist/site/schemas/publication-rehearsal-capsule-v1.schema.json +0 -269
- package/dist/site/schemas/release-tail-capabilities-v1.schema.json +0 -353
- package/dist/site/schemas/release-tail-provider-bindings-v1.schema.json +0 -94
- package/docs/next-development-transition.md +0 -119
- package/docs/publication-rehearsal.md +0 -94
- package/packages/core/buildchain-compatibility-proof.js +0 -631
- package/packages/core/dev-delivery-native-proof.js +0 -333
- package/packages/core/dev-delivery-warrant-shadow.js +0 -502
- package/packages/core/next-development-candidate-reservation.js +0 -186
- package/packages/core/next-development-controller.js +0 -726
- package/packages/core/next-development-projection.js +0 -288
- package/packages/core/next-development-transition.js +0 -738
- package/packages/core/publication-rehearsal-projection.js +0 -173
- package/packages/core/publication-rehearsal-runtime.js +0 -921
- package/scripts/aws-macos-jit-instance-rehydrate.mjs +0 -260
- package/scripts/aws-macos-jit-source-rebind.mjs +0 -724
- package/scripts/dev-delivery-native-run.mjs +0 -187
- package/scripts/dev-delivery-two-phase.mjs +0 -598
- package/scripts/generate-next-development-guidance.mjs +0 -49
- package/scripts/materialize-self-release-candidate-version.mjs +0 -137
- package/scripts/next-development-self-dogfood-harness.mjs +0 -409
- package/scripts/next-development-self-dogfood.mjs +0 -532
- package/scripts/next-development-transition.mjs +0 -47
- package/scripts/release-candidate-tail-reseal.mjs +0 -426
- package/templates/native-dev-delivery.yml +0 -82
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
V4ContractFault,
|
|
6
|
+
v4CanonicalBytes,
|
|
7
|
+
v4ContentRoot,
|
|
8
|
+
} from "./v4-canonical-contracts.js";
|
|
9
|
+
import { emitV4PlatformStageCheckpoint } from "./v4-platform-stage-checkpoints.js";
|
|
10
|
+
import { V4_STAGE_CAPSULE_QUALIFICATION_FAULTS } from "./v4-stage-capsule-qualification.js";
|
|
11
|
+
import { planV4StageCapsuleResume } from "./v4-stage-capsule-resume-planner.js";
|
|
12
|
+
import { v4StageCapsuleBlobRoot } from "./v4-stage-capsule-store.js";
|
|
13
|
+
|
|
14
|
+
export const V4_STAGE_CAPSULE_CAMPAIGN_RECORDED_AT = "2026-08-08T00:00:00.000Z";
|
|
15
|
+
export const V4_STAGE_CAPSULE_CAMPAIGN_STAGES = Object.freeze([
|
|
16
|
+
"install",
|
|
17
|
+
"build",
|
|
18
|
+
"verify",
|
|
19
|
+
"package",
|
|
20
|
+
]);
|
|
21
|
+
export const V4_STAGE_CAPSULE_CAMPAIGN_DEPENDENCIES = Object.freeze({
|
|
22
|
+
install: [],
|
|
23
|
+
build: ["install"],
|
|
24
|
+
verify: ["build"],
|
|
25
|
+
package: ["build", "verify"],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const ZERO_ROOT = `sha256:${"0".repeat(64)}`;
|
|
29
|
+
const RETAIN_UNTIL = "2026-09-08T00:00:00.000Z";
|
|
30
|
+
const EXTERNAL_CONSUMER_STAGES = Object.freeze(["install", "build", "verify"]);
|
|
31
|
+
const EXTERNAL_CONSUMER_DEPENDENCIES = Object.freeze({
|
|
32
|
+
install: [],
|
|
33
|
+
build: ["install"],
|
|
34
|
+
verify: ["build"],
|
|
35
|
+
});
|
|
36
|
+
const EXTERNAL_CONSUMER_EXCLUSIONS = Object.freeze({
|
|
37
|
+
"version-state": "source-mutation",
|
|
38
|
+
publish: "provider-mutation",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function rootOf(label) {
|
|
42
|
+
return v4StageCapsuleBlobRoot(
|
|
43
|
+
Buffer.isBuffer(label)
|
|
44
|
+
? label
|
|
45
|
+
: typeof label === "string"
|
|
46
|
+
? Buffer.from(`${label}\n`, "utf8")
|
|
47
|
+
: v4CanonicalBytes(label),
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function outputBytes(context, stageId, outputName) {
|
|
52
|
+
const evidence = context.campaignProfile?.stageEvidence?.[stageId];
|
|
53
|
+
if (evidence) return v4CanonicalBytes(evidence);
|
|
54
|
+
return Buffer.from(
|
|
55
|
+
`${context.consumer}:${context.consumerSourceRevision}:${context.platform}:${stageId}:${outputName}:qualified-bytes\n`,
|
|
56
|
+
"utf8",
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function inputRoot(context, stageId, name) {
|
|
61
|
+
const stageInputs = context.campaignProfile?.inputRoots?.[stageId];
|
|
62
|
+
if (stageInputs?.[name]) return stageInputs[name];
|
|
63
|
+
const producer = {
|
|
64
|
+
"dependency-layout": ["install", "dependency-layout"],
|
|
65
|
+
"build-output": ["build", "build-output"],
|
|
66
|
+
"verification-report": ["verify", "verification-report"],
|
|
67
|
+
"package-archive": ["package", "package-archive"],
|
|
68
|
+
}[name];
|
|
69
|
+
if (producer)
|
|
70
|
+
return v4StageCapsuleBlobRoot(outputBytes(context, ...producer));
|
|
71
|
+
return rootOf(
|
|
72
|
+
`${context.consumer}:${context.consumerSourceRevision}:${context.platform}:input:${name}`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function campaignFault(code, location, message) {
|
|
77
|
+
throw new V4ContractFault(code, location, message);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function readJson(file, label) {
|
|
81
|
+
if (!fs.existsSync(file))
|
|
82
|
+
campaignFault(
|
|
83
|
+
"missing-stage-capsule-lifecycle-evidence",
|
|
84
|
+
label,
|
|
85
|
+
`${label} does not exist`,
|
|
86
|
+
);
|
|
87
|
+
try {
|
|
88
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
89
|
+
} catch (error) {
|
|
90
|
+
campaignFault(
|
|
91
|
+
"invalid-stage-capsule-lifecycle-evidence",
|
|
92
|
+
label,
|
|
93
|
+
`${label} is not valid JSON: ${error.message}`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function lifecycleStageEvidence({ stageId, manifest, summary, command }) {
|
|
99
|
+
if (
|
|
100
|
+
manifest?.contract !== "kungfu-buildchain-artifact" ||
|
|
101
|
+
manifest.lifecycle?.stage !== stageId ||
|
|
102
|
+
manifest.lifecycle?.commandSource !== "buildchain.toml" ||
|
|
103
|
+
manifest.lifecycle?.executed !== true
|
|
104
|
+
)
|
|
105
|
+
campaignFault(
|
|
106
|
+
"invalid-stage-capsule-lifecycle-evidence",
|
|
107
|
+
`$/lifecycle/${stageId}/manifest`,
|
|
108
|
+
"manifest must prove the executed buildchain.toml lifecycle stage",
|
|
109
|
+
);
|
|
110
|
+
if (
|
|
111
|
+
!Array.isArray(manifest.files) ||
|
|
112
|
+
manifest.files.length === 0 ||
|
|
113
|
+
manifest.files.some(
|
|
114
|
+
(entry) =>
|
|
115
|
+
typeof entry.path !== "string" ||
|
|
116
|
+
!Number.isSafeInteger(entry.size) ||
|
|
117
|
+
entry.size < 0 ||
|
|
118
|
+
!/^[0-9a-f]{64}$/u.test(entry.sha256),
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
campaignFault(
|
|
122
|
+
"invalid-stage-capsule-lifecycle-output",
|
|
123
|
+
`$/lifecycle/${stageId}/manifest/files`,
|
|
124
|
+
"at least one exact lifecycle output root is required",
|
|
125
|
+
);
|
|
126
|
+
if (
|
|
127
|
+
summary?.contract !== "kungfu-buildchain-artifact-summary" ||
|
|
128
|
+
summary?.artifactName !== manifest.artifactName ||
|
|
129
|
+
summary?.platform?.id !== manifest.platform?.id ||
|
|
130
|
+
summary?.fileCount !== manifest.files.length ||
|
|
131
|
+
summary?.totalBytes !==
|
|
132
|
+
manifest.files.reduce((total, entry) => total + entry.size, 0) ||
|
|
133
|
+
JSON.stringify(summary) !== JSON.stringify(manifest.summary)
|
|
134
|
+
)
|
|
135
|
+
campaignFault(
|
|
136
|
+
"stage-capsule-lifecycle-summary-mismatch",
|
|
137
|
+
`$/lifecycle/${stageId}/summary`,
|
|
138
|
+
"summary does not match the lifecycle manifest",
|
|
139
|
+
);
|
|
140
|
+
const body = {
|
|
141
|
+
schema: "buildchain-v4-real-lifecycle-stage-evidence/v1",
|
|
142
|
+
stage: stageId,
|
|
143
|
+
commands: command.commands || [command.script],
|
|
144
|
+
manifestRoot: rootOf(manifest),
|
|
145
|
+
summaryRoot: rootOf(summary),
|
|
146
|
+
outputRoots: manifest.files
|
|
147
|
+
.map(({ path: filePath, size, sha256 }) => ({
|
|
148
|
+
path: filePath,
|
|
149
|
+
root: `sha256:${sha256}`,
|
|
150
|
+
size,
|
|
151
|
+
}))
|
|
152
|
+
.sort((left, right) => left.path.localeCompare(right.path, "en")),
|
|
153
|
+
};
|
|
154
|
+
return {
|
|
155
|
+
...body,
|
|
156
|
+
evidenceRoot: rootOf(body),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function createV4StageCapsuleCampaignProfile(context) {
|
|
161
|
+
const loaded = context.lifecycleConfig;
|
|
162
|
+
if (!loaded?.filePath || !loaded?.config)
|
|
163
|
+
campaignFault(
|
|
164
|
+
"missing-stage-capsule-lifecycle-config",
|
|
165
|
+
"$/lifecycleConfig",
|
|
166
|
+
"public consumer qualification requires an explicitly loaded lifecycle config",
|
|
167
|
+
);
|
|
168
|
+
const executableStages = EXTERNAL_CONSUMER_STAGES;
|
|
169
|
+
const dependencies = EXTERNAL_CONSUMER_DEPENDENCIES;
|
|
170
|
+
const exclusions = EXTERNAL_CONSUMER_EXCLUSIONS;
|
|
171
|
+
const lifecycle = loaded?.config?.lifecycle || {};
|
|
172
|
+
const stageNames = Object.keys(lifecycle).filter(
|
|
173
|
+
(name) => !["env", "shell"].includes(name),
|
|
174
|
+
);
|
|
175
|
+
const unexpected = stageNames.filter(
|
|
176
|
+
(name) => !executableStages.includes(name) && !exclusions[name],
|
|
177
|
+
);
|
|
178
|
+
if (
|
|
179
|
+
executableStages.some((name) => !stageNames.includes(name)) ||
|
|
180
|
+
unexpected.length > 0
|
|
181
|
+
)
|
|
182
|
+
campaignFault(
|
|
183
|
+
"unsupported-stage-capsule-lifecycle-graph",
|
|
184
|
+
"$/lifecycle",
|
|
185
|
+
"real lifecycle stages differ from the fail-closed canary policy",
|
|
186
|
+
);
|
|
187
|
+
if (!context.lifecycleEvidenceRoot)
|
|
188
|
+
campaignFault(
|
|
189
|
+
"missing-stage-capsule-lifecycle-evidence",
|
|
190
|
+
"$/lifecycleEvidenceRoot",
|
|
191
|
+
"real lifecycle canary requires lifecycle evidence",
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const stageEvidence = Object.fromEntries(
|
|
195
|
+
executableStages.map((stageId) => {
|
|
196
|
+
const manifest = readJson(
|
|
197
|
+
path.join(context.lifecycleEvidenceRoot, `${stageId}-manifest.json`),
|
|
198
|
+
`$/lifecycle/${stageId}/manifest`,
|
|
199
|
+
);
|
|
200
|
+
const summary = readJson(
|
|
201
|
+
path.join(context.lifecycleEvidenceRoot, `${stageId}-summary.json`),
|
|
202
|
+
`$/lifecycle/${stageId}/summary`,
|
|
203
|
+
);
|
|
204
|
+
if (
|
|
205
|
+
manifest.platform?.id !== context.platform ||
|
|
206
|
+
manifest.git?.sha !== context.consumerSourceRevision
|
|
207
|
+
)
|
|
208
|
+
campaignFault(
|
|
209
|
+
"stage-capsule-lifecycle-source-mismatch",
|
|
210
|
+
`$/lifecycle/${stageId}/manifest`,
|
|
211
|
+
"lifecycle evidence does not match the requested platform and source",
|
|
212
|
+
);
|
|
213
|
+
return [
|
|
214
|
+
stageId,
|
|
215
|
+
lifecycleStageEvidence({
|
|
216
|
+
stageId,
|
|
217
|
+
manifest,
|
|
218
|
+
summary,
|
|
219
|
+
command: lifecycle[stageId],
|
|
220
|
+
}),
|
|
221
|
+
];
|
|
222
|
+
}),
|
|
223
|
+
);
|
|
224
|
+
const configBytes = fs.readFileSync(loaded.filePath);
|
|
225
|
+
const sourceRoot = rootOf({
|
|
226
|
+
configRoot: rootOf(configBytes),
|
|
227
|
+
sourceRevision: context.consumerSourceRevision,
|
|
228
|
+
});
|
|
229
|
+
const installOutputRoot = v4StageCapsuleBlobRoot(
|
|
230
|
+
v4CanonicalBytes(stageEvidence.install),
|
|
231
|
+
);
|
|
232
|
+
const buildOutputRoot = stageEvidence.build
|
|
233
|
+
? v4StageCapsuleBlobRoot(v4CanonicalBytes(stageEvidence.build))
|
|
234
|
+
: installOutputRoot;
|
|
235
|
+
const lifecycleDeclarations = stageNames.map((name) => ({
|
|
236
|
+
name,
|
|
237
|
+
commands: lifecycle[name].commands || [lifecycle[name].script],
|
|
238
|
+
disposition: executableStages.includes(name)
|
|
239
|
+
? "shadow-executed"
|
|
240
|
+
: exclusions[name],
|
|
241
|
+
}));
|
|
242
|
+
const body = {
|
|
243
|
+
schema: "buildchain-v4-stage-capsule-campaign-profile/v1",
|
|
244
|
+
kind: "real-public-consumer-lifecycle",
|
|
245
|
+
configPath: loaded.path,
|
|
246
|
+
configRoot: rootOf(configBytes),
|
|
247
|
+
stages: executableStages,
|
|
248
|
+
dependencies,
|
|
249
|
+
lifecycleDeclarations,
|
|
250
|
+
stageEvidence,
|
|
251
|
+
productionAuthority: "v3",
|
|
252
|
+
providerEffects: false,
|
|
253
|
+
};
|
|
254
|
+
return {
|
|
255
|
+
...body,
|
|
256
|
+
inputRoots: {
|
|
257
|
+
install: {
|
|
258
|
+
lockfile: installOutputRoot,
|
|
259
|
+
"source-tree": sourceRoot,
|
|
260
|
+
},
|
|
261
|
+
...(stageEvidence.build
|
|
262
|
+
? {
|
|
263
|
+
build: {
|
|
264
|
+
"dependency-layout": installOutputRoot,
|
|
265
|
+
"source-tree": sourceRoot,
|
|
266
|
+
},
|
|
267
|
+
}
|
|
268
|
+
: {}),
|
|
269
|
+
verify: {
|
|
270
|
+
"build-output": buildOutputRoot,
|
|
271
|
+
"source-tree": sourceRoot,
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
profileRoot: rootOf(body),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function v4StageCapsuleCampaignStages(context) {
|
|
279
|
+
return context.campaignProfile?.stages || V4_STAGE_CAPSULE_CAMPAIGN_STAGES;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function v4StageCapsuleCampaignDependencies(context, stageId) {
|
|
283
|
+
return (
|
|
284
|
+
context.campaignProfile?.dependencies?.[stageId] ||
|
|
285
|
+
V4_STAGE_CAPSULE_CAMPAIGN_DEPENDENCIES[stageId]
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function createV4StageCapsuleCampaignCheckpointRequest(
|
|
290
|
+
context,
|
|
291
|
+
stageId,
|
|
292
|
+
store,
|
|
293
|
+
stageOutcome = "success",
|
|
294
|
+
) {
|
|
295
|
+
const stage = context.declaration.stages.find(({ id }) => id === stageId);
|
|
296
|
+
if (!stage) throw new Error(`undeclared campaign stage: ${stageId}`);
|
|
297
|
+
const outputs = Object.fromEntries(
|
|
298
|
+
stage.outputs.map(({ name }) => [
|
|
299
|
+
name,
|
|
300
|
+
outputBytes(context, stageId, name),
|
|
301
|
+
]),
|
|
302
|
+
);
|
|
303
|
+
return {
|
|
304
|
+
declaration: context.declaration,
|
|
305
|
+
platformId: context.platform,
|
|
306
|
+
stageId,
|
|
307
|
+
stageOutcome,
|
|
308
|
+
recordedAt: V4_STAGE_CAPSULE_CAMPAIGN_RECORDED_AT,
|
|
309
|
+
overheadMs: 0,
|
|
310
|
+
inputs: Object.fromEntries(
|
|
311
|
+
stage.inputs.map((name) => [name, inputRoot(context, stageId, name)]),
|
|
312
|
+
),
|
|
313
|
+
outputs,
|
|
314
|
+
productionOutputRoots: Object.fromEntries(
|
|
315
|
+
Object.entries(outputs).map(([name, bytes]) => [
|
|
316
|
+
name,
|
|
317
|
+
v4StageCapsuleBlobRoot(bytes),
|
|
318
|
+
]),
|
|
319
|
+
),
|
|
320
|
+
productionLifecycleResult: { outcome: stageOutcome, stage: stageId },
|
|
321
|
+
shadowLifecycleResult: { outcome: stageOutcome, stage: stageId },
|
|
322
|
+
environment: Object.fromEntries(
|
|
323
|
+
stage.environment.map((name) => [name, `${context.consumer}-${name}`]),
|
|
324
|
+
),
|
|
325
|
+
toolchains: Object.fromEntries(
|
|
326
|
+
stage.toolchains.map((name) => [
|
|
327
|
+
name,
|
|
328
|
+
rootOf(`${context.platform}:toolchain:${name}:node-24`),
|
|
329
|
+
]),
|
|
330
|
+
),
|
|
331
|
+
runtime: {
|
|
332
|
+
engine: "node",
|
|
333
|
+
runtimeRef: context.runtimeRef,
|
|
334
|
+
consumer: context.consumer,
|
|
335
|
+
campaignProfileRoot: context.campaignProfile.profileRoot,
|
|
336
|
+
},
|
|
337
|
+
transformation: {
|
|
338
|
+
interface: context.campaignProfile.kind.startsWith("real-")
|
|
339
|
+
? context.campaignProfile.kind
|
|
340
|
+
: "consumer-equivalent",
|
|
341
|
+
providerEffects: false,
|
|
342
|
+
stage: stageId,
|
|
343
|
+
lifecycleEvidenceRoot:
|
|
344
|
+
context.campaignProfile.stageEvidence?.[stageId]?.evidenceRoot || null,
|
|
345
|
+
},
|
|
346
|
+
qualification: {
|
|
347
|
+
exactBytes: true,
|
|
348
|
+
consumer: context.consumer,
|
|
349
|
+
productionBytesChanged: false,
|
|
350
|
+
campaignProfileRoot: context.campaignProfile.profileRoot,
|
|
351
|
+
},
|
|
352
|
+
retentionPromise: {
|
|
353
|
+
class: "wave-evidence",
|
|
354
|
+
retainUntil: RETAIN_UNTIL,
|
|
355
|
+
},
|
|
356
|
+
store,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export function emitV4StageCapsuleCampaignCheckpoint(
|
|
361
|
+
context,
|
|
362
|
+
stageId,
|
|
363
|
+
store,
|
|
364
|
+
stageOutcome = "success",
|
|
365
|
+
) {
|
|
366
|
+
return emitV4PlatformStageCheckpoint(
|
|
367
|
+
createV4StageCapsuleCampaignCheckpointRequest(
|
|
368
|
+
context,
|
|
369
|
+
stageId,
|
|
370
|
+
store,
|
|
371
|
+
stageOutcome,
|
|
372
|
+
),
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export function v4StageCapsuleCampaignAggregateRoots(entries) {
|
|
377
|
+
const manifests = entries.map(({ stage, manifest }) => ({
|
|
378
|
+
stage,
|
|
379
|
+
manifestRoot: manifest.manifestRoot,
|
|
380
|
+
}));
|
|
381
|
+
const content = entries.flatMap(({ stage, manifest }) =>
|
|
382
|
+
manifest.entries.map(({ name, root, size }) => ({
|
|
383
|
+
stage,
|
|
384
|
+
name,
|
|
385
|
+
root,
|
|
386
|
+
size,
|
|
387
|
+
})),
|
|
388
|
+
);
|
|
389
|
+
return {
|
|
390
|
+
artifactManifestRoot: v4ContentRoot(
|
|
391
|
+
"stage-capsule-artifact-manifest",
|
|
392
|
+
manifests,
|
|
393
|
+
),
|
|
394
|
+
contentRoot: v4ContentRoot("stage-capsule-artifact-content", content),
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function unavailable(availability, status, faultCode) {
|
|
399
|
+
availability.status = status;
|
|
400
|
+
availability.contentRoot = null;
|
|
401
|
+
availability.qualificationRoot = null;
|
|
402
|
+
availability.faultCode = faultCode;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function faultDefinitions() {
|
|
406
|
+
return {
|
|
407
|
+
corrupt: [
|
|
408
|
+
"reject",
|
|
409
|
+
"corrupt",
|
|
410
|
+
(value) =>
|
|
411
|
+
unavailable(
|
|
412
|
+
value.nodes[0].candidate.availability,
|
|
413
|
+
"corrupt",
|
|
414
|
+
"capsule-corrupt",
|
|
415
|
+
),
|
|
416
|
+
],
|
|
417
|
+
"cross-platform": [
|
|
418
|
+
"reject",
|
|
419
|
+
"cross-platform",
|
|
420
|
+
(value) => (value.nodes[0].expectedIdentity.platform = "other-platform"),
|
|
421
|
+
],
|
|
422
|
+
"cross-stage": [
|
|
423
|
+
"reject",
|
|
424
|
+
"stage-mismatch",
|
|
425
|
+
(value) => (value.nodes[0].expectedIdentity.stage = "other-stage"),
|
|
426
|
+
],
|
|
427
|
+
expired: [
|
|
428
|
+
"rebuild",
|
|
429
|
+
"expired",
|
|
430
|
+
(value) => (value.evaluatedAt = "2026-10-08T00:00:00.000Z"),
|
|
431
|
+
],
|
|
432
|
+
missing: [
|
|
433
|
+
"rebuild",
|
|
434
|
+
"unavailable",
|
|
435
|
+
(value) => (value.nodes[0].candidate = null),
|
|
436
|
+
],
|
|
437
|
+
partial: [
|
|
438
|
+
"reject",
|
|
439
|
+
"partial",
|
|
440
|
+
(value) =>
|
|
441
|
+
unavailable(
|
|
442
|
+
value.nodes[0].candidate.availability,
|
|
443
|
+
"partial",
|
|
444
|
+
"capsule-partial",
|
|
445
|
+
),
|
|
446
|
+
],
|
|
447
|
+
"policy-drift": [
|
|
448
|
+
"rebuild",
|
|
449
|
+
"policy-changed",
|
|
450
|
+
(value) => (value.nodes[0].expectedIdentity.policyRoot = ZERO_ROOT),
|
|
451
|
+
],
|
|
452
|
+
"root-mismatch": [
|
|
453
|
+
"reject",
|
|
454
|
+
"root-mismatch",
|
|
455
|
+
(value) =>
|
|
456
|
+
unavailable(
|
|
457
|
+
value.nodes[0].candidate.availability,
|
|
458
|
+
"root-mismatch",
|
|
459
|
+
"capsule-root-mismatch",
|
|
460
|
+
),
|
|
461
|
+
],
|
|
462
|
+
"source-drift": [
|
|
463
|
+
"rebuild",
|
|
464
|
+
"source-changed",
|
|
465
|
+
(value) => (value.nodes[0].expectedIdentity.sourceRoot = ZERO_ROOT),
|
|
466
|
+
],
|
|
467
|
+
"stale-writer": [
|
|
468
|
+
"contract-fault",
|
|
469
|
+
"invalid-stage-capsule-authority",
|
|
470
|
+
(value) =>
|
|
471
|
+
(value.nodes[0].candidate.capsule.writerAuthority = "stale-writer"),
|
|
472
|
+
],
|
|
473
|
+
"toolchain-drift": [
|
|
474
|
+
"rebuild",
|
|
475
|
+
"toolchain-changed",
|
|
476
|
+
(value) =>
|
|
477
|
+
(value.nodes[0].expectedIdentity.toolchainRoots[0].root = ZERO_ROOT),
|
|
478
|
+
],
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export function runV4StageCapsuleFaultCampaign(baseRequest) {
|
|
483
|
+
const definitions = faultDefinitions();
|
|
484
|
+
return V4_STAGE_CAPSULE_QUALIFICATION_FAULTS.map((id) => {
|
|
485
|
+
const request = structuredClone(baseRequest);
|
|
486
|
+
const faultNode =
|
|
487
|
+
request.nodes.find(({ key }) => key === "build") ||
|
|
488
|
+
request.nodes.find(({ candidate }) => candidate !== null);
|
|
489
|
+
request.nodes = [faultNode];
|
|
490
|
+
request.nodes[0].dependencies = [];
|
|
491
|
+
request.targets = [faultNode.key];
|
|
492
|
+
const [expected, expectedReason, mutate] = definitions[id];
|
|
493
|
+
mutate(request);
|
|
494
|
+
let actual = "contract-fault";
|
|
495
|
+
let reasonCode = "unknown-fault";
|
|
496
|
+
try {
|
|
497
|
+
const decision = planV4StageCapsuleResume(request).decisions[0];
|
|
498
|
+
actual = decision.decision;
|
|
499
|
+
reasonCode = decision.reasonCode;
|
|
500
|
+
} catch (error) {
|
|
501
|
+
if (!(error instanceof V4ContractFault)) throw error;
|
|
502
|
+
reasonCode = error.code;
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
id,
|
|
506
|
+
expected,
|
|
507
|
+
actual,
|
|
508
|
+
reasonCode,
|
|
509
|
+
passed: actual === expected && reasonCode === expectedReason,
|
|
510
|
+
};
|
|
511
|
+
});
|
|
512
|
+
}
|