@kungfu-tech/buildchain 4.0.2-alpha.9 → 4.0.3-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 +14 -5
- package/CONTRIBUTING.md +58 -0
- package/README.md +3 -3
- package/actions/promote-buildchain-ref/README.md +1 -1
- package/actions/release-candidate-promote/README.md +31 -0
- package/architecture/agent-change-map.md +190 -126
- package/architecture/{v4-architecture-constitution.md → architecture-constitution.md} +33 -30
- package/architecture/{v3-core-mechanism-inventory.md → baseline-core-mechanism-inventory.md} +1 -1
- package/architecture/{v4-bootstrap-authority.json → bootstrap-authority.json} +3 -3
- package/architecture/{v3-v4-capability-closure.md → capability-parity-closure.md} +3 -3
- package/architecture/{v3-v4-live-capability-inventory.json → capability-parity-live-capability-inventory.json} +4 -4
- package/architecture/{v4-capability-state-machine-manifest.json → capability-state-machine-manifest.json} +2 -2
- package/architecture/{v4-capability-state-machine-manifest.schema.json → capability-state-machine-manifest.schema.json} +2 -2
- package/architecture/ci-lane-change-budget.json +384 -0
- package/architecture/{v4-cross-platform-adopter-qualification.json → cross-platform-adopter-qualification.json} +4 -4
- package/architecture/{v4-delivery-authority-parity.json → delivery-authority-parity.json} +17 -17
- package/architecture/{v4-delivery-warrant-shadow-bootstrap-plan.json → delivery-warrant-shadow-bootstrap-plan.json} +4 -4
- package/architecture/{v4-delivery-warrant-shadow-bootstrap-plan.md → delivery-warrant-shadow-bootstrap-plan.md} +7 -7
- package/architecture/{v4-floating-consumer-policy.json → floating-consumer-policy.json} +2 -2
- package/architecture/{v4-floating-consumer-policy.md → floating-consumer-policy.md} +1 -1
- package/architecture/implementation-naming.json +1273 -0
- package/architecture/internal-capabilities.json +201 -154
- package/architecture/maintainability-debt.json +205 -146
- package/architecture/maintainability-policy.json +37 -33
- package/architecture/{v4-next-development-parity.json → next-development-parity.json} +12 -12
- package/architecture/{v4-partial-mutation-recovery-qualification.json → partial-mutation-recovery-qualification.json} +8 -5
- package/architecture/{v4-platform-stage-checkpoints.json → platform-stage-checkpoints.json} +3 -3
- package/architecture/{v4-provider-operation-journal-contract.json → provider-operation-journal-contract.json} +10 -7
- package/architecture/publication-facade-patches.json +64 -0
- package/architecture/{v4-publication-rehearsal-parity.json → publication-rehearsal-parity.json} +4 -4
- package/architecture/{v4-release-activation-shadow-domain.json → release-activation-shadow-domain.json} +9 -6
- package/architecture/release-tail-contract-inventory.json +6 -6
- package/architecture/{v4-release-topology.json → release-topology.json} +163 -72
- package/architecture/{v4-release-train-parity.json → release-train-parity.json} +2 -2
- package/architecture/{v4-runtime-ref-resume-authority.json → runtime-ref-resume-authority.json} +1 -1
- package/architecture/{v4-runtime-semantic-closure.json → runtime-semantic-closure.json} +2 -2
- package/architecture/{v4-rust-libnode-bridge-evaluation.json → rust-libnode-bridge-evaluation.json} +3 -3
- package/architecture/{v4-rust-libnode-bridge-spike.md → rust-libnode-bridge-spike.md} +6 -6
- package/architecture/rust-wasm-production-authority.json +58 -0
- package/architecture/{v4-stable-publication-fence.json → stable-publication-fence.json} +7 -4
- package/architecture/{v4-stage-capsule-contract.json → stage-capsule-contract.json} +1 -1
- package/architecture/{v4-stage-capsule-qualification.json → stage-capsule-qualification.json} +8 -8
- package/architecture/{v4-stage-capsule-resume-planner.json → stage-capsule-resume-planner.json} +2 -2
- package/architecture/{v4-stage-capsule-store-contract.json → stage-capsule-store-contract.json} +4 -4
- package/architecture/{v4-tail-reseal-parity.json → tail-reseal-parity.json} +35 -33
- package/architecture/universal-workflow-bootstrap.json +176 -0
- package/architecture/universal-workflow-fault-campaign.json +72 -0
- package/architecture/universal-workflow-train-admission.json +40 -0
- package/architecture/workflow-taxonomy.json +1462 -0
- package/bin/buildchain.mjs +10 -10
- package/bin/internal/adopter-delivery-cli.mjs +9 -9
- 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/crates/{buildchain-v4-bridge → buildchain-host-bridge}/Cargo.lock +1 -1
- package/crates/{buildchain-v4-bridge → buildchain-host-bridge}/Cargo.toml +1 -1
- package/crates/{buildchain-v4-bridge → buildchain-host-bridge}/src/main.rs +3 -3
- package/dist/site/buildchain-contract.json +98 -53
- package/dist/site/buildchain-site.json +351 -102
- package/dist/site/capability-registry.json +7 -7
- package/dist/site/controller-registry.json +50 -13
- package/dist/site/kfd-claims.json +2773 -1052
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +14 -14
- package/dist/site/node-api-registry.json +13176 -10733
- package/dist/site/page-registry.json +332 -83
- package/dist/site/public-surface-audit.json +3227 -1222
- package/dist/site/publication-authority-registry.json +1135 -363
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/release-provenance.json +18 -9
- package/dist/site/schemas/dev-delivery-authority-v2.schema.json +16 -2
- package/dist/site/site-manifest.json +18 -18
- package/dist/site/workflow-registry.json +5367 -1931
- package/docs/MAP.md +5 -3
- 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 +26 -3
- package/docs/node-api-reference.md +618 -358
- package/docs/oci-publication.md +173 -0
- package/docs/publication-authority.md +2 -2
- package/docs/publish-transaction.md +36 -3
- 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 +17 -1
- package/docs/v4-adopter-delivery.md +4 -4
- package/docs/v4-canonical-contracts.md +7 -7
- package/docs/v4-delivery-warrant-read-candidate.md +3 -3
- package/docs/v4-delivery-warrant-semantic-diff.md +3 -3
- package/docs/v4-production-release.md +77 -8
- package/docs/v4-publication-rehearsal.md +3 -3
- package/docs/v4-runtime-ref-resume-authority.md +2 -2
- package/docs/v4-rust-wasm-production-authority.md +58 -0
- package/docs/v4-stage-capsule.md +9 -9
- package/docs/v4-tail-reseal.md +2 -2
- package/docs/workflow-catalog.md +155 -0
- package/docs/workflow-path-migration.md +109 -0
- package/package.json +39 -24
- package/packages/compatibility/adopter-delivery.js +16 -0
- package/packages/compatibility/cross-platform-adopter-qualification.js +12 -0
- package/packages/compatibility/floating-consumer-policy.js +14 -0
- package/packages/compatibility/publication-qualification.js +11 -0
- package/packages/compatibility/publication-rehearsal.js +18 -0
- package/packages/compatibility/runtime-ref-resume-authority.js +13 -0
- package/packages/compatibility/tail-reseal-receipt.js +7 -0
- package/packages/compatibility/tail-reseal.js +11 -0
- package/packages/core/{v4-adopter-delivery-parity.js → adopter-delivery-parity.js} +12 -12
- package/packages/core/{v4-adopter-delivery.js → adopter-delivery.js} +24 -24
- package/packages/core/artifact-verification-envelope.js +5 -5
- package/packages/core/buildchain-contract.js +6 -6
- package/packages/core/buildchain-domain.wasm +0 -0
- package/packages/core/buildchain-kfd-claims.js +2 -2
- package/packages/core/buildchain-publication-authority.js +43 -26
- package/packages/core/{v4-canonical-contracts.js → canonical-contracts.js} +39 -103
- package/packages/core/ci-lane-change-budget.js +14 -1
- package/packages/core/controller-evidence.js +4 -1
- package/packages/core/{v4-cross-platform-adopter-qualification.js → cross-platform-adopter-qualification.js} +19 -19
- package/packages/core/{v4-delivery-warrant-fixture-runner.js → delivery-warrant-fixture-runner.js} +36 -32
- package/packages/core/{v4-delivery-warrant-read-candidate.js → delivery-warrant-read-candidate.js} +40 -40
- package/packages/core/{v4-delivery-warrant-semantic-diff-gate.js → delivery-warrant-semantic-diff-gate.js} +58 -59
- package/packages/core/{v4-delivery-warrant-shadow-adapter.js → delivery-warrant-shadow-adapter.js} +15 -15
- package/packages/core/dev-delivery-candidate-identity.js +40 -6
- package/packages/core/dev-delivery-execution-transfer.js +6 -6
- package/packages/core/dev-delivery-native-proof.js +12 -8
- package/packages/core/dev-delivery-warrant-legacy-recovery.js +1 -1
- package/packages/core/dev-delivery-warrant-native-compatibility.js +4 -4
- package/packages/core/dev-delivery-warrant-state.js +14 -15
- package/packages/core/dev-delivery-warrant.js +15 -5
- package/packages/core/domain-wasm-artifact.js +7 -0
- package/packages/core/domain-wasm.js +216 -0
- package/packages/core/{v4-floating-consumer-evidence.js → floating-consumer-evidence.js} +14 -14
- package/packages/core/{v4-floating-consumer-policy.js → floating-consumer-policy.js} +28 -30
- package/packages/core/{v4-floating-consumer-release-passport.js → floating-consumer-release-passport.js} +25 -25
- package/packages/core/github-governance-authority.js +4 -4
- package/packages/core/index.js +4 -8
- package/packages/core/kfd-adopter-manifest.js +46 -47
- package/packages/core/next-development-projection.js +26 -3
- package/packages/core/next-development-transition.js +5 -6
- package/packages/core/oci-compose-qualification.js +143 -0
- package/packages/core/oci-publication-bundle.js +281 -0
- package/packages/core/oci-publication-graph.js +206 -0
- 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/partial-mutation-recovery-qualification.js +18 -0
- package/packages/core/{v4-platform-stage-checkpoints.js → platform-stage-checkpoints.js} +37 -37
- package/packages/core/product-publication.js +59 -0
- package/packages/core/{v4-protected-publication-source.js → protected-publication-source.js} +22 -24
- package/packages/core/provider-operation-journal.js +62 -0
- package/packages/core/{v4-provider-readback-idempotency.js → provider-readback-idempotency.js} +40 -125
- package/packages/core/public-export-compatibility.js +33 -0
- package/packages/core/publication-development.js +72 -0
- package/packages/core/{v4-publication-qualification.js → publication-qualification.js} +17 -17
- package/packages/core/{v4-publication-rehearsal-capsule.js → publication-rehearsal-capsule.js} +23 -23
- package/packages/core/publication-rehearsal-projection.js +2 -2
- package/packages/core/{v4-publication-rehearsal-provider-bindings.js → publication-rehearsal-provider-bindings.js} +4 -4
- package/packages/core/publication-rehearsal-runtime.js +21 -21
- package/packages/core/{v4-publication-rehearsal.js → publication-rehearsal.js} +33 -33
- package/packages/core/publication-sealed-bundle.js +78 -13
- package/packages/core/release-activation-shadow.js +32 -0
- package/packages/core/release-candidate.js +6 -6
- package/packages/core/release-invocation.js +64 -0
- 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 +41 -40
- package/packages/core/release-tail-product-capabilities.js +9 -0
- package/packages/core/release-tail-provider-plane.js +68 -1048
- package/packages/core/{v4-runtime-ref-resume-authority.js → runtime-ref-resume-authority.js} +36 -40
- package/packages/core/{v4-runtime-selector-persistence.js → runtime-selector-persistence.js} +7 -7
- package/packages/core/stable-publication-fence.js +28 -0
- package/packages/core/{v4-stage-capsule-local-store.js → stage-capsule-local-store.js} +56 -54
- package/packages/core/{v4-stage-capsule-qualification-campaign.js → stage-capsule-qualification-campaign.js} +37 -38
- package/packages/core/{v4-stage-capsule-qualification.js → stage-capsule-qualification.js} +28 -29
- package/packages/core/{v4-stage-capsule-resume-planner.js → stage-capsule-resume-planner.js} +29 -29
- package/packages/core/{v4-stage-capsule-store.js → stage-capsule-store.js} +59 -56
- package/packages/core/{v4-stage-capsule.js → stage-capsule.js} +45 -45
- package/packages/core/{v4-tail-reseal-contract.js → tail-reseal-contract.js} +6 -6
- package/packages/core/{v4-tail-reseal-github.js → tail-reseal-github.js} +12 -12
- package/packages/core/{v4-tail-reseal-receipt.js → tail-reseal-receipt.js} +22 -22
- package/packages/core/{v4-tail-reseal.js → tail-reseal.js} +29 -29
- package/packages/core/universal-workflow-bootstrap.js +586 -0
- package/scripts/{v4-architecture.mjs → architecture.mjs} +6 -6
- package/scripts/binary-publication-evidence.mjs +135 -0
- package/scripts/{v4-bridge-bootstrap.mjs → bridge-bootstrap.mjs} +14 -18
- package/scripts/{v4-bridge-evidence.mjs → bridge-evidence.mjs} +8 -8
- package/scripts/build-contract-core.mjs +1 -14
- package/scripts/build-domain-wasm.mjs +177 -0
- package/scripts/{v3-v4-capability-catalog.mjs → capability-parity-catalog.mjs} +19 -19
- package/scripts/check-action-bundles.mjs +12 -2
- package/scripts/{check-v3-v4-capability-inventory.mjs → check-capability-parity-inventory.mjs} +42 -42
- package/scripts/check-ci-lane-change-budget.mjs +4 -1
- package/scripts/check-core-mechanism-inventory.mjs +8 -4
- package/scripts/{check-v4-floating-consumer-policy-contract.mjs → check-floating-consumer-policy-contract.mjs} +10 -10
- package/scripts/check-implementation-naming.mjs +135 -0
- package/scripts/check-inventory.mjs +39 -47
- package/scripts/check-maintainability.mjs +25 -115
- package/scripts/{check-v4-public-dogfood-contract.mjs → check-public-dogfood-contract.mjs} +37 -24
- package/scripts/{check-v4-release-topology.mjs → check-release-topology.mjs} +131 -52
- package/scripts/{check-v4-runtime-semantic-closure.mjs → check-runtime-semantic-closure.mjs} +23 -17
- package/scripts/check-universal-workflow-bootstrap.mjs +266 -0
- package/scripts/check-workflow-taxonomy.mjs +6 -0
- package/scripts/{v4-consumer-policy.mjs → consumer-policy.mjs} +15 -15
- package/scripts/copy-domain-wasm.mjs +14 -0
- package/scripts/{v4-cross-platform-adopter-qualification.mjs → cross-platform-adopter-qualification.mjs} +9 -9
- package/scripts/{v4-declarative-promotion-admission.mjs → declarative-promotion-admission.mjs} +4 -4
- 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 +15 -10
- package/scripts/dev-delivery-warrant-store.mjs +98 -13
- package/scripts/dev-delivery-warrant-transition.mjs +109 -0
- package/scripts/dev-delivery-warrant.mjs +80 -103
- package/scripts/dev-pr-auto-merge.mjs +15 -15
- package/scripts/dev-pr-delivery-warrant.mjs +1 -1
- package/scripts/generate-channel-build-workflow.mjs +7 -2
- package/scripts/generate-channel-promotion-workflow.mjs +19 -34
- package/scripts/generate-release-candidate-passport.mjs +23 -23
- package/scripts/generate-site-bundle.mjs +28 -28
- package/scripts/generate-universal-workflow-facades.mjs +498 -0
- package/scripts/generate-workflow-taxonomy.mjs +25 -0
- package/scripts/github-output.mjs +31 -0
- package/scripts/{v4-host-adapter.mjs → host-adapter.mjs} +1 -1
- package/scripts/implementation-references.mjs +25 -0
- package/scripts/init-repo.mjs +1 -1
- package/scripts/maintainability-metrics.mjs +16 -5
- package/scripts/maintainability-public-surface.mjs +115 -0
- package/scripts/next-development-review.mjs +313 -0
- package/scripts/oci-compose-preview.mjs +261 -0
- package/scripts/paper-work-fleet-cli.mjs +2 -0
- package/scripts/{v4-platform-stage-checkpoint-rehearsal.mjs → platform-stage-checkpoint-rehearsal.mjs} +17 -17
- package/scripts/{v4-product-publication-intent.mjs → product-publication-intent.mjs} +28 -13
- package/scripts/publication-candidate-kind.mjs +93 -0
- package/scripts/publication-candidate-sealer.mjs +16 -1
- package/scripts/{v4-publication-rehearsal-fixture.mjs → publication-rehearsal-fixture.mjs} +5 -5
- package/scripts/publication-settlement.mjs +211 -0
- package/scripts/release-asset-client.mjs +91 -0
- package/scripts/{v4-release-candidate-adapter.mjs → release-candidate-adapter.mjs} +4 -4
- package/scripts/release-candidate-resolver.mjs +24 -35
- package/scripts/release-tail.mjs +5 -5
- package/scripts/resume-from-candidate-run.mjs +35 -42
- package/scripts/site-capability-metadata.mjs +9 -0
- package/scripts/source-verification-evidence.mjs +344 -0
- package/scripts/stable-candidate-qualification.mjs +1 -1
- package/scripts/{v4-stage-capsule-qualification.mjs → stage-capsule-qualification.mjs} +62 -62
- package/scripts/{v4-stage-capsule-resume-rehearsal.mjs → stage-capsule-resume-rehearsal.mjs} +6 -6
- package/scripts/{v4-tail-reseal-macos-rehearsal.mjs → tail-reseal-macos-rehearsal.mjs} +9 -9
- package/scripts/{v4-tail-reseal.mjs → tail-reseal.mjs} +19 -19
- package/scripts/universal-facade-maintainability.mjs +91 -0
- package/scripts/universal-workflow-backflow.mjs +212 -0
- package/scripts/universal-workflow-engine.mjs +620 -0
- package/scripts/universal-workflow-self-dogfood.mjs +205 -0
- package/scripts/verify-version-state-delta.mjs +175 -0
- package/scripts/{v4-warrant-shadow-plan.mjs → warrant-shadow-plan.mjs} +6 -6
- 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
- package/actions/v4-release-candidate-promote/README.md +0 -3
- package/packages/core/v4-partial-mutation-recovery-qualification.js +0 -395
- package/packages/core/v4-product-publication.js +0 -387
- package/packages/core/v4-provider-operation-journal.js +0 -531
- package/packages/core/v4-release-activation-shadow.js +0 -519
- package/packages/core/v4-release-invocation.js +0 -425
- package/packages/core/v4-stable-publication-fence.js +0 -357
- /package/architecture/{v4-adopter-delivery-parity.json → adopter-delivery-parity.json} +0 -0
- /package/architecture/{v3-core-mechanism-inventory.json → baseline-core-mechanism-inventory.json} +0 -0
- /package/architecture/{v4-canonical-contract-fixtures.json → canonical-contract-fixtures.json} +0 -0
- /package/architecture/{v4-compatibility-facts-parity.json → compatibility-facts-parity.json} +0 -0
- /package/architecture/{v4-delivery-warrant-shadow-bootstrap-plan.schema.json → delivery-warrant-shadow-bootstrap-plan.schema.json} +0 -0
- /package/architecture/{v4-delivery-warrant-shadow-fixtures.json → delivery-warrant-shadow-fixtures.json} +0 -0
- /package/architecture/{v4-delivery-warrant-shadow-fixtures.schema.json → delivery-warrant-shadow-fixtures.schema.json} +0 -0
- /package/architecture/{v4-exception-ledger.json → exception-ledger.json} +0 -0
- /package/architecture/{v4-exception-ledger.schema.json → exception-ledger.schema.json} +0 -0
- /package/architecture/{v4-release-invocation-fixtures.json → release-invocation-fixtures.json} +0 -0
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { currentWorkflowPath } from "./workflow-taxonomy.mjs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import {
|
|
8
|
+
admitUniversalWorkflow,
|
|
9
|
+
completeUniversalWorkflow,
|
|
10
|
+
selectRecoveredProductPublicationVersion, productStateVersion,
|
|
11
|
+
validateUniversalWorkflowRequest,
|
|
12
|
+
universalWorkflowRequestRoot,
|
|
13
|
+
} from "../packages/core/universal-workflow-bootstrap.js";
|
|
14
|
+
import {
|
|
15
|
+
createReleaseInvocation,
|
|
16
|
+
createReleaseReceipt,
|
|
17
|
+
createDomainReleaseTransaction,
|
|
18
|
+
planReleaseRoute,
|
|
19
|
+
} from "../packages/core/release-invocation.js";
|
|
20
|
+
import { assertDeclarativePromotionInputs } from "../packages/core/publication-qualification.js";
|
|
21
|
+
import {
|
|
22
|
+
githubJson,
|
|
23
|
+
resolveReleaseCandidateArtifacts,
|
|
24
|
+
} from "./release-candidate-resolver.mjs";
|
|
25
|
+
|
|
26
|
+
function fail(message) {
|
|
27
|
+
throw new Error(message);
|
|
28
|
+
}
|
|
29
|
+
function readJsonEnvironment(name) {
|
|
30
|
+
const source = process.env[name];
|
|
31
|
+
if (!source) fail(`${name} is required`);
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(source);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new Error(`${name} is not valid JSON`, { cause: error });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function exactRuntime(admission) {
|
|
39
|
+
const runtime = admission?.runtime;
|
|
40
|
+
if (
|
|
41
|
+
admission?.status !== "admitted" ||
|
|
42
|
+
runtime?.repository !== "kungfu-systems/buildchain" ||
|
|
43
|
+
!/^[0-9a-f]{40}$/u.test(runtime?.sha || "")
|
|
44
|
+
)
|
|
45
|
+
fail("an exact admitted Buildchain runtime is required");
|
|
46
|
+
return runtime;
|
|
47
|
+
}
|
|
48
|
+
function contentRoot(domain, value) {
|
|
49
|
+
const hash = crypto.createHash("sha256");
|
|
50
|
+
hash.update(domain, "utf8");
|
|
51
|
+
hash.update(Buffer.from([0]));
|
|
52
|
+
hash.update(`${JSON.stringify(value)}\n`, "utf8");
|
|
53
|
+
return `sha256:${hash.digest("hex")}`;
|
|
54
|
+
}
|
|
55
|
+
function emit(value) {
|
|
56
|
+
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
57
|
+
}
|
|
58
|
+
function exactObject(value, keys, label) {
|
|
59
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
60
|
+
fail(`${label} must be an object`);
|
|
61
|
+
const actual = Object.keys(value).sort();
|
|
62
|
+
const expected = [...keys].sort();
|
|
63
|
+
if (
|
|
64
|
+
actual.length !== expected.length ||
|
|
65
|
+
actual.some((key, index) => key !== expected[index])
|
|
66
|
+
)
|
|
67
|
+
fail(`${label} has an invalid field set`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function validateWorkflowInputs(workflowId, inputs) {
|
|
71
|
+
const registry = JSON.parse(
|
|
72
|
+
fs.readFileSync(
|
|
73
|
+
new URL("../dist/site/workflow-registry.json", import.meta.url),
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
const workflow = registry.workflows.find((entry) => entry.id === workflowId);
|
|
77
|
+
if (!workflow) fail(`candidate workflow registry is missing ${workflowId}`);
|
|
78
|
+
const allowed = new Set(workflow.inputs);
|
|
79
|
+
const unknown = Object.keys(inputs).filter((name) => !allowed.has(name));
|
|
80
|
+
if (unknown.length > 0)
|
|
81
|
+
fail(
|
|
82
|
+
`candidate payload has unregistered workflow inputs: ${unknown.sort().join(", ")}`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const TRUSTED_PUBLISHING_NPM_VERSION = "11.13.0";
|
|
86
|
+
function prepareTrustedPublishingNpm() {
|
|
87
|
+
if (
|
|
88
|
+
!process.env.ACTIONS_ID_TOKEN_REQUEST_URL ||
|
|
89
|
+
!process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN
|
|
90
|
+
)
|
|
91
|
+
fail("trusted publishing requires GitHub Actions OIDC authority");
|
|
92
|
+
const binDirectory = path.resolve(".buildchain/runtime/bin");
|
|
93
|
+
const npmShim = path.join(binDirectory, "npm");
|
|
94
|
+
fs.mkdirSync(binDirectory, { recursive: true });
|
|
95
|
+
fs.writeFileSync(
|
|
96
|
+
npmShim,
|
|
97
|
+
`#!/bin/sh\nexec corepack pnpm@11.7.0 dlx npm@${TRUSTED_PUBLISHING_NPM_VERSION} "$@"\n`,
|
|
98
|
+
{ mode: 0o755 },
|
|
99
|
+
);
|
|
100
|
+
fs.chmodSync(npmShim, 0o755);
|
|
101
|
+
process.env.PATH = `${binDirectory}${path.delimiter}${process.env.PATH || ""}`;
|
|
102
|
+
}
|
|
103
|
+
function prepareReleasePromotionConsumerDependencies(repository) {
|
|
104
|
+
if (repository !== "kungfu-systems/buildchain") return;
|
|
105
|
+
const manifest = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
106
|
+
if (manifest.packageManager !== "pnpm@11.7.0" || !fs.existsSync("pnpm-lock.yaml")) fail("Buildchain release consumer dependency lock is unavailable");
|
|
107
|
+
const consumerModules = path.resolve("node_modules"), runtimeModules = path.resolve(".buildchain/runtime/node_modules");
|
|
108
|
+
if (!fs.existsSync(consumerModules) && fs.existsSync(runtimeModules)) fs.symlinkSync(path.relative(path.dirname(consumerModules), runtimeModules), consumerModules, "dir");
|
|
109
|
+
if (!fs.existsSync("node_modules/@kungfu-tech/kfd/package.json")) execFileSync("corepack", "pnpm@11.7.0 install --frozen-lockfile --ignore-scripts".split(" "), { stdio: ["ignore", 2, 2] });
|
|
110
|
+
if (fs.existsSync(runtimeModules)) {
|
|
111
|
+
if (fs.realpathSync(consumerModules) !== fs.realpathSync(runtimeModules)) fail("Buildchain release consumer runtime bridge conflicts");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
fs.mkdirSync(path.dirname(runtimeModules), { recursive: true }); fs.renameSync(consumerModules, runtimeModules);
|
|
115
|
+
fs.symlinkSync(path.relative(path.dirname(consumerModules), runtimeModules), consumerModules, "dir");
|
|
116
|
+
}
|
|
117
|
+
function actionEnvironment(inputs, outputPath) {
|
|
118
|
+
const environment = { ...process.env, GITHUB_OUTPUT: outputPath };
|
|
119
|
+
for (const [name, value] of Object.entries(inputs))
|
|
120
|
+
environment[`INPUT_${name.replace(/ /gu, "_").toUpperCase()}`] =
|
|
121
|
+
typeof value === "boolean" ? String(value) : String(value ?? "");
|
|
122
|
+
return environment;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function readGitHubOutputs(outputPath) {
|
|
126
|
+
const source = fs.readFileSync(outputPath, "utf8");
|
|
127
|
+
const outputs = {};
|
|
128
|
+
const lines = source.split("\n");
|
|
129
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
130
|
+
const line = lines[index];
|
|
131
|
+
const heredoc = line.match(/^([^<]+)<<(.+)$/u);
|
|
132
|
+
if (heredoc) {
|
|
133
|
+
const values = [];
|
|
134
|
+
while (index + 1 < lines.length && lines[index + 1] !== heredoc[2])
|
|
135
|
+
values.push(lines[(index += 1)]);
|
|
136
|
+
if (index + 1 >= lines.length)
|
|
137
|
+
fail(`GitHub output ${heredoc[1]} has no closing delimiter`);
|
|
138
|
+
index += 1;
|
|
139
|
+
outputs[heredoc[1]] = values.join("\n");
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const separator = line.indexOf("=");
|
|
143
|
+
if (separator > 0)
|
|
144
|
+
outputs[line.slice(0, separator)] = line.slice(separator + 1);
|
|
145
|
+
}
|
|
146
|
+
return outputs;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function rawFileRoot(relative) {
|
|
150
|
+
const hash = crypto.createHash("sha256");
|
|
151
|
+
hash.update(fs.readFileSync(new URL(`../${relative}`, import.meta.url)));
|
|
152
|
+
return `sha256:${hash.digest("hex")}`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function executeBootstrapConformance(request, admission) {
|
|
156
|
+
exactObject(
|
|
157
|
+
request.payload,
|
|
158
|
+
["schema", "expectedGovernedWorkflowCount"],
|
|
159
|
+
"bootstrap conformance payload",
|
|
160
|
+
);
|
|
161
|
+
if (
|
|
162
|
+
request.payload.schema !==
|
|
163
|
+
"kungfu-buildchain-v4-universal-bootstrap-conformance/v1"
|
|
164
|
+
)
|
|
165
|
+
fail("bootstrap conformance payload schema is unsupported");
|
|
166
|
+
if (
|
|
167
|
+
!Number.isSafeInteger(request.payload.expectedGovernedWorkflowCount) ||
|
|
168
|
+
request.payload.expectedGovernedWorkflowCount < 1
|
|
169
|
+
)
|
|
170
|
+
fail("bootstrap conformance workflow count is invalid");
|
|
171
|
+
const architecture = JSON.parse(
|
|
172
|
+
fs.readFileSync(
|
|
173
|
+
new URL(
|
|
174
|
+
"../architecture/universal-workflow-bootstrap.json",
|
|
175
|
+
import.meta.url,
|
|
176
|
+
),
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
const policy = JSON.parse(
|
|
180
|
+
fs.readFileSync(
|
|
181
|
+
new URL(
|
|
182
|
+
"../architecture/universal-workflow-train-admission.json",
|
|
183
|
+
import.meta.url,
|
|
184
|
+
),
|
|
185
|
+
),
|
|
186
|
+
);
|
|
187
|
+
if (
|
|
188
|
+
architecture.bootstrapGovernedWorkflows.length !==
|
|
189
|
+
request.payload.expectedGovernedWorkflowCount ||
|
|
190
|
+
architecture.migration.candidateEngine !== "bounded-capability-adapters" ||
|
|
191
|
+
policy.allowedCapabilities.includes("workflow-contract")
|
|
192
|
+
)
|
|
193
|
+
fail("candidate Bootstrap conformance does not close execution semantics");
|
|
194
|
+
for (const relative of architecture.bootstrapGovernedWorkflows) {
|
|
195
|
+
const source = fs.readFileSync(
|
|
196
|
+
path.join(path.resolve(import.meta.dirname, ".."), currentWorkflowPath(path.resolve(import.meta.dirname, ".."), relative)),
|
|
197
|
+
"utf8",
|
|
198
|
+
);
|
|
199
|
+
if (
|
|
200
|
+
relative !== architecture.bootstrap.publicWorkflow &&
|
|
201
|
+
!/(?:\.\/)?\.github\/workflows\/bootstrap\.yml/u.test(source)
|
|
202
|
+
)
|
|
203
|
+
fail(`candidate Bootstrap facade is not governed: ${relative}`);
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
schema: "kungfu-buildchain-v4-universal-bootstrap-conformance-result/v1",
|
|
207
|
+
status: "candidate-engine-executed",
|
|
208
|
+
runtime: exactRuntime(admission),
|
|
209
|
+
governedWorkflowCount: architecture.bootstrapGovernedWorkflows.length,
|
|
210
|
+
architectureRoot: rawFileRoot(
|
|
211
|
+
"architecture/universal-workflow-bootstrap.json",
|
|
212
|
+
),
|
|
213
|
+
engineRoot: rawFileRoot("scripts/universal-workflow-engine.mjs"),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function observeReleaseRoute({
|
|
218
|
+
repository,
|
|
219
|
+
targetRef,
|
|
220
|
+
requestedSha,
|
|
221
|
+
inputs,
|
|
222
|
+
}) {
|
|
223
|
+
const token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN || "";
|
|
224
|
+
const apiUrl = process.env.GITHUB_API_URL || "https://api.github.com";
|
|
225
|
+
const observed = await githubJson({
|
|
226
|
+
apiUrl,
|
|
227
|
+
token,
|
|
228
|
+
path: `/repos/${repository}/git/ref/heads/${targetRef}`,
|
|
229
|
+
});
|
|
230
|
+
const currentSha = observed.object.sha;
|
|
231
|
+
let comparisonStatus = "identical";
|
|
232
|
+
if (currentSha !== requestedSha) {
|
|
233
|
+
const comparison = await githubJson({
|
|
234
|
+
apiUrl,
|
|
235
|
+
token,
|
|
236
|
+
path: `/repos/${repository}/compare/${requestedSha}...${currentSha}`,
|
|
237
|
+
});
|
|
238
|
+
comparisonStatus = comparison.status;
|
|
239
|
+
}
|
|
240
|
+
return planReleaseRoute({
|
|
241
|
+
requestedSha,
|
|
242
|
+
observedSha: currentSha,
|
|
243
|
+
comparisonStatus,
|
|
244
|
+
requestedChannel: inputs.channel,
|
|
245
|
+
targetRef,
|
|
246
|
+
dryRun: inputs["dry-run"] === true,
|
|
247
|
+
resume:
|
|
248
|
+
String(inputs["resume-candidate-run-id"] || "") !== "" ||
|
|
249
|
+
inputs["publish-transaction-override"] === true,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async function observedSourceTimestamp(repository, sourceSha) {
|
|
254
|
+
const token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN || "";
|
|
255
|
+
const apiUrl = process.env.GITHUB_API_URL || "https://api.github.com";
|
|
256
|
+
const commit = await githubJson({
|
|
257
|
+
apiUrl,
|
|
258
|
+
token,
|
|
259
|
+
path: `/repos/${repository}/git/commits/${sourceSha}`,
|
|
260
|
+
});
|
|
261
|
+
const observed = String(
|
|
262
|
+
commit?.committer?.date || commit?.author?.date || "",
|
|
263
|
+
).trim();
|
|
264
|
+
if (!observed || Number.isNaN(Date.parse(observed)))
|
|
265
|
+
fail("protected publication source timestamp is unavailable");
|
|
266
|
+
return new Date(observed).toISOString();
|
|
267
|
+
}
|
|
268
|
+
async function observeProductPublicationRecovery(repository, sourceSha, candidateVersion, channel) {
|
|
269
|
+
const apiUrl = process.env.GITHUB_API_URL || "https://api.github.com", token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN || "", prefix = `heads/buildchain/v4-product-state/${sourceSha}-`;
|
|
270
|
+
const stateRefs = (await githubJson({ apiUrl, token, path: `/repos/${repository}/git/matching-refs/${prefix}`, allowNotFound: true })) || [];
|
|
271
|
+
const recoveryStates = await Promise.all(stateRefs.map(async (stateRef) => { const version = productStateVersion(stateRef, sourceSha); const [stateCommit, exactTagRef] = await Promise.all([githubJson({ apiUrl, token, path: `/repos/${repository}/git/commits/${stateRef.object.sha}` }), githubJson({ apiUrl, token, path: `/repos/${repository}/git/ref/tags/v${version}`, allowNotFound: true })]); return { stateRef, stateCommit, exactTagRef }; }));
|
|
272
|
+
const exactTagRef = recoveryStates.length ? undefined : await githubJson({ apiUrl, token, path: `/repos/${repository}/git/ref/tags/v${encodeURIComponent(channel === "stable" ? candidateVersion.replace(/-alpha\.\d+$/u, "") : candidateVersion)}`, allowNotFound: true }); return { recoveryStates, exactTagRef };
|
|
273
|
+
}
|
|
274
|
+
async function materializeProductPublicationIntent({
|
|
275
|
+
candidate,
|
|
276
|
+
inputs,
|
|
277
|
+
repository,
|
|
278
|
+
route,
|
|
279
|
+
}) {
|
|
280
|
+
const intentPath = path.resolve(
|
|
281
|
+
".buildchain/release-candidate/product-publication-intent.json",
|
|
282
|
+
);
|
|
283
|
+
const sourceTimestamp = await observedSourceTimestamp(repository, route.requestedSha);
|
|
284
|
+
const version = String(candidate.publicationVersion || candidate.version || "").trim(), explicitResume = String(inputs["resume-transaction-id"] || "") !== "";
|
|
285
|
+
const recovery = route.decision !== "Resume" || explicitResume ? {} : await observeProductPublicationRecovery(repository, route.requestedSha, version, route.channel);
|
|
286
|
+
const recoveredVersion = selectRecoveredProductPublicationVersion({ routeDecision: route.decision, candidateVersion: version, channel: route.channel, requestedSha: route.requestedSha, explicitResume, ...recovery });
|
|
287
|
+
execFileSync(
|
|
288
|
+
process.execPath,
|
|
289
|
+
[
|
|
290
|
+
path.resolve(
|
|
291
|
+
".buildchain/candidate/scripts/product-publication-intent.mjs",
|
|
292
|
+
),
|
|
293
|
+
],
|
|
294
|
+
{
|
|
295
|
+
env: {
|
|
296
|
+
...process.env,
|
|
297
|
+
GITHUB_OUTPUT: "",
|
|
298
|
+
BUILDCHAIN_REPOSITORY: repository,
|
|
299
|
+
BUILDCHAIN_CHANNEL: route.channel,
|
|
300
|
+
BUILDCHAIN_TARGET_REF: route.targetRef,
|
|
301
|
+
BUILDCHAIN_SOURCE_SHA: route.requestedSha,
|
|
302
|
+
BUILDCHAIN_SOURCE_TIMESTAMP: sourceTimestamp,
|
|
303
|
+
BUILDCHAIN_CANDIDATE_VERSION:
|
|
304
|
+
candidate.publicationVersion || candidate.version,
|
|
305
|
+
BUILDCHAIN_RECOVERED_PUBLICATION_VERSION: recoveredVersion,
|
|
306
|
+
BUILDCHAIN_SEALED_BUNDLE_MANIFEST: candidate.paths.sealedBundleManifest,
|
|
307
|
+
BUILDCHAIN_REQUIRED_ARTIFACTS_PATH:
|
|
308
|
+
candidate.paths.publishRequiredArtifacts,
|
|
309
|
+
BUILDCHAIN_PUBLISH_ARTIFACT_KIND: inputs["publish-artifact-kind"] || "npm",
|
|
310
|
+
BUILDCHAIN_PUBLISH_PACKAGE_MAIN: inputs["publish-package-main"] || "",
|
|
311
|
+
BUILDCHAIN_PUBLISH_DIST_TAG: inputs["publish-dist-tag"] || "",
|
|
312
|
+
BUILDCHAIN_PRODUCT_PUBLICATION_INTENT_PATH: intentPath,
|
|
313
|
+
},
|
|
314
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
315
|
+
},
|
|
316
|
+
);
|
|
317
|
+
return intentPath;
|
|
318
|
+
}
|
|
319
|
+
function verifiedReleaseDocuments() {
|
|
320
|
+
const base = path.resolve(".buildchain/release-tail");
|
|
321
|
+
const invocation = JSON.parse(
|
|
322
|
+
fs.readFileSync(path.join(base, "release-invocation.json")),
|
|
323
|
+
);
|
|
324
|
+
const transaction = JSON.parse(
|
|
325
|
+
fs.readFileSync(path.join(base, "release-transaction.json")),
|
|
326
|
+
);
|
|
327
|
+
const storedReceipt = JSON.parse(
|
|
328
|
+
fs.readFileSync(path.join(base, "release-receipt.json")),
|
|
329
|
+
);
|
|
330
|
+
const invocationProjection = createReleaseInvocation(invocation);
|
|
331
|
+
const transactionProjection = createDomainReleaseTransaction({
|
|
332
|
+
invocationRoot: transaction.invocationRoot,
|
|
333
|
+
publisherRoot: transaction.publisherRoot,
|
|
334
|
+
runtimeRoot: transaction.runtimeRoot,
|
|
335
|
+
providerRoot: transaction.providerRoot,
|
|
336
|
+
parentRoot: transaction.parentRoot,
|
|
337
|
+
});
|
|
338
|
+
const { receiptRoot, ...receipt } = storedReceipt;
|
|
339
|
+
const receiptProjection = createReleaseReceipt(receipt);
|
|
340
|
+
if (
|
|
341
|
+
transaction.invocationRoot !== invocationProjection.roots.invocationRoot ||
|
|
342
|
+
transaction.transactionRoot !== transactionProjection.transactionRoot ||
|
|
343
|
+
receipt.transactionRoot !== transactionProjection.transactionRoot ||
|
|
344
|
+
receiptProjection.receiptRoot !== receiptRoot ||
|
|
345
|
+
receipt.outcome !== "complete"
|
|
346
|
+
)
|
|
347
|
+
fail("terminal ReleaseReceipt lineage does not verify");
|
|
348
|
+
return { invocation, transaction, receipt: storedReceipt };
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async function executeReleasePromotion(request, admission) {
|
|
352
|
+
const payload = request.payload;
|
|
353
|
+
exactObject(
|
|
354
|
+
payload,
|
|
355
|
+
["schema", "inputs", "dryRunObservation"],
|
|
356
|
+
"release promotion payload",
|
|
357
|
+
);
|
|
358
|
+
if (payload.schema !== "kungfu-buildchain-v4-universal-release-promotion/v1")
|
|
359
|
+
fail("release promotion payload schema is unsupported");
|
|
360
|
+
exactObject(
|
|
361
|
+
payload.inputs,
|
|
362
|
+
Object.keys(payload.inputs),
|
|
363
|
+
"release promotion inputs",
|
|
364
|
+
);
|
|
365
|
+
validateWorkflowInputs("release-candidate-promote", payload.inputs);
|
|
366
|
+
assertDeclarativePromotionInputs(payload.inputs);
|
|
367
|
+
const repository = request.consumer.repository;
|
|
368
|
+
const targetRef = String(payload.inputs["target-ref"] || "").replace(
|
|
369
|
+
/^refs\/heads\//u,
|
|
370
|
+
"",
|
|
371
|
+
);
|
|
372
|
+
const requestedSha = String(
|
|
373
|
+
payload.inputs["target-sha"] || request.consumer.sourceSha,
|
|
374
|
+
);
|
|
375
|
+
let route;
|
|
376
|
+
if (payload.inputs["dry-run"] === true && payload.dryRunObservation) {
|
|
377
|
+
exactObject(
|
|
378
|
+
payload.dryRunObservation,
|
|
379
|
+
["observedSha", "comparisonStatus"],
|
|
380
|
+
"dry-run observation",
|
|
381
|
+
);
|
|
382
|
+
route = planReleaseRoute({
|
|
383
|
+
requestedSha,
|
|
384
|
+
observedSha: payload.dryRunObservation.observedSha,
|
|
385
|
+
comparisonStatus: payload.dryRunObservation.comparisonStatus,
|
|
386
|
+
requestedChannel: payload.inputs.channel,
|
|
387
|
+
targetRef,
|
|
388
|
+
dryRun: true,
|
|
389
|
+
resume: false,
|
|
390
|
+
});
|
|
391
|
+
} else {
|
|
392
|
+
route = await observeReleaseRoute({
|
|
393
|
+
repository,
|
|
394
|
+
targetRef,
|
|
395
|
+
requestedSha,
|
|
396
|
+
inputs: payload.inputs,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
if (route.decision === "Blocked")
|
|
400
|
+
fail(`release route blocked: ${route.reason}`);
|
|
401
|
+
if (route.decision === "NoOp" || payload.inputs["dry-run"] === true)
|
|
402
|
+
return { route, dryRun: payload.inputs["dry-run"] === true };
|
|
403
|
+
prepareReleasePromotionConsumerDependencies(repository);
|
|
404
|
+
if (payload.inputs["trusted-publishing"] === true)
|
|
405
|
+
prepareTrustedPublishingNpm();
|
|
406
|
+
const candidate = await resolveReleaseCandidateArtifacts({
|
|
407
|
+
repository,
|
|
408
|
+
targetRef: route.targetRef,
|
|
409
|
+
targetSha: route.requestedSha,
|
|
410
|
+
token: process.env.GH_TOKEN || process.env.GITHUB_TOKEN,
|
|
411
|
+
workflowFile: payload.inputs["release-candidate-workflow-file"],
|
|
412
|
+
workflowName: payload.inputs["release-candidate-workflow-name"],
|
|
413
|
+
artifactName: payload.inputs["artifact-name"],
|
|
414
|
+
artifactPatterns: payload.inputs["artifact-patterns"],
|
|
415
|
+
githubReleasePayloadPatterns:
|
|
416
|
+
payload.inputs["github-release-payload-patterns"],
|
|
417
|
+
requiredArtifactCount: payload.inputs["required-artifact-count"],
|
|
418
|
+
publishArtifactKind: payload.inputs["publish-artifact-kind"],
|
|
419
|
+
publishPackageMain: payload.inputs["publish-package-main"],
|
|
420
|
+
runtimeSha: admission.runtime.sha,
|
|
421
|
+
outputDir: ".buildchain/release-candidate",
|
|
422
|
+
waitSeconds: payload.inputs["release-candidate-wait-seconds"],
|
|
423
|
+
});
|
|
424
|
+
if (!candidate.enabled)
|
|
425
|
+
fail(candidate.reason || "release candidate is unavailable");
|
|
426
|
+
const productPublicationIntentPath = await materializeProductPublicationIntent({
|
|
427
|
+
candidate,
|
|
428
|
+
inputs: payload.inputs,
|
|
429
|
+
repository,
|
|
430
|
+
route,
|
|
431
|
+
});
|
|
432
|
+
const productPublicationIntent = JSON.parse(fs.readFileSync(productPublicationIntentPath));
|
|
433
|
+
const runtimeTree = execFileSync(
|
|
434
|
+
"git",
|
|
435
|
+
["-C", ".buildchain/candidate", "rev-parse", "HEAD^{tree}"],
|
|
436
|
+
{ encoding: "utf8" },
|
|
437
|
+
).trim();
|
|
438
|
+
const actionInputs = {
|
|
439
|
+
token: process.env.GH_TOKEN || process.env.GITHUB_TOKEN,
|
|
440
|
+
"mutation-token":
|
|
441
|
+
process.env.BUILDCHAIN_PROMOTION_TOKEN || process.env.GH_TOKEN,
|
|
442
|
+
repository,
|
|
443
|
+
"source-sha": route.requestedSha,
|
|
444
|
+
version: productPublicationIntent.version,
|
|
445
|
+
tag: productPublicationIntent.exactTag,
|
|
446
|
+
channel: route.channel,
|
|
447
|
+
"target-ref": route.targetRef,
|
|
448
|
+
"target-sha": route.requestedSha,
|
|
449
|
+
"candidate-passport-path": candidate.paths.passport,
|
|
450
|
+
"candidate-build-summary-path": candidate.paths.buildSummary,
|
|
451
|
+
"stage-capsules-path": candidate.paths.stageCapsules,
|
|
452
|
+
"publication-qualification-path": candidate.paths.publicationQualification,
|
|
453
|
+
"publish-artifact-kind": payload.inputs["publish-artifact-kind"] || "npm",
|
|
454
|
+
"sealed-bundle-root": candidate.paths.sealedBundleRoot,
|
|
455
|
+
"sealed-bundle-manifest": candidate.paths.sealedBundleManifest,
|
|
456
|
+
"required-artifacts-path": candidate.paths.publishRequiredArtifacts,
|
|
457
|
+
"product-publication-intent-path": productPublicationIntentPath,
|
|
458
|
+
"publisher-workflow-sha": admission.runtime.sha,
|
|
459
|
+
"runtime-commit": admission.runtime.sha,
|
|
460
|
+
"runtime-tree": runtimeTree,
|
|
461
|
+
"required-status-check": payload.inputs["required-status-check"],
|
|
462
|
+
"publish-command": payload.inputs["publish-command"],
|
|
463
|
+
"publish-mode": payload.inputs["publish-mode"],
|
|
464
|
+
"publish-dist-tag": payload.inputs["publish-dist-tag"],
|
|
465
|
+
"publish-package-set-order": payload.inputs["publish-package-set-order"],
|
|
466
|
+
"publish-package-main": payload.inputs["publish-package-main"],
|
|
467
|
+
"publish-auth": payload.inputs["trusted-publishing"]
|
|
468
|
+
? "trusted-publishing"
|
|
469
|
+
: "npm-token",
|
|
470
|
+
"publish-rematerialize-on-resume":
|
|
471
|
+
payload.inputs["publish-rematerialize-on-resume"],
|
|
472
|
+
"publish-transaction-override":
|
|
473
|
+
payload.inputs["publish-transaction-override"],
|
|
474
|
+
"resume-transaction-id": payload.inputs["resume-transaction-id"],
|
|
475
|
+
"artifact-paths": candidate.paths.releaseAssets.join("\n"),
|
|
476
|
+
"state-path": ".buildchain/release-tail/state.json",
|
|
477
|
+
"failure-after-capability":
|
|
478
|
+
payload.inputs["provider-failure-after-capability"],
|
|
479
|
+
};
|
|
480
|
+
const actionOutput = path.resolve(".buildchain/universal-release-action.out");
|
|
481
|
+
fs.mkdirSync(path.dirname(actionOutput), { recursive: true });
|
|
482
|
+
fs.writeFileSync(actionOutput, "");
|
|
483
|
+
execFileSync(
|
|
484
|
+
process.execPath,
|
|
485
|
+
[
|
|
486
|
+
path.resolve(
|
|
487
|
+
".buildchain/candidate/actions/release-candidate-promote/dist/index.js",
|
|
488
|
+
),
|
|
489
|
+
],
|
|
490
|
+
{ env: actionEnvironment(actionInputs, actionOutput), stdio: ["ignore", 2, 2] },
|
|
491
|
+
);
|
|
492
|
+
return {
|
|
493
|
+
route,
|
|
494
|
+
candidate: {
|
|
495
|
+
runId: candidate.run.id,
|
|
496
|
+
sourceSha: candidate.artifacts.sourceSha,
|
|
497
|
+
version: candidate.version,
|
|
498
|
+
},
|
|
499
|
+
provider: readGitHubOutputs(actionOutput),
|
|
500
|
+
release: verifiedReleaseDocuments(),
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async function capabilityResult(request, admission) {
|
|
505
|
+
if (request.capability.id === "bootstrap-conformance")
|
|
506
|
+
return executeBootstrapConformance(request, admission);
|
|
507
|
+
if (request.capability.id === "release-invocation") {
|
|
508
|
+
const release = createReleaseInvocation(request.payload);
|
|
509
|
+
return {
|
|
510
|
+
releaseInvocation: release.invocation,
|
|
511
|
+
releaseRoots: release.roots,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
if (request.capability.id === "release-candidate-promote")
|
|
515
|
+
return executeReleasePromotion(request, admission);
|
|
516
|
+
fail(`candidate capability is not implemented: ${request.capability.id}`);
|
|
517
|
+
}
|
|
518
|
+
async function executeCandidate(request, admission) {
|
|
519
|
+
const runtime = exactRuntime(admission);
|
|
520
|
+
if (universalWorkflowRequestRoot(request) !== admission.requestRoot)
|
|
521
|
+
fail("candidate request does not match the admitted request root");
|
|
522
|
+
const engineSha = String(process.env.BUILDCHAIN_UNIVERSAL_ENGINE_SHA || "")
|
|
523
|
+
.trim()
|
|
524
|
+
.toLowerCase();
|
|
525
|
+
if (engineSha !== runtime.sha)
|
|
526
|
+
fail("candidate engine checkout does not match the admitted runtime SHA");
|
|
527
|
+
try {
|
|
528
|
+
return {
|
|
529
|
+
status: "succeeded",
|
|
530
|
+
output: await capabilityResult(request, admission),
|
|
531
|
+
};
|
|
532
|
+
} catch (error) {
|
|
533
|
+
return {
|
|
534
|
+
status: "failed",
|
|
535
|
+
error: {
|
|
536
|
+
code: String(error?.code || "candidate-execution-failed"),
|
|
537
|
+
message: "candidate capability execution failed",
|
|
538
|
+
},
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function assertResultLineage(admission, result) {
|
|
544
|
+
if (
|
|
545
|
+
result?.schema !== "kungfu-buildchain-v4-universal-workflow-result/v1" ||
|
|
546
|
+
result.requestRoot !== admission.requestRoot ||
|
|
547
|
+
result.capabilityRoot !== admission.capabilityRoot ||
|
|
548
|
+
result.runtime?.repository !== admission.runtime?.repository ||
|
|
549
|
+
result.runtime?.sha !== admission.runtime?.sha ||
|
|
550
|
+
!["succeeded", "failed"].includes(result.status)
|
|
551
|
+
)
|
|
552
|
+
fail("candidate result does not match the admitted lineage");
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const command = process.argv[2];
|
|
556
|
+
if (!command) fail("a command is required");
|
|
557
|
+
|
|
558
|
+
if (command === "inspect") {
|
|
559
|
+
const request = validateUniversalWorkflowRequest(
|
|
560
|
+
readJsonEnvironment("BUILDCHAIN_UNIVERSAL_REQUEST_JSON"),
|
|
561
|
+
);
|
|
562
|
+
emit({
|
|
563
|
+
schema: "kungfu-buildchain-v4-universal-workflow-inspection/v1",
|
|
564
|
+
requestRoot: universalWorkflowRequestRoot(request),
|
|
565
|
+
mode: request.mode,
|
|
566
|
+
candidate: request.candidate,
|
|
567
|
+
consumer: request.consumer,
|
|
568
|
+
capability: request.capability,
|
|
569
|
+
});
|
|
570
|
+
} else if (command === "admit") {
|
|
571
|
+
emit(
|
|
572
|
+
admitUniversalWorkflow({
|
|
573
|
+
request: readJsonEnvironment("BUILDCHAIN_UNIVERSAL_REQUEST_JSON"),
|
|
574
|
+
policy: readJsonEnvironment("BUILDCHAIN_UNIVERSAL_ADMISSION_POLICY_JSON"),
|
|
575
|
+
observedRefSha: process.env.BUILDCHAIN_UNIVERSAL_OBSERVED_SHA,
|
|
576
|
+
observedConsumerRepository:
|
|
577
|
+
process.env.BUILDCHAIN_UNIVERSAL_CONSUMER_REPOSITORY,
|
|
578
|
+
observedConsumerSha: process.env.BUILDCHAIN_UNIVERSAL_CONSUMER_SHA,
|
|
579
|
+
observedConsumerWorkflowRef:
|
|
580
|
+
process.env.BUILDCHAIN_UNIVERSAL_CONSUMER_WORKFLOW_REF,
|
|
581
|
+
reviewEvidence: readJsonEnvironment(
|
|
582
|
+
"BUILDCHAIN_UNIVERSAL_REVIEW_EVIDENCE_JSON",
|
|
583
|
+
),
|
|
584
|
+
now: process.env.BUILDCHAIN_UNIVERSAL_OBSERVED_AT,
|
|
585
|
+
}),
|
|
586
|
+
);
|
|
587
|
+
} else if (command === "execute") {
|
|
588
|
+
const request = validateUniversalWorkflowRequest(
|
|
589
|
+
readJsonEnvironment("BUILDCHAIN_UNIVERSAL_REQUEST_JSON"),
|
|
590
|
+
);
|
|
591
|
+
const admission = readJsonEnvironment("BUILDCHAIN_UNIVERSAL_ADMISSION_JSON");
|
|
592
|
+
const runtime = exactRuntime(admission);
|
|
593
|
+
const execution = await executeCandidate(request, admission);
|
|
594
|
+
const result = {
|
|
595
|
+
schema: "kungfu-buildchain-v4-universal-workflow-result/v1",
|
|
596
|
+
status: execution.status,
|
|
597
|
+
requestRoot: admission.requestRoot,
|
|
598
|
+
runtime,
|
|
599
|
+
capabilityRoot: admission.capabilityRoot,
|
|
600
|
+
enginePath: "scripts/universal-workflow-engine.mjs",
|
|
601
|
+
...execution,
|
|
602
|
+
};
|
|
603
|
+
emit({
|
|
604
|
+
...result,
|
|
605
|
+
resultRoot: contentRoot("universal-workflow-result", result),
|
|
606
|
+
});
|
|
607
|
+
} else if (command === "terminal") {
|
|
608
|
+
const admission = readJsonEnvironment("BUILDCHAIN_UNIVERSAL_ADMISSION_JSON");
|
|
609
|
+
const result = readJsonEnvironment("BUILDCHAIN_UNIVERSAL_RESULT_JSON");
|
|
610
|
+
assertResultLineage(admission, result);
|
|
611
|
+
emit(
|
|
612
|
+
completeUniversalWorkflow({
|
|
613
|
+
admission,
|
|
614
|
+
status: result.status,
|
|
615
|
+
resultRoot: result.resultRoot,
|
|
616
|
+
}),
|
|
617
|
+
);
|
|
618
|
+
} else {
|
|
619
|
+
fail(`unsupported command: ${command}`);
|
|
620
|
+
}
|