@intentius/chant 0.124.27 → 0.124.29
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/README.md +1 -1
- package/dist/__golden__/wave-loop/fan-out-gated.json +8 -0
- package/dist/__golden__/wave-loop/fan-out-no-members.json +4 -0
- package/dist/__golden__/wave-loop/fan-out-only.json +6 -0
- package/dist/__golden__/wave-loop/op-by-apply-hold.json +2 -0
- package/dist/__golden__/wave-loop/op-cost-member.json +3 -0
- package/dist/__golden__/wave-loop/op-held-on-before-apply.json +1 -0
- package/dist/__golden__/wave-loop/op-held-on.json +2 -0
- package/dist/__golden__/wave-loop/op-hooks-held.json +2 -0
- package/dist/__golden__/wave-loop/op-hooks-hold-before-apply.json +2 -0
- package/dist/__golden__/wave-loop/op-hooks-refused-at-base.json +3 -0
- package/dist/__golden__/wave-loop/op-hooks-share.json +3 -0
- package/dist/__golden__/wave-loop/op-per-run.json +7 -0
- package/dist/__golden__/wave-loop/op-pr-review.json +7 -0
- package/dist/__golden__/wave-loop/op-sealed.json +3 -0
- package/dist/__golden__/wave-loop/op-spend.json +3 -0
- package/dist/__golden__/wave-loop/op-wave-commands.json +7 -0
- package/dist/__golden__/wave-loop/op-wide-waiting.json +4 -0
- package/dist/build-params.d.ts +34 -1
- package/dist/build-params.d.ts.map +1 -1
- package/dist/build-params.js +31 -1
- package/dist/change-set-graph.d.ts +63 -0
- package/dist/change-set-graph.d.ts.map +1 -0
- package/dist/change-set-graph.js +130 -0
- package/dist/change-set.d.ts +62 -3
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +36 -4
- package/dist/chant-version.d.ts +9 -0
- package/dist/chant-version.d.ts.map +1 -0
- package/dist/chant-version.js +16 -0
- package/dist/cli/build-params-cli.d.ts +7 -1
- package/dist/cli/build-params-cli.d.ts.map +1 -1
- package/dist/cli/build-params-cli.js +17 -8
- package/dist/cli/commands/build.d.ts +8 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +15 -11
- package/dist/cli/commands/check-lexicon-docs.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon-docs.js +30 -2
- package/dist/cli/commands/check-lexicon.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon.js +13 -2
- package/dist/cli/commands/init-lexicon/templates/docs.d.ts +4 -1
- package/dist/cli/commands/init-lexicon/templates/docs.d.ts.map +1 -1
- package/dist/cli/commands/init-lexicon/templates/docs.js +6 -6
- package/dist/cli/commands/init-lexicon.d.ts.map +1 -1
- package/dist/cli/commands/init-lexicon.js +17 -8
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +64 -4
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +43 -4
- package/dist/cli/handlers/change-set.d.ts +10 -0
- package/dist/cli/handlers/change-set.d.ts.map +1 -1
- package/dist/cli/handlers/change-set.js +51 -1
- package/dist/cli/handlers/fan-out.d.ts +10 -1
- package/dist/cli/handlers/fan-out.d.ts.map +1 -1
- package/dist/cli/handlers/fan-out.js +54 -6
- package/dist/cli/handlers/lifecycle-gc.d.ts +19 -0
- package/dist/cli/handlers/lifecycle-gc.d.ts.map +1 -0
- package/dist/cli/handlers/lifecycle-gc.js +143 -0
- package/dist/cli/handlers/pr.d.ts +16 -2
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +269 -37
- package/dist/cli/handlers/promote.d.ts +7 -0
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +440 -28
- package/dist/cli/handlers/release.d.ts +91 -0
- package/dist/cli/handlers/release.d.ts.map +1 -0
- package/dist/cli/handlers/release.js +589 -0
- package/dist/cli/handlers/run.d.ts +38 -2
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +234 -16
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +143 -17
- package/dist/cli/mcp/workspace-tools.js +1 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +73 -5
- package/dist/cli/registry.d.ts +43 -5
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cli/run-events.d.ts +30 -0
- package/dist/cli/run-events.d.ts.map +1 -0
- package/dist/cli/run-events.js +49 -0
- package/dist/cli/version.d.ts +3 -5
- package/dist/cli/version.d.ts.map +1 -1
- package/dist/cli/version.js +3 -13
- package/dist/codegen/docs-in-site.d.ts +71 -0
- package/dist/codegen/docs-in-site.d.ts.map +1 -0
- package/dist/codegen/docs-in-site.js +177 -0
- package/dist/codegen/docs-types.d.ts +14 -1
- package/dist/codegen/docs-types.d.ts.map +1 -1
- package/dist/codegen/docs.d.ts +18 -1
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/codegen/docs.js +40 -7
- package/dist/codegen/rehype-base-url.mjs +15 -9
- package/dist/components/auto-release.d.ts +6 -1
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +3 -0
- package/dist/components/capability.d.ts +9 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/cli-support.d.ts +6 -0
- package/dist/components/cli-support.d.ts.map +1 -1
- package/dist/components/cli-support.js +10 -9
- package/dist/components/driver.d.ts +50 -9
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +116 -54
- package/dist/components/fan-out-inputs.d.ts +69 -0
- package/dist/components/fan-out-inputs.d.ts.map +1 -0
- package/dist/components/fan-out-inputs.js +169 -0
- package/dist/components/fan-out-record.d.ts +13 -0
- package/dist/components/fan-out-record.d.ts.map +1 -1
- package/dist/components/fan-out-record.js +16 -0
- package/dist/components/fan-out-run.d.ts +7 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +85 -26
- package/dist/components/fan-out.d.ts +4 -0
- package/dist/components/fan-out.d.ts.map +1 -1
- package/dist/components/pr-pipeline.d.ts +25 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +22 -4
- package/dist/components/pr-run.d.ts +11 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +20 -1
- package/dist/components/promote-order.d.ts +38 -0
- package/dist/components/promote-order.d.ts.map +1 -0
- package/dist/components/promote-order.js +62 -0
- package/dist/components/promote.d.ts +38 -2
- package/dist/components/promote.d.ts.map +1 -1
- package/dist/components/promote.js +77 -2
- package/dist/components/release-compile.d.ts +142 -0
- package/dist/components/release-compile.d.ts.map +1 -0
- package/dist/components/release-compile.js +382 -0
- package/dist/components/release-gate.d.ts +135 -0
- package/dist/components/release-gate.d.ts.map +1 -0
- package/dist/components/release-gate.js +288 -0
- package/dist/components/release-promote.d.ts +96 -0
- package/dist/components/release-promote.d.ts.map +1 -0
- package/dist/components/release-promote.js +204 -0
- package/dist/components/run-progress.d.ts +7 -0
- package/dist/components/run-progress.d.ts.map +1 -1
- package/dist/components/wave-plan.d.ts +8 -1
- package/dist/components/wave-plan.d.ts.map +1 -1
- package/dist/components/wave-plan.js +11 -3
- package/dist/config.d.ts +45 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -0
- package/dist/flag-params.d.ts +54 -0
- package/dist/flag-params.d.ts.map +1 -0
- package/dist/flag-params.js +130 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +120 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +304 -0
- package/dist/lifecycle/change-set-store.d.ts +68 -0
- package/dist/lifecycle/change-set-store.d.ts.map +1 -0
- package/dist/lifecycle/change-set-store.js +97 -0
- package/dist/lifecycle/commit-sha.d.ts +13 -0
- package/dist/lifecycle/commit-sha.d.ts.map +1 -0
- package/dist/lifecycle/commit-sha.js +21 -0
- package/dist/lifecycle/delivery-metrics.d.ts +139 -0
- package/dist/lifecycle/delivery-metrics.d.ts.map +1 -0
- package/dist/lifecycle/delivery-metrics.js +145 -0
- package/dist/lifecycle/deploy-outcome.d.ts +81 -0
- package/dist/lifecycle/deploy-outcome.d.ts.map +1 -0
- package/dist/lifecycle/deploy-outcome.js +101 -0
- package/dist/lifecycle/gate-change-set.d.ts +78 -0
- package/dist/lifecycle/gate-change-set.d.ts.map +1 -0
- package/dist/lifecycle/gate-change-set.js +138 -0
- package/dist/lifecycle/gate-ledger.d.ts +51 -4
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +18 -0
- package/dist/lifecycle/git.d.ts +30 -1
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +31 -5
- package/dist/lifecycle/index.d.ts +4 -0
- package/dist/lifecycle/index.d.ts.map +1 -1
- package/dist/lifecycle/index.js +4 -0
- package/dist/lifecycle/mixed-environment.d.ts +95 -0
- package/dist/lifecycle/mixed-environment.d.ts.map +1 -0
- package/dist/lifecycle/mixed-environment.js +154 -0
- package/dist/lifecycle/publish-attachments.d.ts +79 -0
- package/dist/lifecycle/publish-attachments.d.ts.map +1 -0
- package/dist/lifecycle/publish-attachments.js +179 -0
- package/dist/lifecycle/publish-credentials.d.ts +37 -0
- package/dist/lifecycle/publish-credentials.d.ts.map +1 -0
- package/dist/lifecycle/publish-credentials.js +69 -0
- package/dist/lifecycle/publish-declaration.d.ts +97 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -0
- package/dist/lifecycle/publish-declaration.js +83 -0
- package/dist/lifecycle/publish-forge.d.ts +53 -0
- package/dist/lifecycle/publish-forge.d.ts.map +1 -0
- package/dist/lifecycle/publish-forge.js +298 -0
- package/dist/lifecycle/publish-npm.d.ts +61 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -0
- package/dist/lifecycle/publish-npm.js +242 -0
- package/dist/lifecycle/publish-oci.d.ts +64 -0
- package/dist/lifecycle/publish-oci.d.ts.map +1 -0
- package/dist/lifecycle/publish-oci.js +383 -0
- package/dist/lifecycle/publish-record.d.ts +66 -0
- package/dist/lifecycle/publish-record.d.ts.map +1 -0
- package/dist/lifecycle/publish-record.js +84 -0
- package/dist/lifecycle/publish-targets.d.ts +45 -0
- package/dist/lifecycle/publish-targets.d.ts.map +1 -0
- package/dist/lifecycle/publish-targets.js +85 -0
- package/dist/lifecycle/release-cut.d.ts +154 -0
- package/dist/lifecycle/release-cut.d.ts.map +1 -0
- package/dist/lifecycle/release-cut.js +366 -0
- package/dist/lifecycle/release-join.d.ts +95 -0
- package/dist/lifecycle/release-join.d.ts.map +1 -0
- package/dist/lifecycle/release-join.js +139 -0
- package/dist/lifecycle/release-ledger.d.ts +54 -0
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +53 -20
- package/dist/lifecycle/release-publish.d.ts +312 -0
- package/dist/lifecycle/release-publish.d.ts.map +1 -0
- package/dist/lifecycle/release-publish.js +335 -0
- package/dist/lifecycle/release-revocation.d.ts +80 -0
- package/dist/lifecycle/release-revocation.d.ts.map +1 -0
- package/dist/lifecycle/release-revocation.js +123 -0
- package/dist/lifecycle/release-store.d.ts +200 -0
- package/dist/lifecycle/release-store.d.ts.map +1 -0
- package/dist/lifecycle/release-store.js +320 -0
- package/dist/lifecycle/release-verify.d.ts +61 -0
- package/dist/lifecycle/release-verify.d.ts.map +1 -0
- package/dist/lifecycle/release-verify.js +92 -0
- package/dist/lifecycle/release-workstation.d.ts +91 -0
- package/dist/lifecycle/release-workstation.d.ts.map +1 -0
- package/dist/lifecycle/release-workstation.js +180 -0
- package/dist/lifecycle/retention-policy.d.ts +45 -0
- package/dist/lifecycle/retention-policy.d.ts.map +1 -0
- package/dist/lifecycle/retention-policy.js +43 -0
- package/dist/lifecycle/retention.d.ts +185 -0
- package/dist/lifecycle/retention.d.ts.map +1 -0
- package/dist/lifecycle/retention.js +400 -0
- package/dist/lifecycle/run-ledger.d.ts +4 -0
- package/dist/lifecycle/run-ledger.d.ts.map +1 -1
- package/dist/lifecycle/run-ledger.js +2 -0
- package/dist/op/activities/change-coverage.d.ts.map +1 -1
- package/dist/op/activities/change-coverage.js +4 -2
- package/dist/op/activities/source-release.d.ts.map +1 -1
- package/dist/op/activities/source-release.js +7 -3
- package/dist/op/activities/source-rollback.d.ts.map +1 -1
- package/dist/op/activities/source-rollback.js +7 -3
- package/dist/op/gate-name.d.ts +11 -2
- package/dist/op/gate-name.d.ts.map +1 -1
- package/dist/op/gate-name.js +12 -3
- package/dist/op/gate-run-locator.d.ts +22 -0
- package/dist/op/gate-run-locator.d.ts.map +1 -1
- package/dist/op/gate-run-locator.js +31 -0
- package/dist/op/gate.d.ts +27 -3
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +57 -3
- package/dist/op/local-executor.d.ts +36 -1
- package/dist/op/local-executor.d.ts.map +1 -1
- package/dist/op/local-executor.js +158 -52
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +4 -0
- package/dist/op/run-live.d.ts +2 -0
- package/dist/op/run-live.d.ts.map +1 -1
- package/dist/op/run-live.js +1 -1
- package/dist/op/runtime.d.ts +46 -0
- package/dist/op/runtime.d.ts.map +1 -1
- package/dist/op/runtimes/local.d.ts.map +1 -1
- package/dist/op/runtimes/local.js +8 -0
- package/dist/plan-summary.d.ts.map +1 -1
- package/dist/plan-summary.js +8 -2
- package/dist/point-decision.d.ts +2 -0
- package/dist/point-decision.d.ts.map +1 -1
- package/dist/point-decision.js +9 -2
- package/dist/pr-loop.d.ts +7 -0
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +23 -4
- package/dist/pr-report-url.d.ts +82 -0
- package/dist/pr-report-url.d.ts.map +1 -0
- package/dist/pr-report-url.js +174 -0
- package/dist/provenance.d.ts +2 -2
- package/dist/provenance.d.ts.map +1 -1
- package/dist/run-event-store.d.ts +104 -0
- package/dist/run-event-store.d.ts.map +1 -0
- package/dist/run-event-store.js +251 -0
- package/dist/run-event-stream.d.ts +133 -0
- package/dist/run-event-stream.d.ts.map +1 -0
- package/dist/run-event-stream.js +242 -0
- package/dist/run-event.d.ts +285 -0
- package/dist/run-event.d.ts.map +1 -0
- package/dist/run-event.js +209 -0
- package/dist/wave-runtime.mjs +262 -226
- package/dist/workspace/__fixtures__/flag-workspace.d.ts +31 -0
- package/dist/workspace/__fixtures__/flag-workspace.d.ts.map +1 -0
- package/dist/workspace/__fixtures__/flag-workspace.js +114 -0
- package/dist/workspace/__fixtures__/run-event-check.d.ts +19 -0
- package/dist/workspace/__fixtures__/run-event-check.d.ts.map +1 -0
- package/dist/workspace/__fixtures__/run-event-check.js +59 -0
- package/dist/workspace/change-set-show.d.ts +56 -0
- package/dist/workspace/change-set-show.d.ts.map +1 -0
- package/dist/workspace/change-set-show.js +54 -0
- package/dist/workspace/change-set-show.schema.json +102 -0
- package/dist/workspace/change-set.schema.json +32 -1
- package/dist/workspace/changes-cli.d.ts.map +1 -1
- package/dist/workspace/changes-cli.js +10 -1
- package/dist/workspace/changes.d.ts +37 -0
- package/dist/workspace/changes.d.ts.map +1 -1
- package/dist/workspace/changes.js +49 -2
- package/dist/workspace/changes.schema.json +135 -0
- package/dist/workspace/check.schema.json +4 -2
- package/dist/workspace/checks/records.d.ts +9 -1
- package/dist/workspace/checks/records.d.ts.map +1 -1
- package/dist/workspace/checks/records.js +35 -1
- package/dist/workspace/checks.d.ts +1 -0
- package/dist/workspace/checks.d.ts.map +1 -1
- package/dist/workspace/checks.js +2 -1
- package/dist/workspace/ci-green-cli.d.ts +19 -4
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +75 -12
- package/dist/workspace/ci-green-forge.d.ts +20 -3
- package/dist/workspace/ci-green-forge.d.ts.map +1 -1
- package/dist/workspace/ci-green-forge.js +6 -4
- package/dist/workspace/ci-green-workflow.d.ts +11 -0
- package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
- package/dist/workspace/ci-green-workflow.js +6 -0
- package/dist/workspace/ci-green.d.ts +281 -13
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +456 -38
- package/dist/workspace/ci-last-green.schema.json +32 -2
- package/dist/workspace/ci-list.schema.json +525 -0
- package/dist/workspace/commit-links.d.ts +85 -0
- package/dist/workspace/commit-links.d.ts.map +1 -0
- package/dist/workspace/commit-links.js +163 -0
- package/dist/workspace/declaration.d.ts +35 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +27 -1
- package/dist/workspace/declaration.schema.json +76 -0
- package/dist/workspace/declared-kinds.d.ts +16 -0
- package/dist/workspace/declared-kinds.d.ts.map +1 -1
- package/dist/workspace/declared-kinds.js +25 -0
- package/dist/workspace/delivery-metrics.d.ts +91 -0
- package/dist/workspace/delivery-metrics.d.ts.map +1 -0
- package/dist/workspace/delivery-metrics.js +217 -0
- package/dist/workspace/delivery-metrics.schema.json +519 -0
- package/dist/workspace/flags-read.d.ts +37 -0
- package/dist/workspace/flags-read.d.ts.map +1 -0
- package/dist/workspace/flags-read.js +103 -0
- package/dist/workspace/flags.d.ts +100 -0
- package/dist/workspace/flags.d.ts.map +1 -0
- package/dist/workspace/flags.js +98 -0
- package/dist/workspace/graph-cli.js +1 -1
- package/dist/workspace/identity-gate-rule.d.ts +37 -0
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +72 -7
- package/dist/workspace/identity.d.ts +12 -0
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/identity.js +13 -1
- package/dist/workspace/intent-cli.d.ts +11 -2
- package/dist/workspace/intent-cli.d.ts.map +1 -1
- package/dist/workspace/intent-cli.js +54 -5
- package/dist/workspace/intent-trace.d.ts +219 -0
- package/dist/workspace/intent-trace.d.ts.map +1 -0
- package/dist/workspace/intent-trace.js +314 -0
- package/dist/workspace/intent.d.ts +36 -7
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +192 -22
- package/dist/workspace/intent.schema.json +702 -6
- package/dist/workspace/ls.d.ts +4 -0
- package/dist/workspace/ls.d.ts.map +1 -1
- package/dist/workspace/ls.js +2 -0
- package/dist/workspace/ls.schema.json +3 -1
- package/dist/workspace/member-pipeline.d.ts +6 -0
- package/dist/workspace/member-pipeline.d.ts.map +1 -1
- package/dist/workspace/member-pipeline.js +6 -0
- package/dist/workspace/overlap.d.ts +146 -0
- package/dist/workspace/overlap.d.ts.map +1 -0
- package/dist/workspace/overlap.js +276 -0
- package/dist/workspace/promotion-order.d.ts +41 -0
- package/dist/workspace/promotion-order.d.ts.map +1 -0
- package/dist/workspace/promotion-order.js +95 -0
- package/dist/workspace/reason-codes.d.ts +4 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +7 -1
- package/dist/workspace/records.d.ts +15 -2
- package/dist/workspace/records.d.ts.map +1 -1
- package/dist/workspace/records.js +32 -0
- package/dist/workspace/records.schema.json +21 -2
- package/dist/workspace/reference-kinds/flag/flag.kind.mjs +32 -0
- package/dist/workspace/reference-kinds/flag/flag.schema.json +53 -0
- package/dist/workspace/releases.d.ts +81 -0
- package/dist/workspace/releases.d.ts.map +1 -0
- package/dist/workspace/releases.js +103 -0
- package/dist/workspace/releases.schema.json +513 -0
- package/dist/workspace/run-event.schema.json +295 -0
- package/dist/workspace/status-gates.d.ts +34 -1
- package/dist/workspace/status-gates.d.ts.map +1 -1
- package/dist/workspace/status-gates.js +31 -2
- package/dist/workspace/status-stewards.d.ts +4 -0
- package/dist/workspace/status-stewards.d.ts.map +1 -1
- package/dist/workspace/status-stewards.js +2 -0
- package/dist/workspace/status.d.ts +117 -0
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/status.js +218 -4
- package/dist/workspace/status.schema.json +268 -2
- package/dist/workspace/trust/ci-tag-statement.d.ts +102 -0
- package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -0
- package/dist/workspace/trust/ci-tag-statement.js +123 -0
- package/dist/workspace/trust/op-run-statement.d.ts +91 -0
- package/dist/workspace/trust/op-run-statement.d.ts.map +1 -0
- package/dist/workspace/trust/op-run-statement.js +143 -0
- package/dist/workspace/trust/rotation.d.ts +18 -2
- package/dist/workspace/trust/rotation.d.ts.map +1 -1
- package/dist/workspace/trust/rotation.js +65 -16
- package/dist/workspace/trust/seal.d.ts +11 -0
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +9 -0
- package/dist/workspace/trust/ssh-commit.d.ts.map +1 -1
- package/dist/workspace/trust/ssh-commit.js +10 -10
- package/dist/workspace/wip.d.ts.map +1 -1
- package/dist/workspace/wip.js +11 -3
- package/package.json +1 -1
- package/src/__golden__/wave-loop/fan-out-gated.json +8 -0
- package/src/__golden__/wave-loop/fan-out-no-members.json +4 -0
- package/src/__golden__/wave-loop/fan-out-only.json +6 -0
- package/src/__golden__/wave-loop/op-by-apply-hold.json +2 -0
- package/src/__golden__/wave-loop/op-cost-member.json +3 -0
- package/src/__golden__/wave-loop/op-held-on-before-apply.json +1 -0
- package/src/__golden__/wave-loop/op-held-on.json +2 -0
- package/src/__golden__/wave-loop/op-hooks-held.json +2 -0
- package/src/__golden__/wave-loop/op-hooks-hold-before-apply.json +2 -0
- package/src/__golden__/wave-loop/op-hooks-refused-at-base.json +3 -0
- package/src/__golden__/wave-loop/op-hooks-share.json +3 -0
- package/src/__golden__/wave-loop/op-per-run.json +7 -0
- package/src/__golden__/wave-loop/op-pr-review.json +7 -0
- package/src/__golden__/wave-loop/op-sealed.json +3 -0
- package/src/__golden__/wave-loop/op-spend.json +3 -0
- package/src/__golden__/wave-loop/op-wave-commands.json +7 -0
- package/src/__golden__/wave-loop/op-wide-waiting.json +4 -0
- package/src/build-params.test.ts +46 -0
- package/src/build-params.ts +55 -1
- package/src/change-set-graph.test.ts +72 -0
- package/src/change-set-graph.ts +141 -0
- package/src/change-set.ts +87 -6
- package/src/chant-version.ts +16 -0
- package/src/cli/build-params-cli.ts +22 -9
- package/src/cli/commands/build.ts +25 -11
- package/src/cli/commands/check-lexicon-docs.test.ts +51 -0
- package/src/cli/commands/check-lexicon-docs.ts +39 -2
- package/src/cli/commands/check-lexicon.ts +14 -2
- package/src/cli/commands/init-lexicon/templates/docs.ts +7 -6
- package/src/cli/commands/init-lexicon.test.ts +25 -0
- package/src/cli/commands/init-lexicon.ts +18 -8
- package/src/cli/handlers/approve-release.test.ts +84 -0
- package/src/cli/handlers/approve-revoked.test.ts +155 -0
- package/src/cli/handlers/approve.ts +65 -2
- package/src/cli/handlers/build.test.ts +67 -0
- package/src/cli/handlers/build.ts +46 -4
- package/src/cli/handlers/change-set.ts +49 -1
- package/src/cli/handlers/fan-out.test.ts +228 -1
- package/src/cli/handlers/fan-out.ts +53 -6
- package/src/cli/handlers/intent-trace.e2e.test.ts +201 -0
- package/src/cli/handlers/lifecycle-gc.test.ts +126 -0
- package/src/cli/handlers/lifecycle-gc.ts +146 -0
- package/src/cli/handlers/operator.test.ts +37 -0
- package/src/cli/handlers/pr.test.ts +341 -0
- package/src/cli/handlers/pr.ts +292 -47
- package/src/cli/handlers/promote.test.ts +669 -7
- package/src/cli/handlers/promote.ts +464 -29
- package/src/cli/handlers/release-implicit.e2e.test.ts +161 -0
- package/src/cli/handlers/release-join.e2e.test.ts +185 -0
- package/src/cli/handlers/release-publish-targets.e2e.test.ts +295 -0
- package/src/cli/handlers/release-verify.e2e.test.ts +117 -0
- package/src/cli/handlers/release-workstation-ci.e2e.test.ts +135 -0
- package/src/cli/handlers/release.e2e.test.ts +199 -0
- package/src/cli/handlers/release.ts +593 -0
- package/src/cli/handlers/run-auto-release.test.ts +80 -0
- package/src/cli/handlers/run-events-cmd.test.ts +92 -0
- package/src/cli/handlers/run-release.test.ts +55 -0
- package/src/cli/handlers/run.test.ts +30 -0
- package/src/cli/handlers/run.ts +243 -18
- package/src/cli/main.test.ts +8 -0
- package/src/cli/main.ts +143 -17
- package/src/cli/mcp/never-over-mcp.test.ts +2 -0
- package/src/cli/mcp/workspace-tools.ts +1 -1
- package/src/cli/parse-args.ts +56 -5
- package/src/cli/registry.ts +43 -5
- package/src/cli/run-events.ts +57 -0
- package/src/cli/version.ts +3 -13
- package/src/codegen/docs-in-site.test.ts +166 -0
- package/src/codegen/docs-in-site.ts +182 -0
- package/src/codegen/docs-site/AgentPrompt.astro +26 -1
- package/src/codegen/docs-types.ts +14 -1
- package/src/codegen/docs.ts +60 -7
- package/src/codegen/rehype-base-url.d.mts +3 -1
- package/src/codegen/rehype-base-url.mjs +15 -9
- package/src/codegen/rehype-base-url.test.ts +34 -0
- package/src/components/auto-release.test.ts +30 -0
- package/src/components/auto-release.ts +9 -1
- package/src/components/capability.ts +9 -0
- package/src/components/cli-support.test.ts +82 -0
- package/src/components/cli-support.ts +16 -9
- package/src/components/driver.test.ts +24 -0
- package/src/components/driver.ts +165 -56
- package/src/components/fan-out-inputs.test.ts +85 -0
- package/src/components/fan-out-inputs.ts +192 -0
- package/src/components/fan-out-record.test.ts +10 -0
- package/src/components/fan-out-record.ts +19 -0
- package/src/components/fan-out-run.ts +104 -35
- package/src/components/fan-out.ts +4 -0
- package/src/components/pr-pipeline.ts +35 -4
- package/src/components/pr-run.ts +30 -1
- package/src/components/promote-order.test.ts +90 -0
- package/src/components/promote-order.ts +75 -0
- package/src/components/promote.test.ts +10 -1
- package/src/components/promote.ts +94 -3
- package/src/components/release-compile.test.ts +147 -0
- package/src/components/release-compile.ts +459 -0
- package/src/components/release-gate.test.ts +215 -0
- package/src/components/release-gate.ts +355 -0
- package/src/components/release-promote.test.ts +159 -0
- package/src/components/release-promote.ts +232 -0
- package/src/components/run-progress.ts +7 -0
- package/src/components/wave-plan.ts +16 -3
- package/src/config.ts +15 -1
- package/src/flag-params.test.ts +144 -0
- package/src/flag-params.ts +134 -0
- package/src/index.ts +2 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +351 -0
- package/src/lifecycle/change-set-store.test.ts +217 -0
- package/src/lifecycle/change-set-store.ts +113 -0
- package/src/lifecycle/commit-sha.ts +23 -0
- package/src/lifecycle/delivery-metrics.ts +263 -0
- package/src/lifecycle/deploy-outcome.ts +147 -0
- package/src/lifecycle/gate-change-set.e2e.test.ts +122 -0
- package/src/lifecycle/gate-change-set.ts +164 -0
- package/src/lifecycle/gate-ledger.test.ts +33 -0
- package/src/lifecycle/gate-ledger.ts +68 -3
- package/src/lifecycle/git.ts +61 -8
- package/src/lifecycle/index.ts +4 -0
- package/src/lifecycle/mixed-environment.test.ts +97 -0
- package/src/lifecycle/mixed-environment.ts +204 -0
- package/src/lifecycle/publish-attachments.ts +196 -0
- package/src/lifecycle/publish-credentials.ts +84 -0
- package/src/lifecycle/publish-declaration.ts +95 -0
- package/src/lifecycle/publish-forge.ts +325 -0
- package/src/lifecycle/publish-npm.ts +259 -0
- package/src/lifecycle/publish-oci.ts +396 -0
- package/src/lifecycle/publish-record.ts +113 -0
- package/src/lifecycle/publish-resume.test.ts +168 -0
- package/src/lifecycle/publish-targets.test.ts +494 -0
- package/src/lifecycle/publish-targets.ts +100 -0
- package/src/lifecycle/release-cut-signed.test.ts +180 -0
- package/src/lifecycle/release-cut.test.ts +483 -0
- package/src/lifecycle/release-cut.ts +503 -0
- package/src/lifecycle/release-flag.test.ts +112 -0
- package/src/lifecycle/release-join.test.ts +68 -0
- package/src/lifecycle/release-join.ts +182 -0
- package/src/lifecycle/release-ledger.test.ts +14 -0
- package/src/lifecycle/release-ledger.ts +85 -17
- package/src/lifecycle/release-publish.test.ts +225 -0
- package/src/lifecycle/release-publish.ts +568 -0
- package/src/lifecycle/release-revocation.ts +147 -0
- package/src/lifecycle/release-store.ts +434 -0
- package/src/lifecycle/release-verify.test.ts +110 -0
- package/src/lifecycle/release-verify.ts +120 -0
- package/src/lifecycle/release-workstation.test.ts +204 -0
- package/src/lifecycle/release-workstation.ts +216 -0
- package/src/lifecycle/retention-growth.e2e.test.ts +279 -0
- package/src/lifecycle/retention-policy.ts +63 -0
- package/src/lifecycle/retention.test.ts +363 -0
- package/src/lifecycle/retention.ts +508 -0
- package/src/lifecycle/run-ledger.test.ts +10 -0
- package/src/lifecycle/run-ledger.ts +6 -0
- package/src/op/activities/change-coverage.ts +4 -1
- package/src/op/activities/source-release.ts +8 -3
- package/src/op/activities/source-rollback.ts +8 -4
- package/src/op/commit-run-gate-deploy-join.test.ts +117 -0
- package/src/op/gate-name.ts +13 -3
- package/src/op/gate-release.test.ts +126 -0
- package/src/op/gate-run-locator.test.ts +110 -0
- package/src/op/gate-run-locator.ts +35 -0
- package/src/op/gate.ts +88 -6
- package/src/op/local-executor.ts +207 -52
- package/src/op/op-waves-run.ts +4 -0
- package/src/op/run-events.test.ts +166 -0
- package/src/op/run-live.ts +1 -1
- package/src/op/runtime.ts +39 -0
- package/src/op/runtimes/local.test.ts +16 -0
- package/src/op/runtimes/local.ts +9 -0
- package/src/plan-summary.test.ts +20 -0
- package/src/plan-summary.ts +8 -1
- package/src/point-decision.ts +12 -2
- package/src/pr-loop.ts +25 -4
- package/src/pr-report-url.test.ts +131 -0
- package/src/pr-report-url.ts +209 -0
- package/src/provenance.ts +2 -2
- package/src/run-event-store.test.ts +144 -0
- package/src/run-event-store.ts +273 -0
- package/src/run-event-stream.test.ts +175 -0
- package/src/run-event-stream.ts +309 -0
- package/src/run-event.test.ts +277 -0
- package/src/run-event.ts +471 -0
- package/src/wave-loop-golden.test.ts +9 -0
- package/src/workspace/__fixtures__/flag-workspace.ts +132 -0
- package/src/workspace/__fixtures__/older-records/change-set-984534ea9.json +100 -0
- package/src/workspace/__fixtures__/older-records/older-records.json +326 -0
- package/src/workspace/__fixtures__/run-event-check.ts +58 -0
- package/src/workspace/ancestry-index.test.ts +93 -0
- package/src/workspace/change-set-show.schema.json +102 -0
- package/src/workspace/change-set-show.ts +72 -0
- package/src/workspace/change-set.schema.json +32 -1
- package/src/workspace/changes-cli.ts +10 -1
- package/src/workspace/changes.schema.json +135 -0
- package/src/workspace/changes.test.ts +1 -1
- package/src/workspace/changes.ts +84 -2
- package/src/workspace/check.schema.json +4 -2
- package/src/workspace/checks/records.ts +35 -1
- package/src/workspace/checks.ts +2 -1
- package/src/workspace/ci-green-cli.ts +75 -13
- package/src/workspace/ci-green-forge.ts +24 -4
- package/src/workspace/ci-green-runs.test.ts +242 -0
- package/src/workspace/ci-green-signed.test.ts +302 -0
- package/src/workspace/ci-green-workflow.test.ts +16 -0
- package/src/workspace/ci-green-workflow.ts +12 -0
- package/src/workspace/ci-green.test.ts +131 -2
- package/src/workspace/ci-green.ts +635 -42
- package/src/workspace/ci-last-green.schema.json +32 -2
- package/src/workspace/ci-list.schema.json +525 -0
- package/src/workspace/commit-links.test.ts +279 -0
- package/src/workspace/commit-links.ts +183 -0
- package/src/workspace/declaration.schema.json +76 -0
- package/src/workspace/declaration.test.ts +28 -0
- package/src/workspace/declaration.ts +60 -2
- package/src/workspace/declared-kinds.ts +40 -1
- package/src/workspace/delivery-metrics.schema.json +519 -0
- package/src/workspace/delivery-metrics.test.ts +236 -0
- package/src/workspace/delivery-metrics.ts +286 -0
- package/src/workspace/flags-read.ts +121 -0
- package/src/workspace/flags.test.ts +141 -0
- package/src/workspace/flags.ts +157 -0
- package/src/workspace/graph-cli.ts +1 -1
- package/src/workspace/identity-gate-rule.ts +91 -7
- package/src/workspace/identity.ts +14 -1
- package/src/workspace/intent-cli.ts +46 -5
- package/src/workspace/intent-trace.test.ts +173 -0
- package/src/workspace/intent-trace.ts +484 -0
- package/src/workspace/intent.schema.json +702 -6
- package/src/workspace/intent.ts +196 -26
- package/src/workspace/ls.schema.json +3 -1
- package/src/workspace/ls.ts +6 -0
- package/src/workspace/member-pipeline.test.ts +17 -0
- package/src/workspace/member-pipeline.ts +9 -0
- package/src/workspace/older-records.test.ts +412 -0
- package/src/workspace/overlap.test.ts +165 -0
- package/src/workspace/overlap.ts +340 -0
- package/src/workspace/promotion-order.ts +97 -0
- package/src/workspace/read-contract.e2e.test.ts +5 -1
- package/src/workspace/reason-codes.test.ts +7 -1
- package/src/workspace/reason-codes.ts +7 -1
- package/src/workspace/record-assets.test.ts +2 -1
- package/src/workspace/records-contract.e2e.test.ts +2 -1
- package/src/workspace/records.schema.json +21 -2
- package/src/workspace/records.ts +36 -2
- package/src/workspace/reference-kinds/flag/flag.kind.mjs +32 -0
- package/src/workspace/reference-kinds/flag/flag.schema.json +53 -0
- package/src/workspace/releases.schema.json +513 -0
- package/src/workspace/releases.test.ts +108 -0
- package/src/workspace/releases.ts +133 -0
- package/src/workspace/run-event.schema.json +295 -0
- package/src/workspace/status-contract.test.ts +81 -1
- package/src/workspace/status-gates.ts +64 -1
- package/src/workspace/status-mixed.test.ts +152 -0
- package/src/workspace/status-revoked.test.ts +153 -0
- package/src/workspace/status-stewards.ts +6 -0
- package/src/workspace/status.schema.json +268 -2
- package/src/workspace/status.ts +334 -4
- package/src/workspace/trust/ci-tag-statement.ts +151 -0
- package/src/workspace/trust/op-run-statement.ts +148 -0
- package/src/workspace/trust/rotation.ts +61 -14
- package/src/workspace/trust/seal.ts +10 -0
- package/src/workspace/trust/ssh-commit.ts +10 -9
- package/src/workspace/wip.ts +11 -2
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/astro.config.mjs +0 -14
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/package.json +0 -16
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content/docs/index.mdx +0 -8
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content.config.ts +0 -15
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/tsconfig.json +0 -10
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Garbage collection of stored change sets, releases and run events by the
|
|
3
|
+
* retention policy (#4036). `chant lifecycle gc` runs it.
|
|
4
|
+
*
|
|
5
|
+
* What it prunes on `chant/lifecycle`, in every member's ledger at once:
|
|
6
|
+
*
|
|
7
|
+
* _change-sets/<digest>.json a stored change set (#4022)
|
|
8
|
+
* _releases/<digest>.json a release (#4026)
|
|
9
|
+
* _releases/templates/<digest>.txt template bytes no kept release names
|
|
10
|
+
*
|
|
11
|
+
* A prune is one new commit on the local branch that removes those files. It
|
|
12
|
+
* never rewrites or force-pushes history: other clones and tools read the
|
|
13
|
+
* branch, and every pruned file stays reachable in the commits before the
|
|
14
|
+
* prune. So a prune bounds the tree a reader walks at the tip, and the
|
|
15
|
+
* repository's history keeps growing by what is written. `git log -- <path>`
|
|
16
|
+
* on the branch still finds a pruned file.
|
|
17
|
+
*
|
|
18
|
+
* What it never touches: the ledgers. `_releases/cuts.jsonl`,
|
|
19
|
+
* `<env>/releases.jsonl`, `_gates/<op>.jsonl`, the run ledgers and every other
|
|
20
|
+
* `.jsonl` on the branch are append-only and are not edited (#4034), and a
|
|
21
|
+
* whole ledger file is not removed either: the latest deploy record of an
|
|
22
|
+
* environment, a gate's standing fact and a release's label all live in them,
|
|
23
|
+
* and they are small next to what they index (one line per fact). Nor does it
|
|
24
|
+
* touch snapshots, `_plans/`, `_builds/` or checkpoints, which have no policy
|
|
25
|
+
* yet. A cut line whose release was pruned stays, so its label keeps naming
|
|
26
|
+
* that digest and can't be given to another release.
|
|
27
|
+
*
|
|
28
|
+
* What is never pruned, whatever its age:
|
|
29
|
+
*
|
|
30
|
+
* 1. A release an environment runs: the release the latest deploy record of
|
|
31
|
+
* each component in each environment names, by its `releaseDigest` or the
|
|
32
|
+
* release gate resolution its admission names (`releaseOfDeploy`, #4043),
|
|
33
|
+
* and that release's templates. A promotion picks up what the step before
|
|
34
|
+
* runs (#4030), so this also keeps every release a promotion can take by
|
|
35
|
+
* default.
|
|
36
|
+
* 2. What a pending gate binds: the change set (`planDigest`) and release
|
|
37
|
+
* (`releaseDigest`) of every pending fact that has not expired.
|
|
38
|
+
* 3. A release still promotable: one whose commit has no `ci/revoked` tag and
|
|
39
|
+
* that was cut within `releases.days`, or is among the newest
|
|
40
|
+
* `releases.keep` releases of its member.
|
|
41
|
+
* 4. A change set a gate fact (an approval, an `empty` resolution or a
|
|
42
|
+
* pending fact) names together with a release that is kept.
|
|
43
|
+
*
|
|
44
|
+
* Anything else is pruned once it is older than its kind's window: a change
|
|
45
|
+
* set `changeSets.days` after it was stored or last named by a gate fact,
|
|
46
|
+
* whichever is later. A file that can't be read as a release is kept.
|
|
47
|
+
*
|
|
48
|
+
* Run events are local files under `<git-common-dir>/chant/run-events/`
|
|
49
|
+
* (`../run-event-store.ts`) and are deleted outright.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
import { execFileSync } from "node:child_process";
|
|
53
|
+
import { RefCASConflictError, writeLedgerFiles, pushLifecycleReport, type LedgerFileRemoval } from "./git";
|
|
54
|
+
import { MEMBERS_DIR } from "./member-ledger";
|
|
55
|
+
import { CHANGE_SETS_DIR } from "./change-set-store";
|
|
56
|
+
import { CUTS_FILE, RELEASES_DIR, TEMPLATES_SUBDIR, parseCuts, parseRelease, type Release } from "./release-store";
|
|
57
|
+
import { parseGateLedger, type GateResolutionRecord, type PendingGateRecord } from "./gate-ledger";
|
|
58
|
+
import { parseReleaseLedger, releaseLedgerLines } from "./release-read";
|
|
59
|
+
import { latestPerComponent } from "./release-ledger";
|
|
60
|
+
import { releaseOfDeploy } from "./release-join";
|
|
61
|
+
import { RELEASE_GATE_OP } from "../op/gate-name";
|
|
62
|
+
import { planRunEventPrune, pruneRunEvents, type RunEventFile } from "../run-event-store";
|
|
63
|
+
import type { RetentionPolicy } from "./retention-policy";
|
|
64
|
+
|
|
65
|
+
const STATE_BRANCH = "chant/lifecycle";
|
|
66
|
+
const DAY_MS = 86_400_000;
|
|
67
|
+
|
|
68
|
+
/** What a pruned or kept file on the branch is. */
|
|
69
|
+
export type GcKind = "change-set" | "release" | "template";
|
|
70
|
+
|
|
71
|
+
/** Why a file is kept. Closed. */
|
|
72
|
+
export type GcKeepCode =
|
|
73
|
+
/** The latest deploy record of a component in an environment names the release. */
|
|
74
|
+
| "deployed"
|
|
75
|
+
/** A pending fact that has not expired binds it. */
|
|
76
|
+
| "pending-gate"
|
|
77
|
+
/** The release is among the newest `releases.keep` of its member and not revoked. */
|
|
78
|
+
| "newest"
|
|
79
|
+
/** It is within its kind's window (and, for a release, not revoked). */
|
|
80
|
+
| "within-window"
|
|
81
|
+
/** A gate fact names the change set with a release that is kept, or a kept release names the template. */
|
|
82
|
+
| "kept-release"
|
|
83
|
+
/** The file can't be read as what its directory holds, so nothing can be said about it. */
|
|
84
|
+
| "unreadable";
|
|
85
|
+
|
|
86
|
+
export interface GcKeepReason {
|
|
87
|
+
code: GcKeepCode;
|
|
88
|
+
/** The environment, gate or release the reason names, when it names one. */
|
|
89
|
+
detail?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface GcFile {
|
|
93
|
+
kind: GcKind;
|
|
94
|
+
/** The member, its path of names joined with `/`, or null for the flat layout. */
|
|
95
|
+
member: string | null;
|
|
96
|
+
/** The full path on the branch. */
|
|
97
|
+
path: string;
|
|
98
|
+
digest: string;
|
|
99
|
+
bytes: number;
|
|
100
|
+
/** The blob sha at the tip read. */
|
|
101
|
+
sha: string;
|
|
102
|
+
/** When it was last written to the branch (the newest commit that added it), or null when history does not say. */
|
|
103
|
+
storedAt: string | null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface GcKept extends GcFile {
|
|
107
|
+
reasons: GcKeepReason[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Files and bytes in the tip's tree. */
|
|
111
|
+
export interface TreeSize {
|
|
112
|
+
files: number;
|
|
113
|
+
bytes: number;
|
|
114
|
+
changeSets: { files: number; bytes: number };
|
|
115
|
+
releases: { files: number; bytes: number };
|
|
116
|
+
templates: { files: number; bytes: number };
|
|
117
|
+
/** Every `.jsonl` file: append-only, never pruned. */
|
|
118
|
+
ledgers: { files: number; bytes: number };
|
|
119
|
+
other: { files: number; bytes: number };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** What a prune of `chant/lifecycle` would do. */
|
|
123
|
+
export interface LifecycleGcPlan {
|
|
124
|
+
/** The branch tip read, or null when the checkout has no `chant/lifecycle`. */
|
|
125
|
+
tip: string | null;
|
|
126
|
+
remove: GcFile[];
|
|
127
|
+
keep: GcKept[];
|
|
128
|
+
before: TreeSize;
|
|
129
|
+
after: TreeSize;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface GcInput {
|
|
133
|
+
/** Any directory in the repository. The whole branch is read, every member at once. */
|
|
134
|
+
cwd: string;
|
|
135
|
+
policy: RetentionPolicy;
|
|
136
|
+
now: Date;
|
|
137
|
+
/** Full shas of commits with a `ci/revoked` tag: their releases are not promotable. */
|
|
138
|
+
revokedCommits?: ReadonlySet<string>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface BranchFile {
|
|
142
|
+
path: string;
|
|
143
|
+
sha: string;
|
|
144
|
+
bytes: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function git(cwd: string, args: string[], input?: string): Buffer {
|
|
148
|
+
return execFileSync("git", args, { cwd, input, maxBuffer: 1024 * 1024 * 1024, stdio: ["pipe", "pipe", "pipe"] });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function branchTip(cwd: string): string | null {
|
|
152
|
+
try {
|
|
153
|
+
return git(cwd, ["rev-parse", "--verify", "--quiet", `refs/heads/${STATE_BRANCH}`]).toString().trim() || null;
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function listTree(cwd: string, tip: string): BranchFile[] {
|
|
160
|
+
const out: BranchFile[] = [];
|
|
161
|
+
for (const line of git(cwd, ["ls-tree", "-r", "-l", "--full-tree", tip]).toString().split("\n")) {
|
|
162
|
+
const m = line.match(/^\d+ blob ([0-9a-f]+)\s+(\d+)\t(.+)$/);
|
|
163
|
+
if (m) out.push({ sha: m[1], bytes: Number(m[2]), path: m[3] });
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** The text of each blob, read in one `git cat-file --batch`. */
|
|
169
|
+
function readBlobs(cwd: string, shas: readonly string[]): Map<string, string> {
|
|
170
|
+
const out = new Map<string, string>();
|
|
171
|
+
const unique = [...new Set(shas)];
|
|
172
|
+
if (unique.length === 0) return out;
|
|
173
|
+
const buf = git(cwd, ["cat-file", "--batch"], `${unique.join("\n")}\n`);
|
|
174
|
+
let at = 0;
|
|
175
|
+
while (at < buf.length) {
|
|
176
|
+
const nl = buf.indexOf(0x0a, at);
|
|
177
|
+
if (nl < 0) break;
|
|
178
|
+
const header = buf.subarray(at, nl).toString().split(" ");
|
|
179
|
+
at = nl + 1;
|
|
180
|
+
if (header[1] === "missing" || header.length < 3) continue;
|
|
181
|
+
const size = Number(header[2]);
|
|
182
|
+
out.set(header[0], buf.subarray(at, at + size).toString("utf8"));
|
|
183
|
+
at += size + 1;
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** When each change set and release file was last added on the branch, newest add first, in one `git log`. */
|
|
189
|
+
function storedTimes(cwd: string, tip: string): Map<string, string> {
|
|
190
|
+
const out = new Map<string, string>();
|
|
191
|
+
const text = git(cwd, [
|
|
192
|
+
"log", "--format=%x00%cI", "--name-only", "--diff-filter=A", tip, "--",
|
|
193
|
+
`:(top,glob)**/${CHANGE_SETS_DIR}/*.json`, `:(top,glob)**/${RELEASES_DIR}/*.json`,
|
|
194
|
+
]).toString();
|
|
195
|
+
for (const chunk of text.split("\0")) {
|
|
196
|
+
const lines = chunk.split("\n").filter(Boolean);
|
|
197
|
+
const when = lines.shift();
|
|
198
|
+
if (!when) continue;
|
|
199
|
+
for (const path of lines) if (!out.has(path)) out.set(path, when);
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Split a branch path into the member prefix (`_members/<a>/_members/<b>/`) and the rest. */
|
|
205
|
+
export function splitLedgerPath(path: string): { prefix: string; member: string | null; rest: string } {
|
|
206
|
+
const segs = path.split("/");
|
|
207
|
+
const names: string[] = [];
|
|
208
|
+
let i = 0;
|
|
209
|
+
while (segs[i] === MEMBERS_DIR && i + 2 < segs.length) {
|
|
210
|
+
names.push(segs[i + 1]);
|
|
211
|
+
i += 2;
|
|
212
|
+
}
|
|
213
|
+
return { prefix: segs.slice(0, i).map((s) => `${s}/`).join(""), member: names.length > 0 ? names.join("/") : null, rest: segs.slice(i).join("/") };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The key a digest is matched by: its hex. A plan digest written `sha256:<hex>`
|
|
218
|
+
* names the same plan as `jcs1-sha256:<hex>` (`samePlanDigest`), and a file
|
|
219
|
+
* name writes `:` as `_`, so both sides are reduced to the hex.
|
|
220
|
+
*/
|
|
221
|
+
export function digestKey(digestOrStem: string): string {
|
|
222
|
+
const hex = digestOrStem.match(/[0-9a-f]{64}$/);
|
|
223
|
+
return hex ? hex[0] : digestOrStem.replace(/:/g, "_");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const stemOf = (name: string, ext: string): string => name.slice(0, -ext.length);
|
|
227
|
+
const fileDigest = (name: string, ext: string): string => stemOf(name, ext).replace(/_/g, ":");
|
|
228
|
+
|
|
229
|
+
interface MemberLedger {
|
|
230
|
+
prefix: string;
|
|
231
|
+
member: string | null;
|
|
232
|
+
changeSets: Map<string, GcFile>;
|
|
233
|
+
releases: Map<string, GcFile>;
|
|
234
|
+
templates: Map<string, GcFile>;
|
|
235
|
+
cuts: BranchFile | null;
|
|
236
|
+
gates: BranchFile[];
|
|
237
|
+
deploys: Array<{ env: string; file: BranchFile }>;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function emptySize(): TreeSize {
|
|
241
|
+
const z = () => ({ files: 0, bytes: 0 });
|
|
242
|
+
return { files: 0, bytes: 0, changeSets: z(), releases: z(), templates: z(), ledgers: z(), other: z() };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function sizeOf(files: readonly BranchFile[], kinds: ReadonlyMap<string, GcKind>): TreeSize {
|
|
246
|
+
const s = emptySize();
|
|
247
|
+
for (const f of files) {
|
|
248
|
+
s.files++;
|
|
249
|
+
s.bytes += f.bytes;
|
|
250
|
+
const kind = kinds.get(f.path);
|
|
251
|
+
const slot = kind === "change-set" ? s.changeSets : kind === "release" ? s.releases : kind === "template" ? s.templates : f.path.endsWith(".jsonl") ? s.ledgers : s.other;
|
|
252
|
+
slot.files++;
|
|
253
|
+
slot.bytes += f.bytes;
|
|
254
|
+
}
|
|
255
|
+
return s;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Decide what a prune of `chant/lifecycle` removes and keeps, by the rules at
|
|
260
|
+
* the top of this file. Reads the branch at its local tip and writes nothing.
|
|
261
|
+
*/
|
|
262
|
+
export function planLifecycleGc(input: GcInput): LifecycleGcPlan {
|
|
263
|
+
const { cwd, policy, now } = input;
|
|
264
|
+
const revoked = input.revokedCommits ?? new Set<string>();
|
|
265
|
+
const tip = branchTip(cwd);
|
|
266
|
+
if (!tip) return { tip: null, remove: [], keep: [], before: emptySize(), after: emptySize() };
|
|
267
|
+
|
|
268
|
+
const files = listTree(cwd, tip);
|
|
269
|
+
const stored = storedTimes(cwd, tip);
|
|
270
|
+
const members = new Map<string, MemberLedger>();
|
|
271
|
+
const kinds = new Map<string, GcKind>();
|
|
272
|
+
const ledgerOf = (prefix: string, member: string | null): MemberLedger => {
|
|
273
|
+
let m = members.get(prefix);
|
|
274
|
+
if (!m) {
|
|
275
|
+
m = { prefix, member, changeSets: new Map(), releases: new Map(), templates: new Map(), cuts: null, gates: [], deploys: [] };
|
|
276
|
+
members.set(prefix, m);
|
|
277
|
+
}
|
|
278
|
+
return m;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
for (const f of files) {
|
|
282
|
+
const { prefix, member, rest } = splitLedgerPath(f.path);
|
|
283
|
+
const segs = rest.split("/");
|
|
284
|
+
const name = segs.at(-1)!;
|
|
285
|
+
const entry = (kind: GcKind, digest: string): GcFile => {
|
|
286
|
+
kinds.set(f.path, kind);
|
|
287
|
+
return { kind, member, path: f.path, digest, bytes: f.bytes, sha: f.sha, storedAt: stored.get(f.path) ?? null };
|
|
288
|
+
};
|
|
289
|
+
if (segs.length === 2 && segs[0] === CHANGE_SETS_DIR && name.endsWith(".json")) {
|
|
290
|
+
const e = entry("change-set", fileDigest(name, ".json"));
|
|
291
|
+
ledgerOf(prefix, member).changeSets.set(digestKey(stemOf(name, ".json")), e);
|
|
292
|
+
} else if (segs.length === 2 && segs[0] === RELEASES_DIR && name.endsWith(".json")) {
|
|
293
|
+
const e = entry("release", fileDigest(name, ".json"));
|
|
294
|
+
ledgerOf(prefix, member).releases.set(digestKey(stemOf(name, ".json")), e);
|
|
295
|
+
} else if (segs.length === 3 && segs[0] === RELEASES_DIR && segs[1] === TEMPLATES_SUBDIR && name.endsWith(".txt")) {
|
|
296
|
+
const e = entry("template", fileDigest(name, ".txt"));
|
|
297
|
+
ledgerOf(prefix, member).templates.set(digestKey(stemOf(name, ".txt")), e);
|
|
298
|
+
} else if (segs.length === 2 && segs[0] === RELEASES_DIR && name === CUTS_FILE) {
|
|
299
|
+
ledgerOf(prefix, member).cuts = f;
|
|
300
|
+
} else if (segs.length === 2 && segs[0] === "_gates" && name.endsWith(".jsonl")) {
|
|
301
|
+
ledgerOf(prefix, member).gates.push(f);
|
|
302
|
+
} else if (segs.length === 2 && name === "releases.jsonl" && !segs[0].startsWith("_")) {
|
|
303
|
+
ledgerOf(prefix, member).deploys.push({ env: segs[0], file: f });
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const blobs = readBlobs(
|
|
308
|
+
cwd,
|
|
309
|
+
[...members.values()].flatMap((m) => [...m.releases.values()].map((r) => r.sha).concat(m.cuts ? [m.cuts.sha] : [], m.gates.map((g) => g.sha), m.deploys.map((d) => d.file.sha))),
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
const keep: GcKept[] = [];
|
|
313
|
+
const remove: GcFile[] = [];
|
|
314
|
+
const nowMs = now.getTime();
|
|
315
|
+
|
|
316
|
+
for (const m of members.values()) {
|
|
317
|
+
const reasons = new Map<GcFile, GcKeepReason[]>();
|
|
318
|
+
const keepFile = (f: GcFile | undefined, reason: GcKeepReason): void => {
|
|
319
|
+
if (!f) return;
|
|
320
|
+
reasons.set(f, [...(reasons.get(f) ?? []), reason]);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// The gate facts of every op in the member.
|
|
324
|
+
const pending: PendingGateRecord[] = [];
|
|
325
|
+
const resolutions: GateResolutionRecord[] = [];
|
|
326
|
+
let releaseGateResolutions: GateResolutionRecord[] = [];
|
|
327
|
+
for (const g of m.gates) {
|
|
328
|
+
const parsed = parseGateLedger(blobs.get(g.sha) ?? "");
|
|
329
|
+
pending.push(...parsed.pending);
|
|
330
|
+
resolutions.push(...parsed.resolutions);
|
|
331
|
+
if (g.path.endsWith(`/${RELEASE_GATE_OP}.jsonl`) || g.path === `_gates/${RELEASE_GATE_OP}.jsonl`) releaseGateResolutions = parsed.resolutions;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Releases, parsed.
|
|
335
|
+
const parsed = new Map<GcFile, Release | null>();
|
|
336
|
+
for (const r of m.releases.values()) {
|
|
337
|
+
const release = parseRelease(blobs.get(r.sha) ?? "");
|
|
338
|
+
parsed.set(r, release && digestKey(release.releaseDigest) === digestKey(r.digest) ? release : null);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Rule 1: what each environment runs.
|
|
342
|
+
for (const { env, file } of m.deploys) {
|
|
343
|
+
const { records } = parseReleaseLedger(releaseLedgerLines(blobs.get(file.sha) ?? null));
|
|
344
|
+
for (const record of latestPerComponent(records).values()) {
|
|
345
|
+
const digest = releaseOfDeploy(record, releaseGateResolutions);
|
|
346
|
+
if (digest !== undefined) keepFile(m.releases.get(digestKey(digest)), { code: "deployed", detail: `${env}/${record.component}` });
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Rule 2: what a pending gate binds, until its fact expires.
|
|
351
|
+
for (const p of pending) {
|
|
352
|
+
if (new Date(p.expiresAt).getTime() <= nowMs) continue;
|
|
353
|
+
const detail = `${p.op}/${p.gate}${p.environment ? ` in ${p.environment}` : ""}`;
|
|
354
|
+
if (p.planDigest) keepFile(m.changeSets.get(digestKey(p.planDigest)), { code: "pending-gate", detail });
|
|
355
|
+
if (p.releaseDigest) keepFile(m.releases.get(digestKey(p.releaseDigest)), { code: "pending-gate", detail });
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Rule 3: a release still promotable.
|
|
359
|
+
const { cuts } = parseCuts(m.cuts ? (blobs.get(m.cuts.sha) ?? null) : null);
|
|
360
|
+
const cutAt = new Map<string, string>();
|
|
361
|
+
for (const c of cuts) {
|
|
362
|
+
const k = digestKey(c.releaseDigest);
|
|
363
|
+
if (!cutAt.has(k) || c.timestamp > cutAt.get(k)!) cutAt.set(k, c.timestamp);
|
|
364
|
+
}
|
|
365
|
+
const releaseCutoff = nowMs - policy.releases.days * DAY_MS;
|
|
366
|
+
const promotable: Array<{ file: GcFile; at: number }> = [];
|
|
367
|
+
for (const [k, file] of m.releases) {
|
|
368
|
+
const release = parsed.get(file)!;
|
|
369
|
+
if (!release) {
|
|
370
|
+
keepFile(file, { code: "unreadable" });
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (revoked.has(release.commit)) continue;
|
|
374
|
+
const when = cutAt.get(k) ?? file.storedAt;
|
|
375
|
+
promotable.push({ file, at: when ? new Date(when).getTime() : Number.POSITIVE_INFINITY });
|
|
376
|
+
}
|
|
377
|
+
promotable.sort((a, b) => b.at - a.at || (a.file.path < b.file.path ? -1 : 1));
|
|
378
|
+
promotable.forEach(({ file, at }, i) => {
|
|
379
|
+
if (i < policy.releases.keep) keepFile(file, { code: "newest" });
|
|
380
|
+
if (at >= releaseCutoff) keepFile(file, { code: "within-window" });
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
const keptReleases = new Set([...m.releases.values()].filter((r) => reasons.has(r)));
|
|
384
|
+
const keptKeys = new Set([...keptReleases].map((r) => digestKey(r.digest)));
|
|
385
|
+
|
|
386
|
+
// Templates follow the releases that name them.
|
|
387
|
+
const unreadableKept = [...keptReleases].some((r) => parsed.get(r) === null);
|
|
388
|
+
for (const r of keptReleases) {
|
|
389
|
+
const release = parsed.get(r);
|
|
390
|
+
if (!release) continue;
|
|
391
|
+
for (const t of release.targets) for (const tpl of t.templates) keepFile(m.templates.get(digestKey(tpl.digest)), { code: "kept-release", detail: r.digest });
|
|
392
|
+
}
|
|
393
|
+
if (unreadableKept) for (const t of m.templates.values()) keepFile(t, { code: "unreadable", detail: "a release file of this member can't be read" });
|
|
394
|
+
|
|
395
|
+
// Rule 4, and the change-set window.
|
|
396
|
+
const lastNamed = new Map<string, number>();
|
|
397
|
+
for (const fact of [...pending, ...resolutions]) {
|
|
398
|
+
if (!fact.planDigest) continue;
|
|
399
|
+
const k = digestKey(fact.planDigest);
|
|
400
|
+
const t = new Date(fact.timestamp).getTime();
|
|
401
|
+
if (!lastNamed.has(k) || t > lastNamed.get(k)!) lastNamed.set(k, t);
|
|
402
|
+
if (fact.releaseDigest && keptKeys.has(digestKey(fact.releaseDigest))) keepFile(m.changeSets.get(k), { code: "kept-release", detail: fact.releaseDigest });
|
|
403
|
+
}
|
|
404
|
+
const changeSetCutoff = nowMs - policy.changeSets.days * DAY_MS;
|
|
405
|
+
for (const [k, file] of m.changeSets) {
|
|
406
|
+
const storedMs = file.storedAt ? new Date(file.storedAt).getTime() : Number.POSITIVE_INFINITY;
|
|
407
|
+
const last = Math.max(storedMs, lastNamed.get(k) ?? Number.NEGATIVE_INFINITY);
|
|
408
|
+
if (last >= changeSetCutoff) keepFile(file, { code: "within-window" });
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
for (const f of [...m.changeSets.values(), ...m.releases.values(), ...m.templates.values()]) {
|
|
412
|
+
const why = reasons.get(f);
|
|
413
|
+
if (why) keep.push({ ...f, reasons: dedupe(why) });
|
|
414
|
+
else remove.push(f);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const byPath = (a: GcFile, b: GcFile) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
419
|
+
remove.sort(byPath);
|
|
420
|
+
keep.sort(byPath);
|
|
421
|
+
const removed = new Set(remove.map((f) => f.path));
|
|
422
|
+
return { tip, remove, keep, before: sizeOf(files, kinds), after: sizeOf(files.filter((f) => !removed.has(f.path)), kinds) };
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function dedupe(reasons: GcKeepReason[]): GcKeepReason[] {
|
|
426
|
+
const seen = new Set<string>();
|
|
427
|
+
return reasons.filter((r) => {
|
|
428
|
+
const k = `${r.code}\0${r.detail ?? ""}`;
|
|
429
|
+
if (seen.has(k)) return false;
|
|
430
|
+
seen.add(k);
|
|
431
|
+
return true;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** The commit message of a prune. */
|
|
436
|
+
export function pruneMessage(remove: readonly GcFile[]): string {
|
|
437
|
+
const n = (kind: GcKind) => remove.filter((f) => f.kind === kind).length;
|
|
438
|
+
return `Retention: remove ${n("change-set")} change set(s), ${n("release")} release(s) and ${n("template")} template(s)`;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const PRUNE_ATTEMPTS = 5;
|
|
442
|
+
|
|
443
|
+
/** What {@link runLifecycleGc} did, or would do on a dry run. */
|
|
444
|
+
export interface GcReport {
|
|
445
|
+
now: string;
|
|
446
|
+
policy: RetentionPolicy;
|
|
447
|
+
dryRun: boolean;
|
|
448
|
+
lifecycle: LifecycleGcPlan & {
|
|
449
|
+
/** The prune commit, or null on a dry run or when nothing was removed. */
|
|
450
|
+
commit: string | null;
|
|
451
|
+
pushed: boolean;
|
|
452
|
+
pushWarning?: string;
|
|
453
|
+
};
|
|
454
|
+
runEvents: {
|
|
455
|
+
dir: string | null;
|
|
456
|
+
remove: RunEventFile[];
|
|
457
|
+
kept: { files: number; bytes: number };
|
|
458
|
+
/** How many files were deleted; 0 on a dry run. */
|
|
459
|
+
deleted: number;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Plan and, unless `dryRun`, carry out a prune: one commit on the local
|
|
465
|
+
* `chant/lifecycle` that removes what the plan lets go, and the run event
|
|
466
|
+
* files it lets go deleted. The commit is planned against the tip it is
|
|
467
|
+
* written on: if the branch moved in between, the plan is made again. It is
|
|
468
|
+
* pushed only when `push` is set.
|
|
469
|
+
*/
|
|
470
|
+
export async function runLifecycleGc(input: GcInput & { dryRun: boolean; push?: boolean }): Promise<GcReport> {
|
|
471
|
+
let plan = planLifecycleGc(input);
|
|
472
|
+
let commit: string | null = null;
|
|
473
|
+
if (!input.dryRun && plan.tip && plan.remove.length > 0) {
|
|
474
|
+
for (let attempt = 1; ; attempt++) {
|
|
475
|
+
const removals: LedgerFileRemoval[] = plan.remove.map((f) => ({ path: f.path, remove: true, expectPriorSha: f.sha }));
|
|
476
|
+
try {
|
|
477
|
+
commit = await writeLedgerFiles(removals, pruneMessage(plan.remove), { cwd: input.cwd, expectTip: plan.tip! });
|
|
478
|
+
break;
|
|
479
|
+
} catch (err) {
|
|
480
|
+
if (!(err instanceof RefCASConflictError) || attempt >= PRUNE_ATTEMPTS) throw err;
|
|
481
|
+
plan = planLifecycleGc(input);
|
|
482
|
+
if (!plan.tip || plan.remove.length === 0) break;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
let pushed = false;
|
|
487
|
+
let pushWarning: string | undefined;
|
|
488
|
+
if (commit && input.push) {
|
|
489
|
+
const r = await pushLifecycleReport({ cwd: input.cwd });
|
|
490
|
+
pushed = r.pushed;
|
|
491
|
+
pushWarning = r.pushWarning;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const events = await planRunEventPrune(input.cwd, input.policy.runEvents, input.now);
|
|
495
|
+
const deleted = input.dryRun ? 0 : pruneRunEvents(events);
|
|
496
|
+
return {
|
|
497
|
+
now: input.now.toISOString(),
|
|
498
|
+
policy: input.policy,
|
|
499
|
+
dryRun: input.dryRun,
|
|
500
|
+
lifecycle: { ...plan, commit, pushed, ...(pushWarning ? { pushWarning } : {}) },
|
|
501
|
+
runEvents: {
|
|
502
|
+
dir: events.dir,
|
|
503
|
+
remove: events.remove,
|
|
504
|
+
kept: { files: events.keep.length, bytes: events.keep.reduce((n, f) => n + f.bytes, 0) },
|
|
505
|
+
deleted,
|
|
506
|
+
},
|
|
507
|
+
};
|
|
508
|
+
}
|
|
@@ -92,6 +92,16 @@ describe("buildRunRecord", () => {
|
|
|
92
92
|
expect(input.phases[1].steps.map((s) => s.status)).toEqual(["ok", "skipped"]);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
test("carries the commit and the CI run origin when given (#4020), and neither when not", () => {
|
|
96
|
+
const times = { started: "2026-01-01T00:00:00.000Z", ended: "2026-01-01T00:00:01.000Z", status: "ok" as const };
|
|
97
|
+
const withBoth = buildRunRecord({ name: "ship" }, [], { ...times, gitSha: "a".repeat(40), runOrigin: { forge: "github", repo: "acme/app" } });
|
|
98
|
+
expect(withBoth.gitSha).toBe("a".repeat(40));
|
|
99
|
+
expect(withBoth.runOrigin).toEqual({ forge: "github", repo: "acme/app" });
|
|
100
|
+
const without = buildRunRecord({ name: "ship" }, [], times);
|
|
101
|
+
expect(without).not.toHaveProperty("gitSha");
|
|
102
|
+
expect(without).not.toHaveProperty("runOrigin");
|
|
103
|
+
});
|
|
104
|
+
|
|
95
105
|
test("a phase with a failed step is fail; a phase whose steps all skipped is skipped", () => {
|
|
96
106
|
const input = buildRunRecord(
|
|
97
107
|
{ name: "deploy" },
|
|
@@ -89,6 +89,10 @@ export function buildRunRecord(
|
|
|
89
89
|
steward?: string;
|
|
90
90
|
/** The gate the run resumed at, for a run that resumed (#3947). */
|
|
91
91
|
resumed?: OpRunRecord["resumed"];
|
|
92
|
+
/** The commit the run built from (#4020). */
|
|
93
|
+
gitSha?: string;
|
|
94
|
+
/** The CI run the Op ran in (#4020), when it ran in CI. */
|
|
95
|
+
runOrigin?: OpRunRecord["runOrigin"];
|
|
92
96
|
/** Each phase's wall-clock time, by name, as the executor measured it. */
|
|
93
97
|
phaseDurations?: Record<string, number>;
|
|
94
98
|
},
|
|
@@ -138,6 +142,8 @@ export function buildRunRecord(
|
|
|
138
142
|
...(times.point ? { point: times.point } : {}),
|
|
139
143
|
...(times.steward ? { steward: times.steward } : {}),
|
|
140
144
|
...(times.resumed ? { resumed: times.resumed } : {}),
|
|
145
|
+
...(times.gitSha ? { gitSha: times.gitSha } : {}),
|
|
146
|
+
...(times.runOrigin ? { runOrigin: times.runOrigin } : {}),
|
|
141
147
|
};
|
|
142
148
|
}
|
|
143
149
|
|
|
@@ -55,6 +55,9 @@ export async function changeCoverage(args: ChangeCoverageArgs = {}): Promise<Cha
|
|
|
55
55
|
findings: doc.findings.map(({ code, path, message, severity, records, triage }) => ({ code, path, message, severity, records, triage })),
|
|
56
56
|
summary: doc.summary,
|
|
57
57
|
};
|
|
58
|
-
if (!doc.ok)
|
|
58
|
+
if (!doc.ok) {
|
|
59
|
+
const all = [...doc.findings.map((f) => `${f.code} ${f.path}`), ...(doc.links?.findings ?? []).map((f) => `${f.code} ${f.commit.slice(0, 8)}`)];
|
|
60
|
+
throw new Error(`changeCoverage: ${all.length} change ${all.length === 1 ? "finding" : "findings"} at severity fail: ${all.join(", ")}`);
|
|
61
|
+
}
|
|
59
62
|
return result;
|
|
60
63
|
}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
22
22
|
import { join, resolve } from "node:path";
|
|
23
|
+
import type { ReleaseAdmission } from "../../lifecycle/release-ledger";
|
|
23
24
|
import { sortedJsonReplacer } from "../../utils";
|
|
24
25
|
import { archiveSourceTree, sha256Digest, type SourceArchive } from "../source-archive";
|
|
25
26
|
|
|
@@ -126,16 +127,19 @@ export async function releaseRecord(args: ReleaseRecordArgs): Promise<ReleaseRec
|
|
|
126
127
|
const env = plan.env as string;
|
|
127
128
|
const gitSha = plan.gitSha as string;
|
|
128
129
|
|
|
129
|
-
const { readReleaseLedger, latestPerComponent, appendReleaseRecord, resolveRunId } = await import("../../lifecycle/release-ledger");
|
|
130
|
+
const { readReleaseLedger, latestPerComponent, appendReleaseRecord, resolveRunId, admissionOf } = await import("../../lifecycle/release-ledger");
|
|
130
131
|
const { persistReleasePlan } = await import("../../lifecycle/plan-ledger");
|
|
131
132
|
const { pushLifecycle } = await import("../../lifecycle/git");
|
|
132
133
|
|
|
133
134
|
let approver: string | null = null;
|
|
135
|
+
let admission: ReleaseAdmission | undefined;
|
|
134
136
|
if (args.approval) {
|
|
135
137
|
const { readGateLedger } = await import("../../lifecycle/gate-ledger");
|
|
136
138
|
const { resolutions } = await readGateLedger(args.approval.op, opts);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
// #4020: the approver and the gate resolution that admitted the release.
|
|
140
|
+
const admitted = admissionOf(resolutions, { ...args.approval, planDigest: plan.digest });
|
|
141
|
+
approver = admitted?.approver ?? null;
|
|
142
|
+
admission = admitted?.admission;
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
const latest = latestPerComponent((await readReleaseLedger(env, opts)).records).get(component);
|
|
@@ -160,6 +164,7 @@ export async function releaseRecord(args: ReleaseRecordArgs): Promise<ReleaseRec
|
|
|
160
164
|
timestamp: new Date().toISOString(),
|
|
161
165
|
actor,
|
|
162
166
|
...(approver ? { approver } : {}),
|
|
167
|
+
...(admission ? { admission } : {}),
|
|
163
168
|
},
|
|
164
169
|
opts,
|
|
165
170
|
);
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
import { execFileSync } from "node:child_process";
|
|
25
25
|
import { realpathSync } from "node:fs";
|
|
26
26
|
import { join, resolve } from "node:path";
|
|
27
|
-
import type { ReleaseRecord, ReleaseRef } from "../../lifecycle/release-ledger";
|
|
27
|
+
import type { ReleaseAdmission, ReleaseRecord, ReleaseRef } from "../../lifecycle/release-ledger";
|
|
28
28
|
import { archiveSourceTree } from "../source-archive";
|
|
29
29
|
import { readReleasePlan, releasePlan, releasePlanDigest } from "./source-release";
|
|
30
30
|
|
|
@@ -200,15 +200,18 @@ export async function releaseRollbackRecord(args: ReleaseRollbackRecordArgs): Pr
|
|
|
200
200
|
const env = plan.env as string;
|
|
201
201
|
const gitSha = plan.gitSha as string;
|
|
202
202
|
|
|
203
|
-
const { readReleaseLedger, latestPerComponent, appendReleaseRecord, resolveRunId } = await import("../../lifecycle/release-ledger");
|
|
203
|
+
const { readReleaseLedger, latestPerComponent, appendReleaseRecord, resolveRunId, admissionOf } = await import("../../lifecycle/release-ledger");
|
|
204
204
|
const { pushLifecycle } = await import("../../lifecycle/git");
|
|
205
205
|
|
|
206
206
|
let approver: string | null = null;
|
|
207
|
+
let admission: ReleaseAdmission | undefined;
|
|
207
208
|
if (args.approval) {
|
|
208
209
|
const { readGateLedger } = await import("../../lifecycle/gate-ledger");
|
|
209
210
|
const { resolutions } = await readGateLedger(args.approval.op, opts);
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
// #4020: the approver and the gate resolution that admitted the release.
|
|
212
|
+
const admitted = admissionOf(resolutions, { ...args.approval, planDigest: plan.digest });
|
|
213
|
+
approver = admitted?.approver ?? null;
|
|
214
|
+
admission = admitted?.admission;
|
|
212
215
|
}
|
|
213
216
|
|
|
214
217
|
const latest = latestPerComponent((await readReleaseLedger(env, opts)).records.filter((r) => r.component === component)).get(component);
|
|
@@ -230,6 +233,7 @@ export async function releaseRollbackRecord(args: ReleaseRollbackRecordArgs): Pr
|
|
|
230
233
|
timestamp: new Date().toISOString(),
|
|
231
234
|
actor,
|
|
232
235
|
...(approver ? { approver } : {}),
|
|
236
|
+
...(admission ? { admission } : {}),
|
|
233
237
|
restores: rollback.restores,
|
|
234
238
|
},
|
|
235
239
|
opts,
|