@kungfu-tech/buildchain 4.0.9 → 4.1.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 +35 -5
- package/CONTRIBUTING.md +18 -29
- package/README.md +55 -29
- package/actions/build/artifact/prepare-attestation/README.md +26 -0
- package/actions/build/artifact/seal-attestation/README.md +26 -0
- package/actions/build/lifecycle/run/README.md +71 -0
- package/actions/build/lifecycle/validate/README.md +52 -0
- package/actions/governance/incident/report/README.md +107 -0
- package/actions/release/promotion/ref/README.md +92 -0
- package/architecture/action-taxonomy.json +543 -0
- package/architecture/agent-change-map.md +2061 -431
- package/architecture/build-environments.json +18 -2
- package/architecture/build-orchestration.json +58 -9
- package/architecture/capability-state-machine-manifest.json +15 -16
- package/architecture/capability-state-machine-manifest.schema.json +2 -2
- package/architecture/ci-lane-change-budget.json +2105 -225
- package/architecture/code-layout.json +55 -0
- package/architecture/core-mechanisms.json +1160 -0
- package/architecture/cross-platform-adopter-qualification.json +4 -14
- package/architecture/delivery-authority-parity.json +46 -46
- package/architecture/delivery-warrant-shadow-bootstrap-plan.json +4 -4
- package/architecture/delivery-warrant-shadow-bootstrap-plan.md +3 -3
- package/architecture/dev-delivery-orchestration.json +175 -0
- package/architecture/floating-consumer-policy.json +15 -11
- package/architecture/history/warrant-shadow-observations.json +900 -0
- package/architecture/internal-capabilities.json +2332 -358
- package/architecture/layered-transition.json +32 -0
- package/architecture/maintainability-debt.json +883 -1840
- package/architecture/maintainability-policy.json +63 -1438
- package/architecture/partial-mutation-recovery-qualification.json +4 -4
- package/architecture/platform-stage-checkpoints.json +1 -1
- package/architecture/promotion-job-topology.json +85 -0
- package/architecture/provider-operation-journal-contract.json +5 -5
- package/architecture/publication-facade-patches.json +5 -5
- package/architecture/release-activation-shadow-domain.json +4 -4
- package/architecture/release-invocation-fixtures.json +31 -16
- package/architecture/release-tail-contract-inventory.json +1 -9
- package/architecture/release-tail-contract.json +273 -0
- package/architecture/release-topology.json +245 -215
- package/architecture/runtime-ref-resume-authority.json +1 -1
- package/architecture/runtime-semantic-closure.json +27 -17
- package/architecture/rust-libnode-bridge-evaluation.json +1 -1
- package/architecture/rust-wasm-production-authority.json +7 -7
- package/architecture/stable-publication-fence.json +4 -4
- package/architecture/stage-capsule-qualification.json +4 -4
- package/architecture/stage-capsule-resume-planner.json +1 -1
- package/architecture/stage-capsule-store-contract.json +2 -2
- package/architecture/tail-reseal-parity.json +22 -17
- package/architecture/universal-workflow-bootstrap.json +121 -102
- package/architecture/universal-workflow-fault-campaign.json +11 -11
- package/architecture/universal-workflow-train-admission.json +44 -8
- package/architecture/workflow-taxonomy.json +81 -798
- package/bin/buildchain.mjs +2 -1820
- package/contracts/buildchain-v2-residuals-v1.json +2 -138
- package/contracts/dev-delivery-authority-v2.schema.json +509 -231
- package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
- package/contracts/promotion-invocation-v1.schema.json +547 -0
- package/contracts/promotion-request-v1.schema.json +472 -0
- package/contracts/v4-adopter-delivery-v1.schema.json +1 -1
- package/contracts/v4-compatibility-facts-v1.schema.json +4 -4
- package/contracts/v4-floating-consumer-policy-receipt-v1.schema.json +124 -21
- package/contracts/v4-release-invocation-v1.schema.json +1 -1
- package/crates/buildchain-host-bridge/src/main.rs +1 -1
- package/dist/site/buildchain-contract.json +145 -2206
- package/dist/site/buildchain-site.json +350 -326
- package/dist/site/capability-registry.json +17 -17
- package/dist/site/cli-registry.json +354 -365
- package/dist/site/controller-registry.json +142 -715
- package/dist/site/kfd-claims.json +5871 -3138
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +26 -26
- package/dist/site/node-api-registry.json +12561 -16063
- package/dist/site/page-registry.json +312 -292
- package/dist/site/public-surface-audit.json +3844 -3601
- package/dist/site/publication-authority-registry.json +295 -1117
- package/dist/site/publication-registry.json +5 -5
- package/dist/site/release-provenance.json +80 -90
- package/dist/site/schemas/dev-delivery-authority-v2.schema.json +509 -231
- package/dist/site/schemas/v4-adopter-delivery-v1.schema.json +1 -1
- package/dist/site/schemas/v4-compatibility-facts-v1.schema.json +4 -4
- package/dist/site/site-manifest.json +31 -31
- package/dist/site/workflow-registry.json +7274 -5321
- package/docs/MAP.md +8 -6
- package/docs/auditable-demo.md +4 -4
- package/docs/aws-us-elastic-runner-burst-plane.md +5 -5
- package/docs/binary-distribution.md +2 -2
- package/docs/bootstrap-recovery.md +50 -0
- package/docs/cli-reference.md +2 -35
- package/docs/cli.md +6 -6
- package/docs/code-organization.md +131 -0
- package/docs/consumer-issue-reporting.md +1 -1
- package/docs/dev-alpha-candidate-patrol.md +1 -1
- package/docs/dev-delivery-orchestration.md +116 -0
- package/docs/dev-delivery-qualification-landing-adr.md +1 -1
- package/docs/dev-delivery-warrant.md +5 -2
- package/docs/dev-qualification-patrol.md +1 -1
- package/docs/engineering-housekeeper.md +3 -3
- package/docs/github-artifact-attestation.md +3 -3
- package/docs/kfd-support.md +1 -1
- package/docs/lifecycle-protocol.md +8 -8
- package/docs/migration-inventory.md +6 -6
- package/docs/next-development-transition.md +4 -4
- package/docs/node-api-reference.md +2273 -2644
- package/docs/ownership.md +3 -3
- package/docs/publication-artifacts.md +5 -5
- package/docs/publication-authority.md +4 -4
- package/docs/publish-transaction.md +10 -10
- package/docs/release-activation-transaction.md +1 -1
- package/docs/release-candidate.md +4 -4
- package/docs/release-governance.md +25 -25
- package/docs/release-passport.md +2 -2
- package/docs/release-promotion-request.md +64 -0
- package/docs/release-propagation.md +19 -18
- package/docs/release-tail-contract.md +40 -76
- package/docs/release-tail-provider-plane.md +17 -26
- package/docs/reusable-build-surface.md +34 -21
- package/docs/shifu-gate-profiles.md +4 -4
- package/docs/site-bundle-contract.md +1 -1
- package/docs/stable-candidate-patrol.md +1 -1
- package/docs/v4-adopter-delivery.md +50 -121
- package/docs/v4-canonical-contracts.md +3 -3
- package/docs/v4-compatibility-facts.md +1 -1
- package/docs/v4-declarative-release-tail-migration.md +24 -29
- package/docs/v4-production-release.md +16 -1
- package/docs/v4-publication-rehearsal.md +1 -1
- package/docs/v4-runtime-ref-resume-authority.md +2 -2
- package/docs/v4-rust-wasm-production-authority.md +2 -2
- package/docs/v4-stage-capsule.md +1 -1
- package/docs/web-surface-deployments.md +22 -28
- package/docs/workflow-catalog.md +82 -127
- package/docs/workflow-path-migration.md +1 -5
- package/package.json +99 -102
- package/packages/core/README.md +41 -164
- package/packages/core/adoption/adopter-delivery-parity.js +219 -0
- package/packages/core/adoption/adopter-delivery.js +210 -0
- package/packages/core/adoption/buildchain-kfd-claims.js +733 -0
- package/packages/core/adoption/cli/delivery.mjs +39 -0
- package/packages/core/adoption/cli/dispatch.mjs +5 -0
- package/packages/core/adoption/cli/kfd-aggregate.mjs +20 -0
- package/packages/core/adoption/cli/kfd-hub.mjs +53 -0
- package/packages/core/adoption/cli/kfd-migrate-layout.mjs +27 -0
- package/packages/core/adoption/cli/kfd-schema.mjs +55 -0
- package/packages/core/adoption/cli/kfd-status.mjs +21 -0
- package/packages/core/adoption/cli/kfd-upstream.mjs +69 -0
- package/packages/core/adoption/cli/kfd.mjs +63 -0
- package/packages/core/adoption/cli/output.mjs +18 -0
- package/packages/core/adoption/cli/product-gate.mjs +110 -0
- package/packages/core/adoption/cli/project.mjs +38 -0
- package/packages/core/adoption/cli/standards.mjs +282 -0
- package/packages/core/adoption/cli/support.mjs +101 -0
- package/packages/core/adoption/cli/surface-register.mjs +172 -0
- package/packages/core/adoption/commands/cross-platform-adopter-qualification.mjs +28 -0
- package/packages/core/adoption/commands/init-repo.mjs +518 -0
- package/packages/core/adoption/cross-platform-adopter-qualification.js +217 -0
- package/packages/core/adoption/kfd-agent-hub.js +496 -0
- package/packages/core/adoption/kfd.js +966 -0
- package/packages/core/adoption/kfd2-product-claims.js +454 -0
- package/packages/core/adoption/kfd3-surface-register.js +924 -0
- package/packages/core/adoption/qualification/actions.js +106 -0
- package/packages/core/adoption/qualification/admission.js +96 -0
- package/packages/core/adoption/qualification/aggregate.js +10 -0
- package/packages/core/adoption/qualification/io.js +51 -0
- package/packages/core/adoption/qualification/platform.js +120 -0
- package/packages/core/build/anchored-version-material.js +281 -0
- package/packages/core/build/artifact/actions.js +47 -0
- package/packages/core/build/artifact/attestation.js +166 -0
- package/packages/core/build/artifact/contracts.js +168 -0
- package/packages/core/build/artifact/coordinates.js +113 -0
- package/packages/core/build/artifact/credential-transport.js +68 -0
- package/packages/core/build/artifact/expectations.js +94 -0
- package/packages/core/build/artifact/files.js +14 -0
- package/packages/core/build/artifact/naming.js +65 -0
- package/packages/core/build/artifact/services.js +17 -0
- package/packages/core/build/artifact/store.js +119 -0
- package/packages/core/build/artifact/summary.js +20 -0
- package/packages/core/build/artifact/transfer-policy.js +34 -0
- package/packages/core/build/artifact/transport.js +112 -0
- package/packages/core/build/artifact/upload.js +178 -0
- package/packages/core/build/artifact-coordinate-action.js +46 -0
- package/packages/core/build/artifact-coordinate.js +58 -0
- package/packages/core/build/artifact-integrity.js +10 -0
- package/packages/core/build/artifact-passport.js +842 -0
- package/packages/core/build/artifact-verification-envelope.js +500 -0
- package/packages/core/build/binary/actions.js +77 -0
- package/packages/core/build/binary/checksums.js +33 -0
- package/packages/core/build/binary/distribution.js +271 -0
- package/packages/core/build/binary-publication-dispatch.js +49 -0
- package/packages/core/build/build-facts.js +518 -0
- package/packages/core/build/cache/compiler-evidence.js +287 -0
- package/packages/core/build/cli/cache.mjs +77 -0
- package/packages/core/build/cli/facts.mjs +120 -0
- package/packages/core/build/cli/homebrew.mjs +101 -0
- package/packages/core/build/cli/lifecycle.mjs +66 -0
- package/packages/core/build/commands/aggregate-build-summary.mjs +75 -0
- package/packages/core/build/commands/anchored-version-material.mjs +42 -0
- package/packages/core/build/commands/artifact-signing-controller.mjs +112 -0
- package/packages/core/build/commands/artifact-signing-delegation.mjs +34 -0
- package/packages/core/build/commands/auditable-demo-platform.mjs +77 -0
- package/packages/core/build/commands/auditable-demo-transport-smoke.mjs +24 -0
- package/packages/core/build/commands/auditable-demo.mjs +63 -0
- package/packages/core/build/commands/compiler-cache-evidence.mjs +39 -0
- package/packages/core/build/commands/dispatch-artifact-signing-authority.mjs +19 -0
- package/packages/core/build/commands/import-artifact-signing-results.mjs +10 -0
- package/packages/core/build/commands/lifecycle-substage-evidence.mjs +42 -0
- package/packages/core/build/commands/resolve-artifact-coordinates.mjs +58 -0
- package/packages/core/build/commands/resolve-artifact-transfer-mode.mjs +54 -0
- package/packages/core/build/commands/resolve-build-configuration.mjs +23 -0
- package/packages/core/build/commands/resolve-build-contract.mjs +94 -0
- package/packages/core/build/commands/run-candidate-body-prefix-renderer.mjs +24 -0
- package/packages/core/build/commands/run-lifecycle.mjs +56 -0
- package/packages/core/build/commands/seal-artifact-signing-requests.mjs +10 -0
- package/packages/core/build/commands/seal-macos-credential-input.mjs +4 -0
- package/packages/core/build/commands/shifu-gate-profile.mjs +43 -0
- package/packages/core/build/commands/source-verification-evidence.mjs +14 -0
- package/packages/core/build/commands/stage-capsule-qualification.mjs +79 -0
- package/packages/core/build/commands/validate-package-manager-contract.mjs +24 -0
- package/packages/core/build/credential/seal-input.js +109 -0
- package/packages/core/build/demo/action-context.js +25 -0
- package/packages/core/build/demo/adapter-actions.js +35 -0
- package/packages/core/build/demo/adapter-transactions.js +66 -0
- package/packages/core/build/demo/adapter.js +272 -0
- package/packages/core/build/demo/binary-action.js +29 -0
- package/packages/core/build/demo/bundle-verification.js +211 -0
- package/packages/core/build/demo/capture-adaptation.js +37 -0
- package/packages/core/build/demo/capture.js +377 -0
- package/packages/core/build/demo/collection-actions.js +62 -0
- package/packages/core/build/demo/collection-containers.js +136 -0
- package/packages/core/build/demo/collection-context.js +40 -0
- package/packages/core/build/demo/collection.js +129 -0
- package/packages/core/build/demo/composition.js +319 -0
- package/packages/core/build/demo/container.js +113 -0
- package/packages/core/build/demo/gate.js +297 -0
- package/packages/core/build/demo/inspection-worker.js +4 -0
- package/packages/core/build/demo/io.js +220 -0
- package/packages/core/build/demo/materialization.js +350 -0
- package/packages/core/build/demo/media-bundle.js +112 -0
- package/packages/core/build/demo/media-inspection.js +332 -0
- package/packages/core/build/demo/media-profile.js +399 -0
- package/packages/core/build/demo/media-qualification-action.js +37 -0
- package/packages/core/build/demo/media-qualification.js +117 -0
- package/packages/core/build/demo/presentation.js +222 -0
- package/packages/core/build/demo/publication.js +118 -0
- package/packages/core/build/demo/renderer-evidence.js +193 -0
- package/packages/core/build/demo/renditions.js +398 -0
- package/packages/core/build/demo/scenario.js +493 -0
- package/packages/core/build/demo/schema.js +278 -0
- package/packages/core/build/demo/transport-smoke.js +149 -0
- package/packages/core/build/demo/values.js +137 -0
- package/packages/core/build/environment/action.js +17 -0
- package/packages/core/build/environment/provision.js +121 -0
- package/packages/core/build/gate/actions.js +99 -0
- package/packages/core/build/gate/aggregate.js +21 -0
- package/packages/core/build/gate/commands.js +66 -0
- package/packages/core/build/gate/controller.js +43 -0
- package/packages/core/build/gate/environment.js +18 -0
- package/packages/core/build/gate/execution.js +88 -0
- package/packages/core/build/gate/files.js +46 -0
- package/packages/core/build/gate/outputs.js +31 -0
- package/packages/core/build/gate/plan.js +61 -0
- package/packages/core/build/github-artifact-attestation.js +642 -0
- package/packages/core/build/github-attestation/action.js +26 -0
- package/packages/core/build/github-attestation/admission.js +34 -0
- package/packages/core/build/github-attestation/transaction.js +83 -0
- package/packages/core/build/homebrew.js +416 -0
- package/packages/core/build/lifecycle/action.js +65 -0
- package/packages/core/build/lifecycle/artifacts.js +123 -0
- package/packages/core/build/lifecycle/context.js +202 -0
- package/packages/core/build/lifecycle/diagnostics.js +254 -0
- package/packages/core/build/lifecycle/errors.js +44 -0
- package/packages/core/build/lifecycle/execution.js +221 -0
- package/packages/core/build/lifecycle/files.js +61 -0
- package/packages/core/build/lifecycle/manifest.js +107 -0
- package/packages/core/build/lifecycle/sampling.js +209 -0
- package/packages/core/build/lifecycle/stage-action.js +18 -0
- package/packages/core/build/lifecycle/stage.js +143 -0
- package/packages/core/build/lifecycle/substage-evidence.js +232 -0
- package/packages/core/build/lifecycle/transaction.js +13 -0
- package/packages/core/build/macos-credential-island/action.js +704 -0
- package/packages/core/build/macos-credential-island/cleanup.js +48 -0
- package/packages/core/build/macos-credential-island/dmg-assembly.js +443 -0
- package/packages/core/build/macos-credential-island/lib.js +816 -0
- package/packages/core/build/package-manager.js +315 -0
- package/packages/core/build/plan/action-context.js +30 -0
- package/packages/core/build/plan/action.js +79 -0
- package/packages/core/build/plan/admission.js +93 -0
- package/packages/core/build/plan/configuration.js +196 -0
- package/packages/core/build/plan/environment.js +18 -0
- package/packages/core/build/plan/identity.js +49 -0
- package/packages/core/build/plan/lifecycle.js +38 -0
- package/packages/core/build/plan/matrices.js +58 -0
- package/packages/core/build/plan/resolve.js +76 -0
- package/packages/core/build/plan/runners.js +48 -0
- package/packages/core/build/plan/source.js +58 -0
- package/packages/core/build/plan/stage-order.js +10 -0
- package/packages/core/build/plan/values.js +10 -0
- package/packages/core/build/platform-stage-checkpoints.js +471 -0
- package/packages/core/build/release-evidence-bundle.js +156 -0
- package/packages/core/build/runner/matrix.js +266 -0
- package/packages/core/build/runner/presets.js +115 -0
- package/packages/core/build/signing/actions.js +54 -0
- package/packages/core/build/signing/authority-actions.js +147 -0
- package/packages/core/build/signing/authority-transaction.js +82 -0
- package/packages/core/build/signing/control.js +223 -0
- package/packages/core/build/signing/controller-transaction.js +110 -0
- package/packages/core/build/signing/credential-transaction.js +66 -0
- package/packages/core/build/signing/delegation.js +281 -0
- package/packages/core/build/signing/detached.js +170 -0
- package/packages/core/build/signing/dispatch.js +307 -0
- package/packages/core/build/signing/environment.js +13 -0
- package/packages/core/build/signing/files.js +53 -0
- package/packages/core/build/signing/import-results.js +151 -0
- package/packages/core/build/signing/intake.js +113 -0
- package/packages/core/build/signing/materialize.js +54 -0
- package/packages/core/build/signing/merge-results.js +82 -0
- package/packages/core/build/signing/native-result.js +244 -0
- package/packages/core/build/signing/prepare.js +44 -0
- package/packages/core/build/signing/request.js +519 -0
- package/packages/core/build/signing/seal-requests.js +402 -0
- package/packages/core/build/signing/transaction.js +158 -0
- package/packages/core/build/signing/verify-results.js +118 -0
- package/packages/core/build/source/checkout-action.js +16 -0
- package/packages/core/build/source/controller-actions.js +52 -0
- package/packages/core/build/source/controller.js +182 -0
- package/packages/core/build/source/lifecycle-action.js +32 -0
- package/packages/core/build/source/lifecycle.js +134 -0
- package/packages/core/build/source/proof-actions.js +57 -0
- package/packages/core/build/source/proof-lookup.js +82 -0
- package/packages/core/build/source/proof.js +134 -0
- package/packages/core/build/source-admission.js +35 -0
- package/packages/core/build/stage-capsule/actions.js +53 -0
- package/packages/core/build/stage-capsule/campaign/aggregate.js +51 -0
- package/packages/core/build/stage-capsule/campaign/context.js +51 -0
- package/packages/core/build/stage-capsule/campaign/resume.js +240 -0
- package/packages/core/build/stage-capsule/campaign/run.js +47 -0
- package/packages/core/build/stage-capsule/campaign/seed.js +124 -0
- package/packages/core/build/stage-capsule/campaign/worker.js +17 -0
- package/packages/core/build/stage-capsule/canary.js +62 -0
- package/packages/core/build/stage-capsule/rehearsal/checkpoint.js +110 -0
- package/packages/core/build/stage-capsule/rehearsal/files.js +36 -0
- package/packages/core/build/stage-capsule/rehearsal/macos-tail.js +104 -0
- package/packages/core/build/stage-capsule/rehearsal/resume.js +38 -0
- package/packages/core/build/stage-capsule/rehearsal/run.js +46 -0
- package/packages/core/build/stage-capsule/rehearsal/verify.js +56 -0
- package/packages/core/build/stage-capsule/rehearsal/worker.js +11 -0
- package/packages/core/build/stage-capsule-local-store.js +428 -0
- package/packages/core/build/stage-capsule-qualification-campaign.js +511 -0
- package/packages/core/build/stage-capsule-qualification.js +455 -0
- package/packages/core/build/stage-capsule-resume-planner.js +397 -0
- package/packages/core/build/stage-capsule-store.js +404 -0
- package/packages/core/build/stage-capsule.js +319 -0
- package/packages/core/build/standalone/build.js +266 -0
- package/packages/core/build/standalone/bundle.js +69 -0
- package/packages/core/build/standalone/identity.js +47 -0
- package/packages/core/build/standalone/logging.js +72 -0
- package/packages/core/build/standalone/process.js +50 -0
- package/packages/core/build/summary/action.js +33 -0
- package/packages/core/build/summary/aggregation.js +120 -0
- package/packages/core/build/summary/artifacts.js +165 -0
- package/packages/core/build/summary/controller-receipt.js +50 -0
- package/packages/core/build/summary/execution.js +39 -0
- package/packages/core/build/summary/finalization.js +133 -0
- package/packages/core/build/summary/payloads.js +80 -0
- package/packages/core/build/validate-config/action.js +58 -0
- package/packages/core/build/validate-config/lib.js +42 -0
- package/packages/core/build/verification/actions.js +54 -0
- package/packages/core/build/verification/discovery.js +115 -0
- package/packages/core/build/verification/identity.js +123 -0
- package/packages/core/build/verification/proof.js +8 -0
- package/packages/core/build/verification/repository.js +4 -0
- package/packages/core/build/verification/runner.js +69 -0
- package/packages/core/build/verification/source.js +169 -0
- package/packages/core/consumer/buildchain-config.js +1825 -0
- package/packages/core/consumer/channel-selection.js +211 -0
- package/packages/core/consumer/cli/infrastructure.mjs +6 -0
- package/packages/core/consumer/commands/buildchain-channel-router.mjs +81 -0
- package/packages/core/consumer/commands/consumer-policy.mjs +229 -0
- package/packages/core/consumer/floating-consumer-evidence.js +341 -0
- package/packages/core/consumer/floating-consumer-policy.js +596 -0
- package/packages/core/consumer/invocation-selector.js +4 -0
- package/packages/core/consumer/policy-admission.js +103 -0
- package/packages/core/consumer/policy-scan.js +33 -0
- package/packages/core/consumer/runtime-selector-persistence.js +291 -0
- package/packages/core/consumer/workflow-definition-authority.js +64 -0
- package/packages/core/contracts/action-inventory.js +78 -0
- package/packages/core/contracts/action-taxonomy.js +46 -0
- package/packages/core/contracts/buildchain-contract.js +1038 -0
- package/packages/core/contracts/canonical-contracts.js +239 -0
- package/packages/core/contracts/cli/context.mjs +28 -0
- package/packages/core/contracts/cli/introspection.mjs +47 -0
- package/packages/core/contracts/cli/options.mjs +85 -0
- package/packages/core/contracts/cli-reference.js +192 -0
- package/packages/core/contracts/commands/buildchain-contract-lock.mjs +120 -0
- package/packages/core/contracts/commands/workflow-call-contract.mjs +133 -0
- package/packages/core/contracts/public-surface-audit.js +274 -0
- package/packages/core/contracts/public-surface-cli.js +134 -0
- package/packages/core/contracts/runtime-contract-action.js +48 -0
- package/packages/core/contracts/runtime-contract-inspection.js +115 -0
- package/packages/core/contracts/structured-values.js +29 -0
- package/packages/core/contracts/workflow-yaml-contract.js +373 -0
- package/packages/core/dev-delivery/admission/gh-cli-client.js +110 -0
- package/packages/core/dev-delivery/admission/github-client.js +274 -0
- package/packages/core/dev-delivery/admission/policy.js +177 -0
- package/packages/core/dev-delivery/admission/queue.js +554 -0
- package/packages/core/dev-delivery/admission/readiness.js +222 -0
- package/packages/core/dev-delivery/admission/report.js +27 -0
- package/packages/core/dev-delivery/admission/request.js +34 -0
- package/packages/core/dev-delivery/admission/targeted.js +375 -0
- package/packages/core/dev-delivery/admission/transaction.js +47 -0
- package/packages/core/dev-delivery/buildchain-delivery-bootstrap.js +240 -0
- package/packages/core/dev-delivery/buildchain-delivery-infrastructure.js +164 -0
- package/packages/core/dev-delivery/buildchain-delivery-self-dogfood.js +395 -0
- package/packages/core/dev-delivery/candidate/admission-actions.js +34 -0
- package/packages/core/dev-delivery/candidate/admission.js +172 -0
- package/packages/core/dev-delivery/candidate/coordinates.js +46 -0
- package/packages/core/dev-delivery/candidate/evidence.js +20 -0
- package/packages/core/dev-delivery/candidate/request.js +39 -0
- package/packages/core/dev-delivery/candidate/reservation-action.js +21 -0
- package/packages/core/dev-delivery/candidate/reservation.js +98 -0
- package/packages/core/dev-delivery/candidate/source-paths.js +102 -0
- package/packages/core/dev-delivery/candidate/submission.js +41 -0
- package/packages/core/dev-delivery/cli/dispatch.mjs +54 -0
- package/packages/core/dev-delivery/commands/dev-delivery-authority-command-adapters.mjs +193 -0
- package/packages/core/dev-delivery/commands/dev-delivery-authority-provider.mjs +28 -0
- package/packages/core/dev-delivery/commands/dev-delivery-authority.mjs +454 -0
- package/packages/core/dev-delivery/commands/dev-delivery-process-boundary.mjs +93 -0
- package/packages/core/dev-delivery/commands/dev-delivery-proof.mjs +258 -0
- package/packages/core/dev-delivery/commands/dev-delivery-provider-heartbeat.mjs +76 -0
- package/packages/core/dev-delivery/commands/dev-delivery-request.sh +160 -0
- package/packages/core/dev-delivery/commands/dev-delivery-source-proof-reuse.mjs +128 -0
- package/packages/core/dev-delivery/commands/dev-delivery-two-phase.mjs +180 -0
- package/packages/core/dev-delivery/commands/dev-delivery-warrant-options.mjs +283 -0
- package/packages/core/dev-delivery/commands/dev-delivery-warrant.mjs +65 -0
- package/packages/core/dev-delivery/commands/dev-merge-queue.mjs +98 -0
- package/packages/core/dev-delivery/commands/dev-pr-auto-merge.mjs +111 -0
- package/packages/core/dev-delivery/commands/dev-pr-delivery-warrant.mjs +467 -0
- package/packages/core/dev-delivery/commands/dev-pr-prequeue-guard.mjs +381 -0
- package/packages/core/dev-delivery/commands/dev-qualification-patrol.mjs +21 -0
- package/packages/core/dev-delivery/delivery-warrant-fixture-runner.js +375 -0
- package/packages/core/dev-delivery/delivery-warrant-read-candidate.js +281 -0
- package/packages/core/dev-delivery/delivery-warrant-semantic-diff-gate.js +351 -0
- package/packages/core/dev-delivery/delivery-warrant-shadow-adapter.js +444 -0
- package/packages/core/dev-delivery/dev-delivery-authority-candidate.js +197 -0
- package/packages/core/dev-delivery/dev-delivery-authority-landing.js +459 -0
- package/packages/core/dev-delivery/dev-delivery-authority-state.js +424 -0
- package/packages/core/dev-delivery/dev-delivery-candidate-identity.js +152 -0
- package/packages/core/dev-delivery/dev-delivery-contract-surface.js +74 -0
- package/packages/core/dev-delivery/dev-delivery-native-proof.js +509 -0
- package/packages/core/dev-delivery/dev-delivery-proof.js +282 -0
- package/packages/core/dev-delivery/dev-delivery-warrant-native-requirements.js +7 -0
- package/packages/core/dev-delivery/dev-delivery-warrant-state.js +580 -0
- package/packages/core/dev-delivery/dev-delivery-warrant.js +588 -0
- package/packages/core/dev-delivery/merge-queue-policy.js +543 -0
- package/packages/core/dev-delivery/native/action-context.js +59 -0
- package/packages/core/dev-delivery/native/actions.js +74 -0
- package/packages/core/dev-delivery/native/attempt.js +93 -0
- package/packages/core/dev-delivery/native/candidate.js +101 -0
- package/packages/core/dev-delivery/native/context-record.js +26 -0
- package/packages/core/dev-delivery/native/execution.js +176 -0
- package/packages/core/dev-delivery/native/failure.js +105 -0
- package/packages/core/dev-delivery/native/files.js +11 -0
- package/packages/core/dev-delivery/native/finalizer-admission.js +93 -0
- package/packages/core/dev-delivery/native/heartbeat-action.js +29 -0
- package/packages/core/dev-delivery/native/heartbeat.js +137 -0
- package/packages/core/dev-delivery/native/provider-boundary.js +71 -0
- package/packages/core/dev-delivery/native/qualification.js +228 -0
- package/packages/core/dev-delivery/native/readback.js +32 -0
- package/packages/core/dev-delivery/native/reuse.js +60 -0
- package/packages/core/dev-delivery/native/seal-action.js +19 -0
- package/packages/core/dev-delivery/native/transactions.js +156 -0
- package/packages/core/dev-delivery/native/transfer.js +122 -0
- package/packages/core/dev-delivery/published-delivery-authority.js +266 -0
- package/packages/core/dev-delivery/qualification/action.js +60 -0
- package/packages/core/dev-delivery/qualification/controller.js +218 -0
- package/packages/core/dev-delivery/qualification/github-client.js +108 -0
- package/packages/core/dev-delivery/qualification/model.js +186 -0
- package/packages/core/dev-delivery/qualification/report.js +25 -0
- package/packages/core/dev-delivery/queue/completion.js +52 -0
- package/packages/core/dev-delivery/queue/landing-action.js +60 -0
- package/packages/core/dev-delivery/queue/reconciliation-action.js +45 -0
- package/packages/core/dev-delivery/source-proof/evidence.js +92 -0
- package/packages/core/dev-delivery/source-proof/io.js +97 -0
- package/packages/core/dev-delivery/source-proof/predicates.js +88 -0
- package/packages/core/dev-delivery/source-proof/replay.js +143 -0
- package/packages/core/dev-delivery/source-proof/reuse.js +116 -0
- package/packages/core/dev-delivery/source-proof/seal.js +32 -0
- package/packages/core/dev-delivery/warrant/actions.js +78 -0
- package/packages/core/dev-delivery/warrant/cancellation.js +49 -0
- package/packages/core/dev-delivery/warrant/failure-settlement.js +93 -0
- package/packages/core/dev-delivery/warrant/handoff.js +107 -0
- package/packages/core/dev-delivery/warrant/observation.js +59 -0
- package/packages/core/dev-delivery/warrant/persistence.js +109 -0
- package/packages/core/dev-delivery/warrant/reservation-readback.js +72 -0
- package/packages/core/dev-delivery/warrant/service.js +134 -0
- package/packages/core/dev-delivery/warrant/terminal-policy.js +53 -0
- package/packages/core/dev-delivery/warrant/terminal.js +89 -0
- package/packages/core/dev-delivery/warrant/transitions.js +222 -0
- package/packages/core/dev-delivery/warrant/values.js +102 -0
- package/packages/core/governance/alpha-candidate/action.js +96 -0
- package/packages/core/governance/alpha-candidate/controller.js +490 -0
- package/packages/core/governance/alpha-candidate/lifecycle.js +121 -0
- package/packages/core/governance/alpha-candidate/options.js +60 -0
- package/packages/core/governance/alpha-candidate/outputs.js +23 -0
- package/packages/core/governance/alpha-candidate/provider.js +192 -0
- package/packages/core/governance/alpha-candidate/report.js +56 -0
- package/packages/core/governance/alpha-candidate/state.js +184 -0
- package/packages/core/governance/alpha-candidate/values.js +90 -0
- package/packages/core/governance/architecture-graph.js +24 -0
- package/packages/core/governance/audit/actions.js +57 -0
- package/packages/core/governance/audit/collection.js +259 -0
- package/packages/core/governance/audit/github-reader.js +204 -0
- package/packages/core/governance/audit/identity.js +86 -0
- package/packages/core/governance/audit/incident.mjs +39 -0
- package/packages/core/governance/audit/transactions.js +75 -0
- package/packages/core/governance/buildchain-compatibility-authority.js +335 -0
- package/packages/core/governance/buildchain-compatibility-fact.js +386 -0
- package/packages/core/governance/buildchain-compatibility-facts.json +18 -0
- package/packages/core/governance/buildchain-compatibility-proof.js +523 -0
- package/packages/core/governance/buildchain-publication-authority.js +117 -0
- package/packages/core/governance/candidate/body-action.js +18 -0
- package/packages/core/governance/candidate/body-renderer.js +160 -0
- package/packages/core/governance/ci-lane-change-budget.js +260 -0
- package/packages/core/governance/cli/compatibility-facts.mjs +101 -0
- package/packages/core/governance/cli/dispatch.mjs +19 -0
- package/packages/core/governance/cli/doctor.mjs +144 -0
- package/packages/core/governance/commands/architecture.mjs +594 -0
- package/packages/core/governance/commands/audit-github-governance.mjs +43 -0
- package/packages/core/governance/commands/audit-publication-control-plane.mjs +26 -0
- package/packages/core/governance/commands/buildchain-patrol.mjs +32 -0
- package/packages/core/governance/commands/create-github-artifact-attestation-policy.mjs +62 -0
- package/packages/core/governance/commands/engineering-housekeeper-workflow.mjs +23 -0
- package/packages/core/governance/commands/reconcile-github-governance.mjs +689 -0
- package/packages/core/governance/commands/reconcile-release-governance.mjs +77 -0
- package/packages/core/governance/commands/workflow-friction-report.mjs +375 -0
- package/packages/core/governance/github-governance-authority.js +1367 -0
- package/packages/core/governance/housekeeping/action.js +45 -0
- package/packages/core/governance/housekeeping/execution.js +75 -0
- package/packages/core/governance/housekeeping/options.js +103 -0
- package/packages/core/governance/housekeeping/report.js +53 -0
- package/packages/core/governance/housekeeping/transactions.js +96 -0
- package/packages/core/governance/patrol/action.js +41 -0
- package/packages/core/governance/patrol/controller.js +125 -0
- package/packages/core/governance/patrol/options.js +121 -0
- package/packages/core/governance/patrol/report.js +53 -0
- package/packages/core/governance/patrol/transaction.js +30 -0
- package/packages/core/governance/publication/audit.js +26 -0
- package/packages/core/governance/publication/collection.js +396 -0
- package/packages/core/governance/publication/policy-values.js +227 -0
- package/packages/core/governance/publication/source-authorization.js +293 -0
- package/packages/core/governance/receipt-admission-action.js +12 -0
- package/packages/core/governance/receipt-admission.js +34 -0
- package/packages/core/governance/release-check-policy.js +179 -0
- package/packages/core/governance/release-reconciliation-action.js +25 -0
- package/packages/core/governance/release-reconciliation.js +122 -0
- package/packages/core/governance/report-issue/action.js +201 -0
- package/packages/core/index.js +85 -117
- package/packages/core/observability/cli/candidate.mjs +42 -0
- package/packages/core/observability/cli/context.mjs +47 -0
- package/packages/core/observability/cli/diagnostics.mjs +88 -0
- package/packages/core/observability/cli/events.mjs +126 -0
- package/packages/core/observability/cli/process-sample.mjs +71 -0
- package/packages/core/observability/commands/aggregate-diagnostics-summary.mjs +45 -0
- package/packages/core/observability/commands/controller-evidence.mjs +109 -0
- package/packages/core/observability/commands/observed-evidence.mjs +27 -0
- package/packages/core/observability/controller/identity-action.js +11 -0
- package/packages/core/observability/controller/identity.js +32 -0
- package/packages/core/observability/controller-actions.js +63 -0
- package/packages/core/observability/controller-evidence-io.js +112 -0
- package/packages/core/observability/controller-evidence.js +555 -0
- package/packages/core/observability/controller-input-boundary.js +47 -0
- package/packages/core/observability/diagnostics/aggregate.js +25 -0
- package/packages/core/observability/diagnostics.js +1904 -0
- package/packages/core/observability/evidence/actions.js +20 -0
- package/packages/core/observability/evidence/bundle.js +163 -0
- package/packages/core/observability/evidence/publication.js +360 -0
- package/packages/core/observability/evidence/transactions.js +62 -0
- package/packages/core/observability/process/sampling.js +128 -0
- package/packages/core/observability/publisher-admission.js +26 -0
- package/packages/core/observability/transaction-journal.js +40 -0
- package/packages/core/paper/cli/dispatch.mjs +17 -0
- package/packages/core/paper/commands/paper-agent-cli.mjs +35 -0
- package/packages/core/paper/commands/paper-work-fleet-cli.mjs +577 -0
- package/packages/core/paper/commands/paper.mjs +632 -0
- package/packages/core/paper/operations/bootstrap.js +73 -0
- package/packages/core/paper/operations/files.js +48 -0
- package/packages/core/paper/operations/github-observation.js +136 -0
- package/packages/core/paper/operations/identity.js +59 -0
- package/packages/core/paper/operations/npm-observation.js +118 -0
- package/packages/core/paper/operations/plans.js +213 -0
- package/packages/core/paper/operations/preflight-checks.js +269 -0
- package/packages/core/paper/operations/provisioning-validation.js +155 -0
- package/packages/core/paper/operations/provisioning.js +113 -0
- package/packages/core/paper/operations/runtime-observation.js +25 -0
- package/packages/core/paper/operations/runtime.js +84 -0
- package/packages/core/paper/operations/scaffold-config.js +77 -0
- package/packages/core/paper/operations/scaffold-workflows.js +99 -0
- package/packages/core/paper/operations/scaffold.js +370 -0
- package/packages/core/paper/operations/status-facts.js +264 -0
- package/packages/core/paper/operations/status.js +353 -0
- package/packages/core/paper/operations/toolchain-observation.js +49 -0
- package/packages/core/paper/operations/workspace.js +60 -0
- package/packages/core/paper/paper-agent-entry.js +396 -0
- package/packages/core/paper/paper-fleet.js +310 -0
- package/packages/core/paper/paper-npm-bootstrap.js +492 -0
- package/packages/core/paper/paper-repository.js +214 -0
- package/packages/core/paper/paper-runtime-channels.js +344 -0
- package/packages/core/paper/paper-scaffold-content.js +574 -0
- package/packages/core/paper/paper.js +308 -0
- package/packages/core/paper/publication/actions.js +109 -0
- package/packages/core/paper/publication/candidate.js +140 -0
- package/packages/core/paper/publication/controller.js +117 -0
- package/packages/core/paper/publication/envelope.js +118 -0
- package/packages/core/paper/publication/propagation.js +135 -0
- package/packages/core/paper/publication/readback.js +89 -0
- package/packages/core/paper/publication/target.js +54 -0
- package/packages/core/paper/publication-controller.js +144 -0
- package/packages/core/providers/artifact-relay/files.js +71 -0
- package/packages/core/providers/artifact-relay/s3-client.js +259 -0
- package/packages/core/providers/artifact-relay/transactions.js +258 -0
- package/packages/core/providers/commands/artifact-relay-s3.mjs +62 -0
- package/packages/core/providers/commands/aws-codebuild-toolchain.mjs +15 -0
- package/packages/core/providers/commands/aws-macos-jit-controller-runtime.mjs +82 -0
- package/packages/core/providers/commands/aws-runner-burst-core.mjs +249 -0
- package/packages/core/providers/commands/aws-runner-burst.mjs +80 -0
- package/packages/core/providers/commands/aws-windows-jit-campaign.mjs +202 -0
- package/packages/core/providers/commands/aws-windows-jit-controller.mjs +578 -0
- package/packages/core/providers/commands/aws-windows-jit-operator.sh +506 -0
- package/packages/core/providers/commands/infra-contract-core.mjs +1032 -0
- package/packages/core/providers/commands/infra-contract.mjs +345 -0
- package/packages/core/providers/commands/locked-source-checkout.mjs +9 -0
- package/packages/core/providers/commands/route-offline-runners.mjs +30 -0
- package/packages/core/providers/demo/capture-worker.py +541 -0
- package/packages/core/providers/dev-delivery/candidate.js +112 -0
- package/packages/core/providers/dev-delivery/protection.js +29 -0
- package/packages/core/providers/dev-delivery/store.js +292 -0
- package/packages/core/providers/git/fetch-process.js +27 -0
- package/packages/core/providers/git/fetch-worker.js +146 -0
- package/packages/core/providers/git/patch-root.js +54 -0
- package/packages/core/providers/git-ref-readback.mjs +22 -0
- package/packages/core/providers/github/artifact-attestation.js +32 -0
- package/packages/core/providers/github/commits.js +32 -0
- package/packages/core/providers/github/json-client.js +65 -0
- package/packages/core/providers/github/product-publication.js +44 -0
- package/packages/core/providers/github/publication-control-plane.js +116 -0
- package/packages/core/providers/github/pull-requests.js +24 -0
- package/packages/core/providers/github/qualification.js +181 -0
- package/packages/core/providers/github/release-assets.js +91 -0
- package/packages/core/providers/github/signing-request.js +81 -0
- package/packages/core/providers/github/source-lock.js +98 -0
- package/packages/core/providers/github-cli-api.js +35 -0
- package/packages/core/providers/github-issue-comment.js +83 -0
- package/packages/core/providers/github-permission.js +11 -0
- package/packages/core/providers/github-token.js +121 -0
- package/packages/core/providers/process/sample-worker.mjs +14 -0
- package/packages/core/providers/runner/observation.js +30 -0
- package/packages/core/providers/runner/offline-routing.js +205 -0
- package/packages/core/providers/signing/detached-key.js +20 -0
- package/packages/core/providers/signing/macos/compound-archive.py +434 -0
- package/packages/core/providers/signing/macos/sign-request.sh +145 -0
- package/packages/core/providers/signing/native.js +77 -0
- package/packages/core/providers/signing/windows/sign-request.ps1 +48 -0
- package/packages/core/providers/source-checkout/action.js +31 -0
- package/packages/core/providers/source-checkout/auth.js +32 -0
- package/packages/core/providers/source-checkout/fetch.js +135 -0
- package/packages/core/providers/source-checkout/git.js +220 -0
- package/packages/core/providers/source-checkout/transaction.js +360 -0
- package/packages/core/providers/source-checkout/values.js +115 -0
- package/packages/core/providers/source-checkout/workspace.js +50 -0
- package/packages/core/providers/sync-git/action.mjs +16 -0
- package/packages/core/providers/sync-git/transfer.mjs +86 -0
- package/packages/core/providers/toolchain/codebuild-policy.js +36 -0
- package/packages/core/providers/toolchain/codebuild.js +220 -0
- package/packages/core/publication/authority/actions.js +156 -0
- package/packages/core/publication/authority/admission.js +113 -0
- package/packages/core/publication/authority/assembly.js +77 -0
- package/packages/core/publication/authority/binary-evidence.js +77 -0
- package/packages/core/publication/authority/candidate-evidence.js +42 -0
- package/packages/core/publication/authority/consumer-gate.js +80 -0
- package/packages/core/publication/authority/control-plane.js +38 -0
- package/packages/core/publication/authority/evidence.js +113 -0
- package/packages/core/publication/authority/gate.js +39 -0
- package/packages/core/publication/authority/governance.js +61 -0
- package/packages/core/publication/authority/paper-evidence.js +24 -0
- package/packages/core/publication/authority/request.js +13 -0
- package/packages/core/publication/authority/result.js +37 -0
- package/packages/core/publication/authority/runner.js +26 -0
- package/packages/core/publication/authority/seal.js +97 -0
- package/packages/core/publication/authority/verification-evidence.js +80 -0
- package/packages/core/publication/authority/verification.js +94 -0
- package/packages/core/publication/binary/action.js +33 -0
- package/packages/core/publication/binary/capability.js +55 -0
- package/packages/core/publication/binary/evidence.js +109 -0
- package/packages/core/publication/binary/transaction.js +38 -0
- package/packages/core/publication/candidate/artifact.js +71 -0
- package/packages/core/publication/candidate/collection-action.js +24 -0
- package/packages/core/publication/candidate/collection.js +70 -0
- package/packages/core/publication/candidate/kind.js +93 -0
- package/packages/core/publication/candidate/manifest.js +35 -0
- package/packages/core/publication/candidate/package-binding.js +42 -0
- package/packages/core/publication/candidate/package.js +50 -0
- package/packages/core/publication/candidate/paper-package.js +120 -0
- package/packages/core/publication/candidate/passport.js +36 -0
- package/packages/core/publication/candidate/qualification-action.js +41 -0
- package/packages/core/publication/candidate/qualification.js +56 -0
- package/packages/core/publication/candidate/registry-hydration.js +204 -0
- package/packages/core/publication/candidate/reproducibility.js +29 -0
- package/packages/core/publication/candidate/sealing.js +184 -0
- package/packages/core/publication/candidate/stage-capsules.js +205 -0
- package/packages/core/publication/candidate/toolchain.js +80 -0
- package/packages/core/publication/cli/dispatch.mjs +107 -0
- package/packages/core/publication/commands/create-release-bundle.mjs +32 -0
- package/packages/core/publication/commands/generate-release-candidate-passport.mjs +80 -0
- package/packages/core/publication/commands/installer-publication.mjs +45 -0
- package/packages/core/publication/commands/npm-publish-dry-run.mjs +48 -0
- package/packages/core/publication/commands/npm-publish-transaction.mjs +55 -0
- package/packages/core/publication/commands/publication-artifact-candidate.mjs +48 -0
- package/packages/core/publication/commands/publication-artifact.mjs +67 -0
- package/packages/core/publication/commands/publication-package.mjs +38 -0
- package/packages/core/publication/commands/publication-registry-hydrate.mjs +19 -0
- package/packages/core/publication/commands/publication-reproducibility.mjs +62 -0
- package/packages/core/publication/installer/evidence.js +319 -0
- package/packages/core/publication/npm/environment.js +18 -0
- package/packages/core/publication/npm/evidence.js +57 -0
- package/packages/core/publication/npm/pack-preview.js +22 -0
- package/packages/core/publication/npm/package-plan.js +82 -0
- package/packages/core/publication/npm/package.js +120 -0
- package/packages/core/publication/npm/preview-action.js +30 -0
- package/packages/core/publication/npm/preview.js +92 -0
- package/packages/core/publication/npm/registry.js +61 -0
- package/packages/core/publication/npm/transaction.js +115 -0
- package/packages/core/publication/oci/preview-actions.js +48 -0
- package/packages/core/publication/oci/preview-admission.js +93 -0
- package/packages/core/publication/oci/preview-promotion.js +64 -0
- package/packages/core/publication/oci/preview-registry.js +36 -0
- package/packages/core/publication/oci/preview-transaction.js +42 -0
- package/packages/core/publication/oci/preview-values.js +8 -0
- package/packages/core/publication/oci-compose-qualification.js +143 -0
- package/packages/core/publication/oci-publication-bundle.js +281 -0
- package/packages/core/publication/publication-artifact-candidate.js +128 -0
- package/packages/core/publication/publication-artifact.js +641 -0
- package/packages/core/publication/publication-authority.js +1163 -0
- package/packages/core/publication/publication-development.js +72 -0
- package/packages/core/publication/publication-package.js +252 -0
- package/packages/core/publication/publication-rehearsal-capsule.js +468 -0
- package/packages/core/publication/publication-rehearsal-projection.js +104 -0
- package/packages/core/publication/publication-rehearsal-runtime.js +190 -0
- package/packages/core/publication/publication-rehearsal.js +481 -0
- package/packages/core/publication/publication-reproducibility.js +947 -0
- package/packages/core/publication/settlement/actions.js +63 -0
- package/packages/core/publication/settlement/transaction.js +197 -0
- package/packages/core/release/binary/coordinates-action.js +25 -0
- package/packages/core/release/binary/coordinates.js +76 -0
- package/packages/core/release/candidate/download.js +64 -0
- package/packages/core/release/candidate/lineage.js +72 -0
- package/packages/core/release/candidate/materialize.js +155 -0
- package/packages/core/release/candidate/payloads.js +330 -0
- package/packages/core/release/candidate/publication-intent.js +89 -0
- package/packages/core/release/candidate/resolve.js +132 -0
- package/packages/core/release/candidate/run-selection.js +88 -0
- package/packages/core/release/candidate/selection.js +181 -0
- package/packages/core/release/candidate/transport.js +143 -0
- package/packages/core/release/cli/command-handlers.mjs +14 -0
- package/packages/core/release/cli/dispatch.mjs +39 -0
- package/packages/core/release/cli/inspection-handlers.mjs +178 -0
- package/packages/core/release/cli/release-handlers.mjs +332 -0
- package/packages/core/release/cli/trust-release.mjs +19 -0
- package/packages/core/release/cli/verification-handlers.mjs +303 -0
- package/packages/core/release/commands/dev-alpha-candidate-patrol.mjs +42 -0
- package/packages/core/release/commands/ensure-github-release.mjs +199 -0
- package/packages/core/release/commands/next-development-review.mjs +77 -0
- package/packages/core/release/commands/next-development-transition.mjs +47 -0
- package/packages/core/release/commands/promotion-channel-router.mjs +62 -0
- package/packages/core/release/commands/promotion-identity-resolver.mjs +77 -0
- package/packages/core/release/commands/publish-source-ref-resolver.mjs +113 -0
- package/packages/core/release/commands/release-candidate-resolver.mjs +122 -0
- package/packages/core/release/commands/release-line-dry-run.mjs +53 -0
- package/packages/core/release/commands/release-propagation.mjs +411 -0
- package/packages/core/release/commands/release-tail.mjs +169 -0
- package/packages/core/release/commands/release-transaction.mjs +212 -0
- package/packages/core/release/commands/resolve-publish-gate.mjs +34 -0
- package/packages/core/release/commands/resolve-publish-source.mjs +96 -0
- package/packages/core/release/commands/resume-from-candidate-run.mjs +107 -0
- package/packages/core/release/commands/stable-candidate-patrol.mjs +31 -0
- package/packages/core/release/commands/stable-candidate-qualification.mjs +24 -0
- package/packages/core/release/commands/stable-release-gate.mjs +351 -0
- package/packages/core/release/commands/tail-reseal.mjs +148 -0
- package/packages/core/release/commands/verify-promotion-router-binding.sh +36 -0
- package/packages/core/release/commands/verify-publish-channel-ref.mjs +83 -0
- package/packages/core/release/commands/verify-publish-source-lock.mjs +37 -0
- package/packages/core/release/commands/verify-release-pr.mjs +6 -0
- package/packages/core/release/commands/verify-version-state-delta.mjs +21 -0
- package/packages/core/release/github-provider-plane.js +319 -0
- package/packages/core/release/github-release.js +385 -0
- package/packages/core/release/line/action.js +49 -0
- package/packages/core/release/line/governance.js +96 -0
- package/packages/core/release/line/plan.js +56 -0
- package/packages/core/release/line/policy.js +320 -0
- package/packages/core/release/line/protection.js +35 -0
- package/packages/core/release/line/request.js +22 -0
- package/packages/core/release/line/source.js +79 -0
- package/packages/core/release/line/transaction.js +33 -0
- package/packages/core/release/line/verification-action.js +13 -0
- package/packages/core/release/line/verification.js +13 -0
- package/packages/core/release/next-development/actions.js +122 -0
- package/packages/core/release/next-development/approval.js +59 -0
- package/packages/core/release/next-development/enqueue.js +51 -0
- package/packages/core/release/next-development/finalization.js +127 -0
- package/packages/core/release/next-development/observation.js +41 -0
- package/packages/core/release/next-development/review-policy.js +56 -0
- package/packages/core/release/next-development/verification.js +89 -0
- package/packages/core/release/next-development-projection.js +310 -0
- package/packages/core/release/next-development-transition.js +737 -0
- package/packages/core/release/partial-mutation-recovery-qualification.js +18 -0
- package/packages/core/release/passport/artifact-index.js +65 -0
- package/packages/core/release/passport/assembly-artifacts.js +43 -0
- package/packages/core/release/passport/assembly-inputs.js +107 -0
- package/packages/core/release/passport/assembly-material.js +261 -0
- package/packages/core/release/passport/assembly-render.js +320 -0
- package/packages/core/release/passport/assembly.js +12 -0
- package/packages/core/release/passport/assets.js +46 -0
- package/packages/core/release/passport/attachments.js +88 -0
- package/packages/core/release/passport/authoritative-base.js +123 -0
- package/packages/core/release/passport/build.js +39 -0
- package/packages/core/release/passport/collection-inputs.js +383 -0
- package/packages/core/release/passport/collection-material.js +199 -0
- package/packages/core/release/passport/collection-options.js +97 -0
- package/packages/core/release/passport/collection-output.js +303 -0
- package/packages/core/release/passport/collection.js +10 -0
- package/packages/core/release/passport/commands.js +44 -0
- package/packages/core/release/passport/consumer-input.js +18 -0
- package/packages/core/release/passport/consumer-validation.js +83 -0
- package/packages/core/release/passport/discovery.js +36 -0
- package/packages/core/release/passport/documents.js +116 -0
- package/packages/core/release/passport/evidence-validation.js +280 -0
- package/packages/core/release/passport/files.js +43 -0
- package/packages/core/release/passport/fixture.js +19 -0
- package/packages/core/release/passport/identity.js +46 -0
- package/packages/core/release/passport/impact-validation.js +230 -0
- package/packages/core/release/passport/impact.js +149 -0
- package/packages/core/release/passport/inputs.js +55 -0
- package/packages/core/release/passport/invariants.js +93 -0
- package/packages/core/release/passport/issues.js +29 -0
- package/packages/core/release/passport/json.js +16 -0
- package/packages/core/release/passport/locations.js +82 -0
- package/packages/core/release/passport/packages.js +123 -0
- package/packages/core/release/passport/publish-validation.js +279 -0
- package/packages/core/release/passport/publish.js +58 -0
- package/packages/core/release/passport/report.js +154 -0
- package/packages/core/release/passport/state-validation.js +163 -0
- package/packages/core/release/passport/transaction.js +69 -0
- package/packages/core/release/passport/trust-claims.js +365 -0
- package/packages/core/release/passport/trust-validation.js +528 -0
- package/packages/core/release/product-publication.js +59 -0
- package/packages/core/release/promote-candidate/action.js +9 -0
- package/packages/core/release/promote-candidate/development-source.js +39 -0
- package/packages/core/release/promote-candidate/evidence-binding.js +142 -0
- package/packages/core/release/promote-candidate/evidence-inputs.js +99 -0
- package/packages/core/release/promote-candidate/files.js +10 -0
- package/packages/core/release/promote-candidate/next-development-provider.js +300 -0
- package/packages/core/release/promote-candidate/next-development-queue.js +63 -0
- package/packages/core/release/promote-candidate/oci-provider.js +241 -0
- package/packages/core/release/promote-candidate/oci-registry-client.js +67 -0
- package/packages/core/release/promote-candidate/outputs.js +29 -0
- package/packages/core/release/promote-candidate/product-finalization-wait.js +52 -0
- package/packages/core/release/promote-candidate/product-provider-adapters.js +462 -0
- package/packages/core/release/promote-candidate/product-provider-github-adapters.js +595 -0
- package/packages/core/release/promote-candidate/product-provider.js +188 -0
- package/packages/core/release/promote-candidate/provider-request.js +51 -0
- package/packages/core/release/promote-candidate/provider-settlement.js +83 -0
- package/packages/core/release/promote-candidate/publication-completion.js +56 -0
- package/packages/core/release/promote-candidate/release-documents.js +156 -0
- package/packages/core/release/promote-candidate/transaction.js +130 -0
- package/packages/core/release/promote-ref/action-environment.js +2 -0
- package/packages/core/release/promote-ref/action-inputs.js +285 -0
- package/packages/core/release/promote-ref/action-outputs.js +140 -0
- package/packages/core/release/promote-ref/action-request.js +205 -0
- package/packages/core/release/promote-ref/action.js +92 -0
- package/packages/core/release/promote-ref/internal/branch-protection.js +218 -0
- package/packages/core/release/promote-ref/internal/candidate-admission.js +149 -0
- package/packages/core/release/promote-ref/internal/channel-governance.js +297 -0
- package/packages/core/release/promote-ref/internal/channel-resume.js +198 -0
- package/packages/core/release/promote-ref/internal/channel-tags.js +207 -0
- package/packages/core/release/promote-ref/internal/contained-published-version-state.js +80 -0
- package/packages/core/release/promote-ref/internal/durable-transaction-operations.js +463 -0
- package/packages/core/release/promote-ref/internal/durable-transaction-store.js +395 -0
- package/packages/core/release/promote-ref/internal/generated-branch.js +16 -0
- package/packages/core/release/promote-ref/internal/generated-identity.js +12 -0
- package/packages/core/release/promote-ref/internal/generated-ref.js +93 -0
- package/packages/core/release/promote-ref/internal/github-adapter.js +312 -0
- package/packages/core/release/promote-ref/internal/npm-distribution.js +185 -0
- package/packages/core/release/promote-ref/internal/npm-existing-evidence.js +61 -0
- package/packages/core/release/promote-ref/internal/passport-files.js +116 -0
- package/packages/core/release/promote-ref/internal/passport-generation.js +567 -0
- package/packages/core/release/promote-ref/internal/promote-alpha-channel.js +588 -0
- package/packages/core/release/promote-ref/internal/promote-major-channel.js +476 -0
- package/packages/core/release/promote-ref/internal/promote-release-channel.js +573 -0
- package/packages/core/release/promote-ref/internal/promotion-operations.js +1170 -0
- package/packages/core/release/promote-ref/internal/promotion-options.js +101 -0
- package/packages/core/release/promote-ref/internal/promotion-policy.js +218 -0
- package/packages/core/release/promote-ref/internal/publish-command.js +211 -0
- package/packages/core/release/promote-ref/internal/publish-contract.js +181 -0
- package/packages/core/release/promote-ref/internal/publish-transaction.js +510 -0
- package/packages/core/release/promote-ref/internal/tag-selection.js +159 -0
- package/packages/core/release/promote-ref/internal/transaction-context.js +506 -0
- package/packages/core/release/promote-ref/internal/transaction-recovery.js +379 -0
- package/packages/core/release/promote-ref/internal/version-state-operations.js +545 -0
- package/packages/core/release/promote-ref/lib.js +600 -0
- package/packages/core/release/promote-ref/release-tail.js +102 -0
- package/packages/core/release/promote-ref/source-lock.js +91 -0
- package/packages/core/release/promotion/actions.js +133 -0
- package/packages/core/release/promotion/admission.js +52 -0
- package/packages/core/release/promotion/candidate.js +71 -0
- package/packages/core/release/promotion/channel.js +104 -0
- package/packages/core/release/promotion/identities.js +56 -0
- package/packages/core/release/promotion/product-state.js +68 -0
- package/packages/core/release/promotion/publish-gate.js +128 -0
- package/packages/core/release/promotion/qualification-action.js +72 -0
- package/packages/core/release/promotion/qualification.js +95 -0
- package/packages/core/release/promotion/routing.js +94 -0
- package/packages/core/release/promotion/selection.js +55 -0
- package/packages/core/release/promotion/source-intent.js +35 -0
- package/packages/core/release/promotion-request.js +148 -0
- package/packages/core/release/propagation/actions.js +75 -0
- package/packages/core/release/propagation/delivery.js +202 -0
- package/packages/core/release/propagation/planning.js +197 -0
- package/packages/core/release/propagation/report.js +97 -0
- package/packages/core/release/propagation/store.js +26 -0
- package/packages/core/release/propagation/transactions.js +213 -0
- package/packages/core/release/propagation/work.js +146 -0
- package/packages/core/release/protected-publication-source.js +91 -0
- package/packages/core/release/provider-operation-journal.js +62 -0
- package/packages/core/release/provider-readback-idempotency.js +309 -0
- package/packages/core/release/qualification/actions.js +51 -0
- package/packages/core/release/qualification/campaign.js +154 -0
- package/packages/core/release/qualification/options.js +102 -0
- package/packages/core/release/qualification/public-build.js +109 -0
- package/packages/core/release/recovery/artifacts.js +161 -0
- package/packages/core/release/recovery/candidate.js +529 -0
- package/packages/core/release/recovery/capsules.js +102 -0
- package/packages/core/release/recovery/download.js +191 -0
- package/packages/core/release/recovery/files.js +39 -0
- package/packages/core/release/recovery/provenance.js +199 -0
- package/packages/core/release/recovery/publication.js +193 -0
- package/packages/core/release/recovery/readback.js +169 -0
- package/packages/core/release/recovery/runtime.js +224 -0
- package/packages/core/release/recovery/transactions.js +139 -0
- package/packages/core/release/release-activation-shadow.js +32 -0
- package/packages/core/release/release-blocker-priority.js +183 -0
- package/packages/core/release/release-candidate-recovery.js +595 -0
- package/packages/core/release/release-candidate.js +591 -0
- package/packages/core/release/release-invocation.js +64 -0
- package/packages/core/release/release-line-bootstrap.js +292 -0
- package/packages/core/release/release-line-dry-run.js +302 -0
- package/packages/core/release/release-passport-contract.js +479 -0
- package/packages/core/release/release-passport.js +74 -0
- package/packages/core/release/release-tail-provider-adapters.js +460 -0
- package/packages/core/release/release-tail-provider-plane.js +248 -0
- package/packages/core/release/reseal/actions.js +84 -0
- package/packages/core/release/reseal/admission.js +75 -0
- package/packages/core/release/reseal/files.js +39 -0
- package/packages/core/release/reseal/finalize-platform.js +65 -0
- package/packages/core/release/reseal/outputs.js +21 -0
- package/packages/core/release/reseal/plan.js +24 -0
- package/packages/core/release/reseal/platform.js +135 -0
- package/packages/core/release/reseal/readbacks.js +36 -0
- package/packages/core/release/reseal/seal.js +125 -0
- package/packages/core/release/reuse-complete-release.js +240 -0
- package/packages/core/release/runtime-override-authorization.js +242 -0
- package/packages/core/release/settle/action.js +412 -0
- package/packages/core/release/source/channel.js +45 -0
- package/packages/core/release/source/coordinates.js +160 -0
- package/packages/core/release/source/lineage.js +144 -0
- package/packages/core/release/source/manifest.js +114 -0
- package/packages/core/release/stable-patrol/action.js +87 -0
- package/packages/core/release/stable-patrol/controller.js +346 -0
- package/packages/core/release/stable-patrol/coordinates.js +16 -0
- package/packages/core/release/stable-patrol/github-client.js +181 -0
- package/packages/core/release/stable-patrol/options.js +87 -0
- package/packages/core/release/stable-patrol/report.js +28 -0
- package/packages/core/release/stable-publication-fence.js +28 -0
- package/packages/core/release/tail-reseal-github.js +175 -0
- package/packages/core/release/tail-reseal-receipt.js +228 -0
- package/packages/core/release/tail-reseal.js +594 -0
- package/packages/core/release/version-state/verification.js +164 -0
- package/packages/core/release/version-state.js +458 -0
- package/packages/core/runtime/action-host.js +19 -0
- package/packages/core/runtime/action-process.mjs +23 -0
- package/packages/core/runtime/buildchain-domain.wasm +0 -0
- package/packages/core/runtime/checkout-identity.js +27 -0
- package/packages/core/runtime/commands/bridge-bootstrap.mjs +147 -0
- package/packages/core/runtime/commands/host-adapter.mjs +185 -0
- package/packages/core/runtime/commands/runtime-ref-core.mjs +171 -0
- package/packages/core/runtime/consumer-shell.js +174 -0
- package/packages/core/runtime/domain-wasm-artifact.js +7 -0
- package/packages/core/runtime/installation-root.js +29 -0
- package/packages/core/runtime/locked-dependencies.js +74 -0
- package/packages/core/runtime/provider-closure.js +60 -0
- package/packages/core/runtime/runtime-selection-action.js +34 -0
- package/packages/core/runtime/runtime-selection.js +136 -0
- package/packages/core/runtime/toolchain/actions.js +14 -0
- package/packages/core/runtime/toolchain/user-paths.js +9 -0
- package/packages/core/runtime/toolchain/windows-rust.js +67 -0
- package/packages/core/runtime/workflow-runtime.js +11 -0
- package/packages/core/web/apply-admission-action.js +20 -0
- package/packages/core/web/apply-admission.js +44 -0
- package/packages/core/web/cli/badges.mjs +100 -0
- package/packages/core/web/cli/surface.mjs +6 -0
- package/packages/core/web/commands/web-surface-core.mjs +2603 -0
- package/packages/core/web/commands/web-surface-production-release-pr.mjs +126 -0
- package/packages/core/web/commands/web-surface.mjs +294 -0
- package/packages/core/web/controller-actions.js +45 -0
- package/packages/core/web/controller.js +145 -0
- package/packages/core/web/deployment/apply-action.js +31 -0
- package/packages/core/web/deployment/apply-evidence.js +134 -0
- package/packages/core/web/deployment/apply.js +118 -0
- package/packages/core/web/deployment/cloudfront-wait.js +88 -0
- package/packages/core/web/deployment/plan-files.js +41 -0
- package/packages/core/web/deployment/planning-action.js +28 -0
- package/packages/core/web/deployment/planning.js +126 -0
- package/packages/core/web/deployment/report-action.js +74 -0
- package/packages/core/web/deployment/summary.js +44 -0
- package/packages/core/web/preview-feedback-action.js +26 -0
- package/packages/core/web/preview-feedback.js +40 -0
- package/packages/core/web/production-decision-action.js +42 -0
- package/packages/core/web/production-decision.js +85 -0
- package/packages/core/web/production-intent-action.js +14 -0
- package/packages/core/web/production-intent.js +167 -0
- package/packages/core/web/publication-admission-action.js +92 -0
- package/packages/core/web/publication-admission.js +183 -0
- package/packages/core/web/publication-capability-action.js +22 -0
- package/packages/core/web/publication-capability.js +73 -0
- package/packages/core/web/readme-badges.js +891 -0
- package/packages/core/web/release-feedback.js +414 -0
- package/packages/core/web/release-pr-action.js +47 -0
- package/packages/core/web/release-pr-handoff.js +176 -0
- package/packages/core/web/release-pr-provider.js +295 -0
- package/packages/core/web/release-pr-summary.js +42 -0
- package/packages/core/web/release-pr-transaction.js +158 -0
- package/packages/core/web/release-review-action.js +21 -0
- package/packages/core/web/release-review.js +130 -0
- package/packages/core/web/web-surface-publication-candidate.js +162 -0
- package/packages/core/workflow/admission/actions.js +56 -0
- package/packages/core/workflow/admission/recovery.js +47 -0
- package/packages/core/workflow/admission/review.js +188 -0
- package/packages/core/workflow/admission/transactions.js +60 -0
- package/packages/core/workflow/cli/main.mjs +131 -0
- package/packages/core/workflow/cli/process.mjs +16 -0
- package/packages/core/workflow/commands/buildchain-cli-help.mjs +318 -0
- package/packages/core/workflow/commands/universal-workflow-backflow.mjs +26 -0
- package/packages/core/workflow/commands/universal-workflow-engine.mjs +73 -0
- package/packages/core/workflow/dogfood/actions.js +62 -0
- package/packages/core/workflow/dogfood/readiness.js +74 -0
- package/packages/core/workflow/dogfood/transactions.js +90 -0
- package/packages/core/workflow/engine/action.js +42 -0
- package/packages/core/workflow/engine/conformance.js +93 -0
- package/packages/core/workflow/engine/execution.js +77 -0
- package/packages/core/workflow/engine/identity.js +34 -0
- package/packages/core/workflow/engine/provider-context.js +16 -0
- package/packages/core/workflow/engine/release-environment.js +57 -0
- package/packages/core/workflow/engine/release-evidence.js +39 -0
- package/packages/core/workflow/engine/release-observation.js +97 -0
- package/packages/core/workflow/engine/release-promotion.js +227 -0
- package/packages/core/workflow/event-trust.js +25 -0
- package/packages/core/workflow/installation.js +33 -0
- package/packages/core/workflow/request-rejection.js +3 -0
- package/packages/core/workflow/settlement/actions.js +34 -0
- package/packages/core/workflow/settlement/backflow.js +187 -0
- package/packages/core/workflow/universal-self-dogfood.js +163 -0
- package/packages/core/workflow/universal-workflow-bootstrap.js +586 -0
- package/packages/core/workflow/workflow-taxonomy.mjs +351 -0
- package/scripts/bridge-evidence.mjs +9 -2
- package/scripts/build-domain-wasm.mjs +15 -3
- package/scripts/build-standalone-binary.mjs +1 -375
- package/scripts/check-action-bundles.mjs +14 -25
- package/scripts/check-ci-lane-change-budget.mjs +3 -3
- package/scripts/check-code-layout.mjs +386 -0
- package/scripts/check-core-mechanism-inventory.mjs +17 -16
- package/scripts/check-dev-delivery-actions.mjs +35 -0
- package/scripts/check-floating-consumer-policy-contract.mjs +33 -59
- package/scripts/check-implementation-naming.mjs +2 -23
- package/scripts/check-internal-architecture.mjs +3 -3
- package/scripts/check-inventory.mjs +160 -318
- package/scripts/check-javascript-syntax.mjs +1 -1
- package/scripts/check-maintainability.mjs +25 -21
- package/scripts/check-project-cut-merge-queue-admission.mjs +1 -1
- package/scripts/check-public-dogfood-contract.mjs +166 -43
- package/scripts/check-release-tail-contract.mjs +62 -71
- package/scripts/check-release-topology.mjs +101 -77
- package/scripts/check-runtime-semantic-closure.mjs +5 -8
- package/scripts/check-source-bindings.mjs +54 -0
- package/scripts/check-universal-workflow-bootstrap.mjs +136 -124
- package/scripts/check-workflow-taxonomy.mjs +1 -1
- package/scripts/check-workflows.sh +11 -0
- package/scripts/generate-bootstrap-admission.mjs +32 -0
- package/scripts/generate-bootstrap-recovery.mjs +94 -0
- package/scripts/generate-buildchain-kfd-witnesses.mjs +3 -3
- package/scripts/generate-channel-promotion-workflow.mjs +39 -518
- package/scripts/generate-next-development-guidance.mjs +1 -1
- package/scripts/generate-public-reference.mjs +2 -2
- package/scripts/generate-site-bundle.mjs +42 -43
- package/scripts/generate-tail-reseal-fixture.mjs +108 -0
- package/scripts/generate-workflow-taxonomy.mjs +2 -2
- package/scripts/inventory/binary.mjs +36 -0
- package/scripts/inventory/promotion.mjs +72 -0
- package/scripts/maintainability-domain-metrics.mjs +1 -1
- package/scripts/maintainability-metrics.mjs +37 -37
- package/scripts/maintainability-public-surface.mjs +19 -95
- package/scripts/next-development-self-dogfood-harness.mjs +2 -2
- package/scripts/next-development-self-dogfood.mjs +2 -2
- package/scripts/platform-stage-checkpoint-rehearsal.mjs +33 -201
- package/scripts/public-reference.mjs +0 -187
- package/scripts/publication-rehearsal-fixture.mjs +1 -1
- package/scripts/release-train-self-dogfood.mjs +9 -14
- package/scripts/site-action-audit.mjs +16 -0
- package/scripts/site-capability-metadata.mjs +3 -7
- package/scripts/source-metric-lineage.mjs +17 -0
- package/scripts/stage-capsule-resume-rehearsal.mjs +19 -55
- package/scripts/tail-reseal-macos-rehearsal.mjs +1 -109
- package/scripts/tsup-action.config.mjs +21 -0
- package/scripts/verify-golden-path.mjs +1 -1
- package/scripts/warrant-shadow-plan.mjs +49 -243
- package/scripts/workflow-action-graph.mjs +149 -0
- package/templates/bootstrap-recovery/actions/build/source/admit/action.yml +17 -0
- package/templates/bootstrap-recovery/actions/build/source/admit/dist/index.js +63 -0
- package/templates/bootstrap-recovery/actions/runtime/dependencies/install/action.yml +18 -0
- package/templates/bootstrap-recovery/actions/runtime/dependencies/install/dist/index.js +63 -0
- package/templates/bootstrap-recovery/actions/runtime/environment/prepare/action.yml +21 -0
- package/templates/bootstrap-recovery/actions/workflow/admission/inspect/action.yml +27 -0
- package/templates/bootstrap-recovery/actions/workflow/admission/inspect/dist/index.js +64 -0
- package/templates/bootstrap-recovery/actions/workflow/admission/review/action.yml +15 -0
- package/templates/bootstrap-recovery/actions/workflow/admission/review/dist/index.js +65 -0
- package/templates/bootstrap-recovery/actions/workflow/recovery/admit/action.yml +47 -0
- package/templates/bootstrap-recovery/actions/workflow/recovery/execute/action.yml +48 -0
- package/templates/bootstrap-recovery/actions/workflow/recovery/settle/action.yml +54 -0
- package/templates/bootstrap-recovery/actions/workflow/settlement/seal/action.yml +17 -0
- package/templates/bootstrap-recovery/actions/workflow/settlement/seal/dist/index.js +65 -0
- package/templates/bootstrap-recovery/manifest.json +68 -0
- package/templates/bootstrap-recovery/package.json +9 -0
- package/templates/native-dev-delivery.yml +28 -41
- package/templates/universal-buildchain-bootstrap-recovery.yml +46 -213
- package/templates/universal-buildchain-bootstrap.yml +1 -1
- package/actions/github-artifact-attestation/README.md +0 -10
- package/actions/promote-buildchain-ref/README.md +0 -549
- package/actions/report-buildchain-issue/README.md +0 -107
- package/actions/run-lifecycle/README.md +0 -71
- package/actions/validate-config/README.md +0 -52
- package/architecture/implementation-naming.json +0 -1273
- package/bin/internal/adopter-delivery-cli.mjs +0 -70
- package/bin/internal/cli-options.mjs +0 -79
- package/bin/internal/compatibility-facts-cli.mjs +0 -101
- package/bin/internal/trust-release-cli.mjs +0 -19
- package/bin/internal/trust-release-command-handlers.mjs +0 -14
- package/bin/internal/trust-release-inspection-handlers.mjs +0 -175
- package/bin/internal/trust-release-release-handlers.mjs +0 -332
- package/bin/internal/trust-release-verification-handlers.mjs +0 -306
- package/contracts/fixtures/v4-adopter-delivery-v1/archive-template.json +0 -19
- package/contracts/fixtures/v4-adopter-delivery-v1/bootstrap-positive.json +0 -93
- package/packages/compatibility/adopter-delivery.js +0 -16
- package/packages/compatibility/cross-platform-adopter-qualification.js +0 -12
- package/packages/compatibility/floating-consumer-policy.js +0 -14
- package/packages/compatibility/publication-qualification.js +0 -11
- package/packages/compatibility/publication-rehearsal.js +0 -18
- package/packages/compatibility/runtime-ref-resume-authority.js +0 -13
- package/packages/compatibility/tail-reseal-receipt.js +0 -7
- package/packages/compatibility/tail-reseal.js +0 -11
- package/packages/core/adopter-delivery-parity.js +0 -219
- package/packages/core/adopter-delivery.js +0 -359
- package/packages/core/anchored-version-material.js +0 -281
- package/packages/core/artifact-passport.js +0 -847
- package/packages/core/artifact-verification-envelope.js +0 -500
- package/packages/core/build-facts.js +0 -575
- package/packages/core/buildchain-compatibility-authority.js +0 -336
- package/packages/core/buildchain-compatibility-fact.js +0 -394
- package/packages/core/buildchain-compatibility-facts.json +0 -217
- package/packages/core/buildchain-compatibility-proof.js +0 -566
- package/packages/core/buildchain-config.js +0 -1887
- package/packages/core/buildchain-contract.js +0 -1048
- package/packages/core/buildchain-delivery-bootstrap.js +0 -240
- package/packages/core/buildchain-delivery-infrastructure.js +0 -164
- package/packages/core/buildchain-delivery-self-dogfood.js +0 -395
- package/packages/core/buildchain-domain.wasm +0 -0
- package/packages/core/buildchain-kfd-claims.js +0 -733
- package/packages/core/buildchain-publication-authority.js +0 -118
- package/packages/core/canonical-contracts.js +0 -239
- package/packages/core/ci-lane-change-budget.js +0 -260
- package/packages/core/controller-evidence.js +0 -553
- package/packages/core/cross-platform-adopter-qualification.js +0 -343
- package/packages/core/delivery-warrant-fixture-runner.js +0 -375
- package/packages/core/delivery-warrant-read-candidate.js +0 -286
- package/packages/core/delivery-warrant-semantic-diff-gate.js +0 -351
- package/packages/core/delivery-warrant-shadow-adapter.js +0 -447
- package/packages/core/dev-delivery-authority-candidate.js +0 -270
- package/packages/core/dev-delivery-authority-landing.js +0 -461
- package/packages/core/dev-delivery-authority-state.js +0 -583
- package/packages/core/dev-delivery-candidate-identity.js +0 -169
- package/packages/core/dev-delivery-contract-surface.js +0 -76
- package/packages/core/dev-delivery-native-proof.js +0 -566
- package/packages/core/dev-delivery-proof.js +0 -286
- package/packages/core/dev-delivery-warrant-legacy-recovery.js +0 -248
- package/packages/core/dev-delivery-warrant-native-compatibility.js +0 -33
- package/packages/core/dev-delivery-warrant-state.js +0 -599
- package/packages/core/dev-delivery-warrant.js +0 -598
- package/packages/core/diagnostics.js +0 -1904
- package/packages/core/domain-wasm-artifact.js +0 -7
- package/packages/core/floating-consumer-evidence.js +0 -338
- package/packages/core/floating-consumer-policy.js +0 -571
- package/packages/core/github-artifact-attestation.js +0 -642
- package/packages/core/github-governance-authority.js +0 -1369
- package/packages/core/homebrew.js +0 -414
- package/packages/core/kfd-agent-hub.js +0 -496
- package/packages/core/kfd.js +0 -966
- package/packages/core/kfd2-product-claims.js +0 -454
- package/packages/core/kfd3-surface-register.js +0 -924
- package/packages/core/legacy-kfd-adopter-driver.js +0 -167
- package/packages/core/next-development-projection.js +0 -310
- package/packages/core/next-development-transition.js +0 -737
- package/packages/core/oci-compose-qualification.js +0 -143
- package/packages/core/oci-publication-bundle.js +0 -281
- package/packages/core/package-manager.js +0 -323
- package/packages/core/paper-agent-entry.js +0 -396
- package/packages/core/paper-fleet.js +0 -313
- package/packages/core/paper-npm-bootstrap.js +0 -492
- package/packages/core/paper-repository.js +0 -214
- package/packages/core/paper-runtime-channels.js +0 -348
- package/packages/core/paper-scaffold-content.js +0 -574
- package/packages/core/paper.js +0 -2478
- package/packages/core/partial-mutation-recovery-qualification.js +0 -18
- package/packages/core/platform-stage-checkpoints.js +0 -471
- package/packages/core/product-publication.js +0 -59
- package/packages/core/protected-publication-source.js +0 -91
- package/packages/core/provider-operation-journal.js +0 -62
- package/packages/core/provider-readback-idempotency.js +0 -309
- package/packages/core/public-export-compatibility.js +0 -33
- package/packages/core/public-surface-audit.js +0 -273
- package/packages/core/public-surface-cli.js +0 -128
- package/packages/core/publication-artifact-candidate.js +0 -128
- package/packages/core/publication-artifact.js +0 -641
- package/packages/core/publication-authority.js +0 -1163
- package/packages/core/publication-development.js +0 -72
- package/packages/core/publication-package.js +0 -252
- package/packages/core/publication-rehearsal-capsule.js +0 -468
- package/packages/core/publication-rehearsal-projection.js +0 -104
- package/packages/core/publication-rehearsal-runtime.js +0 -190
- package/packages/core/publication-rehearsal.js +0 -481
- package/packages/core/publication-reproducibility.js +0 -947
- package/packages/core/published-delivery-authority.js +0 -266
- package/packages/core/readme-badges.js +0 -893
- package/packages/core/release-activation-shadow.js +0 -32
- package/packages/core/release-blocker-priority.js +0 -192
- package/packages/core/release-candidate-recovery.js +0 -595
- package/packages/core/release-candidate.js +0 -591
- package/packages/core/release-invocation.js +0 -64
- package/packages/core/release-line-bootstrap.js +0 -297
- package/packages/core/release-line-dry-run.js +0 -303
- package/packages/core/release-passport-contract.js +0 -479
- package/packages/core/release-passport.js +0 -2884
- package/packages/core/release-tail-compatibility.js +0 -60
- package/packages/core/release-tail-provider-adapters.js +0 -461
- package/packages/core/release-tail-provider-plane.js +0 -248
- package/packages/core/runtime-selector-persistence.js +0 -228
- package/packages/core/stable-publication-fence.js +0 -28
- package/packages/core/stage-capsule-local-store.js +0 -428
- package/packages/core/stage-capsule-qualification-campaign.js +0 -511
- package/packages/core/stage-capsule-qualification.js +0 -455
- package/packages/core/stage-capsule-resume-planner.js +0 -397
- package/packages/core/stage-capsule-store.js +0 -404
- package/packages/core/stage-capsule.js +0 -319
- package/packages/core/tail-reseal-github.js +0 -178
- package/packages/core/tail-reseal-receipt.js +0 -225
- package/packages/core/tail-reseal.js +0 -594
- package/packages/core/universal-workflow-bootstrap.js +0 -586
- package/packages/core/web-surface-publication-candidate.js +0 -162
- package/packages/core/workflow-yaml-contract.js +0 -342
- package/scripts/aggregate-build-summary.mjs +0 -187
- package/scripts/aggregate-diagnostics-summary.mjs +0 -54
- package/scripts/anchored-version-material.mjs +0 -42
- package/scripts/architecture.mjs +0 -610
- package/scripts/artifact-relay-s3.mjs +0 -539
- package/scripts/artifact-signing-controller-core.mjs +0 -525
- package/scripts/artifact-signing-controller.mjs +0 -302
- package/scripts/artifact-signing-delegation.mjs +0 -316
- package/scripts/assemble-binary-release-admission.mjs +0 -213
- package/scripts/assemble-publication-artifact-admission.mjs +0 -200
- package/scripts/assemble-self-publication-admission.mjs +0 -201
- package/scripts/assemble-web-surface-publication-admission.mjs +0 -204
- package/scripts/audit-github-governance.mjs +0 -493
- package/scripts/audit-publication-control-plane.mjs +0 -527
- package/scripts/auditable-demo-bundle-verification.mjs +0 -148
- package/scripts/auditable-demo-platform.mjs +0 -600
- package/scripts/auditable-demo-presentation.mjs +0 -83
- package/scripts/auditable-demo-renditions.mjs +0 -399
- package/scripts/auditable-demo-transport-smoke.mjs +0 -176
- package/scripts/auditable-demo.mjs +0 -1324
- package/scripts/aws-codebuild-toolchain.mjs +0 -285
- package/scripts/aws-macos-jit-controller-runtime.mjs +0 -82
- package/scripts/aws-runner-burst-core.mjs +0 -248
- package/scripts/aws-runner-burst.mjs +0 -79
- package/scripts/aws-windows-jit-campaign.mjs +0 -202
- package/scripts/aws-windows-jit-controller.mjs +0 -578
- package/scripts/binary-publication-evidence.mjs +0 -133
- package/scripts/bridge-bootstrap.mjs +0 -137
- package/scripts/build-contract-core.mjs +0 -1216
- package/scripts/buildchain-channel-router.mjs +0 -249
- package/scripts/buildchain-cli-help.mjs +0 -321
- package/scripts/buildchain-contract-lock.mjs +0 -184
- package/scripts/buildchain-patrol.mjs +0 -280
- package/scripts/compiler-cache-evidence.mjs +0 -304
- package/scripts/consumer-policy.mjs +0 -231
- package/scripts/controller-evidence.mjs +0 -208
- package/scripts/copy-domain-wasm.mjs +0 -14
- package/scripts/create-github-artifact-attestation-policy.mjs +0 -62
- package/scripts/create-release-bundle.mjs +0 -167
- package/scripts/cross-platform-adopter-qualification.mjs +0 -228
- package/scripts/declarative-promotion-admission.mjs +0 -45
- package/scripts/dev-alpha-candidate-patrol.mjs +0 -1197
- package/scripts/dev-delivery-authority-command-adapters.mjs +0 -206
- package/scripts/dev-delivery-authority-provider.mjs +0 -28
- package/scripts/dev-delivery-authority.mjs +0 -490
- package/scripts/dev-delivery-native-run.mjs +0 -177
- package/scripts/dev-delivery-process-boundary.mjs +0 -260
- package/scripts/dev-delivery-proof.mjs +0 -258
- package/scripts/dev-delivery-provider-heartbeat.mjs +0 -215
- package/scripts/dev-delivery-source-proof-replay.mjs +0 -153
- package/scripts/dev-delivery-source-proof-reuse.mjs +0 -548
- package/scripts/dev-delivery-two-phase-resume.mjs +0 -345
- package/scripts/dev-delivery-two-phase.mjs +0 -573
- package/scripts/dev-delivery-warrant-options.mjs +0 -298
- package/scripts/dev-delivery-warrant-store.mjs +0 -316
- package/scripts/dev-delivery-warrant-transition.mjs +0 -109
- package/scripts/dev-delivery-warrant.mjs +0 -559
- package/scripts/dev-merge-queue.mjs +0 -536
- package/scripts/dev-pr-auto-merge.mjs +0 -1222
- package/scripts/dev-pr-delivery-warrant.mjs +0 -467
- package/scripts/dev-pr-prequeue-guard.mjs +0 -381
- package/scripts/dev-qualification-patrol.mjs +0 -594
- package/scripts/dispatch-artifact-signing-authority.mjs +0 -407
- package/scripts/engineering-housekeeper-workflow.mjs +0 -401
- package/scripts/ensure-github-release.mjs +0 -199
- package/scripts/finalize-native-artifact-signing-result.mjs +0 -272
- package/scripts/generate-channel-build-workflow.mjs +0 -69
- package/scripts/generate-release-candidate-passport.mjs +0 -285
- package/scripts/generate-universal-workflow-facades.mjs +0 -499
- package/scripts/git-fetch-process-tree.mjs +0 -175
- package/scripts/host-adapter.mjs +0 -182
- package/scripts/implementation-references.mjs +0 -25
- package/scripts/import-artifact-signing-results.mjs +0 -135
- package/scripts/infra-contract-core.mjs +0 -1032
- package/scripts/infra-contract.mjs +0 -345
- package/scripts/init-repo.mjs +0 -518
- package/scripts/inspect-artifact-signing-requests.mjs +0 -157
- package/scripts/installer-publication.mjs +0 -361
- package/scripts/lifecycle-substage-evidence.mjs +0 -274
- package/scripts/locked-source-checkout.mjs +0 -595
- package/scripts/materialize-artifact-signing-request.mjs +0 -66
- package/scripts/merge-artifact-signing-results.mjs +0 -76
- package/scripts/next-development-review.mjs +0 -331
- package/scripts/next-development-transition.mjs +0 -47
- package/scripts/npm-publish-dry-run.mjs +0 -182
- package/scripts/npm-publish-transaction.mjs +0 -331
- package/scripts/observed-evidence.mjs +0 -311
- package/scripts/oci-compose-preview.mjs +0 -261
- package/scripts/paper-agent-cli.mjs +0 -35
- package/scripts/paper-work-fleet-cli.mjs +0 -594
- package/scripts/paper.mjs +0 -644
- package/scripts/product-publication-intent.mjs +0 -129
- package/scripts/promotion-channel-router.mjs +0 -139
- package/scripts/promotion-identity-resolver.mjs +0 -129
- package/scripts/publication-artifact-candidate.mjs +0 -122
- package/scripts/publication-artifact.mjs +0 -67
- package/scripts/publication-candidate-kind.mjs +0 -93
- package/scripts/publication-candidate-sealer.mjs +0 -119
- package/scripts/publication-package.mjs +0 -38
- package/scripts/publication-registry-hydrate.mjs +0 -216
- package/scripts/publication-reproducibility.mjs +0 -62
- package/scripts/publication-settlement.mjs +0 -217
- package/scripts/publish-source-ref-resolver.mjs +0 -113
- package/scripts/reconcile-github-governance.mjs +0 -689
- package/scripts/reconcile-release-governance.mjs +0 -368
- package/scripts/release-asset-client.mjs +0 -91
- package/scripts/release-candidate-adapter.mjs +0 -41
- package/scripts/release-candidate-anchor-provenance.mjs +0 -99
- package/scripts/release-candidate-resolver.mjs +0 -842
- package/scripts/release-finalization-review.mjs +0 -53
- package/scripts/release-line-dry-run.mjs +0 -53
- package/scripts/release-line-policy.mjs +0 -231
- package/scripts/release-propagation.mjs +0 -411
- package/scripts/release-tail.mjs +0 -178
- package/scripts/release-transaction.mjs +0 -212
- package/scripts/resolve-artifact-coordinates.mjs +0 -174
- package/scripts/resolve-artifact-transfer-mode.mjs +0 -126
- package/scripts/resolve-build-configuration.mjs +0 -105
- package/scripts/resolve-build-contract.mjs +0 -96
- package/scripts/resolve-publish-gate.mjs +0 -33
- package/scripts/resolve-publish-source.mjs +0 -99
- package/scripts/resume-from-candidate-run.mjs +0 -1117
- package/scripts/route-offline-runners.mjs +0 -237
- package/scripts/run-candidate-body-prefix-renderer.mjs +0 -187
- package/scripts/run-lifecycle-core.mjs +0 -850
- package/scripts/run-lifecycle.mjs +0 -56
- package/scripts/runtime-ref-core.mjs +0 -171
- package/scripts/seal-artifact-signing-requests.mjs +0 -431
- package/scripts/seal-macos-credential-input.mjs +0 -135
- package/scripts/shifu-gate-profile.mjs +0 -374
- package/scripts/sign-detached-artifact-requests.mjs +0 -237
- package/scripts/source-verification-evidence.mjs +0 -344
- package/scripts/stable-candidate-patrol.mjs +0 -527
- package/scripts/stable-candidate-policy.mjs +0 -25
- package/scripts/stable-candidate-qualification.mjs +0 -358
- package/scripts/stable-release-gate.mjs +0 -351
- package/scripts/stage-capsule-qualification.mjs +0 -528
- package/scripts/tail-reseal.mjs +0 -416
- package/scripts/universal-facade-maintainability.mjs +0 -91
- package/scripts/universal-workflow-backflow.mjs +0 -212
- package/scripts/universal-workflow-engine.mjs +0 -620
- package/scripts/universal-workflow-self-dogfood.mjs +0 -212
- package/scripts/validate-package-manager-contract.mjs +0 -24
- package/scripts/verify-artifact-signing-results.mjs +0 -124
- package/scripts/verify-publish-channel-ref.mjs +0 -125
- package/scripts/verify-publish-source-lock.mjs +0 -37
- package/scripts/verify-release-pr.mjs +0 -34
- package/scripts/verify-version-state-delta.mjs +0 -175
- package/scripts/verify-web-surface-publication-capability.mjs +0 -78
- package/scripts/web-surface-core.mjs +0 -2603
- package/scripts/web-surface-production-decision.mjs +0 -158
- package/scripts/web-surface-production-release-pr.mjs +0 -712
- package/scripts/web-surface-release-feedback.mjs +0 -358
- package/scripts/web-surface-release-pr-review.mjs +0 -187
- package/scripts/web-surface.mjs +0 -460
- package/scripts/workflow-call-contract.mjs +0 -133
- package/scripts/workflow-friction-report.mjs +0 -375
- package/scripts/workflow-taxonomy.mjs +0 -507
- /package/actions/{macos-credential-island → build/credential/macos-island}/README.md +0 -0
- /package/actions/{release-candidate-promote → release/promotion/candidate}/README.md +0 -0
- /package/actions/{release-tail → release/tail/settle}/README.md +0 -0
- /package/packages/core/{adopter-delivery-gate.js → adoption/adopter-delivery-gate.js} +0 -0
- /package/packages/core/{adopter-delivery-json.js → adoption/adopter-delivery-json.js} +0 -0
- /package/packages/core/{adopter-delivery-passport.js → adoption/adopter-delivery-passport.js} +0 -0
- /package/packages/core/{adopter-delivery-vectors.js → adoption/adopter-delivery-vectors.js} +0 -0
- /package/packages/core/{adopter-delivery-vectors.json → adoption/adopter-delivery-vectors.json} +0 -0
- /package/packages/core/{buildchain-agent-manuals.js → adoption/buildchain-agent-manuals.js} +0 -0
- /package/packages/core/{kfd-adopter-category-driver.js → adoption/kfd-adopter-category-driver.js} +0 -0
- /package/packages/core/{kfd-adopter-manifest.js → adoption/kfd-adopter-manifest.js} +0 -0
- /package/packages/core/{kfd-gate.js → adoption/kfd-gate.js} +0 -0
- /package/packages/core/{kfd-product-gates.js → adoption/kfd-product-gates.js} +0 -0
- /package/packages/core/{artifact-signing-result.js → build/artifact-signing-result.js} +0 -0
- /package/packages/core/{artifact-signing.js → build/artifact-signing.js} +0 -0
- /package/packages/core/{build-configuration.js → build/build-configuration.js} +0 -0
- /package/{scripts → packages/core/build/commands}/resolve-artifact-signing-upload-route.mjs +0 -0
- /package/packages/core/{detached-artifact-signature.js → build/detached-artifact-signature.js} +0 -0
- /package/{scripts/gate-profile-core.mjs → packages/core/build/gate/contracts.js} +0 -0
- /package/packages/core/{portable-dev-cache.js → build/portable-dev-cache.js} +0 -0
- /package/packages/core/{buildchain-channel-identity.js → consumer/buildchain-channel-identity.js} +0 -0
- /package/packages/core/{floating-consumer-release-passport.js → consumer/floating-consumer-release-passport.js} +0 -0
- /package/packages/core/{runtime-ref-resume-authority.js → consumer/runtime-ref-resume-authority.js} +0 -0
- /package/packages/core/{buildchain-layout.js → contracts/buildchain-layout.js} +0 -0
- /package/{bin/internal → packages/core/contracts}/command-registry.mjs +0 -0
- /package/packages/core/{kungfu-temporal-fact.js → contracts/kungfu-temporal-fact.js} +0 -0
- /package/packages/core/{surface-manifest.js → contracts/surface-manifest.js} +0 -0
- /package/packages/core/{workflow-call-contract.js → contracts/workflow-call-contract.js} +0 -0
- /package/{scripts → packages/core/dev-delivery/commands}/project-cut-merge-queue-admission.mjs +0 -0
- /package/packages/core/{dev-delivery-authority-evidence.js → dev-delivery/dev-delivery-authority-evidence.js} +0 -0
- /package/packages/core/{dev-delivery-authority-observation.js → dev-delivery/dev-delivery-authority-observation.js} +0 -0
- /package/packages/core/{dev-delivery-authority-qualification.js → dev-delivery/dev-delivery-authority-qualification.js} +0 -0
- /package/packages/core/{dev-delivery-authority-settlement.js → dev-delivery/dev-delivery-authority-settlement.js} +0 -0
- /package/packages/core/{dev-delivery-common.js → dev-delivery/dev-delivery-common.js} +0 -0
- /package/packages/core/{dev-delivery-execution-failure.js → dev-delivery/dev-delivery-execution-failure.js} +0 -0
- /package/packages/core/{dev-delivery-execution-transfer.js → dev-delivery/dev-delivery-execution-transfer.js} +0 -0
- /package/packages/core/{dev-delivery-landing-admission-core.js → dev-delivery/dev-delivery-landing-admission-core.js} +0 -0
- /package/packages/core/{dev-delivery-landing-readback.js → dev-delivery/dev-delivery-landing-readback.js} +0 -0
- /package/packages/core/{dev-delivery-landing-terminal-evidence.js → dev-delivery/dev-delivery-landing-terminal-evidence.js} +0 -0
- /package/packages/core/{dev-delivery-landing-testing-port.js → dev-delivery/dev-delivery-landing-testing-port.js} +0 -0
- /package/packages/core/{dev-delivery-native-execution.js → dev-delivery/dev-delivery-native-execution.js} +0 -0
- /package/packages/core/{dev-delivery-process-boundary.js → dev-delivery/dev-delivery-process-boundary.js} +0 -0
- /package/packages/core/{dev-delivery-provider-attempt.js → dev-delivery/dev-delivery-provider-attempt.js} +0 -0
- /package/packages/core/{dev-delivery-provider-heartbeat.js → dev-delivery/dev-delivery-provider-heartbeat.js} +0 -0
- /package/packages/core/{dev-delivery-warrant-cancellation.js → dev-delivery/dev-delivery-warrant-cancellation.js} +0 -0
- /package/packages/core/{dev-delivery-warrant-qualification.js → dev-delivery/dev-delivery-warrant-qualification.js} +0 -0
- /package/packages/core/{dev-delivery-warrant-settlement.js → dev-delivery/dev-delivery-warrant-settlement.js} +0 -0
- /package/packages/core/{dev-delivery-writer-protocol-transition.js → dev-delivery/dev-delivery-writer-protocol-transition.js} +0 -0
- /package/packages/core/{engineering-housekeeper-github-client.js → governance/engineering-housekeeper-github-client.js} +0 -0
- /package/packages/core/{engineering-housekeeper-github.js → governance/engineering-housekeeper-github.js} +0 -0
- /package/packages/core/{engineering-housekeeper.js → governance/engineering-housekeeper.js} +0 -0
- /package/packages/core/{issue-reporting.js → governance/issue-reporting.js} +0 -0
- /package/packages/core/{cache-evidence.js → observability/cache-evidence.js} +0 -0
- /package/packages/core/{candidate-timeline.js → observability/candidate-timeline.js} +0 -0
- /package/packages/core/{logging.js → observability/logging.js} +0 -0
- /package/packages/core/{paper-work.js → paper/paper-work.js} +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-macos-jit-controller-core.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-macos-jit-controller.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-macos-jit-core.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-macos-jit-job-controller.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-macos-jit.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-windows-jit-campaign-core.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-windows-jit-controller-core.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-windows-jit-core.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/aws-windows-jit.mjs +0 -0
- /package/{scripts → packages/core/providers/commands}/github-output.mjs +0 -0
- /package/packages/core/{oci-publication-graph.js → publication/oci-publication-graph.js} +0 -0
- /package/packages/core/{publication-control-plane-audit.js → publication/publication-control-plane-audit.js} +0 -0
- /package/packages/core/{publication-qualification.js → publication/publication-qualification.js} +0 -0
- /package/packages/core/{publication-rehearsal-provider-bindings.js → publication/publication-rehearsal-provider-bindings.js} +0 -0
- /package/packages/core/{publication-sealed-bundle.js → publication/publication-sealed-bundle.js} +0 -0
- /package/packages/core/{channel-candidate.js → release/channel-candidate.js} +0 -0
- /package/packages/core/{channel-promotion-baseline.js → release/channel-promotion-baseline.js} +0 -0
- /package/{scripts → packages/core/release/commands}/promotion-routing-evidence.mjs +0 -0
- /package/packages/core/{dev-alpha-active-release-train.js → release/dev-alpha-active-release-train.js} +0 -0
- /package/packages/core/{dev-alpha-candidate-selection.js → release/dev-alpha-candidate-selection.js} +0 -0
- /package/packages/core/{next-development-candidate-reservation.js → release/next-development-candidate-reservation.js} +0 -0
- /package/packages/core/{next-development-controller.js → release/next-development-controller.js} +0 -0
- /package/packages/core/{publish-transaction.js → release/publish-transaction.js} +0 -0
- /package/packages/core/{release-activation-transaction.js → release/release-activation-transaction.js} +0 -0
- /package/packages/core/{release-propagation-agent-entry.js → release/release-propagation-agent-entry.js} +0 -0
- /package/packages/core/{release-propagation-capture.js → release/release-propagation-capture.js} +0 -0
- /package/packages/core/{release-propagation-common.js → release/release-propagation-common.js} +0 -0
- /package/packages/core/{release-propagation-execution-profile.js → release/release-propagation-execution-profile.js} +0 -0
- /package/packages/core/{release-propagation-pickup.js → release/release-propagation-pickup.js} +0 -0
- /package/packages/core/{release-propagation-push.js → release/release-propagation-push.js} +0 -0
- /package/packages/core/{release-propagation-release.js → release/release-propagation-release.js} +0 -0
- /package/packages/core/{release-propagation-stage-evidence.js → release/release-propagation-stage-evidence.js} +0 -0
- /package/packages/core/{release-propagation-work-capture.js → release/release-propagation-work-capture.js} +0 -0
- /package/packages/core/{release-propagation-work-constants.js → release/release-propagation-work-constants.js} +0 -0
- /package/packages/core/{release-propagation-work-control.js → release/release-propagation-work-control.js} +0 -0
- /package/packages/core/{release-propagation-work-transitions.js → release/release-propagation-work-transitions.js} +0 -0
- /package/packages/core/{release-propagation-work.js → release/release-propagation-work.js} +0 -0
- /package/packages/core/{release-propagation.js → release/release-propagation.js} +0 -0
- /package/packages/core/{release-tail-product-capabilities.js → release/release-tail-product-capabilities.js} +0 -0
- /package/packages/core/{release-train.js → release/release-train.js} +0 -0
- /package/packages/core/{self-dogfood-version.js → release/self-dogfood-version.js} +0 -0
- /package/packages/core/{stable-candidate-ledger.js → release/stable-candidate-ledger.js} +0 -0
- /package/packages/core/{stable-release-gate.js → release/stable-release-gate.js} +0 -0
- /package/packages/core/{tail-reseal-contract.js → release/tail-reseal-contract.js} +0 -0
- /package/packages/core/{domain-wasm.js → runtime/domain-wasm.js} +0 -0
- /package/packages/core/{spawn-command.js → runtime/spawn-command.js} +0 -0
- /package/packages/core/{badges.js → web/badges.js} +0 -0
- /package/{scripts → packages/core/web/commands}/web-surface-cloudfront-rewrite.mjs +0 -0
- /package/{scripts → packages/core/web/commands}/web-surface-immutable-object.mjs +0 -0
- /package/{scripts → packages/core/web/commands}/web-surface-routing.mjs +0 -0
|
@@ -0,0 +1,2603 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import dns from "node:dns/promises";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
8
|
+
import { installationRoot } from "../../runtime/installation-root.js";
|
|
9
|
+
import { loadBuildchainConfig, validateBuildchainConfig } from "../../consumer/buildchain-config.js";
|
|
10
|
+
import { createSurfaceTimestampPolicy } from "../../contracts/surface-manifest.js";
|
|
11
|
+
import { validateInstallerPublication, verifyInstallerPublicReadback } from "../../publication/installer/evidence.js";
|
|
12
|
+
import {
|
|
13
|
+
classifyPreviewAlias,
|
|
14
|
+
resolveChannelUrl,
|
|
15
|
+
resolvePathOnlyUrl,
|
|
16
|
+
resolveSurfaceUrl,
|
|
17
|
+
manifestPrefixFor,
|
|
18
|
+
objectPrefixFor,
|
|
19
|
+
normalizeSurfacePath,
|
|
20
|
+
surfaceDeployConfig,
|
|
21
|
+
surfaceObjectPrefixFor,
|
|
22
|
+
normalizeS3Key,
|
|
23
|
+
joinS3Key,
|
|
24
|
+
joinUrlPath,
|
|
25
|
+
urlWithPath,
|
|
26
|
+
s3Uri,
|
|
27
|
+
cdnPath,
|
|
28
|
+
cdnWildcardPath,
|
|
29
|
+
viewerWildcardPath,
|
|
30
|
+
surfaceArtifactPrefix,
|
|
31
|
+
surfaceArtifactRootFor,
|
|
32
|
+
syncStaticArtifactArgs,
|
|
33
|
+
mutableCacheControlArgs,
|
|
34
|
+
} from "./web-surface-routing.mjs";
|
|
35
|
+
|
|
36
|
+
const commandDirectory = () => path.join(installationRoot(import.meta.url), "packages/core/web/commands");
|
|
37
|
+
|
|
38
|
+
const DEFAULT_RETENTION = Object.freeze({
|
|
39
|
+
preview: {
|
|
40
|
+
pr_days: 14,
|
|
41
|
+
sha_days: 90,
|
|
42
|
+
},
|
|
43
|
+
staging: {
|
|
44
|
+
days: 90,
|
|
45
|
+
keep_deploys: 10,
|
|
46
|
+
},
|
|
47
|
+
production: {
|
|
48
|
+
days: 365,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function assertWebSurfaceConfig(loadedConfig) {
|
|
53
|
+
if (loadedConfig?.config?.project?.type !== "web-surface") {
|
|
54
|
+
throw new Error('buildchain.toml project.type must be "web-surface"');
|
|
55
|
+
}
|
|
56
|
+
return loadedConfig.config;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function assertSha(value, label) {
|
|
60
|
+
const sha = String(value || "").trim();
|
|
61
|
+
if (!/^[0-9a-f]{40}$/i.test(sha)) {
|
|
62
|
+
throw new Error(`${label} must be a 40-character Git SHA`);
|
|
63
|
+
}
|
|
64
|
+
return sha.toLowerCase();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function assertHash(value, label) {
|
|
68
|
+
const hash = String(value || "").trim();
|
|
69
|
+
if (!/^[0-9a-f]{64}$/i.test(hash)) {
|
|
70
|
+
throw new Error(`${label} must be a 64-character SHA-256 hash`);
|
|
71
|
+
}
|
|
72
|
+
return hash.toLowerCase();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function toPosix(value) {
|
|
76
|
+
return String(value || "").split(path.sep).join("/");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function listFiles(root, rel) {
|
|
80
|
+
const target = path.isAbsolute(rel) ? rel : path.join(root, rel);
|
|
81
|
+
if (!fs.existsSync(target)) {
|
|
82
|
+
throw new Error(`artifact path does not exist: ${rel}`);
|
|
83
|
+
}
|
|
84
|
+
const stat = fs.statSync(target);
|
|
85
|
+
if (stat.isFile()) {
|
|
86
|
+
return [target];
|
|
87
|
+
}
|
|
88
|
+
return fs
|
|
89
|
+
.readdirSync(target, { withFileTypes: true })
|
|
90
|
+
.flatMap((entry) => listFiles(root, path.join(target, entry.name)));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function sha256File(filePath) {
|
|
94
|
+
const hash = crypto.createHash("sha256");
|
|
95
|
+
hash.update(fs.readFileSync(filePath));
|
|
96
|
+
return hash.digest("hex");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function addDays(iso, days) {
|
|
100
|
+
if (days === undefined || days === null) {
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
103
|
+
const date = new Date(iso);
|
|
104
|
+
date.setUTCDate(date.getUTCDate() + Number(days));
|
|
105
|
+
return date.toISOString();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function retentionConfig(config, channel) {
|
|
109
|
+
return {
|
|
110
|
+
...(DEFAULT_RETENTION[channel] || {}),
|
|
111
|
+
...(config.retention?.[channel] || {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
const PUBLICATION_ARCHIVE_POLICY_CONTRACT = "kungfu-buildchain-publication-archive-policy";
|
|
158
|
+
const OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT = "kungfu-buildchain-observed-evidence-ownership";
|
|
159
|
+
const PUBLICATION_FAST_PATH_CONTRACT = "kungfu-buildchain-publication-package-pin-fast-path";
|
|
160
|
+
|
|
161
|
+
function immutablePrefix(value, label) {
|
|
162
|
+
const raw = String(value || "").trim().replaceAll("\\", "/");
|
|
163
|
+
if (!raw || raw.split("/").includes("..")) {
|
|
164
|
+
throw new Error(`invalid ${label}: ${value}`);
|
|
165
|
+
}
|
|
166
|
+
const normalized = normalizeS3Key(raw);
|
|
167
|
+
if (!normalized || normalized.split("/").length < 2) {
|
|
168
|
+
throw new Error(`${label} must identify a versioned path below an immutable root: ${value}`);
|
|
169
|
+
}
|
|
170
|
+
return normalized;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function publicationFastPathScope({ artifactRoot, bindings }) {
|
|
174
|
+
const manifestFile = path.join(artifactRoot, "manifest.json");
|
|
175
|
+
if (!fs.existsSync(manifestFile)) return null;
|
|
176
|
+
let manifest;
|
|
177
|
+
try {
|
|
178
|
+
manifest = JSON.parse(fs.readFileSync(manifestFile, "utf8"));
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw new Error(`invalid web-surface artifact manifest: ${error.message}`);
|
|
181
|
+
}
|
|
182
|
+
const raw = manifest?.publicationFastPath;
|
|
183
|
+
if (raw === undefined || raw === null) return null;
|
|
184
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
185
|
+
throw new Error("publicationFastPath must be an object");
|
|
186
|
+
}
|
|
187
|
+
if (raw.contract !== PUBLICATION_FAST_PATH_CONTRACT || raw.mode !== "package-pin-only") {
|
|
188
|
+
throw new Error("publicationFastPath contract or mode is unsupported");
|
|
189
|
+
}
|
|
190
|
+
const targetSurface = String(raw.targetSurface || "").trim();
|
|
191
|
+
const binding = bindings.find((entry) => entry.surface === targetSurface);
|
|
192
|
+
if (!binding) {
|
|
193
|
+
throw new Error(`publicationFastPath target surface is not declared: ${targetSurface}`);
|
|
194
|
+
}
|
|
195
|
+
const qualificationRoot = String(raw.qualificationRoot || "").trim();
|
|
196
|
+
if (!/^sha256:[a-f0-9]{64}$/.test(qualificationRoot)) {
|
|
197
|
+
throw new Error("publicationFastPath qualificationRoot must be an exact SHA-256 root");
|
|
198
|
+
}
|
|
199
|
+
const surfaceRoot = surfaceArtifactRootFor({ artifactRoot, binding });
|
|
200
|
+
const immutablePrefixes = [...new Set((raw.immutablePrefixes || []).map((entry) =>
|
|
201
|
+
immutablePrefix(entry, "publicationFastPath immutable prefix"),
|
|
202
|
+
))].sort();
|
|
203
|
+
if (immutablePrefixes.length === 0) {
|
|
204
|
+
throw new Error("publicationFastPath must declare immutablePrefixes");
|
|
205
|
+
}
|
|
206
|
+
const mutableFiles = [...new Set((raw.mutableFiles || []).map((entry) => {
|
|
207
|
+
const normalized = normalizeS3Key(entry);
|
|
208
|
+
const candidate = path.join(surfaceRoot, normalized);
|
|
209
|
+
if (
|
|
210
|
+
!normalized
|
|
211
|
+
|| String(entry).includes("..")
|
|
212
|
+
|| !fs.statSync(candidate, { throwIfNoEntry: false })?.isFile()
|
|
213
|
+
) {
|
|
214
|
+
throw new Error(`invalid or missing publicationFastPath mutable file: ${entry}`);
|
|
215
|
+
}
|
|
216
|
+
return normalized;
|
|
217
|
+
}))].sort();
|
|
218
|
+
if (mutableFiles.length === 0) {
|
|
219
|
+
throw new Error("publicationFastPath must declare mutableFiles");
|
|
220
|
+
}
|
|
221
|
+
if (mutableFiles.some((file) =>
|
|
222
|
+
immutablePrefixes.some((prefix) => file === prefix || file.startsWith(`${prefix}/`)))) {
|
|
223
|
+
throw new Error("publicationFastPath mutable files cannot overlap immutable prefixes");
|
|
224
|
+
}
|
|
225
|
+
for (const prefix of immutablePrefixes) {
|
|
226
|
+
if (!fs.statSync(path.join(surfaceRoot, prefix), { throwIfNoEntry: false })?.isDirectory()) {
|
|
227
|
+
throw new Error(`publicationFastPath immutable prefix does not exist: ${prefix}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const invalidationPaths = [...new Set((raw.invalidationPaths || []).map((entry) => {
|
|
231
|
+
const value = String(entry || "").trim();
|
|
232
|
+
if (!value.startsWith("/") || value.includes("..")) {
|
|
233
|
+
throw new Error(`invalid publicationFastPath invalidation path: ${entry}`);
|
|
234
|
+
}
|
|
235
|
+
return value;
|
|
236
|
+
}))].sort();
|
|
237
|
+
if (invalidationPaths.length === 0) {
|
|
238
|
+
throw new Error("publicationFastPath must declare invalidationPaths");
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
contract: PUBLICATION_FAST_PATH_CONTRACT,
|
|
242
|
+
mode: "package-pin-only",
|
|
243
|
+
targetSurface,
|
|
244
|
+
qualificationRoot,
|
|
245
|
+
immutablePrefixes,
|
|
246
|
+
mutableFiles,
|
|
247
|
+
invalidationPaths,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function applyPublicationFastPathScope(bindings, { cwd, artifactPath }) {
|
|
252
|
+
const artifactRoot = path.resolve(cwd, artifactPath);
|
|
253
|
+
const scope = publicationFastPathScope({ artifactRoot, bindings });
|
|
254
|
+
if (!scope) {
|
|
255
|
+
return { bindings, scope: null };
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
bindings: bindings
|
|
259
|
+
.filter((binding) => binding.surface === scope.targetSurface)
|
|
260
|
+
.map((binding) => ({ ...binding, publicationFastPath: scope })),
|
|
261
|
+
scope,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function publicationImmutablePolicy({ artifactRoot, binding }) {
|
|
266
|
+
const surfaceRoot = surfaceArtifactRootFor({ artifactRoot, binding });
|
|
267
|
+
const manifestFile = path.join(surfaceRoot, "manifest.json");
|
|
268
|
+
if (!fs.existsSync(manifestFile)) return null;
|
|
269
|
+
let manifest;
|
|
270
|
+
try {
|
|
271
|
+
manifest = JSON.parse(fs.readFileSync(manifestFile, "utf8"));
|
|
272
|
+
} catch (error) {
|
|
273
|
+
throw new Error(`invalid publication archive manifest ${toPosix(path.relative(artifactRoot, manifestFile))}: ${error.message}`);
|
|
274
|
+
}
|
|
275
|
+
if (manifest?.archivePolicy?.contract !== PUBLICATION_ARCHIVE_POLICY_CONTRACT) return null;
|
|
276
|
+
const declaredVersions = (manifest.publications || []).flatMap((publication) =>
|
|
277
|
+
(publication.versions || []).map((version) => ({
|
|
278
|
+
prefix: immutablePrefix(
|
|
279
|
+
version.immutablePath,
|
|
280
|
+
`publication ${publication.id || "unknown"} immutablePath`,
|
|
281
|
+
),
|
|
282
|
+
materialized: Object.hasOwn(version, "immutableIndex"),
|
|
283
|
+
})),
|
|
284
|
+
);
|
|
285
|
+
const declaredPrefixes = [...new Set(declaredVersions.map((entry) => entry.prefix))].sort();
|
|
286
|
+
if (declaredPrefixes.length === 0) {
|
|
287
|
+
throw new Error("publication archive policy must declare at least one immutable version prefix");
|
|
288
|
+
}
|
|
289
|
+
const hasMaterializationEnvelope = declaredVersions.some((entry) => entry.materialized);
|
|
290
|
+
const materializedPrefixes = [...new Set(
|
|
291
|
+
(hasMaterializationEnvelope
|
|
292
|
+
? declaredVersions.filter((entry) => entry.materialized)
|
|
293
|
+
: declaredVersions
|
|
294
|
+
).map((entry) => entry.prefix),
|
|
295
|
+
)].sort();
|
|
296
|
+
for (const prefix of materializedPrefixes) {
|
|
297
|
+
if (!fs.existsSync(path.join(surfaceRoot, prefix))) {
|
|
298
|
+
throw new Error(`materialized immutable publication prefix does not exist in artifact: ${prefix}`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const preservedRoots = declaredPrefixes;
|
|
302
|
+
const uploadRoots = binding.publicationFastPath?.immutablePrefixes || materializedPrefixes;
|
|
303
|
+
if (binding.publicationFastPath) {
|
|
304
|
+
for (const prefix of uploadRoots) {
|
|
305
|
+
if (!declaredPrefixes.includes(prefix)) {
|
|
306
|
+
throw new Error(`publicationFastPath immutable prefix is not declared by the archive manifest: ${prefix}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const files = uploadRoots
|
|
311
|
+
.flatMap((root) => listFiles(surfaceRoot, root))
|
|
312
|
+
.map((filePath) => ({
|
|
313
|
+
path: toPosix(path.relative(surfaceRoot, filePath)),
|
|
314
|
+
size: fs.statSync(filePath).size,
|
|
315
|
+
sha256: sha256File(filePath),
|
|
316
|
+
}))
|
|
317
|
+
.sort((left, right) => left.path.localeCompare(right.path));
|
|
318
|
+
return {
|
|
319
|
+
contract: "kungfu-buildchain-web-surface-immutable-publication",
|
|
320
|
+
sourceContract: manifest.contract || "",
|
|
321
|
+
archivePolicyContract: PUBLICATION_ARCHIVE_POLICY_CONTRACT,
|
|
322
|
+
manifestPath: toPosix(path.relative(artifactRoot, manifestFile)),
|
|
323
|
+
preservedRoots,
|
|
324
|
+
declaredPrefixes,
|
|
325
|
+
materializedPrefixes,
|
|
326
|
+
uploadRoots,
|
|
327
|
+
files,
|
|
328
|
+
fastPath: binding.publicationFastPath || undefined,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function observedEvidenceOwnershipPolicy({ artifactRoot, binding }) {
|
|
333
|
+
const surfaceRoot = surfaceArtifactRootFor({ artifactRoot, binding });
|
|
334
|
+
const policyFile = path.join(surfaceRoot, ".buildchain", "observed-evidence-ownership.json");
|
|
335
|
+
if (!fs.existsSync(policyFile)) return null;
|
|
336
|
+
let policy;
|
|
337
|
+
try {
|
|
338
|
+
policy = JSON.parse(fs.readFileSync(policyFile, "utf8"));
|
|
339
|
+
} catch (error) {
|
|
340
|
+
throw new Error(`invalid observed evidence ownership policy: ${error.message}`);
|
|
341
|
+
}
|
|
342
|
+
if (policy?.schemaVersion !== 1 || policy?.contract !== OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT) {
|
|
343
|
+
throw new Error(`observed evidence ownership policy must be ${OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT} schemaVersion 1`);
|
|
344
|
+
}
|
|
345
|
+
const paths = [...new Set(policy.paths || [])].map((entry) => String(entry).replaceAll("\\", "/").replace(/^\/+/, ""));
|
|
346
|
+
if (paths.length === 0 || paths.some((entry) => !entry || entry.split("/").includes("..") || entry === "*")) {
|
|
347
|
+
throw new Error("observed evidence ownership policy requires bounded relative paths");
|
|
348
|
+
}
|
|
349
|
+
return {
|
|
350
|
+
contract: OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT,
|
|
351
|
+
policyPath: toPosix(path.relative(artifactRoot, policyFile)),
|
|
352
|
+
paths: paths.sort(),
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function withImmutablePublicationPolicies(bindings, { cwd, artifactPath }) {
|
|
357
|
+
const artifactRoot = path.resolve(cwd, artifactPath);
|
|
358
|
+
const withOwnPolicies = bindings.map((binding) => {
|
|
359
|
+
const immutablePublication = publicationImmutablePolicy({ artifactRoot, binding });
|
|
360
|
+
const observedEvidenceOwnership = observedEvidenceOwnershipPolicy({ artifactRoot, binding });
|
|
361
|
+
if (!immutablePublication && !observedEvidenceOwnership) return binding;
|
|
362
|
+
return { ...binding, ...(immutablePublication ? { immutablePublication } : {}), ...(observedEvidenceOwnership ? { observedEvidenceOwnership } : {}) };
|
|
363
|
+
});
|
|
364
|
+
const protectedRoots = withOwnPolicies.flatMap((binding) =>
|
|
365
|
+
(binding.immutablePublication?.preservedRoots || []).map((root) => ({
|
|
366
|
+
owner: binding.surface,
|
|
367
|
+
path: joinS3Key(binding.artifactPathPrefix, root),
|
|
368
|
+
})),
|
|
369
|
+
);
|
|
370
|
+
const withDeleteExcludes = withOwnPolicies.map((binding) => {
|
|
371
|
+
const bindingPrefix = normalizeS3Key(binding.artifactPathPrefix);
|
|
372
|
+
const mutableDeleteExcludes = [...new Set([
|
|
373
|
+
...protectedRoots
|
|
374
|
+
.map((protectedRoot) => {
|
|
375
|
+
if (!bindingPrefix) return `${protectedRoot.path}/*`;
|
|
376
|
+
if (protectedRoot.path === bindingPrefix) return "*";
|
|
377
|
+
if (!protectedRoot.path.startsWith(`${bindingPrefix}/`)) return "";
|
|
378
|
+
return `${protectedRoot.path.slice(bindingPrefix.length + 1)}/*`;
|
|
379
|
+
})
|
|
380
|
+
.filter(Boolean),
|
|
381
|
+
...(binding.observedEvidenceOwnership?.paths || []),
|
|
382
|
+
])].sort();
|
|
383
|
+
return mutableDeleteExcludes.length > 0
|
|
384
|
+
? { ...binding, mutableDeleteExcludes }
|
|
385
|
+
: binding;
|
|
386
|
+
});
|
|
387
|
+
return withDeleteExcludes.map((binding) => {
|
|
388
|
+
if (!binding.immutablePublication) return binding;
|
|
389
|
+
const ownedPaths = protectedRoots
|
|
390
|
+
.filter((protectedRoot) => protectedRoot.owner === binding.surface)
|
|
391
|
+
.map((protectedRoot) => protectedRoot.path);
|
|
392
|
+
const coveringBindings = withDeleteExcludes
|
|
393
|
+
.map((candidate) => {
|
|
394
|
+
const candidatePrefix = normalizeS3Key(candidate.artifactPathPrefix);
|
|
395
|
+
const excludes = ownedPaths
|
|
396
|
+
.map((ownedPath) => {
|
|
397
|
+
if (!candidatePrefix) return `${ownedPath}/*`;
|
|
398
|
+
if (ownedPath === candidatePrefix) return "*";
|
|
399
|
+
if (!ownedPath.startsWith(`${candidatePrefix}/`)) return "";
|
|
400
|
+
return `${ownedPath.slice(candidatePrefix.length + 1)}/*`;
|
|
401
|
+
})
|
|
402
|
+
.filter(Boolean)
|
|
403
|
+
.sort();
|
|
404
|
+
return excludes.length > 0
|
|
405
|
+
? { surface: candidate.surface, mutableDeleteExcludes: excludes }
|
|
406
|
+
: null;
|
|
407
|
+
})
|
|
408
|
+
.filter(Boolean)
|
|
409
|
+
.sort((left, right) => left.surface.localeCompare(right.surface));
|
|
410
|
+
return {
|
|
411
|
+
...binding,
|
|
412
|
+
immutablePublication: {
|
|
413
|
+
...binding.immutablePublication,
|
|
414
|
+
coveringBindings,
|
|
415
|
+
},
|
|
416
|
+
};
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function pathUnderPreservedRoot(relativePath, preservedRoots = []) {
|
|
421
|
+
const normalized = normalizeS3Key(relativePath);
|
|
422
|
+
return preservedRoots.some((root) => normalized === root || normalized.startsWith(`${root}/`));
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function pathExcludedFromMutableDelete(relativePath, patterns = []) {
|
|
426
|
+
if (patterns.includes("*")) return true;
|
|
427
|
+
return pathUnderPreservedRoot(
|
|
428
|
+
relativePath,
|
|
429
|
+
patterns.map((pattern) => pattern.replace(/\/\*$/, "")),
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function directoryIndexAliasKeys({ objectPrefix, relativeIndexPath }) {
|
|
434
|
+
const normalizedPrefix = normalizeS3Key(objectPrefix);
|
|
435
|
+
if (!normalizedPrefix) {
|
|
436
|
+
return [];
|
|
437
|
+
}
|
|
438
|
+
const normalizedIndexPath = normalizeS3Key(relativeIndexPath);
|
|
439
|
+
if (!normalizedIndexPath.endsWith("index.html")) {
|
|
440
|
+
return [];
|
|
441
|
+
}
|
|
442
|
+
const directory = normalizeS3Key(normalizedIndexPath.slice(0, -"index.html".length));
|
|
443
|
+
const aliasBase = joinS3Key(normalizedPrefix, directory);
|
|
444
|
+
return [...new Set([aliasBase, `${aliasBase}/`].filter(Boolean))];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function directoryIndexAliasOperations({ surfaceArtifactRoot, bucket, binding }) {
|
|
448
|
+
if (binding.directoryIndexResolution === false || !bucket || !binding.objectPrefix || !fs.existsSync(surfaceArtifactRoot)) {
|
|
449
|
+
return [];
|
|
450
|
+
}
|
|
451
|
+
return listFiles(surfaceArtifactRoot, ".")
|
|
452
|
+
.filter((filePath) => path.basename(filePath) === (binding.directoryIndex || "index.html"))
|
|
453
|
+
.filter((filePath) => !pathExcludedFromMutableDelete(
|
|
454
|
+
toPosix(path.relative(surfaceArtifactRoot, filePath)),
|
|
455
|
+
binding.mutableDeleteExcludes || [],
|
|
456
|
+
))
|
|
457
|
+
.flatMap((filePath) => {
|
|
458
|
+
const relativeIndexPath = toPosix(path.relative(surfaceArtifactRoot, filePath));
|
|
459
|
+
return directoryIndexAliasKeys({ objectPrefix: binding.objectPrefix, relativeIndexPath }).map((key) => ({
|
|
460
|
+
action: "write-directory-index-alias",
|
|
461
|
+
surface: binding.surface,
|
|
462
|
+
command: "aws",
|
|
463
|
+
args: [
|
|
464
|
+
"s3api",
|
|
465
|
+
"put-object",
|
|
466
|
+
"--bucket",
|
|
467
|
+
bucket,
|
|
468
|
+
"--key",
|
|
469
|
+
key,
|
|
470
|
+
"--body",
|
|
471
|
+
filePath,
|
|
472
|
+
"--content-type",
|
|
473
|
+
"text/html",
|
|
474
|
+
...(binding.cacheControl?.mutable
|
|
475
|
+
? ["--cache-control", binding.cacheControl.mutable]
|
|
476
|
+
: []),
|
|
477
|
+
],
|
|
478
|
+
routing: {
|
|
479
|
+
...(binding.routing || {}),
|
|
480
|
+
directoryIndexAlias: key,
|
|
481
|
+
directoryIndexSource: relativeIndexPath,
|
|
482
|
+
},
|
|
483
|
+
}));
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function cloudFrontDirectoryIndexFunctionName(distributionId = "") {
|
|
488
|
+
const suffix = String(distributionId || "")
|
|
489
|
+
.replace(/[^0-9A-Za-z-]/g, "-")
|
|
490
|
+
.slice(0, 48);
|
|
491
|
+
return `buildchain-web-surface-index-${suffix || "distribution"}`;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function directoryIndexRewriteMode(binding) {
|
|
495
|
+
return binding.directoryIndexRewrite === "external" ? "external" : "buildchain";
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function directoryIndexRoutingStrategy(binding) {
|
|
499
|
+
return directoryIndexRewriteMode(binding) === "external"
|
|
500
|
+
? "external-viewer-request-function"
|
|
501
|
+
: "cloudfront-function";
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function cloudFrontDirectoryIndexRewriteOperations(bindings) {
|
|
505
|
+
const seen = new Set();
|
|
506
|
+
const helper = path.join(commandDirectory(), "web-surface-cloudfront-rewrite.mjs");
|
|
507
|
+
return bindings
|
|
508
|
+
.filter((binding) => directoryIndexRewriteMode(binding) === "buildchain")
|
|
509
|
+
.map((binding) => binding.distributionId || "")
|
|
510
|
+
.filter(Boolean)
|
|
511
|
+
.filter((distributionId) => {
|
|
512
|
+
if (seen.has(distributionId)) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
seen.add(distributionId);
|
|
516
|
+
return true;
|
|
517
|
+
})
|
|
518
|
+
.map((distributionId) => ({
|
|
519
|
+
action: "ensure-cloudfront-directory-index-rewrite",
|
|
520
|
+
surface: "__distribution__",
|
|
521
|
+
command: "node",
|
|
522
|
+
args: [
|
|
523
|
+
helper,
|
|
524
|
+
"--distribution-id",
|
|
525
|
+
distributionId,
|
|
526
|
+
"--function-name",
|
|
527
|
+
cloudFrontDirectoryIndexFunctionName(distributionId),
|
|
528
|
+
],
|
|
529
|
+
routing: {
|
|
530
|
+
contract: "kungfu-buildchain-web-surface-directory-index-rewrite",
|
|
531
|
+
strategy: "cloudfront-function",
|
|
532
|
+
managedBy: "buildchain",
|
|
533
|
+
distributionId,
|
|
534
|
+
functionName: cloudFrontDirectoryIndexFunctionName(distributionId),
|
|
535
|
+
requestRewrite: "viewer request paths ending in / are rewritten to /index.html",
|
|
536
|
+
},
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function defaultCommandRunner({ command, args, stdin = "" }) {
|
|
541
|
+
const result = spawnSync(command, args, {
|
|
542
|
+
encoding: "utf8",
|
|
543
|
+
input: stdin,
|
|
544
|
+
});
|
|
545
|
+
if (result.error) {
|
|
546
|
+
throw result.error;
|
|
547
|
+
}
|
|
548
|
+
if (result.status !== 0) {
|
|
549
|
+
const stderr = String(result.stderr || "").trim();
|
|
550
|
+
throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status}${stderr ? `: ${stderr}` : ""}`);
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
exitCode: result.status,
|
|
554
|
+
stdout: String(result.stdout || ""),
|
|
555
|
+
stderr: String(result.stderr || ""),
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function runAdapterOperation({ operation, dryRun, commandRunner }) {
|
|
560
|
+
if (dryRun) {
|
|
561
|
+
return {
|
|
562
|
+
...operation,
|
|
563
|
+
status: "planned",
|
|
564
|
+
executed: false,
|
|
565
|
+
exitCode: null,
|
|
566
|
+
stdout: "",
|
|
567
|
+
stderr: "",
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
try {
|
|
571
|
+
const commandResult = commandRunner(operation);
|
|
572
|
+
const exitCode = commandResult?.exitCode ?? 0;
|
|
573
|
+
return {
|
|
574
|
+
...operation,
|
|
575
|
+
status: exitCode === 0 ? "applied" : "failed",
|
|
576
|
+
executed: true,
|
|
577
|
+
exitCode,
|
|
578
|
+
stdout: commandResult?.stdout || "",
|
|
579
|
+
stderr: commandResult?.stderr || "",
|
|
580
|
+
};
|
|
581
|
+
} catch (error) {
|
|
582
|
+
return {
|
|
583
|
+
...operation,
|
|
584
|
+
status: "failed",
|
|
585
|
+
executed: true,
|
|
586
|
+
exitCode: null,
|
|
587
|
+
stdout: "",
|
|
588
|
+
stderr: String(error.message || error),
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function runAdapterOperations({ operations, dryRun, commandRunner }) {
|
|
594
|
+
const results = [];
|
|
595
|
+
for (const operation of operations) {
|
|
596
|
+
const result = runAdapterOperation({ operation, dryRun, commandRunner });
|
|
597
|
+
results.push(result);
|
|
598
|
+
if (result.status === "failed") {
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return results;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function appliedStatus({ dryRun, operations, noOp = false }) {
|
|
606
|
+
if (noOp) {
|
|
607
|
+
return "no-op";
|
|
608
|
+
}
|
|
609
|
+
if (operations.some((operation) => operation.status === "failed")) {
|
|
610
|
+
return "failed";
|
|
611
|
+
}
|
|
612
|
+
return dryRun ? "planned" : "applied";
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function isPlaceholderValue(value) {
|
|
616
|
+
const normalized = String(value || "").trim().toLowerCase();
|
|
617
|
+
return (
|
|
618
|
+
normalized === "" ||
|
|
619
|
+
normalized === "pending" ||
|
|
620
|
+
normalized.startsWith("pending-") ||
|
|
621
|
+
normalized.startsWith("pending_") ||
|
|
622
|
+
normalized.includes("placeholder") ||
|
|
623
|
+
normalized.includes("example.")
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function assertConcreteAwsDeployConfig({ deployConfig, channel, operation }) {
|
|
628
|
+
const bucket = deployConfig.bucket || deployConfig.target || "";
|
|
629
|
+
const distribution = deployConfig.cloudfront_distribution || deployConfig.distribution || "";
|
|
630
|
+
if (isPlaceholderValue(bucket)) {
|
|
631
|
+
throw new Error(`web-surface ${operation} apply requires concrete deploy.${channel}.bucket or deploy.${channel}.target`);
|
|
632
|
+
}
|
|
633
|
+
if (isPlaceholderValue(distribution)) {
|
|
634
|
+
throw new Error(
|
|
635
|
+
`web-surface ${operation} apply requires concrete deploy.${channel}.cloudfront_distribution or deploy.${channel}.distribution`,
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function urlHost(value = "") {
|
|
641
|
+
try {
|
|
642
|
+
return new URL(value).hostname.toLowerCase();
|
|
643
|
+
} catch {
|
|
644
|
+
return "";
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function wildcardHostMatches(alias = "", host = "") {
|
|
649
|
+
const normalizedAlias = String(alias || "").toLowerCase();
|
|
650
|
+
const normalizedHost = String(host || "").toLowerCase();
|
|
651
|
+
if (!normalizedAlias.startsWith("*.")) return false;
|
|
652
|
+
const suffix = normalizedAlias.slice(1);
|
|
653
|
+
return normalizedHost.endsWith(suffix) && normalizedHost.slice(0, -suffix.length).indexOf(".") === -1;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function aliasMatchesHost(aliases = [], host = "") {
|
|
657
|
+
const normalizedHost = String(host || "").toLowerCase();
|
|
658
|
+
return aliases.some((alias) => {
|
|
659
|
+
const normalizedAlias = String(alias || "").toLowerCase();
|
|
660
|
+
return normalizedAlias === normalizedHost || wildcardHostMatches(normalizedAlias, normalizedHost);
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function parseCloudFrontAliases(stdout = "") {
|
|
665
|
+
if (!stdout) return [];
|
|
666
|
+
try {
|
|
667
|
+
const parsed = JSON.parse(stdout);
|
|
668
|
+
const aliases = parsed?.Distribution?.DistributionConfig?.Aliases?.Items ||
|
|
669
|
+
parsed?.DistributionConfig?.Aliases?.Items ||
|
|
670
|
+
parsed?.Aliases?.Items ||
|
|
671
|
+
parsed?.Aliases ||
|
|
672
|
+
[];
|
|
673
|
+
return Array.isArray(aliases) ? aliases : [];
|
|
674
|
+
} catch {
|
|
675
|
+
return [];
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
async function defaultDnsResolver(host) {
|
|
680
|
+
try {
|
|
681
|
+
const answers = await dns.resolve(host);
|
|
682
|
+
return answers.map((address) => ({ type: "A", value: address }));
|
|
683
|
+
} catch (error) {
|
|
684
|
+
if (error?.code === "ENODATA" || error?.code === "ENOTFOUND") {
|
|
685
|
+
const answers = await dns.resolve6(host);
|
|
686
|
+
return answers.map((address) => ({ type: "AAAA", value: address }));
|
|
687
|
+
}
|
|
688
|
+
throw error;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function preflightCheck({ name, status = "pass", details = {}, message = "" }) {
|
|
693
|
+
return { name, status, message, details };
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function preflightStatus(checks) {
|
|
697
|
+
return checks.some((check) => check.status === "fail") ? "failed" : "passed";
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function deployManifestKey(deployConfig, manifest) {
|
|
701
|
+
return joinS3Key(manifestPrefixFor(deployConfig), `${manifest.alias || manifest.channel}.json`);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function deploySurfaceManifestKey(deployConfig, binding) {
|
|
705
|
+
const suffix = binding.surface === "default"
|
|
706
|
+
? `${binding.alias || binding.channel}.json`
|
|
707
|
+
: `${binding.alias || binding.channel}/${binding.surface}.json`;
|
|
708
|
+
return joinS3Key(manifestPrefixFor(deployConfig), suffix);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function assertDeployPlan(plan) {
|
|
712
|
+
if (plan?.contract !== "kungfu-buildchain-web-surface-deploy-plan") {
|
|
713
|
+
throw new Error("web-surface deploy apply requires a deploy plan");
|
|
714
|
+
}
|
|
715
|
+
if (!plan.manifest) {
|
|
716
|
+
throw new Error("web-surface deploy plan is missing manifest");
|
|
717
|
+
}
|
|
718
|
+
if (!plan.artifact?.hash) {
|
|
719
|
+
throw new Error("web-surface deploy plan is missing artifact hash");
|
|
720
|
+
}
|
|
721
|
+
if (plan.manifest.artifactHash !== plan.artifact.hash) {
|
|
722
|
+
throw new Error("web-surface deploy plan artifact hash does not match manifest");
|
|
723
|
+
}
|
|
724
|
+
return plan;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function verifyDeployPlanArtifact({ cwd, plan }) {
|
|
728
|
+
const artifactPath = plan.artifact.path || ".";
|
|
729
|
+
const actual = createWebSurfaceArtifactHash({ cwd, artifactPath });
|
|
730
|
+
if (actual.artifactHash !== plan.artifact.hash) {
|
|
731
|
+
throw new Error(
|
|
732
|
+
`web-surface deploy plan artifact hash mismatch: expected ${plan.artifact.hash}, got ${actual.artifactHash}`,
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
return {
|
|
736
|
+
...plan,
|
|
737
|
+
artifact: {
|
|
738
|
+
...plan.artifact,
|
|
739
|
+
path: artifactPath,
|
|
740
|
+
files: actual.files,
|
|
741
|
+
},
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function assertCleanupPlan(plan) {
|
|
746
|
+
if (plan?.contract !== "kungfu-buildchain-web-surface-cleanup-plan") {
|
|
747
|
+
throw new Error("web-surface cleanup apply requires a cleanup plan");
|
|
748
|
+
}
|
|
749
|
+
if (!Array.isArray(plan.entries)) {
|
|
750
|
+
throw new Error("web-surface cleanup plan is missing entries");
|
|
751
|
+
}
|
|
752
|
+
return plan;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function retentionFor({ config, channelName, alias, deployedAt }) {
|
|
756
|
+
if (channelName === "preview") {
|
|
757
|
+
const classified = classifyPreviewAlias(alias);
|
|
758
|
+
const days = retentionConfig(config, "preview")[classified.retentionKey];
|
|
759
|
+
return {
|
|
760
|
+
aliasKind: classified.kind,
|
|
761
|
+
mutableAlias: classified.mutable,
|
|
762
|
+
retentionClass: classified.retentionClass,
|
|
763
|
+
expiresAt: addDays(deployedAt, days),
|
|
764
|
+
retentionDays: days,
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
if (channelName === "staging") {
|
|
768
|
+
const retention = retentionConfig(config, "staging");
|
|
769
|
+
return {
|
|
770
|
+
aliasKind: "",
|
|
771
|
+
mutableAlias: true,
|
|
772
|
+
retentionClass: "staging-protected",
|
|
773
|
+
expiresAt: addDays(deployedAt, retention.days),
|
|
774
|
+
retentionDays: retention.days,
|
|
775
|
+
keepDeploys: retention.keep_deploys,
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
const retention = retentionConfig(config, "production");
|
|
779
|
+
return {
|
|
780
|
+
aliasKind: "",
|
|
781
|
+
mutableAlias: false,
|
|
782
|
+
retentionClass: "production-canonical",
|
|
783
|
+
expiresAt: addDays(deployedAt, retention.days),
|
|
784
|
+
retentionDays: retention.days,
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function configuredSurfaces(config) {
|
|
789
|
+
if (config.surfaces && Object.keys(config.surfaces).length > 0) {
|
|
790
|
+
return Object.values(config.surfaces);
|
|
791
|
+
}
|
|
792
|
+
return [{
|
|
793
|
+
name: "default",
|
|
794
|
+
path: "/",
|
|
795
|
+
pathOnly: false,
|
|
796
|
+
canonical: true,
|
|
797
|
+
}];
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function resolveSurfaceBindings({ config, channelName, alias, deployConfig }) {
|
|
801
|
+
const channel = config.channels?.[channelName];
|
|
802
|
+
if (!channel) {
|
|
803
|
+
throw new Error(`unknown web-surface channel: ${channelName}`);
|
|
804
|
+
}
|
|
805
|
+
return configuredSurfaces(config).map((surface) => {
|
|
806
|
+
const effectiveDeploy = surfaceDeployConfig(deployConfig, surface.name);
|
|
807
|
+
const url = surface.name === "default" && !config.surfaces
|
|
808
|
+
? resolveChannelUrl(channel, alias)
|
|
809
|
+
: resolveSurfaceUrl({ surface, channel, channelName, alias });
|
|
810
|
+
const objectPrefix = surface.name === "default" && !config.surfaces
|
|
811
|
+
? objectPrefixFor(deployConfig, alias || channelName)
|
|
812
|
+
: surfaceObjectPrefixFor({ deployConfig, surface, alias: alias || channelName });
|
|
813
|
+
const bucket = effectiveDeploy.bucket || effectiveDeploy.target || "";
|
|
814
|
+
const distributionId = effectiveDeploy.cloudfront_distribution || effectiveDeploy.distribution || "";
|
|
815
|
+
return {
|
|
816
|
+
surface: surface.name,
|
|
817
|
+
channel: channelName,
|
|
818
|
+
alias,
|
|
819
|
+
url,
|
|
820
|
+
sourcePath: normalizeSurfacePath(surface.path),
|
|
821
|
+
artifactPathPrefix: surfaceArtifactPrefix({ sourcePath: surface.path }),
|
|
822
|
+
viewerPathPrefix: "/",
|
|
823
|
+
directoryIndex: "index.html",
|
|
824
|
+
directoryIndexResolution: true,
|
|
825
|
+
directoryIndexRewrite: effectiveDeploy.directoryIndexRewrite || "buildchain",
|
|
826
|
+
healthStrategy: effectiveDeploy.healthStrategy || "",
|
|
827
|
+
cacheControl: effectiveDeploy.cacheControl || undefined,
|
|
828
|
+
canonicalUrl: surface.productionUrl || (channelName === "production" ? url : ""),
|
|
829
|
+
pathOnly: Boolean(surface.pathOnly),
|
|
830
|
+
bucket,
|
|
831
|
+
distributionId,
|
|
832
|
+
originPath: effectiveDeploy.origin_path || effectiveDeploy.originPath || "",
|
|
833
|
+
objectPrefix,
|
|
834
|
+
manifestKey: "",
|
|
835
|
+
noindex: channel.noindex,
|
|
836
|
+
accessControl: channel.accessControl,
|
|
837
|
+
};
|
|
838
|
+
}).map((binding) => ({
|
|
839
|
+
...binding,
|
|
840
|
+
manifestKey: deploySurfaceManifestKey(deployConfig, binding),
|
|
841
|
+
}));
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function relativeArtifactPath({ artifactPath, filePath }) {
|
|
845
|
+
const normalizedArtifact = normalizeS3Key(artifactPath);
|
|
846
|
+
const normalizedFile = normalizeS3Key(filePath);
|
|
847
|
+
if (!normalizedArtifact) {
|
|
848
|
+
return normalizedFile;
|
|
849
|
+
}
|
|
850
|
+
return normalizedFile === normalizedArtifact
|
|
851
|
+
? ""
|
|
852
|
+
: normalizedFile.startsWith(`${normalizedArtifact}/`)
|
|
853
|
+
? normalizedFile.slice(normalizedArtifact.length + 1)
|
|
854
|
+
: normalizedFile;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function requestPathFromArtifactPath({ binding, artifactPath, filePath }) {
|
|
858
|
+
const relative = relativeArtifactPath({ artifactPath, filePath });
|
|
859
|
+
const prefix = normalizeS3Key(binding.artifactPathPrefix || surfaceArtifactPrefix(binding));
|
|
860
|
+
if (prefix && relative !== prefix && !relative.startsWith(`${prefix}/`)) {
|
|
861
|
+
return "";
|
|
862
|
+
}
|
|
863
|
+
const surfaceRelative = prefix
|
|
864
|
+
? relative.slice(prefix.length).replace(/^\/+/, "")
|
|
865
|
+
: relative;
|
|
866
|
+
if (!surfaceRelative || surfaceRelative === "index.html") {
|
|
867
|
+
return "/";
|
|
868
|
+
}
|
|
869
|
+
if (surfaceRelative.endsWith("/index.html")) {
|
|
870
|
+
const directoryPath = normalizeS3Key(surfaceRelative.slice(0, -"index.html".length));
|
|
871
|
+
return directoryPath ? `/${directoryPath}/` : "/";
|
|
872
|
+
}
|
|
873
|
+
return joinUrlPath(surfaceRelative);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
function smokeUrlsForBinding({ binding, artifactPath, files }) {
|
|
877
|
+
const rootUrl = urlWithPath(binding.url, "/");
|
|
878
|
+
const candidates = (files || [])
|
|
879
|
+
.map((file) => requestPathFromArtifactPath({ binding, artifactPath, filePath: file.path }))
|
|
880
|
+
.filter(Boolean)
|
|
881
|
+
.filter((requestPath) => requestPath !== "/")
|
|
882
|
+
.filter((requestPath) => requestPath.endsWith("/") || requestPath.endsWith(".html"))
|
|
883
|
+
.sort();
|
|
884
|
+
const nestedPath = candidates[0] || "";
|
|
885
|
+
return [
|
|
886
|
+
{
|
|
887
|
+
kind: "root",
|
|
888
|
+
requestPath: "/",
|
|
889
|
+
url: rootUrl,
|
|
890
|
+
required: true,
|
|
891
|
+
},
|
|
892
|
+
...(nestedPath
|
|
893
|
+
? [{
|
|
894
|
+
kind: "nested",
|
|
895
|
+
requestPath: nestedPath,
|
|
896
|
+
url: urlWithPath(binding.url, nestedPath),
|
|
897
|
+
required: true,
|
|
898
|
+
}]
|
|
899
|
+
: []),
|
|
900
|
+
];
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function withSurfaceRoutingEvidence(bindings, { artifactPath, files }) {
|
|
904
|
+
return bindings.map((binding) => {
|
|
905
|
+
const directoryIndexRewrite = directoryIndexRewriteMode(binding);
|
|
906
|
+
return {
|
|
907
|
+
...binding,
|
|
908
|
+
directoryIndexRewrite,
|
|
909
|
+
artifactPathPrefix: normalizeS3Key(binding.artifactPathPrefix || surfaceArtifactPrefix(binding)),
|
|
910
|
+
viewerPathPrefix: binding.viewerPathPrefix || "/",
|
|
911
|
+
directoryIndex: binding.directoryIndex || "index.html",
|
|
912
|
+
directoryIndexResolution: binding.directoryIndexResolution !== false,
|
|
913
|
+
routing: {
|
|
914
|
+
contract: "kungfu-buildchain-web-surface-path-prefix-rewrite",
|
|
915
|
+
viewerPathPrefix: binding.viewerPathPrefix || "/",
|
|
916
|
+
artifactPathPrefix: normalizeS3Key(binding.artifactPathPrefix || surfaceArtifactPrefix(binding)),
|
|
917
|
+
objectPrefix: binding.objectPrefix,
|
|
918
|
+
directoryIndex: binding.directoryIndex || "index.html",
|
|
919
|
+
directoryIndexResolution: binding.directoryIndexResolution !== false,
|
|
920
|
+
directoryIndexRewrite,
|
|
921
|
+
directoryIndexManagedBy: directoryIndexRewrite === "external" ? "external" : "buildchain",
|
|
922
|
+
directoryIndexStrategy: directoryIndexRoutingStrategy(binding),
|
|
923
|
+
},
|
|
924
|
+
smokeUrls: smokeUrlsForBinding({ binding, artifactPath, files }),
|
|
925
|
+
};
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
export function validateWebSurfaceProject(cwd = process.cwd()) {
|
|
930
|
+
const summary = validateBuildchainConfig(cwd, {
|
|
931
|
+
requireConfig: true,
|
|
932
|
+
});
|
|
933
|
+
if (summary.project?.type !== "web-surface") {
|
|
934
|
+
throw new Error('buildchain.toml project.type must be "web-surface"');
|
|
935
|
+
}
|
|
936
|
+
return summary;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
export function createWebSurfaceArtifactHash({ cwd = process.cwd(), artifactPath = "" } = {}) {
|
|
940
|
+
const root = path.resolve(cwd);
|
|
941
|
+
const files = listFiles(root, artifactPath || ".")
|
|
942
|
+
.sort()
|
|
943
|
+
.map((filePath) => {
|
|
944
|
+
const stat = fs.statSync(filePath);
|
|
945
|
+
const relative = toPosix(path.relative(root, filePath));
|
|
946
|
+
return {
|
|
947
|
+
path: relative,
|
|
948
|
+
size: stat.size,
|
|
949
|
+
sha256: sha256File(filePath),
|
|
950
|
+
};
|
|
951
|
+
});
|
|
952
|
+
const digest = crypto.createHash("sha256");
|
|
953
|
+
for (const file of files) {
|
|
954
|
+
digest.update(`${file.path}\0${file.size}\0${file.sha256}\n`);
|
|
955
|
+
}
|
|
956
|
+
return {
|
|
957
|
+
artifactHash: digest.digest("hex"),
|
|
958
|
+
files,
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
function installerPublicationEvidence(artifactRoot) {
|
|
963
|
+
const manifestPath = path.join(artifactRoot, "installer-publication.json");
|
|
964
|
+
if (!fs.existsSync(manifestPath)) return null;
|
|
965
|
+
let publication;
|
|
966
|
+
try {
|
|
967
|
+
publication = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
968
|
+
} catch (error) {
|
|
969
|
+
throw new Error(`invalid installer publication manifest: ${error.message}`);
|
|
970
|
+
}
|
|
971
|
+
return validateInstallerPublication({ publication, artifactRoot });
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
export function createWebSurfaceDeploymentManifest({
|
|
975
|
+
cwd = process.cwd(),
|
|
976
|
+
channel = "preview",
|
|
977
|
+
alias = "",
|
|
978
|
+
sourceSha = "",
|
|
979
|
+
artifactHash = "",
|
|
980
|
+
deployedAt = new Date().toISOString(),
|
|
981
|
+
deploymentId = "",
|
|
982
|
+
runtimeId = "",
|
|
983
|
+
configFingerprint = "",
|
|
984
|
+
healthCheck = "",
|
|
985
|
+
migrationState = "",
|
|
986
|
+
rollbackPointer = "",
|
|
987
|
+
rollbackLimitations = "",
|
|
988
|
+
} = {}) {
|
|
989
|
+
const loadedConfig = loadBuildchainConfig(cwd);
|
|
990
|
+
const config = assertWebSurfaceConfig(loadedConfig);
|
|
991
|
+
const channelConfig = config.channels?.[channel];
|
|
992
|
+
if (!channelConfig) {
|
|
993
|
+
throw new Error(`unknown web-surface channel: ${channel}`);
|
|
994
|
+
}
|
|
995
|
+
const deployConfig = config.deploy?.[channel];
|
|
996
|
+
if (!deployConfig) {
|
|
997
|
+
throw new Error(`missing deploy.${channel}`);
|
|
998
|
+
}
|
|
999
|
+
const retention = retentionFor({ config, channelName: channel, alias, deployedAt });
|
|
1000
|
+
const surfaceBindings = resolveSurfaceBindings({
|
|
1001
|
+
config,
|
|
1002
|
+
channelName: channel,
|
|
1003
|
+
alias,
|
|
1004
|
+
deployConfig,
|
|
1005
|
+
});
|
|
1006
|
+
const primaryBinding = surfaceBindings[0];
|
|
1007
|
+
const timestampPolicy = createSurfaceTimestampPolicy({
|
|
1008
|
+
generatedAt: deployedAt,
|
|
1009
|
+
publishedAt: deployedAt,
|
|
1010
|
+
sourceRevision: sourceSha,
|
|
1011
|
+
timestampPolicy: "ci-injected",
|
|
1012
|
+
deterministicInputs: [
|
|
1013
|
+
"web-surface artifact content",
|
|
1014
|
+
"buildchain.toml web-surface channels/deploy/surfaces",
|
|
1015
|
+
"sourceSha",
|
|
1016
|
+
"artifactHash",
|
|
1017
|
+
"deployment channel",
|
|
1018
|
+
"deployment alias",
|
|
1019
|
+
],
|
|
1020
|
+
timestampFields: ["generatedAt", "publishedAt", "deployedAt"],
|
|
1021
|
+
timestampFieldsParticipateInArtifactDigest: false,
|
|
1022
|
+
artifactDigestScope: "web-surface artifactHash excludes deployment manifest timestamps",
|
|
1023
|
+
});
|
|
1024
|
+
return {
|
|
1025
|
+
schemaVersion: 1,
|
|
1026
|
+
contract: "kungfu-buildchain-web-surface-deployment",
|
|
1027
|
+
...timestampPolicy,
|
|
1028
|
+
site: config.project.site || config.project.name || "",
|
|
1029
|
+
channel,
|
|
1030
|
+
alias,
|
|
1031
|
+
url: primaryBinding.url,
|
|
1032
|
+
sourceSha: assertSha(sourceSha, "sourceSha"),
|
|
1033
|
+
artifactHash: assertHash(artifactHash, "artifactHash"),
|
|
1034
|
+
deployTarget: deployConfig.target || deployConfig.bucket || deployConfig.environment || deployConfig.service || "",
|
|
1035
|
+
adapter: deployConfig.adapter,
|
|
1036
|
+
deploymentId,
|
|
1037
|
+
deployedAt,
|
|
1038
|
+
retentionClass: retention.retentionClass,
|
|
1039
|
+
expiresAt: retention.expiresAt,
|
|
1040
|
+
mutableAlias: retention.mutableAlias,
|
|
1041
|
+
accessControl: channelConfig.accessControl,
|
|
1042
|
+
edgeAuth: channelConfig.edgeAuth,
|
|
1043
|
+
noindex: channelConfig.noindex,
|
|
1044
|
+
promotable: channelConfig.promotable,
|
|
1045
|
+
canonical: channelConfig.canonical,
|
|
1046
|
+
runtimeId,
|
|
1047
|
+
configFingerprint,
|
|
1048
|
+
secretRefs: [
|
|
1049
|
+
...new Set([
|
|
1050
|
+
...(deployConfig.secretRefs || []),
|
|
1051
|
+
...(config.security?.[channel]?.secretRefs || []),
|
|
1052
|
+
]),
|
|
1053
|
+
],
|
|
1054
|
+
healthCheck,
|
|
1055
|
+
migrationState,
|
|
1056
|
+
rollbackPointer,
|
|
1057
|
+
rollbackLimitations,
|
|
1058
|
+
surfaceBindings,
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
export function planWebSurfaceDeploy({
|
|
1063
|
+
cwd = process.cwd(),
|
|
1064
|
+
channel = "preview",
|
|
1065
|
+
alias = "",
|
|
1066
|
+
sourceSha = "",
|
|
1067
|
+
artifactHash = "",
|
|
1068
|
+
artifactPath = "",
|
|
1069
|
+
runtimeId = "",
|
|
1070
|
+
configFingerprint = "",
|
|
1071
|
+
rollbackPointer = "",
|
|
1072
|
+
rollbackLimitations = "",
|
|
1073
|
+
dryRun = true,
|
|
1074
|
+
deployedAt = new Date().toISOString(),
|
|
1075
|
+
} = {}) {
|
|
1076
|
+
if (!dryRun) {
|
|
1077
|
+
throw new Error("web-surface deploy currently supports dry-run planning only");
|
|
1078
|
+
}
|
|
1079
|
+
const loadedConfig = loadBuildchainConfig(cwd);
|
|
1080
|
+
const config = assertWebSurfaceConfig(loadedConfig);
|
|
1081
|
+
const deployConfig = config.deploy?.[channel];
|
|
1082
|
+
if (!deployConfig) {
|
|
1083
|
+
throw new Error(`missing deploy.${channel}`);
|
|
1084
|
+
}
|
|
1085
|
+
const resolvedArtifact = artifactHash
|
|
1086
|
+
? { artifactHash: assertHash(artifactHash, "artifactHash"), files: [] }
|
|
1087
|
+
: createWebSurfaceArtifactHash({
|
|
1088
|
+
cwd,
|
|
1089
|
+
artifactPath: artifactPath || deployConfig.artifactPath || ".",
|
|
1090
|
+
});
|
|
1091
|
+
const manifest = createWebSurfaceDeploymentManifest({
|
|
1092
|
+
cwd,
|
|
1093
|
+
channel,
|
|
1094
|
+
alias,
|
|
1095
|
+
sourceSha,
|
|
1096
|
+
artifactHash: resolvedArtifact.artifactHash,
|
|
1097
|
+
runtimeId,
|
|
1098
|
+
configFingerprint,
|
|
1099
|
+
rollbackPointer,
|
|
1100
|
+
rollbackLimitations,
|
|
1101
|
+
deployedAt,
|
|
1102
|
+
});
|
|
1103
|
+
const installerEvidence = installerPublicationEvidence(
|
|
1104
|
+
path.resolve(cwd, artifactPath || deployConfig.artifactPath || "."),
|
|
1105
|
+
);
|
|
1106
|
+
if (installerEvidence) {
|
|
1107
|
+
manifest.installerPublicationEvidence = installerEvidence;
|
|
1108
|
+
}
|
|
1109
|
+
const scoped = applyPublicationFastPathScope(manifest.surfaceBindings, {
|
|
1110
|
+
cwd,
|
|
1111
|
+
artifactPath: artifactPath || deployConfig.artifactPath || ".",
|
|
1112
|
+
});
|
|
1113
|
+
const surfaceBindings = withImmutablePublicationPolicies(withSurfaceRoutingEvidence(scoped.bindings, {
|
|
1114
|
+
artifactPath: artifactPath || deployConfig.artifactPath || ".",
|
|
1115
|
+
files: resolvedArtifact.files,
|
|
1116
|
+
}), {
|
|
1117
|
+
cwd,
|
|
1118
|
+
artifactPath: artifactPath || deployConfig.artifactPath || ".",
|
|
1119
|
+
});
|
|
1120
|
+
if (installerEvidence) {
|
|
1121
|
+
const preserved = surfaceBindings.some((binding) =>
|
|
1122
|
+
binding.immutablePublication?.declaredPrefixes?.includes(installerEvidence.immutablePath));
|
|
1123
|
+
if (!preserved) {
|
|
1124
|
+
throw new Error(
|
|
1125
|
+
`installer immutable path is not covered by append-only publication policy: ${installerEvidence.immutablePath}`,
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
manifest.surfaceBindings = surfaceBindings;
|
|
1130
|
+
if (scoped.scope) {
|
|
1131
|
+
manifest.publicationFastPath = scoped.scope;
|
|
1132
|
+
manifest.url = surfaceBindings[0].url;
|
|
1133
|
+
}
|
|
1134
|
+
return {
|
|
1135
|
+
schemaVersion: 1,
|
|
1136
|
+
contract: "kungfu-buildchain-web-surface-deploy-plan",
|
|
1137
|
+
dryRun: true,
|
|
1138
|
+
adapter: deployConfig.adapter,
|
|
1139
|
+
channel,
|
|
1140
|
+
alias,
|
|
1141
|
+
url: manifest.url,
|
|
1142
|
+
urls: Object.fromEntries(surfaceBindings.map((binding) => [binding.surface, binding.url])),
|
|
1143
|
+
artifact: {
|
|
1144
|
+
path: artifactPath || deployConfig.artifactPath || ".",
|
|
1145
|
+
hash: resolvedArtifact.artifactHash,
|
|
1146
|
+
files: resolvedArtifact.files,
|
|
1147
|
+
},
|
|
1148
|
+
manifest,
|
|
1149
|
+
surfaceBindings,
|
|
1150
|
+
publicationFastPath: scoped.scope || undefined,
|
|
1151
|
+
steps: planAdapterSteps(deployConfig.adapter, deployConfig, manifest),
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
export function verifyWebSurfaceArtifactChannelFacts({ cwd = process.cwd(), plan } = {}) {
|
|
1156
|
+
const resolvedPlan = assertDeployPlan(plan);
|
|
1157
|
+
const artifactRoot = path.resolve(cwd, resolvedPlan.artifact.path);
|
|
1158
|
+
const expectedHosts = new Set((resolvedPlan.manifest?.surfaceBindings || []).map((binding) => {
|
|
1159
|
+
try { return new URL(binding.url).host; } catch { return ""; }
|
|
1160
|
+
}).filter(Boolean));
|
|
1161
|
+
const observed = [];
|
|
1162
|
+
const scopedPrefix = normalizeS3Key(
|
|
1163
|
+
resolvedPlan.publicationFastPath
|
|
1164
|
+
? resolvedPlan.surfaceBindings?.[0]?.artifactPathPrefix || ""
|
|
1165
|
+
: "",
|
|
1166
|
+
);
|
|
1167
|
+
for (const filePath of listFiles(artifactRoot, artifactRoot)
|
|
1168
|
+
.filter((entry) => entry.endsWith(".json"))
|
|
1169
|
+
.filter((entry) => {
|
|
1170
|
+
if (!scopedPrefix) return true;
|
|
1171
|
+
const relative = normalizeS3Key(path.relative(artifactRoot, entry));
|
|
1172
|
+
return relative === scopedPrefix || relative.startsWith(`${scopedPrefix}/`);
|
|
1173
|
+
})) {
|
|
1174
|
+
let value;
|
|
1175
|
+
try { value = JSON.parse(fs.readFileSync(filePath, "utf8")); } catch { continue; }
|
|
1176
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || !String(value.contract || "").includes("manifest")) continue;
|
|
1177
|
+
const facts = [];
|
|
1178
|
+
if (typeof value.canonicalHost === "string" && value.canonicalHost.trim()) facts.push({ field: "canonicalHost", host: value.canonicalHost.trim() });
|
|
1179
|
+
if (Array.isArray(value.pages)) {
|
|
1180
|
+
for (const [index, page] of value.pages.entries()) {
|
|
1181
|
+
if (typeof page?.host === "string" && page.host.trim()) facts.push({ field: `pages[${index}].host`, host: page.host.trim() });
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
for (const fact of facts) observed.push({ path: toPosix(path.relative(cwd, filePath)), ...fact });
|
|
1185
|
+
}
|
|
1186
|
+
const mismatches = observed.filter((fact) => !expectedHosts.has(fact.host));
|
|
1187
|
+
if (mismatches.length > 0) {
|
|
1188
|
+
throw new Error(`web-surface artifact channel facts mismatch for ${resolvedPlan.channel}: ${mismatches.map((fact) => `${fact.path}#${fact.field}=${fact.host}`).join(", ")}`);
|
|
1189
|
+
}
|
|
1190
|
+
return { channel: resolvedPlan.channel, expectedHosts: [...expectedHosts].sort(), observed };
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
export function applyWebSurfaceDeploy({
|
|
1194
|
+
cwd = process.cwd(),
|
|
1195
|
+
channel = "preview",
|
|
1196
|
+
alias = "",
|
|
1197
|
+
sourceSha = "",
|
|
1198
|
+
artifactHash = "",
|
|
1199
|
+
artifactPath = "",
|
|
1200
|
+
plan = null,
|
|
1201
|
+
dryRun = true,
|
|
1202
|
+
actor = "",
|
|
1203
|
+
runId = "",
|
|
1204
|
+
appliedAt = new Date().toISOString(),
|
|
1205
|
+
commandRunner = defaultCommandRunner,
|
|
1206
|
+
} = {}) {
|
|
1207
|
+
const resolvedPlan = plan
|
|
1208
|
+
? verifyDeployPlanArtifact({ cwd, plan: assertDeployPlan(plan) })
|
|
1209
|
+
: planWebSurfaceDeploy({
|
|
1210
|
+
cwd,
|
|
1211
|
+
channel,
|
|
1212
|
+
alias,
|
|
1213
|
+
sourceSha,
|
|
1214
|
+
artifactHash,
|
|
1215
|
+
artifactPath,
|
|
1216
|
+
dryRun: true,
|
|
1217
|
+
deployedAt: appliedAt,
|
|
1218
|
+
});
|
|
1219
|
+
verifyWebSurfaceArtifactChannelFacts({ cwd, plan: resolvedPlan });
|
|
1220
|
+
const loadedConfig = loadBuildchainConfig(cwd);
|
|
1221
|
+
const config = assertWebSurfaceConfig(loadedConfig);
|
|
1222
|
+
const deployConfig = config.deploy?.[resolvedPlan.channel];
|
|
1223
|
+
if (!deployConfig) {
|
|
1224
|
+
throw new Error(`missing deploy.${resolvedPlan.channel}`);
|
|
1225
|
+
}
|
|
1226
|
+
if (resolvedPlan.adapter !== "aws-s3-cloudfront") {
|
|
1227
|
+
throw new Error(`web-surface deploy apply does not support adapter: ${resolvedPlan.adapter}`);
|
|
1228
|
+
}
|
|
1229
|
+
const bucket = deployConfig.bucket || deployConfig.target || "";
|
|
1230
|
+
const artifactRoot = path.resolve(cwd, resolvedPlan.artifact.path);
|
|
1231
|
+
const bindings = withImmutablePublicationPolicies(withSurfaceRoutingEvidence(resolvedPlan.manifest.surfaceBindings || [], {
|
|
1232
|
+
artifactPath: resolvedPlan.artifact.path,
|
|
1233
|
+
files: resolvedPlan.artifact.files || [],
|
|
1234
|
+
}), {
|
|
1235
|
+
cwd,
|
|
1236
|
+
artifactPath: resolvedPlan.artifact.path,
|
|
1237
|
+
});
|
|
1238
|
+
resolvedPlan.manifest.surfaceBindings = bindings;
|
|
1239
|
+
if (!dryRun) {
|
|
1240
|
+
for (const binding of bindings) {
|
|
1241
|
+
assertConcreteAwsDeployConfig({
|
|
1242
|
+
deployConfig: surfaceDeployConfig(deployConfig, binding.surface),
|
|
1243
|
+
channel: `${resolvedPlan.channel}.surfaces.${binding.surface}`,
|
|
1244
|
+
operation: "deploy",
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
const bindingOperations = bindings.flatMap((binding) => deployBindingOperations({
|
|
1249
|
+
artifactRoot,
|
|
1250
|
+
deployConfig,
|
|
1251
|
+
manifest: resolvedPlan.manifest,
|
|
1252
|
+
binding,
|
|
1253
|
+
}));
|
|
1254
|
+
const operations = [
|
|
1255
|
+
...bindingOperations.filter((operation) => operation.action === "verify-immutable-artifact-before-upload"),
|
|
1256
|
+
...bindingOperations.filter((operation) => operation.action === "sync-immutable-artifact"),
|
|
1257
|
+
...bindingOperations.filter((operation) => operation.action === "verify-immutable-artifact-after-upload"),
|
|
1258
|
+
...cloudFrontDirectoryIndexRewriteOperations(bindings.filter((binding) => !binding.publicationFastPath)),
|
|
1259
|
+
...bindingOperations.filter((operation) => ![
|
|
1260
|
+
"verify-immutable-artifact-before-upload",
|
|
1261
|
+
"sync-immutable-artifact",
|
|
1262
|
+
"verify-immutable-artifact-after-upload",
|
|
1263
|
+
].includes(operation.action)),
|
|
1264
|
+
];
|
|
1265
|
+
const primaryBinding = bindings[0] || {};
|
|
1266
|
+
const objectPrefix = primaryBinding.objectPrefix || objectPrefixFor(deployConfig, resolvedPlan.manifest.alias || resolvedPlan.manifest.channel);
|
|
1267
|
+
const manifestKey = primaryBinding.manifestKey || deployManifestKey(deployConfig, resolvedPlan.manifest);
|
|
1268
|
+
const invalidationPaths = bindings.flatMap((binding) =>
|
|
1269
|
+
binding.publicationFastPath
|
|
1270
|
+
? [...binding.publicationFastPath.invalidationPaths, cdnPath(binding.manifestKey)]
|
|
1271
|
+
: [viewerWildcardPath(binding), cdnPath(binding.manifestKey)]);
|
|
1272
|
+
const operationResults = runAdapterOperations({ operations, dryRun, commandRunner });
|
|
1273
|
+
const immutablePreservation = bindings
|
|
1274
|
+
.filter((binding) => binding.immutablePublication)
|
|
1275
|
+
.map((binding) => {
|
|
1276
|
+
const relevant = operationResults.filter((operation) =>
|
|
1277
|
+
operation.surface === binding.surface &&
|
|
1278
|
+
[
|
|
1279
|
+
"verify-immutable-artifact-before-upload",
|
|
1280
|
+
"sync-immutable-artifact",
|
|
1281
|
+
"verify-immutable-artifact-after-upload",
|
|
1282
|
+
"sync-static-artifact",
|
|
1283
|
+
"sync-publication-fast-path",
|
|
1284
|
+
].includes(operation.action),
|
|
1285
|
+
);
|
|
1286
|
+
const expectedOperationCount = (binding.immutablePublication.files.length * 2) +
|
|
1287
|
+
binding.immutablePublication.uploadRoots.length +
|
|
1288
|
+
(binding.publicationFastPath ? binding.publicationFastPath.mutableFiles.length : 1);
|
|
1289
|
+
const complete = relevant.length === expectedOperationCount;
|
|
1290
|
+
return {
|
|
1291
|
+
surface: binding.surface,
|
|
1292
|
+
manifestPath: binding.immutablePublication.manifestPath,
|
|
1293
|
+
preservedRoots: binding.immutablePublication.preservedRoots,
|
|
1294
|
+
declaredPrefixes: binding.immutablePublication.declaredPrefixes,
|
|
1295
|
+
fileCount: binding.immutablePublication.files.length,
|
|
1296
|
+
mutableDeleteExcludes: binding.mutableDeleteExcludes || [],
|
|
1297
|
+
coveringBindings: binding.immutablePublication.coveringBindings,
|
|
1298
|
+
status: !complete || relevant.some((operation) => operation.status === "failed")
|
|
1299
|
+
? "failed"
|
|
1300
|
+
: dryRun ? "planned" : "applied",
|
|
1301
|
+
};
|
|
1302
|
+
});
|
|
1303
|
+
return {
|
|
1304
|
+
schemaVersion: 1,
|
|
1305
|
+
contract: "kungfu-buildchain-web-surface-deploy-apply",
|
|
1306
|
+
dryRun,
|
|
1307
|
+
applyMode: dryRun ? "dry-run" : "apply",
|
|
1308
|
+
status: appliedStatus({ dryRun, operations: operationResults }),
|
|
1309
|
+
actor,
|
|
1310
|
+
runId,
|
|
1311
|
+
appliedAt,
|
|
1312
|
+
channel: resolvedPlan.channel,
|
|
1313
|
+
alias: resolvedPlan.alias,
|
|
1314
|
+
url: resolvedPlan.url,
|
|
1315
|
+
urls: resolvedPlan.urls || Object.fromEntries(bindings.map((binding) => [binding.surface, binding.url])),
|
|
1316
|
+
sourceSha: resolvedPlan.manifest.sourceSha,
|
|
1317
|
+
artifactHash: resolvedPlan.artifact.hash,
|
|
1318
|
+
adapter: resolvedPlan.adapter,
|
|
1319
|
+
target: bucket,
|
|
1320
|
+
objectPrefix,
|
|
1321
|
+
manifestKey,
|
|
1322
|
+
invalidationPaths,
|
|
1323
|
+
publicationFastPath: resolvedPlan.publicationFastPath || resolvedPlan.manifest.publicationFastPath,
|
|
1324
|
+
manifest: resolvedPlan.manifest,
|
|
1325
|
+
surfaceBindings: bindings,
|
|
1326
|
+
immutablePreservation,
|
|
1327
|
+
operations: operationResults,
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
export async function preflightWebSurfaceProduction({
|
|
1332
|
+
cwd = process.cwd(),
|
|
1333
|
+
plan = null,
|
|
1334
|
+
execute = false,
|
|
1335
|
+
commandRunner = defaultCommandRunner,
|
|
1336
|
+
dnsResolver = defaultDnsResolver,
|
|
1337
|
+
checkedAt = new Date().toISOString(),
|
|
1338
|
+
} = {}) {
|
|
1339
|
+
const resolvedPlan = plan ? assertDeployPlan(plan) : planWebSurfaceDeploy({
|
|
1340
|
+
cwd,
|
|
1341
|
+
channel: "production",
|
|
1342
|
+
sourceSha: "0".repeat(40),
|
|
1343
|
+
artifactHash: "0".repeat(64),
|
|
1344
|
+
dryRun: true,
|
|
1345
|
+
deployedAt: checkedAt,
|
|
1346
|
+
});
|
|
1347
|
+
if (resolvedPlan.channel !== "production") {
|
|
1348
|
+
throw new Error("web-surface production preflight requires a production deploy plan");
|
|
1349
|
+
}
|
|
1350
|
+
const loadedConfig = loadBuildchainConfig(cwd);
|
|
1351
|
+
const config = assertWebSurfaceConfig(loadedConfig);
|
|
1352
|
+
const channel = config.channels?.production || {};
|
|
1353
|
+
const deployConfig = config.deploy?.production;
|
|
1354
|
+
if (!deployConfig) {
|
|
1355
|
+
throw new Error("missing deploy.production");
|
|
1356
|
+
}
|
|
1357
|
+
const checks = [];
|
|
1358
|
+
const configuredProductionBindings = resolveSurfaceBindings({
|
|
1359
|
+
config,
|
|
1360
|
+
channelName: "production",
|
|
1361
|
+
alias: "",
|
|
1362
|
+
deployConfig,
|
|
1363
|
+
});
|
|
1364
|
+
const bindings = resolvedPlan.manifest?.surfaceBindings || resolveSurfaceBindings({
|
|
1365
|
+
config,
|
|
1366
|
+
channelName: "production",
|
|
1367
|
+
alias: "",
|
|
1368
|
+
deployConfig,
|
|
1369
|
+
});
|
|
1370
|
+
|
|
1371
|
+
checks.push(preflightCheck({
|
|
1372
|
+
name: "production-channel",
|
|
1373
|
+
status: channel.canonical === true && channel.noindex === false ? "pass" : "fail",
|
|
1374
|
+
details: {
|
|
1375
|
+
canonical: channel.canonical,
|
|
1376
|
+
noindex: channel.noindex,
|
|
1377
|
+
},
|
|
1378
|
+
message: channel.canonical === true && channel.noindex === false
|
|
1379
|
+
? "production channel is canonical and indexable"
|
|
1380
|
+
: "channels.production must be canonical=true and noindex=false",
|
|
1381
|
+
}));
|
|
1382
|
+
|
|
1383
|
+
const configuredSurfaceNames = configuredProductionBindings.map((binding) => binding.surface).sort();
|
|
1384
|
+
const plannedSurfaceNames = bindings.map((binding) => binding.surface).sort();
|
|
1385
|
+
const missingSurfaces = configuredSurfaceNames.filter((surface) => !plannedSurfaceNames.includes(surface));
|
|
1386
|
+
const extraSurfaces = plannedSurfaceNames.filter((surface) => !configuredSurfaceNames.includes(surface));
|
|
1387
|
+
checks.push(preflightCheck({
|
|
1388
|
+
name: "production-surface-set",
|
|
1389
|
+
status: missingSurfaces.length === 0 && extraSurfaces.length === 0 ? "pass" : "fail",
|
|
1390
|
+
details: {
|
|
1391
|
+
configured: configuredSurfaceNames,
|
|
1392
|
+
planned: plannedSurfaceNames,
|
|
1393
|
+
missing: missingSurfaces,
|
|
1394
|
+
extra: extraSurfaces,
|
|
1395
|
+
},
|
|
1396
|
+
message: missingSurfaces.length === 0 && extraSurfaces.length === 0
|
|
1397
|
+
? "production plan covers every configured surface"
|
|
1398
|
+
: `production plan surface mismatch: missing=${missingSurfaces.join(",") || "-"} extra=${extraSurfaces.join(",") || "-"}`,
|
|
1399
|
+
}));
|
|
1400
|
+
|
|
1401
|
+
const concreteFailures = [];
|
|
1402
|
+
for (const binding of bindings) {
|
|
1403
|
+
const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
|
|
1404
|
+
try {
|
|
1405
|
+
assertConcreteAwsDeployConfig({
|
|
1406
|
+
deployConfig: effectiveDeploy,
|
|
1407
|
+
channel: `production.surfaces.${binding.surface}`,
|
|
1408
|
+
operation: "deploy",
|
|
1409
|
+
});
|
|
1410
|
+
} catch (error) {
|
|
1411
|
+
concreteFailures.push(String(error.message || error));
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
checks.push(preflightCheck({
|
|
1415
|
+
name: "production-targets",
|
|
1416
|
+
status: concreteFailures.length === 0 ? "pass" : "fail",
|
|
1417
|
+
details: {
|
|
1418
|
+
bindings: bindings.map((binding) => ({
|
|
1419
|
+
surface: binding.surface,
|
|
1420
|
+
bucket: binding.bucket,
|
|
1421
|
+
distributionId: binding.distributionId,
|
|
1422
|
+
objectPrefix: binding.objectPrefix,
|
|
1423
|
+
manifestKey: binding.manifestKey,
|
|
1424
|
+
})),
|
|
1425
|
+
failures: concreteFailures,
|
|
1426
|
+
},
|
|
1427
|
+
message: concreteFailures.length === 0
|
|
1428
|
+
? "production bucket and CloudFront distribution values are concrete"
|
|
1429
|
+
: concreteFailures.join("; "),
|
|
1430
|
+
}));
|
|
1431
|
+
|
|
1432
|
+
const hosts = bindings.map((binding) => ({
|
|
1433
|
+
surface: binding.surface,
|
|
1434
|
+
url: binding.url,
|
|
1435
|
+
host: urlHost(binding.url),
|
|
1436
|
+
distributionId: binding.distributionId,
|
|
1437
|
+
}));
|
|
1438
|
+
const invalidHosts = hosts.filter((entry) => !entry.host || !entry.url.startsWith("https://"));
|
|
1439
|
+
checks.push(preflightCheck({
|
|
1440
|
+
name: "production-surface-hosts",
|
|
1441
|
+
status: invalidHosts.length === 0 ? "pass" : "fail",
|
|
1442
|
+
details: { hosts, invalidHosts },
|
|
1443
|
+
message: invalidHosts.length === 0
|
|
1444
|
+
? "all production surfaces declare HTTPS hosts"
|
|
1445
|
+
: `invalid production surface hosts: ${invalidHosts.map((entry) => entry.surface).join(", ")}`,
|
|
1446
|
+
}));
|
|
1447
|
+
|
|
1448
|
+
const awsResults = [];
|
|
1449
|
+
if (execute) {
|
|
1450
|
+
const checkedBuckets = new Set();
|
|
1451
|
+
for (const binding of bindings) {
|
|
1452
|
+
const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
|
|
1453
|
+
const bucket = binding.bucket || effectiveDeploy.bucket || effectiveDeploy.target || "";
|
|
1454
|
+
if (bucket && !checkedBuckets.has(bucket)) {
|
|
1455
|
+
checkedBuckets.add(bucket);
|
|
1456
|
+
const operation = {
|
|
1457
|
+
action: "preflight-head-bucket",
|
|
1458
|
+
surface: binding.surface,
|
|
1459
|
+
command: "aws",
|
|
1460
|
+
args: ["s3api", "head-bucket", "--bucket", bucket],
|
|
1461
|
+
};
|
|
1462
|
+
awsResults.push(runAdapterOperation({ operation, dryRun: false, commandRunner }));
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
const checkedDistributions = new Set();
|
|
1467
|
+
for (const binding of bindings) {
|
|
1468
|
+
const distributionId = binding.distributionId || "";
|
|
1469
|
+
if (distributionId && !checkedDistributions.has(distributionId)) {
|
|
1470
|
+
checkedDistributions.add(distributionId);
|
|
1471
|
+
const operation = {
|
|
1472
|
+
action: "preflight-get-distribution",
|
|
1473
|
+
surface: binding.surface,
|
|
1474
|
+
command: "aws",
|
|
1475
|
+
args: ["cloudfront", "get-distribution", "--id", distributionId, "--output", "json"],
|
|
1476
|
+
};
|
|
1477
|
+
awsResults.push(runAdapterOperation({ operation, dryRun: false, commandRunner }));
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
const failedAws = awsResults.filter((result) => result.status === "failed");
|
|
1483
|
+
checks.push(preflightCheck({
|
|
1484
|
+
name: "production-aws-access",
|
|
1485
|
+
status: !execute || failedAws.length === 0 ? "pass" : "fail",
|
|
1486
|
+
details: {
|
|
1487
|
+
execute,
|
|
1488
|
+
operations: awsResults.map((result) => ({
|
|
1489
|
+
action: result.action,
|
|
1490
|
+
surface: result.surface,
|
|
1491
|
+
status: result.status,
|
|
1492
|
+
stderr: result.stderr,
|
|
1493
|
+
})),
|
|
1494
|
+
},
|
|
1495
|
+
message: !execute
|
|
1496
|
+
? "AWS access check planned but not executed"
|
|
1497
|
+
: failedAws.length === 0
|
|
1498
|
+
? "production role can inspect buckets and CloudFront distributions"
|
|
1499
|
+
: `production AWS access failed: ${failedAws.map((result) => `${result.action}:${result.surface}`).join(", ")}`,
|
|
1500
|
+
}));
|
|
1501
|
+
|
|
1502
|
+
const aliasChecks = [];
|
|
1503
|
+
if (execute) {
|
|
1504
|
+
const aliasesByDistribution = new Map();
|
|
1505
|
+
for (const result of awsResults.filter((entry) => entry.action === "preflight-get-distribution" && entry.status !== "failed")) {
|
|
1506
|
+
const aliases = parseCloudFrontAliases(result.stdout);
|
|
1507
|
+
aliasesByDistribution.set(result.args[result.args.indexOf("--id") + 1], aliases);
|
|
1508
|
+
}
|
|
1509
|
+
for (const host of hosts) {
|
|
1510
|
+
const aliases = aliasesByDistribution.get(host.distributionId) || [];
|
|
1511
|
+
aliasChecks.push({
|
|
1512
|
+
...host,
|
|
1513
|
+
aliases,
|
|
1514
|
+
matched: aliasMatchesHost(aliases, host.host),
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
const missingAliases = aliasChecks.filter((entry) => !entry.matched);
|
|
1519
|
+
checks.push(preflightCheck({
|
|
1520
|
+
name: "production-cloudfront-aliases",
|
|
1521
|
+
status: !execute || missingAliases.length === 0 ? "pass" : "fail",
|
|
1522
|
+
details: {
|
|
1523
|
+
execute,
|
|
1524
|
+
aliases: aliasChecks,
|
|
1525
|
+
},
|
|
1526
|
+
message: !execute
|
|
1527
|
+
? "CloudFront alias check planned but not executed"
|
|
1528
|
+
: missingAliases.length === 0
|
|
1529
|
+
? "production CloudFront aliases cover every surface host"
|
|
1530
|
+
: `missing CloudFront aliases: ${missingAliases.map((entry) => entry.host).join(", ")}`,
|
|
1531
|
+
}));
|
|
1532
|
+
|
|
1533
|
+
const dnsChecks = [];
|
|
1534
|
+
if (execute) {
|
|
1535
|
+
for (const host of hosts) {
|
|
1536
|
+
try {
|
|
1537
|
+
const answers = await dnsResolver(host.host);
|
|
1538
|
+
dnsChecks.push({ ...host, status: "pass", answers });
|
|
1539
|
+
} catch (error) {
|
|
1540
|
+
dnsChecks.push({ ...host, status: "fail", error: String(error.message || error) });
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
const failedDns = dnsChecks.filter((entry) => entry.status === "fail");
|
|
1545
|
+
checks.push(preflightCheck({
|
|
1546
|
+
name: "production-dns",
|
|
1547
|
+
status: !execute || failedDns.length === 0 ? "pass" : "fail",
|
|
1548
|
+
details: {
|
|
1549
|
+
execute,
|
|
1550
|
+
hosts: dnsChecks,
|
|
1551
|
+
},
|
|
1552
|
+
message: !execute
|
|
1553
|
+
? "DNS check planned but not executed"
|
|
1554
|
+
: failedDns.length === 0
|
|
1555
|
+
? "production DNS resolves for every surface host"
|
|
1556
|
+
: `production DNS failed: ${failedDns.map((entry) => entry.host).join(", ")}`,
|
|
1557
|
+
}));
|
|
1558
|
+
|
|
1559
|
+
return {
|
|
1560
|
+
schemaVersion: 1,
|
|
1561
|
+
contract: "kungfu-buildchain-web-surface-production-preflight",
|
|
1562
|
+
checkedAt,
|
|
1563
|
+
execute,
|
|
1564
|
+
channel: "production",
|
|
1565
|
+
status: preflightStatus(checks),
|
|
1566
|
+
url: resolvedPlan.url,
|
|
1567
|
+
urls: resolvedPlan.urls,
|
|
1568
|
+
sourceSha: resolvedPlan.manifest.sourceSha,
|
|
1569
|
+
artifactHash: resolvedPlan.artifact.hash,
|
|
1570
|
+
surfaceBindings: bindings,
|
|
1571
|
+
checks,
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
function healthStatus(checks) {
|
|
1576
|
+
return checks.some((check) => check.status === "fail") ? "failed" : "passed";
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
function noindexHeader(headers) {
|
|
1580
|
+
const value = headers?.get?.("x-robots-tag") || "";
|
|
1581
|
+
return String(value).toLowerCase().includes("noindex");
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function noindexMeta(html = "") {
|
|
1585
|
+
const source = String(html || "").toLowerCase();
|
|
1586
|
+
return /<meta\s+[^>]*name=["']robots["'][^>]*content=["'][^"']*noindex/.test(source) ||
|
|
1587
|
+
/<meta\s+[^>]*content=["'][^"']*noindex[^"']*["'][^>]*name=["']robots["']/.test(source);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
function htmlLikeResponse(response, url = "") {
|
|
1591
|
+
const contentType = response.headers?.get?.("content-type") || "";
|
|
1592
|
+
return String(contentType).toLowerCase().includes("text/html") || /\/$|\.html(?:$|[?#])/.test(String(url || ""));
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
function operationEvidenceStatus(operation, { plannedEvidence = false } = {}) {
|
|
1596
|
+
if (plannedEvidence && operation.status === undefined) {
|
|
1597
|
+
return true;
|
|
1598
|
+
}
|
|
1599
|
+
return operation.status === "applied" || operation.status === "planned";
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
function managedNetworkHealthEvidence({ target, result, plan }) {
|
|
1603
|
+
const requiredActions = [
|
|
1604
|
+
target.publicationFastPath
|
|
1605
|
+
? "sync-publication-fast-path"
|
|
1606
|
+
: "sync-static-artifact",
|
|
1607
|
+
"write-deployment-manifest",
|
|
1608
|
+
];
|
|
1609
|
+
const operationSource = Array.isArray(result?.operations) && result.operations.length > 0
|
|
1610
|
+
? "apply-result"
|
|
1611
|
+
: "deploy-plan";
|
|
1612
|
+
const operations = operationSource === "apply-result"
|
|
1613
|
+
? result.operations
|
|
1614
|
+
: (Array.isArray(plan?.steps) ? plan.steps : []);
|
|
1615
|
+
const surfaceOperations = operations.filter((operation) => operation.surface === target.surface);
|
|
1616
|
+
const presentActions = new Set(
|
|
1617
|
+
surfaceOperations
|
|
1618
|
+
.filter((operation) => operationEvidenceStatus(operation, { plannedEvidence: operationSource === "deploy-plan" }))
|
|
1619
|
+
.map((operation) => operation.action),
|
|
1620
|
+
);
|
|
1621
|
+
const missingActions = requiredActions.filter((action) => !presentActions.has(action));
|
|
1622
|
+
const missingFields = [];
|
|
1623
|
+
if (!target.manifestKey) missingFields.push("manifestKey");
|
|
1624
|
+
if (!target.bucket) missingFields.push("bucket");
|
|
1625
|
+
if (target.objectPrefix === undefined || target.objectPrefix === null) missingFields.push("objectPrefix");
|
|
1626
|
+
return {
|
|
1627
|
+
source: operationSource,
|
|
1628
|
+
actions: [...presentActions].sort(),
|
|
1629
|
+
requiredActions,
|
|
1630
|
+
missingActions,
|
|
1631
|
+
missingFields,
|
|
1632
|
+
status: missingActions.length === 0 && missingFields.length === 0 ? "pass" : "fail",
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
function managedNetworkTargetObjectKey(target) {
|
|
1637
|
+
const requestPath = String(target.requestPath || "/");
|
|
1638
|
+
let relative = requestPath.replace(/^\/+/, "");
|
|
1639
|
+
if (!relative) {
|
|
1640
|
+
relative = "index.html";
|
|
1641
|
+
} else if (requestPath.endsWith("/")) {
|
|
1642
|
+
relative = `${relative.replace(/\/+$/, "")}/index.html`;
|
|
1643
|
+
}
|
|
1644
|
+
return joinS3Key(target.objectPrefix, relative);
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
function managedNetworkHeadObject({ target, kind, key, commandRunner }) {
|
|
1648
|
+
return runAdapterOperation({
|
|
1649
|
+
operation: {
|
|
1650
|
+
action: `health-head-${kind}`,
|
|
1651
|
+
surface: target.surface,
|
|
1652
|
+
command: "aws",
|
|
1653
|
+
args: ["s3api", "head-object", "--bucket", target.bucket, "--key", key],
|
|
1654
|
+
},
|
|
1655
|
+
dryRun: false,
|
|
1656
|
+
commandRunner,
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
function managedNetworkS3HealthCheck({ target, evidence, commandRunner }) {
|
|
1661
|
+
const objectKey = managedNetworkTargetObjectKey(target);
|
|
1662
|
+
const headResults = [
|
|
1663
|
+
managedNetworkHeadObject({ target, kind: "manifest", key: target.manifestKey, commandRunner }),
|
|
1664
|
+
managedNetworkHeadObject({ target, kind: "object", key: objectKey, commandRunner }),
|
|
1665
|
+
];
|
|
1666
|
+
const failed = headResults.filter((operation) => operation.status === "failed");
|
|
1667
|
+
return {
|
|
1668
|
+
surface: target.surface,
|
|
1669
|
+
kind: target.kind,
|
|
1670
|
+
requestPath: target.requestPath,
|
|
1671
|
+
url: target.url,
|
|
1672
|
+
accessControl: target.accessControl || "",
|
|
1673
|
+
healthStrategy: "s3-object",
|
|
1674
|
+
status: evidence.status === "pass" && failed.length === 0 ? "pass" : "fail",
|
|
1675
|
+
httpStatus: null,
|
|
1676
|
+
finalUrl: "",
|
|
1677
|
+
noindexHeader: false,
|
|
1678
|
+
manifestKey: target.manifestKey || "",
|
|
1679
|
+
bucket: target.bucket || "",
|
|
1680
|
+
objectPrefix: target.objectPrefix || "",
|
|
1681
|
+
objectKey,
|
|
1682
|
+
evidence,
|
|
1683
|
+
s3Checks: headResults.map((operation) => ({
|
|
1684
|
+
action: operation.action,
|
|
1685
|
+
bucket: target.bucket,
|
|
1686
|
+
key: operation.args?.[operation.args.indexOf("--key") + 1] || "",
|
|
1687
|
+
status: operation.status,
|
|
1688
|
+
exitCode: operation.exitCode,
|
|
1689
|
+
stderr: operation.stderr || "",
|
|
1690
|
+
})),
|
|
1691
|
+
message: evidence.status === "pass" && failed.length === 0
|
|
1692
|
+
? "surface health verified from S3 manifest and object head checks; direct public fetch skipped"
|
|
1693
|
+
: `S3 object health failed: ${failed.map((operation) => `${operation.action}:${operation.stderr || operation.exitCode}`).join("; ") || "missing deployment evidence"}`,
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
function managedNetworkHealthCheck({ target, result, plan, commandRunner, verifyS3Objects = true }) {
|
|
1698
|
+
const evidence = managedNetworkHealthEvidence({ target, result, plan });
|
|
1699
|
+
if (verifyS3Objects && result?.status === "applied" && evidence.status === "pass") {
|
|
1700
|
+
return managedNetworkS3HealthCheck({ target, evidence, commandRunner });
|
|
1701
|
+
}
|
|
1702
|
+
return {
|
|
1703
|
+
surface: target.surface,
|
|
1704
|
+
kind: target.kind,
|
|
1705
|
+
requestPath: target.requestPath,
|
|
1706
|
+
url: target.url,
|
|
1707
|
+
accessControl: target.accessControl || "",
|
|
1708
|
+
healthStrategy: "deployment-evidence",
|
|
1709
|
+
status: evidence.status,
|
|
1710
|
+
httpStatus: null,
|
|
1711
|
+
finalUrl: "",
|
|
1712
|
+
noindexHeader: false,
|
|
1713
|
+
manifestKey: target.manifestKey || "",
|
|
1714
|
+
bucket: target.bucket || "",
|
|
1715
|
+
objectPrefix: target.objectPrefix || "",
|
|
1716
|
+
evidence,
|
|
1717
|
+
message: evidence.status === "pass"
|
|
1718
|
+
? "managed-network surface health verified from deployment manifest and S3 object sync evidence; direct public fetch skipped"
|
|
1719
|
+
: `managed-network surface health requires manifest and S3 object evidence; missing actions=${evidence.missingActions.join(",") || "none"}, missing fields=${evidence.missingFields.join(",") || "none"}`,
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
async function fetchWithRetry(url, {
|
|
1724
|
+
fetchImpl,
|
|
1725
|
+
attempts = 3,
|
|
1726
|
+
intervalMs = 5000,
|
|
1727
|
+
shouldRetry = () => false,
|
|
1728
|
+
} = {}) {
|
|
1729
|
+
const maxAttempts = Math.max(1, Number(attempts) || 1);
|
|
1730
|
+
let lastError = null;
|
|
1731
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
1732
|
+
try {
|
|
1733
|
+
const response = await fetchImpl(url, { redirect: "follow" });
|
|
1734
|
+
if (attempt >= maxAttempts || !shouldRetry(response)) {
|
|
1735
|
+
return { response, attempts: attempt };
|
|
1736
|
+
}
|
|
1737
|
+
} catch (error) {
|
|
1738
|
+
lastError = error;
|
|
1739
|
+
if (attempt >= maxAttempts) {
|
|
1740
|
+
throw Object.assign(error, { attempts: attempt });
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (intervalMs > 0) {
|
|
1744
|
+
await sleep(intervalMs);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
throw Object.assign(lastError || new Error("web-surface fetch retry exhausted"), { attempts: maxAttempts });
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
function retryableHealthResponse(response) {
|
|
1751
|
+
return response.status === 403 || response.status === 404 || response.status >= 500;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
const DEFAULT_HEALTH_HTTP_RETRY_ATTEMPTS = 12;
|
|
1755
|
+
const DEFAULT_HEALTH_HTTP_RETRY_INTERVAL_MS = 10000;
|
|
1756
|
+
|
|
1757
|
+
export async function checkWebSurfaceHealth({
|
|
1758
|
+
result = null,
|
|
1759
|
+
plan = null,
|
|
1760
|
+
cwd = process.cwd(),
|
|
1761
|
+
fetchImpl = fetch,
|
|
1762
|
+
checkedAt = new Date().toISOString(),
|
|
1763
|
+
allowedStatuses = [200],
|
|
1764
|
+
allowedManagedNetworkRunner = false,
|
|
1765
|
+
managedNetworkS3ObjectVerification = true,
|
|
1766
|
+
commandRunner = defaultCommandRunner,
|
|
1767
|
+
httpRetryAttempts = Number(process.env.BUILDCHAIN_WEB_SURFACE_HEALTH_HTTP_RETRY_ATTEMPTS || DEFAULT_HEALTH_HTTP_RETRY_ATTEMPTS),
|
|
1768
|
+
httpRetryIntervalMs = Number(process.env.BUILDCHAIN_WEB_SURFACE_HEALTH_HTTP_RETRY_INTERVAL_MS || DEFAULT_HEALTH_HTTP_RETRY_INTERVAL_MS),
|
|
1769
|
+
} = {}) {
|
|
1770
|
+
const loadedConfig = loadBuildchainConfig(cwd);
|
|
1771
|
+
const config = assertWebSurfaceConfig(loadedConfig);
|
|
1772
|
+
const manifest = result?.manifest || plan?.manifest;
|
|
1773
|
+
const channel = result?.channel || plan?.channel || manifest?.channel || "production";
|
|
1774
|
+
const urls = result?.urls || plan?.urls || (manifest?.surfaceBindings
|
|
1775
|
+
? Object.fromEntries(manifest.surfaceBindings.map((binding) => [binding.surface, binding.url]))
|
|
1776
|
+
: {});
|
|
1777
|
+
const bindings = manifest?.surfaceBindings || [];
|
|
1778
|
+
const checks = [];
|
|
1779
|
+
if (Object.keys(urls).length === 0) {
|
|
1780
|
+
checks.push({
|
|
1781
|
+
surface: "__urls__",
|
|
1782
|
+
url: "",
|
|
1783
|
+
status: "fail",
|
|
1784
|
+
httpStatus: 0,
|
|
1785
|
+
finalUrl: "",
|
|
1786
|
+
noindexHeader: false,
|
|
1787
|
+
message: "web-surface health check requires at least one surface URL from an apply result or deploy plan",
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
const smokeTargets = bindings.length > 0
|
|
1792
|
+
? bindings.flatMap((binding) => {
|
|
1793
|
+
const smokeUrls = Array.isArray(binding.smokeUrls) && binding.smokeUrls.length > 0
|
|
1794
|
+
? binding.smokeUrls
|
|
1795
|
+
: [{ kind: "root", requestPath: "/", url: binding.url || urls[binding.surface] || "", required: true }];
|
|
1796
|
+
return smokeUrls.map((smoke) => ({
|
|
1797
|
+
surface: binding.surface,
|
|
1798
|
+
kind: smoke.kind || "root",
|
|
1799
|
+
requestPath: smoke.requestPath || "",
|
|
1800
|
+
url: smoke.url || "",
|
|
1801
|
+
required: smoke.required !== false,
|
|
1802
|
+
missing: Boolean(smoke.missing),
|
|
1803
|
+
message: smoke.message || "",
|
|
1804
|
+
accessControl: binding.accessControl || config.channels?.[channel]?.accessControl || "",
|
|
1805
|
+
healthStrategy: binding.healthStrategy || "",
|
|
1806
|
+
manifestKey: binding.manifestKey || "",
|
|
1807
|
+
bucket: binding.bucket || "",
|
|
1808
|
+
objectPrefix: binding.objectPrefix || "",
|
|
1809
|
+
publicationFastPath: binding.publicationFastPath || null,
|
|
1810
|
+
}));
|
|
1811
|
+
})
|
|
1812
|
+
: Object.entries(urls).map(([surface, url]) => ({
|
|
1813
|
+
surface,
|
|
1814
|
+
kind: "root",
|
|
1815
|
+
requestPath: "/",
|
|
1816
|
+
url,
|
|
1817
|
+
required: true,
|
|
1818
|
+
accessControl: config.channels?.[channel]?.accessControl || "",
|
|
1819
|
+
healthStrategy: "",
|
|
1820
|
+
}));
|
|
1821
|
+
|
|
1822
|
+
for (const target of smokeTargets) {
|
|
1823
|
+
const { surface, url } = target;
|
|
1824
|
+
if (!url || target.missing) {
|
|
1825
|
+
checks.push({
|
|
1826
|
+
surface,
|
|
1827
|
+
kind: target.kind,
|
|
1828
|
+
requestPath: target.requestPath,
|
|
1829
|
+
url: url || "",
|
|
1830
|
+
status: "fail",
|
|
1831
|
+
httpStatus: 0,
|
|
1832
|
+
finalUrl: "",
|
|
1833
|
+
noindexHeader: false,
|
|
1834
|
+
message: target.message || "web-surface smoke URL is missing",
|
|
1835
|
+
});
|
|
1836
|
+
continue;
|
|
1837
|
+
}
|
|
1838
|
+
if (target.healthStrategy === "s3-object") {
|
|
1839
|
+
checks.push(managedNetworkHealthCheck({
|
|
1840
|
+
target,
|
|
1841
|
+
result,
|
|
1842
|
+
plan,
|
|
1843
|
+
commandRunner,
|
|
1844
|
+
verifyS3Objects: managedNetworkS3ObjectVerification,
|
|
1845
|
+
}));
|
|
1846
|
+
continue;
|
|
1847
|
+
}
|
|
1848
|
+
if (target.accessControl === "managed-network" && !allowedManagedNetworkRunner) {
|
|
1849
|
+
checks.push(managedNetworkHealthCheck({
|
|
1850
|
+
target,
|
|
1851
|
+
result,
|
|
1852
|
+
plan,
|
|
1853
|
+
commandRunner,
|
|
1854
|
+
verifyS3Objects: managedNetworkS3ObjectVerification,
|
|
1855
|
+
}));
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
try {
|
|
1859
|
+
const { response, attempts } = await fetchWithRetry(url, {
|
|
1860
|
+
fetchImpl,
|
|
1861
|
+
attempts: httpRetryAttempts,
|
|
1862
|
+
intervalMs: httpRetryIntervalMs,
|
|
1863
|
+
shouldRetry: retryableHealthResponse,
|
|
1864
|
+
});
|
|
1865
|
+
const expectedNoindex = Boolean(config.channels?.[channel]?.noindex);
|
|
1866
|
+
const headerNoindex = noindexHeader(response.headers);
|
|
1867
|
+
const body = htmlLikeResponse(response, url) && typeof response.text === "function"
|
|
1868
|
+
? await response.text()
|
|
1869
|
+
: "";
|
|
1870
|
+
const metaNoindex = noindexMeta(body);
|
|
1871
|
+
const noindex = headerNoindex || metaNoindex;
|
|
1872
|
+
const statusOk = allowedStatuses.includes(response.status);
|
|
1873
|
+
const noindexOk = channel !== "production" || expectedNoindex || !noindex;
|
|
1874
|
+
checks.push({
|
|
1875
|
+
surface,
|
|
1876
|
+
kind: target.kind,
|
|
1877
|
+
requestPath: target.requestPath,
|
|
1878
|
+
url,
|
|
1879
|
+
accessControl: target.accessControl || "",
|
|
1880
|
+
healthStrategy: "http",
|
|
1881
|
+
status: statusOk && noindexOk ? "pass" : "fail",
|
|
1882
|
+
httpStatus: response.status,
|
|
1883
|
+
attempts,
|
|
1884
|
+
finalUrl: response.url || url,
|
|
1885
|
+
noindexHeader: noindex,
|
|
1886
|
+
noindexHeaderValue: headerNoindex,
|
|
1887
|
+
noindexMeta: metaNoindex,
|
|
1888
|
+
message: statusOk && noindexOk
|
|
1889
|
+
? "surface is reachable"
|
|
1890
|
+
: `surface health failed: http=${response.status}, noindex=${noindex}`,
|
|
1891
|
+
});
|
|
1892
|
+
} catch (error) {
|
|
1893
|
+
checks.push({
|
|
1894
|
+
surface,
|
|
1895
|
+
kind: target.kind,
|
|
1896
|
+
requestPath: target.requestPath,
|
|
1897
|
+
url,
|
|
1898
|
+
status: "fail",
|
|
1899
|
+
httpStatus: 0,
|
|
1900
|
+
attempts: error.attempts || 1,
|
|
1901
|
+
finalUrl: "",
|
|
1902
|
+
noindexHeader: false,
|
|
1903
|
+
message: String(error.message || error),
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
const immutableBindings = bindings.filter((binding) => binding.immutablePublication);
|
|
1909
|
+
if (immutableBindings.length > 0) {
|
|
1910
|
+
const operationSource = Array.isArray(result?.operations) && result.operations.length > 0
|
|
1911
|
+
? result.operations
|
|
1912
|
+
: (Array.isArray(plan?.steps) ? plan.steps : []);
|
|
1913
|
+
const preservationBindings = immutableBindings.map((binding) => {
|
|
1914
|
+
const requiredActions = [
|
|
1915
|
+
"verify-immutable-artifact-before-upload",
|
|
1916
|
+
"sync-immutable-artifact",
|
|
1917
|
+
"verify-immutable-artifact-after-upload",
|
|
1918
|
+
binding.publicationFastPath
|
|
1919
|
+
? "sync-publication-fast-path"
|
|
1920
|
+
: "sync-static-artifact",
|
|
1921
|
+
];
|
|
1922
|
+
const actions = new Set(operationSource
|
|
1923
|
+
.filter((operation) => operation.surface === binding.surface)
|
|
1924
|
+
.filter((operation) => operationEvidenceStatus(operation, { plannedEvidence: !result }))
|
|
1925
|
+
.map((operation) => operation.action));
|
|
1926
|
+
const missingActions = requiredActions.filter((action) => !actions.has(action));
|
|
1927
|
+
const coveringBindings = binding.publicationFastPath
|
|
1928
|
+
? []
|
|
1929
|
+
: (binding.immutablePublication.coveringBindings || []).map((covering) => {
|
|
1930
|
+
const sync = operationSource.find((operation) =>
|
|
1931
|
+
operation.surface === covering.surface &&
|
|
1932
|
+
operation.action === "sync-static-artifact" &&
|
|
1933
|
+
operationEvidenceStatus(operation, { plannedEvidence: !result }),
|
|
1934
|
+
);
|
|
1935
|
+
const actualExcludes = sync?.preservation?.mutableDeleteExcludes || sync?.deleteExcludes || [];
|
|
1936
|
+
return {
|
|
1937
|
+
...covering,
|
|
1938
|
+
status: sync && covering.mutableDeleteExcludes.every((pattern) => actualExcludes.includes(pattern))
|
|
1939
|
+
? "pass"
|
|
1940
|
+
: "fail",
|
|
1941
|
+
};
|
|
1942
|
+
});
|
|
1943
|
+
return {
|
|
1944
|
+
surface: binding.surface,
|
|
1945
|
+
manifestPath: binding.immutablePublication.manifestPath,
|
|
1946
|
+
preservedRoots: binding.immutablePublication.preservedRoots,
|
|
1947
|
+
declaredPrefixes: binding.immutablePublication.declaredPrefixes,
|
|
1948
|
+
fileCount: binding.immutablePublication.files.length,
|
|
1949
|
+
mutableDeleteExcludes: binding.mutableDeleteExcludes || [],
|
|
1950
|
+
coveringBindings,
|
|
1951
|
+
actions: [...actions].sort(),
|
|
1952
|
+
requiredActions,
|
|
1953
|
+
missingActions,
|
|
1954
|
+
status: missingActions.length === 0 && coveringBindings.every((covering) => covering.status === "pass")
|
|
1955
|
+
? "pass"
|
|
1956
|
+
: "fail",
|
|
1957
|
+
};
|
|
1958
|
+
});
|
|
1959
|
+
checks.push({
|
|
1960
|
+
surface: "__immutable__",
|
|
1961
|
+
url: "",
|
|
1962
|
+
status: preservationBindings.every((binding) => binding.status === "pass") ? "pass" : "fail",
|
|
1963
|
+
bindings: preservationBindings,
|
|
1964
|
+
message: preservationBindings.every((binding) => binding.status === "pass")
|
|
1965
|
+
? "immutable publication roots were excluded from mutable deletion and verified around no-overwrite upload"
|
|
1966
|
+
: "immutable publication preservation evidence is incomplete",
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
const installerPublication = manifest?.installerPublicationEvidence;
|
|
1971
|
+
const managedInstallerSurface =
|
|
1972
|
+
config.channels?.[channel]?.accessControl === "managed-network" &&
|
|
1973
|
+
!allowedManagedNetworkRunner;
|
|
1974
|
+
if (installerPublication && !managedInstallerSurface) {
|
|
1975
|
+
try {
|
|
1976
|
+
const publicBase = new URL(urls.hub || manifest?.url || Object.values(urls)[0]);
|
|
1977
|
+
const projected = {
|
|
1978
|
+
...installerPublication,
|
|
1979
|
+
assets: installerPublication.assets.map((asset) => ({
|
|
1980
|
+
...asset,
|
|
1981
|
+
friendlyUrl: new URL(new URL(asset.friendlyUrl).pathname, publicBase).href,
|
|
1982
|
+
immutableUrl: new URL(new URL(asset.immutableUrl).pathname, publicBase).href,
|
|
1983
|
+
})),
|
|
1984
|
+
};
|
|
1985
|
+
const evidence = await verifyInstallerPublicReadback({
|
|
1986
|
+
publication: projected,
|
|
1987
|
+
fetchImpl,
|
|
1988
|
+
});
|
|
1989
|
+
checks.push({
|
|
1990
|
+
surface: "__installer__",
|
|
1991
|
+
url: publicBase.href,
|
|
1992
|
+
status: "pass",
|
|
1993
|
+
evidence,
|
|
1994
|
+
message: "friendly and immutable installer routes match signed publication bytes and cache policy",
|
|
1995
|
+
});
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
checks.push({
|
|
1998
|
+
surface: "__installer__",
|
|
1999
|
+
url: urls.hub || manifest?.url || "",
|
|
2000
|
+
status: "fail",
|
|
2001
|
+
message: String(error.message || error),
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
const manifestChecks = bindings.map((binding) => ({
|
|
2007
|
+
surface: binding.surface,
|
|
2008
|
+
manifestKey: binding.manifestKey,
|
|
2009
|
+
bucket: binding.bucket,
|
|
2010
|
+
distributionId: binding.distributionId,
|
|
2011
|
+
status: binding.manifestKey ? "pass" : "fail",
|
|
2012
|
+
}));
|
|
2013
|
+
checks.push({
|
|
2014
|
+
surface: "__manifest__",
|
|
2015
|
+
url: "",
|
|
2016
|
+
status: manifestChecks.length > 0 && manifestChecks.every((entry) => entry.status === "pass") ? "pass" : "fail",
|
|
2017
|
+
manifests: manifestChecks,
|
|
2018
|
+
message: "deployment manifest pointers are recorded for every surface",
|
|
2019
|
+
});
|
|
2020
|
+
|
|
2021
|
+
return {
|
|
2022
|
+
schemaVersion: 1,
|
|
2023
|
+
contract: "kungfu-buildchain-web-surface-health-check",
|
|
2024
|
+
checkedAt,
|
|
2025
|
+
channel,
|
|
2026
|
+
status: healthStatus(checks),
|
|
2027
|
+
sourceSha: manifest?.sourceSha || result?.sourceSha || "",
|
|
2028
|
+
artifactHash: manifest?.artifactHash || result?.artifactHash || "",
|
|
2029
|
+
urls,
|
|
2030
|
+
checks,
|
|
2031
|
+
};
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
function deployBindingOperations({ artifactRoot, deployConfig, manifest, binding }) {
|
|
2035
|
+
const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
|
|
2036
|
+
const bucket = binding.bucket || effectiveDeploy.bucket || effectiveDeploy.target || "";
|
|
2037
|
+
const distribution = binding.distributionId || effectiveDeploy.cloudfront_distribution || effectiveDeploy.distribution || "";
|
|
2038
|
+
const surfaceArtifactRoot = surfaceArtifactRootFor({ artifactRoot, binding });
|
|
2039
|
+
const immutable = binding.immutablePublication;
|
|
2040
|
+
const installer = manifest.installerPublicationEvidence;
|
|
2041
|
+
const installerRoot = installer?.immutablePath || "";
|
|
2042
|
+
const ownsArtifactRoot = normalizeS3Key(
|
|
2043
|
+
binding.artifactPathPrefix || surfaceArtifactPrefix(binding),
|
|
2044
|
+
) === "";
|
|
2045
|
+
const ownsInstallerAssets = installer?.assets?.every((asset) =>
|
|
2046
|
+
fs.existsSync(path.join(surfaceArtifactRoot, asset.friendly.path)));
|
|
2047
|
+
const installerBinding =
|
|
2048
|
+
installer &&
|
|
2049
|
+
ownsArtifactRoot &&
|
|
2050
|
+
ownsInstallerAssets &&
|
|
2051
|
+
immutable?.declaredPrefixes?.includes(installer.immutablePath)
|
|
2052
|
+
? installer
|
|
2053
|
+
: null;
|
|
2054
|
+
const immutableVerifier = path.join(commandDirectory(), "web-surface-immutable-object.mjs");
|
|
2055
|
+
const verifyImmutable = (phase) => (immutable?.files || []).map((file) => ({
|
|
2056
|
+
action: `verify-immutable-artifact-${phase}`,
|
|
2057
|
+
surface: binding.surface,
|
|
2058
|
+
command: "node",
|
|
2059
|
+
args: [
|
|
2060
|
+
immutableVerifier,
|
|
2061
|
+
"--bucket",
|
|
2062
|
+
bucket,
|
|
2063
|
+
"--key",
|
|
2064
|
+
joinS3Key(binding.objectPrefix, file.path),
|
|
2065
|
+
"--sha256",
|
|
2066
|
+
file.sha256,
|
|
2067
|
+
],
|
|
2068
|
+
immutable: {
|
|
2069
|
+
phase,
|
|
2070
|
+
path: file.path,
|
|
2071
|
+
sha256: file.sha256,
|
|
2072
|
+
},
|
|
2073
|
+
}));
|
|
2074
|
+
const syncImmutable = (immutable?.uploadRoots || immutable?.preservedRoots || []).map((root) => {
|
|
2075
|
+
const isInstallerRoot = Boolean(installerBinding && root === installerRoot);
|
|
2076
|
+
const immutableMetadataArgs = isInstallerRoot
|
|
2077
|
+
? [
|
|
2078
|
+
"--content-type",
|
|
2079
|
+
"application/octet-stream",
|
|
2080
|
+
"--cache-control",
|
|
2081
|
+
"public,max-age=31536000,immutable",
|
|
2082
|
+
]
|
|
2083
|
+
: binding.cacheControl?.immutable
|
|
2084
|
+
? ["--cache-control", binding.cacheControl.immutable]
|
|
2085
|
+
: [];
|
|
2086
|
+
return {
|
|
2087
|
+
action: "sync-immutable-artifact",
|
|
2088
|
+
surface: binding.surface,
|
|
2089
|
+
command: "aws",
|
|
2090
|
+
args: [
|
|
2091
|
+
"s3",
|
|
2092
|
+
"sync",
|
|
2093
|
+
path.join(surfaceArtifactRoot, root),
|
|
2094
|
+
s3Uri(bucket, joinS3Key(binding.objectPrefix, root)),
|
|
2095
|
+
"--no-overwrite",
|
|
2096
|
+
"--checksum-algorithm",
|
|
2097
|
+
"SHA256",
|
|
2098
|
+
...immutableMetadataArgs,
|
|
2099
|
+
],
|
|
2100
|
+
immutable: {
|
|
2101
|
+
preservedRoot: root,
|
|
2102
|
+
overwrite: false,
|
|
2103
|
+
cacheControl: isInstallerRoot
|
|
2104
|
+
? "public,max-age=31536000,immutable"
|
|
2105
|
+
: binding.cacheControl?.immutable,
|
|
2106
|
+
},
|
|
2107
|
+
};
|
|
2108
|
+
});
|
|
2109
|
+
const publishFriendlyInstallers = (installerBinding?.assets || []).map((asset) => ({
|
|
2110
|
+
action: "publish-friendly-installer",
|
|
2111
|
+
surface: binding.surface,
|
|
2112
|
+
command: "aws",
|
|
2113
|
+
args: [
|
|
2114
|
+
"s3",
|
|
2115
|
+
"cp",
|
|
2116
|
+
path.join(surfaceArtifactRoot, asset.friendly.path),
|
|
2117
|
+
s3Uri(bucket, joinS3Key(binding.objectPrefix, asset.friendly.path)),
|
|
2118
|
+
"--content-type",
|
|
2119
|
+
asset.contentType,
|
|
2120
|
+
"--cache-control",
|
|
2121
|
+
"public,max-age=300,must-revalidate",
|
|
2122
|
+
],
|
|
2123
|
+
installer: {
|
|
2124
|
+
name: asset.name,
|
|
2125
|
+
digest: asset.digest,
|
|
2126
|
+
cacheControl: "public,max-age=300,must-revalidate",
|
|
2127
|
+
},
|
|
2128
|
+
}));
|
|
2129
|
+
const fastPathMutable = (binding.publicationFastPath?.mutableFiles || []).map((file) => ({
|
|
2130
|
+
action: "sync-publication-fast-path",
|
|
2131
|
+
surface: binding.surface,
|
|
2132
|
+
command: "aws",
|
|
2133
|
+
args: [
|
|
2134
|
+
"s3",
|
|
2135
|
+
"cp",
|
|
2136
|
+
path.join(surfaceArtifactRoot, file),
|
|
2137
|
+
s3Uri(bucket, joinS3Key(binding.objectPrefix, file)),
|
|
2138
|
+
"--checksum-algorithm",
|
|
2139
|
+
"SHA256",
|
|
2140
|
+
],
|
|
2141
|
+
publicationFastPath: {
|
|
2142
|
+
qualificationRoot: binding.publicationFastPath.qualificationRoot,
|
|
2143
|
+
path: file,
|
|
2144
|
+
overwriteBoundary: "declared-mutable-file-only",
|
|
2145
|
+
},
|
|
2146
|
+
}));
|
|
2147
|
+
const mutableSync = binding.publicationFastPath
|
|
2148
|
+
? fastPathMutable
|
|
2149
|
+
: [
|
|
2150
|
+
{
|
|
2151
|
+
action: "sync-static-artifact",
|
|
2152
|
+
surface: binding.surface,
|
|
2153
|
+
command: "aws",
|
|
2154
|
+
args: syncStaticArtifactArgs({
|
|
2155
|
+
artifactRoot: surfaceArtifactRoot,
|
|
2156
|
+
bucket,
|
|
2157
|
+
objectPrefix: binding.objectPrefix,
|
|
2158
|
+
deleteExcludes: binding.mutableDeleteExcludes || [],
|
|
2159
|
+
cacheControl: binding.cacheControl?.default || "",
|
|
2160
|
+
}),
|
|
2161
|
+
routing: binding.routing,
|
|
2162
|
+
preservation: binding.mutableDeleteExcludes?.length > 0
|
|
2163
|
+
? {
|
|
2164
|
+
contract: "kungfu-buildchain-web-surface-immutable-delete-exclusion",
|
|
2165
|
+
mutableDeleteExcludes: binding.mutableDeleteExcludes,
|
|
2166
|
+
}
|
|
2167
|
+
: undefined,
|
|
2168
|
+
},
|
|
2169
|
+
...(binding.cacheControl?.mutable
|
|
2170
|
+
? [{
|
|
2171
|
+
action: "apply-mutable-cache-control",
|
|
2172
|
+
surface: binding.surface,
|
|
2173
|
+
command: "aws",
|
|
2174
|
+
args: mutableCacheControlArgs({
|
|
2175
|
+
artifactRoot: surfaceArtifactRoot,
|
|
2176
|
+
bucket,
|
|
2177
|
+
objectPrefix: binding.objectPrefix,
|
|
2178
|
+
cacheControl: binding.cacheControl.mutable,
|
|
2179
|
+
excludePatterns: binding.mutableDeleteExcludes || [],
|
|
2180
|
+
}),
|
|
2181
|
+
cacheControl: binding.cacheControl.mutable,
|
|
2182
|
+
patterns: ["*.html", "*.json", "*.xml"],
|
|
2183
|
+
excludes: binding.mutableDeleteExcludes || [],
|
|
2184
|
+
}]
|
|
2185
|
+
: []),
|
|
2186
|
+
];
|
|
2187
|
+
const operations = [
|
|
2188
|
+
...verifyImmutable("before-upload"),
|
|
2189
|
+
...syncImmutable,
|
|
2190
|
+
...verifyImmutable("after-upload"),
|
|
2191
|
+
...mutableSync,
|
|
2192
|
+
...publishFriendlyInstallers,
|
|
2193
|
+
...(binding.publicationFastPath
|
|
2194
|
+
? []
|
|
2195
|
+
: directoryIndexAliasOperations({ surfaceArtifactRoot, bucket, binding })),
|
|
2196
|
+
{
|
|
2197
|
+
action: "write-deployment-manifest",
|
|
2198
|
+
surface: binding.surface,
|
|
2199
|
+
command: "aws",
|
|
2200
|
+
args: [
|
|
2201
|
+
"s3",
|
|
2202
|
+
"cp",
|
|
2203
|
+
"-",
|
|
2204
|
+
s3Uri(bucket, binding.manifestKey),
|
|
2205
|
+
"--content-type",
|
|
2206
|
+
"application/json",
|
|
2207
|
+
...(binding.cacheControl?.mutable
|
|
2208
|
+
? ["--cache-control", binding.cacheControl.mutable]
|
|
2209
|
+
: []),
|
|
2210
|
+
],
|
|
2211
|
+
stdin: `${JSON.stringify({
|
|
2212
|
+
...manifest,
|
|
2213
|
+
surface: binding.surface,
|
|
2214
|
+
url: binding.url,
|
|
2215
|
+
surfaceBinding: binding,
|
|
2216
|
+
}, null, 2)}\n`,
|
|
2217
|
+
},
|
|
2218
|
+
];
|
|
2219
|
+
if (distribution) {
|
|
2220
|
+
const invalidationPaths = binding.publicationFastPath?.invalidationPaths
|
|
2221
|
+
|| [viewerWildcardPath(binding)];
|
|
2222
|
+
operations.push({
|
|
2223
|
+
action: "invalidate-cdn",
|
|
2224
|
+
surface: binding.surface,
|
|
2225
|
+
command: "aws",
|
|
2226
|
+
args: [
|
|
2227
|
+
"cloudfront",
|
|
2228
|
+
"create-invalidation",
|
|
2229
|
+
"--distribution-id",
|
|
2230
|
+
distribution,
|
|
2231
|
+
"--paths",
|
|
2232
|
+
...invalidationPaths,
|
|
2233
|
+
cdnPath(binding.manifestKey),
|
|
2234
|
+
],
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
return operations;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
function planAdapterSteps(adapter, deployConfig, manifest) {
|
|
2241
|
+
if (adapter === "aws-s3-cloudfront") {
|
|
2242
|
+
const bindingSteps = manifest.surfaceBindings.flatMap((binding) => [
|
|
2243
|
+
...(binding.immutablePublication
|
|
2244
|
+
? [
|
|
2245
|
+
{
|
|
2246
|
+
action: "verify-immutable-artifact-before-upload",
|
|
2247
|
+
surface: binding.surface,
|
|
2248
|
+
fileCount: binding.immutablePublication.files.length,
|
|
2249
|
+
},
|
|
2250
|
+
{
|
|
2251
|
+
action: "sync-immutable-artifact",
|
|
2252
|
+
surface: binding.surface,
|
|
2253
|
+
roots: binding.immutablePublication.uploadRoots,
|
|
2254
|
+
overwrite: false,
|
|
2255
|
+
},
|
|
2256
|
+
{
|
|
2257
|
+
action: "verify-immutable-artifact-after-upload",
|
|
2258
|
+
surface: binding.surface,
|
|
2259
|
+
fileCount: binding.immutablePublication.files.length,
|
|
2260
|
+
},
|
|
2261
|
+
]
|
|
2262
|
+
: []),
|
|
2263
|
+
...(binding.publicationFastPath
|
|
2264
|
+
? binding.publicationFastPath.mutableFiles.map((file) => ({
|
|
2265
|
+
action: "sync-publication-fast-path",
|
|
2266
|
+
surface: binding.surface,
|
|
2267
|
+
target: binding.bucket,
|
|
2268
|
+
path: file,
|
|
2269
|
+
qualificationRoot: binding.publicationFastPath.qualificationRoot,
|
|
2270
|
+
}))
|
|
2271
|
+
: [{
|
|
2272
|
+
action: "sync-static-artifact",
|
|
2273
|
+
surface: binding.surface,
|
|
2274
|
+
target: binding.bucket,
|
|
2275
|
+
prefix: binding.objectPrefix,
|
|
2276
|
+
deleteExcludes: binding.mutableDeleteExcludes || [],
|
|
2277
|
+
cacheControl: binding.cacheControl || undefined,
|
|
2278
|
+
},
|
|
2279
|
+
...(binding.cacheControl?.mutable
|
|
2280
|
+
? [{
|
|
2281
|
+
action: "apply-mutable-cache-control",
|
|
2282
|
+
surface: binding.surface,
|
|
2283
|
+
cacheControl: binding.cacheControl.mutable,
|
|
2284
|
+
patterns: ["*.html", "*.json", "*.xml"],
|
|
2285
|
+
excludes: binding.mutableDeleteExcludes || [],
|
|
2286
|
+
}]
|
|
2287
|
+
: []),
|
|
2288
|
+
]),
|
|
2289
|
+
{
|
|
2290
|
+
action: "write-deployment-manifest",
|
|
2291
|
+
surface: binding.surface,
|
|
2292
|
+
target: manifestPrefixFor(deployConfig),
|
|
2293
|
+
key: binding.manifestKey,
|
|
2294
|
+
},
|
|
2295
|
+
{
|
|
2296
|
+
action: "invalidate-cdn",
|
|
2297
|
+
surface: binding.surface,
|
|
2298
|
+
distribution: binding.distributionId,
|
|
2299
|
+
paths: binding.publicationFastPath?.invalidationPaths,
|
|
2300
|
+
},
|
|
2301
|
+
]);
|
|
2302
|
+
return [
|
|
2303
|
+
...bindingSteps.filter((step) => step.action === "verify-immutable-artifact-before-upload"),
|
|
2304
|
+
...bindingSteps.filter((step) => step.action === "sync-immutable-artifact"),
|
|
2305
|
+
...bindingSteps.filter((step) => step.action === "verify-immutable-artifact-after-upload"),
|
|
2306
|
+
...cloudFrontDirectoryIndexRewriteOperations(
|
|
2307
|
+
(manifest.surfaceBindings || []).filter((binding) => !binding.publicationFastPath),
|
|
2308
|
+
).map((operation) => ({
|
|
2309
|
+
action: operation.action,
|
|
2310
|
+
distribution: operation.routing.distributionId,
|
|
2311
|
+
functionName: operation.routing.functionName,
|
|
2312
|
+
strategy: operation.routing.strategy,
|
|
2313
|
+
})),
|
|
2314
|
+
...bindingSteps.filter((step) => ![
|
|
2315
|
+
"verify-immutable-artifact-before-upload",
|
|
2316
|
+
"sync-immutable-artifact",
|
|
2317
|
+
"verify-immutable-artifact-after-upload",
|
|
2318
|
+
].includes(step.action)),
|
|
2319
|
+
];
|
|
2320
|
+
}
|
|
2321
|
+
return [
|
|
2322
|
+
{
|
|
2323
|
+
action: "prepare-dynamic-environment",
|
|
2324
|
+
target: manifest.deployTarget,
|
|
2325
|
+
},
|
|
2326
|
+
{
|
|
2327
|
+
action: "write-deployment-manifest",
|
|
2328
|
+
target: manifestPrefixFor(deployConfig),
|
|
2329
|
+
},
|
|
2330
|
+
];
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
export function planWebSurfaceCleanup({
|
|
2334
|
+
cwd = process.cwd(),
|
|
2335
|
+
aliases = [],
|
|
2336
|
+
channel = "preview",
|
|
2337
|
+
now = new Date().toISOString(),
|
|
2338
|
+
event = "manual",
|
|
2339
|
+
sourceSha = "",
|
|
2340
|
+
pullNumber = "",
|
|
2341
|
+
actor = "",
|
|
2342
|
+
runId = "",
|
|
2343
|
+
dryRun = true,
|
|
2344
|
+
} = {}) {
|
|
2345
|
+
const loadedConfig = loadBuildchainConfig(cwd);
|
|
2346
|
+
const config = assertWebSurfaceConfig(loadedConfig);
|
|
2347
|
+
if (channel !== "preview") {
|
|
2348
|
+
throw new Error("web-surface cleanup currently supports preview aliases only");
|
|
2349
|
+
}
|
|
2350
|
+
const deployConfig = config.deploy?.[channel];
|
|
2351
|
+
if (!deployConfig) {
|
|
2352
|
+
throw new Error(`missing deploy.${channel}`);
|
|
2353
|
+
}
|
|
2354
|
+
const requestedAliases = [...aliases];
|
|
2355
|
+
if (requestedAliases.length === 0 && pullNumber) {
|
|
2356
|
+
requestedAliases.push(`pr-${pullNumber}`);
|
|
2357
|
+
}
|
|
2358
|
+
const manifestPrefix = manifestPrefixFor(deployConfig);
|
|
2359
|
+
const bindingsByAlias = new Map(requestedAliases.map((alias) => [
|
|
2360
|
+
alias,
|
|
2361
|
+
resolveSurfaceBindings({ config, channelName: channel, alias, deployConfig }),
|
|
2362
|
+
]));
|
|
2363
|
+
return {
|
|
2364
|
+
schemaVersion: 1,
|
|
2365
|
+
contract: "kungfu-buildchain-web-surface-cleanup-plan",
|
|
2366
|
+
dryRun,
|
|
2367
|
+
applyMode: dryRun ? "dry-run" : "apply",
|
|
2368
|
+
event,
|
|
2369
|
+
channel,
|
|
2370
|
+
now,
|
|
2371
|
+
sourceSha: sourceSha ? assertSha(sourceSha, "sourceSha") : "",
|
|
2372
|
+
pullNumber: pullNumber ? String(pullNumber) : "",
|
|
2373
|
+
actor,
|
|
2374
|
+
runId,
|
|
2375
|
+
status: requestedAliases.length === 0 ? "no-op" : "planned",
|
|
2376
|
+
adapter: deployConfig.adapter,
|
|
2377
|
+
target: deployConfig.bucket || deployConfig.target || "",
|
|
2378
|
+
manifestPrefix,
|
|
2379
|
+
secretRefs: [...new Set([...(deployConfig.secretRefs || [])])],
|
|
2380
|
+
entries: requestedAliases.map((alias) => {
|
|
2381
|
+
const classified = classifyPreviewAlias(alias);
|
|
2382
|
+
const retention = retentionConfig(config, "preview");
|
|
2383
|
+
const surfaceBindings = bindingsByAlias.get(alias) || [];
|
|
2384
|
+
const primaryBinding = surfaceBindings[0] || {};
|
|
2385
|
+
const objectPrefix = primaryBinding.objectPrefix || objectPrefixFor(deployConfig, alias);
|
|
2386
|
+
return {
|
|
2387
|
+
alias,
|
|
2388
|
+
aliasKind: classified.kind,
|
|
2389
|
+
mutableAlias: classified.mutable,
|
|
2390
|
+
retentionClass: classified.retentionClass,
|
|
2391
|
+
retentionDays: retention[classified.retentionKey],
|
|
2392
|
+
action: "delete-preview-alias",
|
|
2393
|
+
objectPrefix,
|
|
2394
|
+
manifestKey: primaryBinding.manifestKey || `${manifestPrefix.replace(/\/$/, "")}/${alias}.json`,
|
|
2395
|
+
surfaceBindings,
|
|
2396
|
+
steps: cleanupAdapterSteps(deployConfig.adapter, deployConfig, {
|
|
2397
|
+
alias,
|
|
2398
|
+
objectPrefix,
|
|
2399
|
+
manifestPrefix,
|
|
2400
|
+
surfaceBindings,
|
|
2401
|
+
}),
|
|
2402
|
+
};
|
|
2403
|
+
}),
|
|
2404
|
+
};
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
export function applyWebSurfaceCleanup({
|
|
2408
|
+
cwd = process.cwd(),
|
|
2409
|
+
aliases = [],
|
|
2410
|
+
channel = "preview",
|
|
2411
|
+
now = new Date().toISOString(),
|
|
2412
|
+
event = "manual",
|
|
2413
|
+
sourceSha = "",
|
|
2414
|
+
pullNumber = "",
|
|
2415
|
+
actor = "",
|
|
2416
|
+
runId = "",
|
|
2417
|
+
plan = null,
|
|
2418
|
+
dryRun = true,
|
|
2419
|
+
commandRunner = defaultCommandRunner,
|
|
2420
|
+
} = {}) {
|
|
2421
|
+
const cleanup = plan
|
|
2422
|
+
? assertCleanupPlan(plan)
|
|
2423
|
+
: planWebSurfaceCleanup({
|
|
2424
|
+
cwd,
|
|
2425
|
+
aliases,
|
|
2426
|
+
channel,
|
|
2427
|
+
now,
|
|
2428
|
+
event,
|
|
2429
|
+
sourceSha,
|
|
2430
|
+
pullNumber,
|
|
2431
|
+
actor,
|
|
2432
|
+
runId,
|
|
2433
|
+
dryRun,
|
|
2434
|
+
});
|
|
2435
|
+
const loadedConfig = loadBuildchainConfig(cwd);
|
|
2436
|
+
const config = assertWebSurfaceConfig(loadedConfig);
|
|
2437
|
+
const deployConfig = config.deploy?.[cleanup.channel];
|
|
2438
|
+
if (!deployConfig) {
|
|
2439
|
+
throw new Error(`missing deploy.${cleanup.channel}`);
|
|
2440
|
+
}
|
|
2441
|
+
if (cleanup.adapter !== "aws-s3-cloudfront") {
|
|
2442
|
+
throw new Error(`web-surface cleanup apply does not support adapter: ${cleanup.adapter}`);
|
|
2443
|
+
}
|
|
2444
|
+
if (!dryRun) {
|
|
2445
|
+
for (const entry of cleanup.entries) {
|
|
2446
|
+
const bindings = entry.surfaceBindings?.length
|
|
2447
|
+
? entry.surfaceBindings
|
|
2448
|
+
: [{
|
|
2449
|
+
surface: "default",
|
|
2450
|
+
}];
|
|
2451
|
+
for (const binding of bindings) {
|
|
2452
|
+
assertConcreteAwsDeployConfig({
|
|
2453
|
+
deployConfig: surfaceDeployConfig(deployConfig, binding.surface),
|
|
2454
|
+
channel: `${cleanup.channel}.surfaces.${binding.surface}`,
|
|
2455
|
+
operation: "cleanup",
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
const bucket = deployConfig.bucket || deployConfig.target || "";
|
|
2461
|
+
const operations = cleanup.entries.flatMap((entry) => cleanupEntryOperations({ deployConfig, entry, bucket }));
|
|
2462
|
+
const operationResults = runAdapterOperations({ operations, dryRun, commandRunner });
|
|
2463
|
+
return {
|
|
2464
|
+
schemaVersion: 1,
|
|
2465
|
+
contract: "kungfu-buildchain-web-surface-cleanup-apply",
|
|
2466
|
+
dryRun,
|
|
2467
|
+
applyMode: dryRun ? "dry-run" : "apply",
|
|
2468
|
+
status: appliedStatus({ dryRun, operations: operationResults, noOp: cleanup.status === "no-op" }),
|
|
2469
|
+
event,
|
|
2470
|
+
channel,
|
|
2471
|
+
now,
|
|
2472
|
+
sourceSha: cleanup.sourceSha,
|
|
2473
|
+
pullNumber: cleanup.pullNumber,
|
|
2474
|
+
actor,
|
|
2475
|
+
runId,
|
|
2476
|
+
adapter: cleanup.adapter,
|
|
2477
|
+
target: bucket,
|
|
2478
|
+
manifestPrefix: cleanup.manifestPrefix,
|
|
2479
|
+
entries: cleanup.entries,
|
|
2480
|
+
operations: operationResults,
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
function cleanupEntryOperations({ deployConfig, entry, bucket }) {
|
|
2485
|
+
const bindings = entry.surfaceBindings?.length
|
|
2486
|
+
? entry.surfaceBindings
|
|
2487
|
+
: [{
|
|
2488
|
+
surface: "default",
|
|
2489
|
+
objectPrefix: entry.objectPrefix,
|
|
2490
|
+
manifestKey: entry.manifestKey,
|
|
2491
|
+
bucket,
|
|
2492
|
+
distributionId: deployConfig.cloudfront_distribution || deployConfig.distribution || "",
|
|
2493
|
+
}];
|
|
2494
|
+
return bindings.flatMap((binding) => {
|
|
2495
|
+
const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
|
|
2496
|
+
const bindingBucket = binding.bucket || effectiveDeploy.bucket || effectiveDeploy.target || bucket;
|
|
2497
|
+
const distribution = binding.distributionId || effectiveDeploy.cloudfront_distribution || effectiveDeploy.distribution || "";
|
|
2498
|
+
const entryOperations = [
|
|
2499
|
+
{
|
|
2500
|
+
action: "delete-static-prefix",
|
|
2501
|
+
alias: entry.alias,
|
|
2502
|
+
surface: binding.surface,
|
|
2503
|
+
command: "aws",
|
|
2504
|
+
args: ["s3", "rm", s3Uri(bindingBucket, binding.objectPrefix), "--recursive"],
|
|
2505
|
+
},
|
|
2506
|
+
{
|
|
2507
|
+
action: "delete-deployment-manifest",
|
|
2508
|
+
alias: entry.alias,
|
|
2509
|
+
surface: binding.surface,
|
|
2510
|
+
command: "aws",
|
|
2511
|
+
args: ["s3", "rm", s3Uri(bindingBucket, binding.manifestKey)],
|
|
2512
|
+
},
|
|
2513
|
+
];
|
|
2514
|
+
if (distribution) {
|
|
2515
|
+
entryOperations.push({
|
|
2516
|
+
action: "invalidate-cdn",
|
|
2517
|
+
alias: entry.alias,
|
|
2518
|
+
surface: binding.surface,
|
|
2519
|
+
command: "aws",
|
|
2520
|
+
args: [
|
|
2521
|
+
"cloudfront",
|
|
2522
|
+
"create-invalidation",
|
|
2523
|
+
"--distribution-id",
|
|
2524
|
+
distribution,
|
|
2525
|
+
"--paths",
|
|
2526
|
+
viewerWildcardPath(binding),
|
|
2527
|
+
cdnPath(binding.manifestKey),
|
|
2528
|
+
],
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
return entryOperations;
|
|
2532
|
+
});
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
function cleanupAdapterSteps(adapter, deployConfig, entry) {
|
|
2536
|
+
if (adapter === "aws-s3-cloudfront") {
|
|
2537
|
+
const bindings = entry.surfaceBindings?.length
|
|
2538
|
+
? entry.surfaceBindings
|
|
2539
|
+
: [{
|
|
2540
|
+
surface: "default",
|
|
2541
|
+
objectPrefix: entry.objectPrefix,
|
|
2542
|
+
manifestKey: `${entry.manifestPrefix.replace(/\/$/, "")}/${entry.alias}.json`,
|
|
2543
|
+
bucket: deployConfig.bucket || deployConfig.target || "",
|
|
2544
|
+
distributionId: deployConfig.cloudfront_distribution || deployConfig.distribution || "",
|
|
2545
|
+
}];
|
|
2546
|
+
return bindings.flatMap((binding) => [
|
|
2547
|
+
{
|
|
2548
|
+
action: "delete-static-prefix",
|
|
2549
|
+
surface: binding.surface,
|
|
2550
|
+
target: binding.bucket,
|
|
2551
|
+
prefix: binding.objectPrefix,
|
|
2552
|
+
},
|
|
2553
|
+
{
|
|
2554
|
+
action: "delete-deployment-manifest",
|
|
2555
|
+
surface: binding.surface,
|
|
2556
|
+
target: entry.manifestPrefix,
|
|
2557
|
+
key: binding.manifestKey,
|
|
2558
|
+
},
|
|
2559
|
+
{
|
|
2560
|
+
action: "invalidate-cdn",
|
|
2561
|
+
surface: binding.surface,
|
|
2562
|
+
distribution: binding.distributionId,
|
|
2563
|
+
},
|
|
2564
|
+
]);
|
|
2565
|
+
}
|
|
2566
|
+
return [
|
|
2567
|
+
{
|
|
2568
|
+
action: "delete-preview-environment",
|
|
2569
|
+
target: deployConfig.environment || deployConfig.service || deployConfig.target || "",
|
|
2570
|
+
alias: entry.alias,
|
|
2571
|
+
},
|
|
2572
|
+
{
|
|
2573
|
+
action: "delete-deployment-manifest",
|
|
2574
|
+
target: entry.manifestPrefix,
|
|
2575
|
+
key: `${entry.manifestPrefix.replace(/\/$/, "")}/${entry.alias}.json`,
|
|
2576
|
+
},
|
|
2577
|
+
];
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
export function defaultWebSurfaceAlias({ channel = "preview", sourceSha = "", pullNumber = "" } = {}) {
|
|
2581
|
+
if (channel !== "preview") {
|
|
2582
|
+
return "";
|
|
2583
|
+
}
|
|
2584
|
+
if (pullNumber) {
|
|
2585
|
+
return `pr-${pullNumber}`;
|
|
2586
|
+
}
|
|
2587
|
+
const sha = assertSha(sourceSha, "sourceSha");
|
|
2588
|
+
return `sha-${sha.slice(0, 12)}`;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
export function localWebSurfaceContext() {
|
|
2592
|
+
return {
|
|
2593
|
+
sourceSha: process.env.BUILDCHAIN_SOURCE_SHA || process.env.GITHUB_SHA || "",
|
|
2594
|
+
sourceRef: process.env.BUILDCHAIN_SOURCE_REF || process.env.GITHUB_REF || "",
|
|
2595
|
+
repository: process.env.GITHUB_REPOSITORY || "",
|
|
2596
|
+
runId: process.env.GITHUB_RUN_ID || "",
|
|
2597
|
+
runAttempt: process.env.GITHUB_RUN_ATTEMPT || "",
|
|
2598
|
+
runner: {
|
|
2599
|
+
os: process.env.RUNNER_OS || os.platform(),
|
|
2600
|
+
arch: process.env.RUNNER_ARCH || os.arch(),
|
|
2601
|
+
},
|
|
2602
|
+
};
|
|
2603
|
+
}
|