@intentius/chant 0.124.87 → 0.124.89
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/dist/action-pins.d.ts +1 -0
- package/dist/action-pins.d.ts.map +1 -1
- package/dist/action-pins.js +2 -0
- package/dist/actor.d.ts +47 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +56 -0
- package/dist/bundle-check.d.ts +20 -5
- package/dist/bundle-check.d.ts.map +1 -1
- package/dist/bundle-check.js +20 -5
- package/dist/chant-install.d.ts +98 -0
- package/dist/chant-install.d.ts.map +1 -1
- package/dist/chant-install.js +203 -2
- package/dist/ci-base.d.ts +30 -0
- package/dist/ci-base.d.ts.map +1 -0
- package/dist/ci-base.js +33 -0
- package/dist/ci-comment-commands.d.ts +177 -0
- package/dist/ci-comment-commands.d.ts.map +1 -0
- package/dist/ci-comment-commands.js +325 -0
- package/dist/ci-comment-replies.d.ts +40 -0
- package/dist/ci-comment-replies.d.ts.map +1 -0
- package/dist/ci-comment-replies.js +59 -0
- package/dist/ci-commit.d.ts +1 -1
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +1 -2
- package/dist/ci-control.d.ts +1 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +1 -1
- package/dist/ci-evidence-claims.d.ts +59 -0
- package/dist/ci-evidence-claims.d.ts.map +1 -0
- package/dist/ci-evidence-claims.js +87 -0
- package/dist/ci-evidence-from-job.d.ts +128 -0
- package/dist/ci-evidence-from-job.d.ts.map +1 -0
- package/dist/ci-evidence-from-job.js +203 -0
- package/dist/ci-evidence-jobs.d.ts +68 -4
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +82 -5
- package/dist/ci-handover.d.ts +12 -0
- package/dist/ci-handover.d.ts.map +1 -1
- package/dist/ci-handover.js +15 -3
- package/dist/ci-identity.d.ts +32 -6
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +40 -8
- package/dist/ci-image.d.ts +65 -10
- package/dist/ci-image.d.ts.map +1 -1
- package/dist/ci-image.js +101 -22
- package/dist/ci-jobs.d.ts +1 -1
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +7 -2
- package/dist/ci-login.d.ts +75 -13
- package/dist/ci-login.d.ts.map +1 -1
- package/dist/ci-login.js +89 -37
- package/dist/ci-note-commands.d.ts +63 -3
- package/dist/ci-note-commands.d.ts.map +1 -1
- package/dist/ci-note-commands.js +69 -35
- package/dist/ci-product-words.d.ts +62 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +52 -1
- package/dist/ci-product.d.ts +52 -2
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +51 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +29 -2
- package/dist/cli/handlers/approve-confirm.d.ts +14 -0
- package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
- package/dist/cli/handlers/approve-confirm.js +46 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +2 -1
- package/dist/cli/handlers/build.d.ts +1 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -1
- package/dist/cli/handlers/ci-check.d.ts +1 -1
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +37 -7
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +255 -20
- package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-forge-check.js +34 -17
- package/dist/cli/handlers/components.d.ts.map +1 -1
- package/dist/cli/handlers/components.js +3 -1
- package/dist/cli/handlers/generated-check.d.ts +11 -0
- package/dist/cli/handlers/generated-check.d.ts.map +1 -0
- package/dist/cli/handlers/generated-check.js +71 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +3 -0
- package/dist/cli/handlers/local-chant.d.ts +13 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -1
- package/dist/cli/handlers/local-chant.js +42 -1
- package/dist/cli/handlers/lock.d.ts.map +1 -1
- package/dist/cli/handlers/lock.js +121 -4
- package/dist/cli/handlers/pr-comment.d.ts +21 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
- package/dist/cli/handlers/pr-comment.js +112 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -1
- package/dist/cli/handlers/pr-env.js +6 -3
- package/dist/cli/handlers/pr.d.ts +23 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +97 -14
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +2 -1
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +11 -2
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +36 -2
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +2 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +60 -4
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +82 -0
- package/dist/cli/registry.d.ts +35 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +2 -1
- package/dist/components/check-hooks.d.ts +10 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +18 -0
- package/dist/components/pr-checks.d.ts +169 -0
- package/dist/components/pr-checks.d.ts.map +1 -0
- package/dist/components/pr-checks.js +180 -0
- package/dist/components/pr-pipeline.d.ts +38 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +6 -1
- package/dist/components/product-pipeline.d.ts +58 -2
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +76 -9
- package/dist/components/product-plan.d.ts +445 -7
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +426 -15
- package/dist/config.d.ts +10 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -6
- package/dist/control/consumers.d.ts +6 -0
- package/dist/control/consumers.d.ts.map +1 -1
- package/dist/control/consumers.js +6 -0
- package/dist/dead-guards.d.ts.map +1 -1
- package/dist/dead-guards.js +9 -6
- package/dist/discovery/files.d.ts +1 -1
- package/dist/discovery/files.js +1 -1
- package/dist/drift-issue.d.ts +20 -3
- package/dist/drift-issue.d.ts.map +1 -1
- package/dist/drift-issue.js +16 -0
- package/dist/drift-record.d.ts +52 -5
- package/dist/drift-record.d.ts.map +1 -1
- package/dist/drift-record.js +46 -6
- package/dist/floor-table.d.ts +6 -6
- package/dist/floor-table.d.ts.map +1 -1
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +81 -21
- package/dist/floor-table.js +10 -7
- package/dist/forge-check/contract.d.ts +19 -1
- package/dist/forge-check/contract.d.ts.map +1 -1
- package/dist/forge-check/contract.js +8 -2
- package/dist/forge-check/index.d.ts +4 -0
- package/dist/forge-check/index.d.ts.map +1 -1
- package/dist/forge-check/index.js +4 -0
- package/dist/forge-flags.d.ts +10 -0
- package/dist/forge-flags.d.ts.map +1 -1
- package/dist/forge-flags.js +31 -0
- package/dist/forge-remote.d.ts +47 -0
- package/dist/forge-remote.d.ts.map +1 -0
- package/dist/forge-remote.js +69 -0
- package/dist/gate-resume-run.d.ts +9 -1
- package/dist/gate-resume-run.d.ts.map +1 -1
- package/dist/gate-resume-run.js +26 -3
- package/dist/generated-check.d.ts +88 -0
- package/dist/generated-check.d.ts.map +1 -0
- package/dist/generated-check.js +248 -0
- package/dist/image-pins.d.ts +26 -0
- package/dist/image-pins.d.ts.map +1 -0
- package/dist/image-pins.js +19 -0
- package/dist/lexicon.d.ts +27 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +11 -0
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +30 -3
- package/dist/lifecycle/publish-npm.d.ts +26 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +76 -4
- package/dist/lifecycle/reach-locks.d.ts +131 -0
- package/dist/lifecycle/reach-locks.d.ts.map +1 -0
- package/dist/lifecycle/reach-locks.js +118 -0
- package/dist/lifecycle/release-cut.d.ts +3 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-images.d.ts +22 -1
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +26 -3
- package/dist/lifecycle/release-ledger.d.ts +4 -3
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +3 -2
- package/dist/local-chant.d.ts +57 -3
- package/dist/local-chant.d.ts.map +1 -1
- package/dist/local-chant.js +122 -13
- package/dist/notify-product.d.ts +12 -3
- package/dist/notify-product.d.ts.map +1 -1
- package/dist/notify-product.js +10 -6
- package/dist/op/activities/source-release.d.ts.map +1 -1
- package/dist/op/activities/source-release.js +2 -1
- package/dist/op/activities/source-rollback.d.ts.map +1 -1
- package/dist/op/activities/source-rollback.js +2 -1
- package/dist/op/index.d.ts +2 -0
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -0
- package/dist/op/op-waves-evidence-jobs.d.ts +97 -0
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-jobs.js +118 -0
- package/dist/op/op-waves-evidence.d.ts +12 -1
- package/dist/op/op-waves-evidence.d.ts.map +1 -1
- package/dist/op/op-waves-evidence.js +23 -2
- package/dist/op/op-waves-render-spec.d.ts +100 -0
- package/dist/op/op-waves-render-spec.d.ts.map +1 -0
- package/dist/op/op-waves-render-spec.js +162 -0
- package/dist/op/op-waves-run.d.ts +14 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +56 -4
- package/dist/op/op-waves.d.ts +12 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +14 -1
- package/dist/op/schedule-overdue.d.ts +39 -2
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +148 -10
- package/dist/op/wave-stop.d.ts +64 -0
- package/dist/op/wave-stop.d.ts.map +1 -0
- package/dist/op/wave-stop.js +127 -0
- package/dist/planned-files.d.ts +76 -0
- package/dist/planned-files.d.ts.map +1 -0
- package/dist/planned-files.js +108 -0
- package/dist/pr-forge-job.d.ts +22 -0
- package/dist/pr-forge-job.d.ts.map +1 -0
- package/dist/pr-forge-job.js +46 -0
- package/dist/pr-forge-reads.d.ts +21 -1
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +19 -1
- package/dist/pr-forge.d.ts +7 -1
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +7 -2
- package/dist/pr-loop.d.ts +3 -6
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +4 -81
- package/dist/pr-plan-note.d.ts +121 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +104 -1
- package/dist/pr-plan-record.d.ts +47 -0
- package/dist/pr-plan-record.d.ts.map +1 -0
- package/dist/pr-plan-record.js +89 -0
- package/dist/pr-post.d.ts +68 -3
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +218 -13
- package/dist/pr-requires.d.ts +8 -0
- package/dist/pr-requires.d.ts.map +1 -1
- package/dist/pr-requires.js +3 -1
- package/dist/pr-status.d.ts +16 -0
- package/dist/pr-status.d.ts.map +1 -0
- package/dist/pr-status.js +90 -0
- package/dist/ref-gate-init.d.ts +90 -0
- package/dist/ref-gate-init.d.ts.map +1 -0
- package/dist/ref-gate-init.js +155 -0
- package/dist/ref-gate-rules.d.ts +19 -0
- package/dist/ref-gate-rules.d.ts.map +1 -0
- package/dist/ref-gate-rules.js +17 -0
- package/dist/release-floors.d.ts +100 -16
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +101 -17
- package/dist/render-module.d.ts +15 -0
- package/dist/render-module.d.ts.map +1 -0
- package/dist/render-module.js +73 -0
- package/dist/state-migration.d.ts +24 -1
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +39 -4
- package/dist/state-unlock.d.ts +32 -1
- package/dist/state-unlock.d.ts.map +1 -1
- package/dist/state-unlock.js +31 -0
- package/dist/wave-runtime.mjs +307 -297
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +15 -8
- package/dist/workspace/drift-cli.d.ts +1 -1
- package/dist/workspace/drift-cli.d.ts.map +1 -1
- package/dist/workspace/drift-cli.js +5 -12
- package/dist/workspace/forge-work.d.ts +3 -2
- package/dist/workspace/forge-work.d.ts.map +1 -1
- package/dist/workspace/forge-work.js +7 -17
- package/dist/workspace/lexicon-outputs.js +2 -2
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +2 -1
- package/dist/workspace/release-workflow.d.ts +27 -3
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +52 -7
- package/dist/workspace/trust/check-evidence-report.d.ts +25 -2
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +28 -8
- package/dist/workspace/trust/check-evidence.d.ts +13 -1
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence.js +8 -3
- package/dist/workspace/trust/evidence.d.ts +5 -0
- package/dist/workspace/trust/evidence.d.ts.map +1 -1
- package/dist/workspace/trust/evidence.js +5 -0
- package/dist/workspace/trust/open-evidence.d.ts +67 -0
- package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/open-evidence.js +92 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate-cli.js +93 -11
- package/dist/workspace/trust/ref-gate.d.ts +61 -2
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate.js +72 -7
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -1
- package/package.json +1 -1
- package/src/action-pins.ts +2 -0
- package/src/actor.test.ts +78 -0
- package/src/actor.ts +79 -0
- package/src/bundle-check.test.ts +22 -0
- package/src/bundle-check.ts +33 -5
- package/src/chant-install.test.ts +108 -1
- package/src/chant-install.ts +242 -2
- package/src/ci-base.test.ts +41 -0
- package/src/ci-base.ts +43 -0
- package/src/ci-comment-commands.test.ts +376 -0
- package/src/ci-comment-commands.ts +389 -0
- package/src/ci-comment-replies.ts +78 -0
- package/src/ci-commit.test.ts +51 -6
- package/src/ci-commit.ts +1 -2
- package/src/ci-control.ts +1 -0
- package/src/ci-evidence-claims.ts +102 -0
- package/src/ci-evidence-from-job.test.ts +165 -0
- package/src/ci-evidence-from-job.ts +251 -0
- package/src/ci-evidence-jobs.ts +88 -6
- package/src/ci-handover.ts +16 -3
- package/src/ci-identity.test.ts +3 -3
- package/src/ci-identity.ts +51 -11
- package/src/ci-image.test.ts +187 -16
- package/src/ci-image.ts +157 -25
- package/src/ci-jobs.ts +7 -2
- package/src/ci-login.test.ts +131 -3
- package/src/ci-login.token-drop.test.ts +204 -0
- package/src/ci-login.ts +137 -39
- package/src/ci-note-commands.ts +104 -41
- package/src/ci-product-words.ts +89 -0
- package/src/ci-product.ts +62 -1
- package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
- package/src/cli/commands/build.test.ts +41 -0
- package/src/cli/commands/build.ts +27 -2
- package/src/cli/handlers/approve-confirm.test.ts +35 -0
- package/src/cli/handlers/approve-confirm.ts +44 -0
- package/src/cli/handlers/approve.ts +2 -1
- package/src/cli/handlers/build-source-dir.test.ts +4 -0
- package/src/cli/handlers/build.ts +20 -2
- package/src/cli/handlers/ci-check.ts +37 -7
- package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
- package/src/cli/handlers/ci-evidence.ts +233 -18
- package/src/cli/handlers/ci-forge-check.ts +22 -9
- package/src/cli/handlers/components.ts +3 -1
- package/src/cli/handlers/generated-check.ts +69 -0
- package/src/cli/handlers/lifecycle.test.ts +20 -0
- package/src/cli/handlers/lifecycle.ts +4 -0
- package/src/cli/handlers/local-chant.ts +39 -1
- package/src/cli/handlers/lock-reach.test.ts +103 -0
- package/src/cli/handlers/lock.ts +100 -4
- package/src/cli/handlers/pr-comment.ts +104 -0
- package/src/cli/handlers/pr-env.ts +6 -3
- package/src/cli/handlers/pr-record.test.ts +1 -1
- package/src/cli/handlers/pr.ts +93 -15
- package/src/cli/handlers/promote.ts +2 -1
- package/src/cli/handlers/release.e2e.test.ts +35 -0
- package/src/cli/handlers/release.ts +14 -2
- package/src/cli/handlers/run-wave.ts +35 -2
- package/src/cli/handlers/run.ts +2 -1
- package/src/cli/main.ts +60 -4
- package/src/cli/parse-args.ts +58 -0
- package/src/cli/registry.ts +35 -0
- package/src/components/auto-release.ts +2 -1
- package/src/components/check-hooks.ts +22 -0
- package/src/components/check-report-summary.test.ts +78 -0
- package/src/components/pr-checks.ts +254 -0
- package/src/components/pr-pipeline.ts +43 -1
- package/src/components/product-pipeline.ts +113 -9
- package/src/components/product-plan.test.ts +140 -1
- package/src/components/product-plan.ts +707 -20
- package/src/config.ts +13 -8
- package/src/control/consumers.ts +7 -0
- package/src/dead-guards.test.ts +27 -5
- package/src/dead-guards.ts +9 -6
- package/src/discovery/files.ts +1 -1
- package/src/drift-issue.test.ts +29 -1
- package/src/drift-issue.ts +28 -3
- package/src/drift-record.test.ts +45 -0
- package/src/drift-record.ts +71 -6
- package/src/floor-table.data.ts +81 -21
- package/src/floor-table.ts +12 -9
- package/src/forge-check/contract.ts +23 -2
- package/src/forge-check/forge-check.test.ts +25 -0
- package/src/forge-check/index.ts +4 -0
- package/src/forge-flags.test.ts +25 -1
- package/src/forge-flags.ts +34 -0
- package/src/forge-remote.test.ts +37 -0
- package/src/forge-remote.ts +79 -0
- package/src/gate-resume-run.ts +27 -3
- package/src/generated-check.e2e.test.ts +118 -0
- package/src/generated-check.test.ts +170 -0
- package/src/generated-check.ts +310 -0
- package/src/image-pins.ts +31 -0
- package/src/lexicon.ts +28 -0
- package/src/lifecycle/git.test.ts +48 -0
- package/src/lifecycle/git.ts +27 -4
- package/src/lifecycle/publish-npm.ts +87 -4
- package/src/lifecycle/reach-locks.test.ts +87 -0
- package/src/lifecycle/reach-locks.ts +169 -0
- package/src/lifecycle/release-catalog.test.ts +2 -2
- package/src/lifecycle/release-cut.ts +17 -1
- package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
- package/src/lifecycle/release-images.test.ts +100 -0
- package/src/lifecycle/release-images.ts +38 -3
- package/src/lifecycle/release-ledger.ts +4 -3
- package/src/local-chant.e2e.test.ts +81 -6
- package/src/local-chant.test.ts +22 -3
- package/src/local-chant.ts +130 -13
- package/src/notify-product.ts +19 -8
- package/src/op/activities/source-release.ts +2 -1
- package/src/op/activities/source-rollback.ts +2 -1
- package/src/op/gate-resume.test.ts +27 -0
- package/src/op/index.ts +10 -0
- package/src/op/op-waves-evidence-jobs.ts +140 -0
- package/src/op/op-waves-evidence.test.ts +36 -3
- package/src/op/op-waves-evidence.ts +23 -3
- package/src/op/op-waves-notify-words.test.ts +18 -0
- package/src/op/op-waves-render-spec.test.ts +160 -0
- package/src/op/op-waves-render-spec.ts +171 -0
- package/src/op/op-waves-run.ts +59 -3
- package/src/op/op-waves.ts +16 -2
- package/src/op/schedule-overdue.test.ts +126 -1
- package/src/op/schedule-overdue.ts +164 -12
- package/src/op/wave-stop.test.ts +72 -0
- package/src/op/wave-stop.ts +137 -0
- package/src/planned-files.test.ts +80 -0
- package/src/planned-files.ts +134 -0
- package/src/pr-forge-job.test.ts +53 -0
- package/src/pr-forge-job.ts +46 -0
- package/src/pr-forge-reads-compare.test.ts +2 -1
- package/src/pr-forge-reads.ts +37 -1
- package/src/pr-forge.ts +14 -3
- package/src/pr-loop-narrowed.test.ts +2 -1
- package/src/pr-loop-words.test.ts +2 -1
- package/src/pr-loop.test.ts +1 -2
- package/src/pr-loop.ts +4 -80
- package/src/pr-plan-note.ts +184 -3
- package/src/pr-plan-record.test.ts +75 -0
- package/src/pr-plan-record.ts +101 -0
- package/src/pr-post-plan-note.test.ts +60 -0
- package/src/pr-post-replan.test.ts +144 -0
- package/src/pr-post-subject.test.ts +230 -0
- package/src/pr-post.test.ts +32 -1
- package/src/pr-post.ts +254 -15
- package/src/pr-requires.test.ts +20 -0
- package/src/pr-requires.ts +10 -1
- package/src/pr-status.ts +91 -0
- package/src/ref-gate-init.ts +208 -0
- package/src/ref-gate-rules.ts +26 -0
- package/src/release-floors.ts +139 -17
- package/src/render-module.ts +73 -0
- package/src/state-migration-record.test.ts +89 -0
- package/src/state-migration.test.ts +1 -1
- package/src/state-migration.ts +52 -4
- package/src/state-unlock.test.ts +33 -1
- package/src/state-unlock.ts +49 -1
- package/src/workspace/ci-green-cli.ts +14 -7
- package/src/workspace/ci-green-workflow.test.ts +32 -1
- package/src/workspace/drift-cli.ts +6 -18
- package/src/workspace/forge-work.ts +7 -14
- package/src/workspace/lexicon-outputs.ts +2 -2
- package/src/workspace/release-train.ts +2 -1
- package/src/workspace/release-workflow.test.ts +104 -3
- package/src/workspace/release-workflow.ts +60 -9
- package/src/workspace/trust/check-evidence-report.ts +39 -8
- package/src/workspace/trust/check-evidence.test.ts +5 -0
- package/src/workspace/trust/check-evidence.ts +17 -5
- package/src/workspace/trust/evidence.ts +5 -0
- package/src/workspace/trust/open-evidence.ts +129 -0
- package/src/workspace/trust/ref-gate-cli.ts +88 -10
- package/src/workspace/trust/ref-gate-pieces.test.ts +220 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
- package/src/workspace/trust/ref-gate.test.ts +10 -0
- package/src/workspace/trust/ref-gate.ts +87 -6
- package/src/workspace/workspace-run.ts +2 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The claim files a check's step leaves for a signer in another job (#4926),
|
|
3
|
+
* and the variable that names which step or job each check's pass is read
|
|
4
|
+
* from. No import beyond node's, so the wave runner and the generators carry
|
|
5
|
+
* it at no cost.
|
|
6
|
+
*
|
|
7
|
+
* A step that ran a check writes `<dir>/<check>.json` (`:` turned into `-`):
|
|
8
|
+
* the check's name, whether the step saw it pass, and what it said (the
|
|
9
|
+
* claim the statement digests). The step runs the change's code, so the file
|
|
10
|
+
* is data and never enough on its own: `chant ci evidence sign --from-job`
|
|
11
|
+
* signs a check only when the forge reports that step (on GitLab, that job)
|
|
12
|
+
* concluded `success` and the file says the check passed
|
|
13
|
+
* (./ci-evidence-from-job.ts).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The variable a `--from-job` signing step reads its sources from: JSON,
|
|
21
|
+
* each check to the job (default `--from-job`'s) and the step whose
|
|
22
|
+
* conclusion stands for it. A check with no step is read from its job's
|
|
23
|
+
* own status, as on GitLab.
|
|
24
|
+
*/
|
|
25
|
+
export const EVIDENCE_SOURCES_ENV = "CHANT_EVIDENCE_SOURCES";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* What a generated wave command step signs itself (#4926), set by the
|
|
29
|
+
* generator beside the wave's evidence job: `plan` signs `plan:<wave>` and
|
|
30
|
+
* leaves `policy:<wave>` to the evidence job, which reads the policy step's
|
|
31
|
+
* result; `job` signs nothing and leaves both. Either way the step writes
|
|
32
|
+
* `plan:<wave>`'s claim file for that job. Unset, the step signs both as it
|
|
33
|
+
* did (#4870). See ./op/op-waves-evidence.ts.
|
|
34
|
+
*/
|
|
35
|
+
export const WAVE_EVIDENCE_ENV = "CHANT_WAVE_EVIDENCE";
|
|
36
|
+
|
|
37
|
+
/** Where one check's pass is read from (#4926). */
|
|
38
|
+
export interface EvidenceSourceSpec {
|
|
39
|
+
/** The job's name in the run. Default: `--from-job`'s. */
|
|
40
|
+
job?: string;
|
|
41
|
+
/** The step's name in that job, as the forge lists it. Without it, the job's own result. */
|
|
42
|
+
step?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** What a check's step wrote for its signer. */
|
|
46
|
+
export interface CheckClaimFile {
|
|
47
|
+
check: string;
|
|
48
|
+
passed: boolean;
|
|
49
|
+
/** What the check said, digested into the statement's `claim`. */
|
|
50
|
+
claim?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The file name a check's claim is kept under: `plan:dev` is `plan-dev.json`. */
|
|
54
|
+
export function checkClaimFileName(check: string): string {
|
|
55
|
+
return `${check.replace(/[^A-Za-z0-9._-]/g, "-")}.json`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Write a check's claim file in `dir`. Returns its path. */
|
|
59
|
+
export function writeCheckClaimFile(dir: string, file: CheckClaimFile): string {
|
|
60
|
+
mkdirSync(dir, { recursive: true });
|
|
61
|
+
const path = join(dir, checkClaimFileName(file.check));
|
|
62
|
+
writeFileSync(path, JSON.stringify({ check: file.check, passed: file.passed, ...(file.claim !== undefined ? { claim: file.claim } : {}) }, null, 2) + "\n");
|
|
63
|
+
return path;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A check's claim file in `dir`, or why there is none that counts. Read as data: a file for another check, or of another shape, does not count. */
|
|
67
|
+
export function readCheckClaimFile(dir: string, check: string): CheckClaimFile | { problem: string } {
|
|
68
|
+
const name = checkClaimFileName(check);
|
|
69
|
+
let doc: unknown;
|
|
70
|
+
try {
|
|
71
|
+
doc = JSON.parse(readFileSync(join(dir, name), "utf-8"));
|
|
72
|
+
} catch {
|
|
73
|
+
return { problem: `the job left no readable ${name}` };
|
|
74
|
+
}
|
|
75
|
+
const d = doc && typeof doc === "object" ? (doc as Record<string, unknown>) : {};
|
|
76
|
+
if (d.check !== check || typeof d.passed !== "boolean" || (d.claim !== undefined && typeof d.claim !== "string")) return { problem: `${name} is not ${check}'s claim file` };
|
|
77
|
+
return { check, passed: d.passed, ...(typeof d.claim === "string" ? { claim: d.claim } : {}) };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The sources `CHANT_EVIDENCE_SOURCES` names, or why they do not read. A step name alone stands for `{ step }`. */
|
|
81
|
+
export function parseEvidenceSources(raw: string | undefined): { sources: Record<string, EvidenceSourceSpec> } | { problem: string } {
|
|
82
|
+
if (raw === undefined || raw.trim() === "") return { sources: {} };
|
|
83
|
+
let doc: unknown;
|
|
84
|
+
try {
|
|
85
|
+
doc = JSON.parse(raw);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
return { problem: `${EVIDENCE_SOURCES_ENV} is not JSON: ${err instanceof Error ? err.message : String(err)}` };
|
|
88
|
+
}
|
|
89
|
+
if (!doc || typeof doc !== "object" || Array.isArray(doc)) return { problem: `${EVIDENCE_SOURCES_ENV} must map each check to its job and step` };
|
|
90
|
+
const out: Record<string, EvidenceSourceSpec> = {};
|
|
91
|
+
for (const [check, v] of Object.entries(doc as Record<string, unknown>)) {
|
|
92
|
+
if (typeof v === "string" && v !== "") out[check] = { step: v };
|
|
93
|
+
else if (v && typeof v === "object" && !Array.isArray(v)) {
|
|
94
|
+
const o = v as Record<string, unknown>;
|
|
95
|
+
if ((o.job !== undefined && (typeof o.job !== "string" || o.job === "")) || (o.step !== undefined && (typeof o.step !== "string" || o.step === ""))) {
|
|
96
|
+
return { problem: `${EVIDENCE_SOURCES_ENV}: ${check}'s job and step must be names` };
|
|
97
|
+
}
|
|
98
|
+
out[check] = { ...(typeof o.job === "string" ? { job: o.job } : {}), ...(typeof o.step === "string" ? { step: o.step } : {}) };
|
|
99
|
+
} else return { problem: `${EVIDENCE_SOURCES_ENV}: ${check} must name a step, or { job, step }` };
|
|
100
|
+
}
|
|
101
|
+
return { sources: out };
|
|
102
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4926: `chant ci evidence sign --from-job` against a fake forge. It signs
|
|
3
|
+
* only the checks whose steps passed, refuses a job of another commit or
|
|
4
|
+
* run, gives a failed policy step no `policy:` evidence whatever its claim
|
|
5
|
+
* file says, and each statement names the run, job and step it relied on.
|
|
6
|
+
* The forge's job records come through the real reads with a fake `fetch`;
|
|
7
|
+
* the signing is a real runner key over a local repository.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execFileSync } from "node:child_process";
|
|
11
|
+
import { generateKeyPairSync } from "node:crypto";
|
|
12
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { describe, expect, test } from "vitest";
|
|
16
|
+
import type { ForgeFetch } from "./pr-forge";
|
|
17
|
+
import { githubReads, gitlabReads, type ForgeReads, type RunJob } from "./pr-forge-reads";
|
|
18
|
+
import { checksFromJob, signFromJob } from "./ci-evidence-from-job";
|
|
19
|
+
import { checkClaimFileName, parseEvidenceSources, readCheckClaimFile, writeCheckClaimFile } from "./ci-evidence-claims";
|
|
20
|
+
import { loadRunnerKey } from "./workspace/trust/dsse";
|
|
21
|
+
import { readCheckEvidence } from "./workspace/trust/check-evidence";
|
|
22
|
+
|
|
23
|
+
const SHA = "a".repeat(40);
|
|
24
|
+
const PLAN_STEP = "Plan, gate and apply wave 1 (dev)";
|
|
25
|
+
const POLICY_STEP = "Check wave 1 (dev)'s plans against the policy";
|
|
26
|
+
const SOURCES = { "plan:dev": { step: PLAN_STEP }, "policy:dev": { step: POLICY_STEP } };
|
|
27
|
+
|
|
28
|
+
/** A run's jobs as GitHub lists them, through the real reads. */
|
|
29
|
+
function githubRun(run: number, jobs: unknown[]): Pick<ForgeReads, "runJobs"> {
|
|
30
|
+
const fetch: ForgeFetch = async (url) => {
|
|
31
|
+
const u = new URL(url);
|
|
32
|
+
if (u.pathname !== `/repos/acme/infra/actions/runs/${run}/jobs`) return { ok: false, status: 404, text: async () => "{}" };
|
|
33
|
+
return { ok: true, status: 200, text: async () => JSON.stringify({ total_count: jobs.length, jobs }) };
|
|
34
|
+
};
|
|
35
|
+
return githubReads({ apiBase: "https://api.github.com", repo: "acme/infra", token: "t", fetch });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const step = (name: string, conclusion: string, number: number) => ({ name, status: "completed", conclusion, number });
|
|
39
|
+
const waveJob = (over: Record<string, unknown> = {}, steps = [step(POLICY_STEP, "success", 4), step(PLAN_STEP, "success", 5)]) => ({ id: 77, run_id: 9, name: "wave-1-dev", status: "completed", conclusion: "success", head_sha: SHA, steps, ...over });
|
|
40
|
+
|
|
41
|
+
describe("the forge's record of a job (#4926)", () => {
|
|
42
|
+
test("github and forgejo name the commit and the steps; gitlab names the pipeline's commit and no steps", async () => {
|
|
43
|
+
const [job] = await githubRun(9, [waveJob()]).runJobs(9);
|
|
44
|
+
expect(job).toMatchObject({ id: 77, run: 9, headSha: SHA, conclusion: "success" });
|
|
45
|
+
expect(job!.steps).toEqual([{ name: POLICY_STEP, number: 4, status: "completed", conclusion: "success" }, { name: PLAN_STEP, number: 5, status: "completed", conclusion: "success" }]);
|
|
46
|
+
const fetch: ForgeFetch = async () => ({ ok: true, status: 200, text: async () => JSON.stringify([{ id: 5, name: "wave-1-dev-policy", status: "failed", pipeline: { id: 9, sha: SHA }, commit: { id: SHA } }]) });
|
|
47
|
+
const [gl] = await gitlabReads({ apiBase: "https://gitlab.com/api/v4", project: "acme/infra", token: "t", fetch }).runJobs(9);
|
|
48
|
+
expect(gl).toEqual({ id: 5, name: "wave-1-dev-policy", status: "failed", done: true, run: 9, headSha: SHA });
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("which checks a job's record lets the evidence job sign (#4926)", () => {
|
|
53
|
+
const claims = (files: Array<{ check: string; passed: boolean; claim?: string }>): string => {
|
|
54
|
+
const dir = mkdtempSync(join(tmpdir(), "chant-4926-claims-"));
|
|
55
|
+
for (const f of files) writeCheckClaimFile(dir, f);
|
|
56
|
+
return dir;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
test("signs only the checks whose steps passed, each with the run, job and step it read", async () => {
|
|
60
|
+
const reads = githubRun(9, [waveJob({}, [step(POLICY_STEP, "failure", 4), step(PLAN_STEP, "success", 5)])]);
|
|
61
|
+
const got = await checksFromJob({ reads, run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev", "policy:dev"], sources: SOURCES });
|
|
62
|
+
expect(got).toEqual({
|
|
63
|
+
sign: [{ check: "plan:dev", source: { run: 9, job: 77, step: PLAN_STEP } }],
|
|
64
|
+
skipped: [{ check: "policy:dev", reason: `step ${JSON.stringify(POLICY_STEP)} of job wave-1-dev concluded failure` }],
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("a failed policy step gets no policy evidence even when its claim file says it passed", async () => {
|
|
69
|
+
const dir = claims([{ check: "plan:dev", passed: true, claim: "sha256:1" }, { check: "policy:dev", passed: true, claim: "[]" }]);
|
|
70
|
+
const reads = githubRun(9, [waveJob({ conclusion: "failure" }, [step(POLICY_STEP, "failure", 4), step(PLAN_STEP, "success", 5)])]);
|
|
71
|
+
const got = await checksFromJob({ reads, run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev", "policy:dev"], sources: SOURCES, claims: dir });
|
|
72
|
+
expect("sign" in got && got.sign.map((s) => [s.check, s.claim])).toEqual([["plan:dev", "sha256:1"]]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("a passed step whose claim file says the check did not pass, or left none, signs nothing", async () => {
|
|
76
|
+
const dir = claims([{ check: "policy:dev", passed: false }]);
|
|
77
|
+
const got = await checksFromJob({ reads: githubRun(9, [waveJob()]), run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev", "policy:dev"], sources: SOURCES, claims: dir });
|
|
78
|
+
expect(got).toEqual({
|
|
79
|
+
sign: [],
|
|
80
|
+
skipped: [
|
|
81
|
+
{ check: "plan:dev", reason: `the job left no readable ${checkClaimFileName("plan:dev")}` },
|
|
82
|
+
{ check: "policy:dev", reason: "job wave-1-dev's claim file says policy:dev did not pass" },
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("a job of another commit or another run is refused", async () => {
|
|
88
|
+
const other = "b".repeat(40);
|
|
89
|
+
expect(await checksFromJob({ reads: githubRun(9, [waveJob({ head_sha: other })]), run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev"], sources: SOURCES })).toEqual({
|
|
90
|
+
refused: `job wave-1-dev (77) ran for commit ${other.slice(0, 12)}, not this run's ${SHA.slice(0, 12)}`,
|
|
91
|
+
});
|
|
92
|
+
expect(await checksFromJob({ reads: githubRun(9, [waveJob({ run_id: 8 })]), run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev"], sources: SOURCES })).toEqual({ refused: "job wave-1-dev (77) belongs to run 8, not this run 9" });
|
|
93
|
+
expect(await checksFromJob({ reads: githubRun(9, []), run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev"] })).toEqual({ refused: "run 9 has no job named wave-1-dev" });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("on gitlab a check is read from its job's status, the policy from the policy job", async () => {
|
|
97
|
+
const jobs: RunJob[] = [
|
|
98
|
+
{ id: 40, name: "wave-1-dev", status: "success", done: true, run: 9, headSha: SHA },
|
|
99
|
+
{ id: 41, name: "wave-1-dev-policy", status: "failed", done: true, run: 9, headSha: SHA },
|
|
100
|
+
];
|
|
101
|
+
const got = await checksFromJob({ reads: { runJobs: async () => jobs }, run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev", "policy:dev"], sources: { "policy:dev": { job: "wave-1-dev-policy" } } });
|
|
102
|
+
expect(got).toEqual({ sign: [{ check: "plan:dev", source: { run: 9, job: 40 } }], skipped: [{ check: "policy:dev", reason: "job wave-1-dev-policy ended failed" }] });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("#4978: a wave job retried with its evidence job is waited for, and signs once its new try ends", async () => {
|
|
106
|
+
const tries: RunJob[][] = [
|
|
107
|
+
[{ id: 50, name: "wave-1-dev", status: "created", done: false, run: 9, headSha: SHA }],
|
|
108
|
+
[{ id: 50, name: "wave-1-dev", status: "running", done: false, run: 9, headSha: SHA }],
|
|
109
|
+
[{ id: 50, name: "wave-1-dev", status: "success", done: true, run: 9, headSha: SHA }],
|
|
110
|
+
];
|
|
111
|
+
let reads = 0;
|
|
112
|
+
const slept: number[] = [];
|
|
113
|
+
const runJobs = async () => tries[Math.min(reads++, tries.length - 1)]!;
|
|
114
|
+
const got = await checksFromJob({ reads: { runJobs }, run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev"], waitMs: 60_000, pollMs: 10_000, sleep: async (ms) => void slept.push(ms) });
|
|
115
|
+
expect(got).toEqual({ sign: [{ check: "plan:dev", source: { run: 9, job: 50 } }], skipped: [] });
|
|
116
|
+
expect(slept).toEqual([10_000, 10_000]);
|
|
117
|
+
// Out of time, the job still going is not signed.
|
|
118
|
+
reads = 0;
|
|
119
|
+
const late = await checksFromJob({ reads: { runJobs: async () => tries[0]! }, run: 9, sha: SHA, fromJob: "wave-1-dev", checks: ["plan:dev"], waitMs: 20_000, pollMs: 10_000, sleep: async () => {} });
|
|
120
|
+
expect(late).toEqual({ sign: [], skipped: [{ check: "plan:dev", reason: "job wave-1-dev has not finished (created)" }] });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("the sources and claim files read as data", () => {
|
|
124
|
+
expect(parseEvidenceSources('{"plan:dev":"Plan","policy:dev":{"job":"p"}}')).toEqual({ sources: { "plan:dev": { step: "Plan" }, "policy:dev": { job: "p" } } });
|
|
125
|
+
expect(parseEvidenceSources("[]")).toHaveProperty("problem");
|
|
126
|
+
const dir = mkdtempSync(join(tmpdir(), "chant-4926-claim-"));
|
|
127
|
+
writeFileSync(join(dir, checkClaimFileName("policy:dev")), JSON.stringify({ check: "policy:prod", passed: true }));
|
|
128
|
+
expect(readCheckClaimFile(dir, "policy:dev")).toEqual({ problem: "policy-dev.json is not policy:dev's claim file" });
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
function git(cwd: string, ...args: string[]): string {
|
|
133
|
+
return execFileSync("git", ["-c", "user.name=t", "-c", "user.email=t@example.invalid", "-c", "init.defaultBranch=main", ...args], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
describe("signFromJob (#4926)", () => {
|
|
137
|
+
test("signs the passed checks over the run's commit, with the source in the statement, and refuses another commit", async () => {
|
|
138
|
+
const cwd = mkdtempSync(join(tmpdir(), "chant-4926-sign-"));
|
|
139
|
+
const { privateKey } = generateKeyPairSync("ed25519");
|
|
140
|
+
const pem = privateKey.export({ format: "pem", type: "pkcs8" }).toString();
|
|
141
|
+
git(cwd, "init", "--quiet");
|
|
142
|
+
mkdirSync(join(cwd, ".chant"));
|
|
143
|
+
writeFileSync(join(cwd, ".chant/trust.json"), JSON.stringify({ schema: 1, runners: [{ principal: "ci", class: "runner", key: loadRunnerKey(pem).publicKey }] }));
|
|
144
|
+
git(cwd, "add", ".");
|
|
145
|
+
git(cwd, "commit", "--quiet", "-m", "base");
|
|
146
|
+
const base = git(cwd, "rev-parse", "HEAD");
|
|
147
|
+
writeFileSync(join(cwd, "main.tf"), "# change\n");
|
|
148
|
+
git(cwd, "add", "main.tf");
|
|
149
|
+
git(cwd, "commit", "--quiet", "-m", "merge");
|
|
150
|
+
const head = git(cwd, "rev-parse", "HEAD");
|
|
151
|
+
const reads = githubRun(9, [waveJob({ head_sha: head }, [step(POLICY_STEP, "failure", 4), step(PLAN_STEP, "success", 5)])]);
|
|
152
|
+
const env = { GITHUB_RUN_ID: "9", GITHUB_SHA: head, CHANT_EVIDENCE_SOURCES: JSON.stringify(SOURCES) } as NodeJS.ProcessEnv;
|
|
153
|
+
const logs: string[] = [];
|
|
154
|
+
const done = await signFromJob({ repo: cwd, base, fromJob: "wave-1-dev", checks: ["plan:dev", "policy:dev"], reads, env, key: pem, push: false, log: (l) => logs.push(l) });
|
|
155
|
+
expect(done).toMatchObject({ signed: [{ check: "plan:dev", runner: "ci", commit: head, source: { run: 9, job: 77, step: PLAN_STEP } }] });
|
|
156
|
+
expect((await readCheckEvidence(cwd, head, base, ["plan:dev", "policy:dev"])).map((v) => v.status)).toEqual(["current", "missing"]);
|
|
157
|
+
const note = git(cwd, "notes", "--ref", "refs/notes/chant/evidence", "show", head);
|
|
158
|
+
const statement = JSON.parse(Buffer.from(JSON.parse(note.split("\n")[0]!).payload, "base64").toString("utf8"));
|
|
159
|
+
expect(statement.predicate.source).toEqual({ run: 9, job: 77, step: PLAN_STEP });
|
|
160
|
+
expect(logs.some((l) => l.startsWith("ci evidence: policy:dev not signed: step"))).toBe(true);
|
|
161
|
+
expect(await signFromJob({ repo: cwd, base, fromJob: "wave-1-dev", checks: ["plan:dev"], at: base, reads, env, key: pem, push: false, log: () => {} })).toEqual({
|
|
162
|
+
refused: `--at names ${base.slice(0, 12)}, and this run is for ${head.slice(0, 12)}; --from-job signs only the run's own commit`,
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which checks a job outside the check's own may sign (#4926): `chant ci
|
|
3
|
+
* evidence sign --from-job <job>`, the evidence job after a wave job.
|
|
4
|
+
*
|
|
5
|
+
* The wave job runs the change's code, so whatever could sign in it could
|
|
6
|
+
* sign a check that never passed, and a wave that trades cloud credentials
|
|
7
|
+
* can request no signing token after the trade anyway. The evidence job runs
|
|
8
|
+
* none of that code. It reads the wave job's own record from the forge
|
|
9
|
+
* (./pr-forge-reads.ts `runJobs`) with the job token and signs a check only
|
|
10
|
+
* when:
|
|
11
|
+
*
|
|
12
|
+
* - the job it names ran in this run, for this commit: a job of another run
|
|
13
|
+
* or commit refuses the whole command;
|
|
14
|
+
* - the forge reports the check's step (GitHub, Forgejo) or job (GitLab,
|
|
15
|
+
* which reports no steps) finished with `success`. Change code can fail or
|
|
16
|
+
* pass its own steps, but it cannot make the forge report a passing policy
|
|
17
|
+
* step whose command failed;
|
|
18
|
+
* - with `claims`, the step's claim file (./ci-evidence-claims.ts) says the
|
|
19
|
+
* check passed. Its claim, such as the policy rows, is what the statement
|
|
20
|
+
* digests.
|
|
21
|
+
*
|
|
22
|
+
* Each check signed carries `source: { run, job, step }`, the ids it relied
|
|
23
|
+
* on, so a verifier can look them up.
|
|
24
|
+
*
|
|
25
|
+
* A job it reads that has not finished is waited for, up to
|
|
26
|
+
* {@link FROM_JOB_WAIT_MS} (#4978): `chant run resume` retries a GitLab
|
|
27
|
+
* wave job's evidence job with the wave job, and the two may start
|
|
28
|
+
* together.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import type { ForgeReads, RunJob } from "./pr-forge-reads";
|
|
32
|
+
import { commitAndTree, noRunnerIdentity, recordChecks, runnerEvidenceSigner, signChecks, type CheckSource } from "./workspace/trust/check-evidence";
|
|
33
|
+
import { EVIDENCE_SOURCES_ENV, parseEvidenceSources, readCheckClaimFile, type EvidenceSourceSpec } from "./ci-evidence-claims";
|
|
34
|
+
|
|
35
|
+
/** What {@link checksFromJob} reads. */
|
|
36
|
+
export interface ChecksFromJobInput {
|
|
37
|
+
reads: Pick<ForgeReads, "runJobs">;
|
|
38
|
+
/** This run's id: `GITHUB_RUN_ID`, `CI_PIPELINE_ID`. */
|
|
39
|
+
run: number;
|
|
40
|
+
/** This run's commit: `GITHUB_SHA`, `CI_COMMIT_SHA`. */
|
|
41
|
+
sha: string;
|
|
42
|
+
/** The job the checks ran in, by name. */
|
|
43
|
+
fromJob: string;
|
|
44
|
+
checks: readonly string[];
|
|
45
|
+
/** Each check's job and step; a check with none is read from `fromJob`'s own result. */
|
|
46
|
+
sources?: Readonly<Record<string, EvidenceSourceSpec>>;
|
|
47
|
+
/** The directory of the jobs' claim files. Without it, a check needs only its step's success and signs no claim. */
|
|
48
|
+
claims?: string;
|
|
49
|
+
/**
|
|
50
|
+
* How long to wait for a job it reads that has not finished (#4978), in
|
|
51
|
+
* milliseconds, reading the run's jobs again every `pollMs` (default 15
|
|
52
|
+
* seconds). A GitLab evidence job retried with its wave job can start
|
|
53
|
+
* before the new try ends. Default 0: a job not finished is not signed.
|
|
54
|
+
*/
|
|
55
|
+
waitMs?: number;
|
|
56
|
+
pollMs?: number;
|
|
57
|
+
/** For tests: in place of a timer. */
|
|
58
|
+
sleep?: (ms: number) => Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** What may be signed, and what not and why. */
|
|
62
|
+
export type ChecksFromJob =
|
|
63
|
+
| { sign: Array<{ check: string; claim?: string; source: CheckSource }>; skipped: Array<{ check: string; reason: string }> }
|
|
64
|
+
| { refused: string };
|
|
65
|
+
|
|
66
|
+
const SUCCESS = "success";
|
|
67
|
+
|
|
68
|
+
/** Whether the forge reports `job` passed: GitHub's and Forgejo's conclusion, GitLab's status. */
|
|
69
|
+
function jobPassed(job: RunJob): boolean {
|
|
70
|
+
return job.conclusion !== undefined ? job.conclusion === SUCCESS : job.status === SUCCESS;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The run's jobs once every job the checks read has finished, or as they
|
|
75
|
+
* are when `waitMs` runs out (#4978). A job not in the run is left to
|
|
76
|
+
* {@link checksFromJob} to refuse.
|
|
77
|
+
*/
|
|
78
|
+
async function settledJobs(input: ChecksFromJobInput): Promise<RunJob[]> {
|
|
79
|
+
const names = new Set(input.checks.map((c) => input.sources?.[c]?.job ?? input.fromJob));
|
|
80
|
+
const sleep = input.sleep ?? ((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)));
|
|
81
|
+
const poll = Math.max(1, input.pollMs ?? 15_000);
|
|
82
|
+
let left = input.waitMs ?? 0;
|
|
83
|
+
for (;;) {
|
|
84
|
+
const jobs = await input.reads.runJobs(input.run);
|
|
85
|
+
const going = jobs.some((j) => names.has(j.name) && !j.done);
|
|
86
|
+
if (!going || left <= 0) return jobs;
|
|
87
|
+
await sleep(Math.min(poll, left));
|
|
88
|
+
left -= poll;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The checks the run's record lets this job sign (#4926), or why the job it names does not count at all. */
|
|
93
|
+
export async function checksFromJob(input: ChecksFromJobInput): Promise<ChecksFromJob> {
|
|
94
|
+
const jobs = await settledJobs(input);
|
|
95
|
+
const found = new Map<string, RunJob | string>();
|
|
96
|
+
const jobNamed = (name: string): RunJob | string => {
|
|
97
|
+
const had = found.get(name);
|
|
98
|
+
if (had !== undefined) return had;
|
|
99
|
+
const named = jobs.filter((j) => j.name === name);
|
|
100
|
+
let got: RunJob | string;
|
|
101
|
+
if (named.length === 0) got = `run ${input.run} has no job named ${name}`;
|
|
102
|
+
else if (named.length > 1) got = `run ${input.run} has ${named.length} jobs named ${name}, so which one ran the check is not known`;
|
|
103
|
+
else {
|
|
104
|
+
const j = named[0]!;
|
|
105
|
+
if (j.run !== undefined && j.run !== input.run) got = `job ${name} (${j.id}) belongs to run ${j.run}, not this run ${input.run}`;
|
|
106
|
+
else if (j.headSha === undefined) got = `the forge names no commit for job ${name} (${j.id}), so it cannot be bound to ${input.sha.slice(0, 12)}`;
|
|
107
|
+
else if (j.headSha !== input.sha) got = `job ${name} (${j.id}) ran for commit ${j.headSha.slice(0, 12)}, not this run's ${input.sha.slice(0, 12)}`;
|
|
108
|
+
else got = j;
|
|
109
|
+
}
|
|
110
|
+
found.set(name, got);
|
|
111
|
+
return got;
|
|
112
|
+
};
|
|
113
|
+
const sign: Array<{ check: string; claim?: string; source: CheckSource }> = [];
|
|
114
|
+
const skipped: Array<{ check: string; reason: string }> = [];
|
|
115
|
+
for (const check of input.checks) {
|
|
116
|
+
const spec = input.sources?.[check] ?? {};
|
|
117
|
+
const name = spec.job ?? input.fromJob;
|
|
118
|
+
const job = jobNamed(name);
|
|
119
|
+
if (typeof job === "string") return { refused: job };
|
|
120
|
+
if (!job.done) {
|
|
121
|
+
skipped.push({ check, reason: `job ${name} has not finished (${job.status})` });
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
let step: string | undefined;
|
|
125
|
+
if (spec.step !== undefined) {
|
|
126
|
+
if (!job.steps) {
|
|
127
|
+
skipped.push({ check, reason: `the forge lists no steps for job ${name}` });
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const s = job.steps.filter((x) => x.name === spec.step);
|
|
131
|
+
if (s.length !== 1) {
|
|
132
|
+
skipped.push({ check, reason: s.length === 0 ? `job ${name} has no step named ${JSON.stringify(spec.step)}` : `job ${name} has ${s.length} steps named ${JSON.stringify(spec.step)}` });
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (s[0]!.conclusion !== SUCCESS) {
|
|
136
|
+
skipped.push({ check, reason: `step ${JSON.stringify(spec.step)} of job ${name} concluded ${s[0]!.conclusion ?? s[0]!.status}` });
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
step = spec.step;
|
|
140
|
+
} else if (!jobPassed(job)) {
|
|
141
|
+
skipped.push({ check, reason: `job ${name} ended ${job.conclusion ?? job.status}` });
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
let claim: string | undefined;
|
|
145
|
+
if (input.claims !== undefined) {
|
|
146
|
+
const file = readCheckClaimFile(input.claims, check);
|
|
147
|
+
if ("problem" in file) {
|
|
148
|
+
skipped.push({ check, reason: file.problem });
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (!file.passed) {
|
|
152
|
+
skipped.push({ check, reason: `job ${name}'s claim file says ${check} did not pass` });
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
claim = file.claim;
|
|
156
|
+
}
|
|
157
|
+
sign.push({ check, ...(claim !== undefined ? { claim } : {}), source: { run: input.run, job: job.id, ...(step ? { step } : {}) } });
|
|
158
|
+
}
|
|
159
|
+
return { sign, skipped };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** What {@link signFromJob} does in a job. */
|
|
163
|
+
export interface SignFromJobInput {
|
|
164
|
+
repo: string;
|
|
165
|
+
/** The commit whose `.chant/trust.json` lists the runner identities. */
|
|
166
|
+
base: string;
|
|
167
|
+
fromJob: string;
|
|
168
|
+
checks: readonly string[];
|
|
169
|
+
claims?: string;
|
|
170
|
+
/** The commit to sign. Default: the run's commit. It must be the run's commit. */
|
|
171
|
+
at?: string;
|
|
172
|
+
reads: Pick<ForgeReads, "runJobs">;
|
|
173
|
+
env?: NodeJS.ProcessEnv;
|
|
174
|
+
/** The runner key in place of `CHANT_RUNNER_KEY`. */
|
|
175
|
+
key?: string;
|
|
176
|
+
push?: boolean;
|
|
177
|
+
fetch?: typeof fetch;
|
|
178
|
+
log?: (line: string) => void;
|
|
179
|
+
/** How long to wait for an unfinished job it reads (#4978). Default {@link FROM_JOB_WAIT_MS}. */
|
|
180
|
+
waitMs?: number;
|
|
181
|
+
pollMs?: number;
|
|
182
|
+
sleep?: (ms: number) => Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* How long `sign --from-job` waits for a job it reads to finish (#4978): a
|
|
187
|
+
* GitLab `<wave job>-evidence` retried with its wave job by `chant run
|
|
188
|
+
* resume` may start before the wave job's new try ends. 30 minutes.
|
|
189
|
+
*/
|
|
190
|
+
export const FROM_JOB_WAIT_MS = 30 * 60_000;
|
|
191
|
+
|
|
192
|
+
/** What {@link signFromJob} signed and skipped, or why it refused. */
|
|
193
|
+
export type SignFromJobResult =
|
|
194
|
+
| { signed: Array<{ check: string; runner: string; commit: string; tree: string; source: CheckSource }>; skipped: Array<{ check: string; reason: string }>; pushWarning?: string }
|
|
195
|
+
| { refused: string };
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* `chant ci evidence sign --from-job` (#4926): this run's id and commit from
|
|
199
|
+
* the job's environment (`GITHUB_RUN_ID` and `GITHUB_SHA` on GitHub and
|
|
200
|
+
* Forgejo, `CI_PIPELINE_ID` and `CI_COMMIT_SHA` on GitLab), the sources from
|
|
201
|
+
* `CHANT_EVIDENCE_SOURCES`, the checks {@link checksFromJob} allows, signed
|
|
202
|
+
* with the job's runner identity and pushed. Without a runner identity it
|
|
203
|
+
* signs nothing and says so, as `sign` does.
|
|
204
|
+
*/
|
|
205
|
+
export async function signFromJob(input: SignFromJobInput): Promise<SignFromJobResult> {
|
|
206
|
+
const env = input.env ?? process.env;
|
|
207
|
+
const log = input.log ?? ((line: string) => console.error(line));
|
|
208
|
+
const rawRun = env.GITHUB_RUN_ID ?? env.CI_PIPELINE_ID;
|
|
209
|
+
const sha = env.GITHUB_SHA ?? env.CI_COMMIT_SHA;
|
|
210
|
+
if (!rawRun || !/^\d+$/.test(rawRun) || !sha) return { refused: "--from-job reads this run from the job's environment: GITHUB_RUN_ID and GITHUB_SHA, or CI_PIPELINE_ID and CI_COMMIT_SHA" };
|
|
211
|
+
let commit: string;
|
|
212
|
+
try {
|
|
213
|
+
commit = commitAndTree(input.repo, input.at ?? sha).commit;
|
|
214
|
+
} catch {
|
|
215
|
+
return { refused: `${input.at ?? sha} is not a commit in this checkout; fetch the run's commit first` };
|
|
216
|
+
}
|
|
217
|
+
if (commit !== sha) return { refused: `--at names ${commit.slice(0, 12)}, and this run is for ${sha.slice(0, 12)}; --from-job signs only the run's own commit` };
|
|
218
|
+
const parsed = parseEvidenceSources(env[EVIDENCE_SOURCES_ENV]);
|
|
219
|
+
if ("problem" in parsed) return { refused: parsed.problem };
|
|
220
|
+
const decided = await checksFromJob({
|
|
221
|
+
reads: input.reads,
|
|
222
|
+
run: Number(rawRun),
|
|
223
|
+
sha,
|
|
224
|
+
fromJob: input.fromJob,
|
|
225
|
+
checks: input.checks,
|
|
226
|
+
sources: parsed.sources,
|
|
227
|
+
...(input.claims !== undefined ? { claims: input.claims } : {}),
|
|
228
|
+
waitMs: input.waitMs ?? FROM_JOB_WAIT_MS,
|
|
229
|
+
...(input.pollMs !== undefined ? { pollMs: input.pollMs } : {}),
|
|
230
|
+
...(input.sleep ? { sleep: input.sleep } : {}),
|
|
231
|
+
});
|
|
232
|
+
if ("refused" in decided) return decided;
|
|
233
|
+
for (const s of decided.skipped) log(`ci evidence: ${s.check} not signed: ${s.reason}`);
|
|
234
|
+
if (decided.sign.length === 0) return { signed: [], skipped: decided.skipped };
|
|
235
|
+
const signer = await runnerEvidenceSigner(input.repo, input.base, { env, ...(input.key ? { key: input.key } : {}), ...(input.fetch ? { fetch: input.fetch } : {}) });
|
|
236
|
+
if (!signer) {
|
|
237
|
+
log(`ci evidence: ${noRunnerIdentity()}, so no check was signed`);
|
|
238
|
+
return { signed: [], skipped: [...decided.skipped, ...decided.sign.map((s) => ({ check: s.check, reason: noRunnerIdentity() }))] };
|
|
239
|
+
}
|
|
240
|
+
const signed = await signChecks(input.repo, commit, decided.sign, signer);
|
|
241
|
+
const pushed = await recordChecks(input.repo, signed, { push: input.push !== false });
|
|
242
|
+
const bySource = new Map(decided.sign.map((s) => [s.check, s.source]));
|
|
243
|
+
for (const s of signed) log(`ci evidence: signed ${s.check} at ${s.commit.slice(0, 12)} as ${s.runner}, from job ${bySource.get(s.check)!.job}${bySource.get(s.check)!.step ? ` step ${JSON.stringify(bySource.get(s.check)!.step)}` : ""} of run ${rawRun}`);
|
|
244
|
+
const warning = input.push !== false && !pushed.pushed ? pushed.pushWarning : undefined;
|
|
245
|
+
if (warning) log(`ci evidence: the evidence is attached here, and the push did not land: ${warning}`);
|
|
246
|
+
return {
|
|
247
|
+
signed: signed.map((s) => ({ check: s.check, runner: s.runner, commit: s.commit, tree: s.tree, source: bySource.get(s.check)! })),
|
|
248
|
+
skipped: decided.skipped,
|
|
249
|
+
...(warning ? { pushWarning: warning } : {}),
|
|
250
|
+
};
|
|
251
|
+
}
|
package/src/ci-evidence-jobs.ts
CHANGED
|
@@ -14,11 +14,20 @@
|
|
|
14
14
|
* before posting the note, which then says which checks were signed. The
|
|
15
15
|
* key is in that one step, in a job that runs none of the change's code.
|
|
16
16
|
* GitLab posts its notes from a target-branch pipeline that reads every
|
|
17
|
-
* open merge request, so there a job of its own
|
|
18
|
-
* (`<plan job>-evidence`) signs from
|
|
17
|
+
* open merge request, so there a job of its own in that pipeline, before
|
|
18
|
+
* the note job (`<plan job>-evidence`), signs from each merge request's
|
|
19
|
+
* plan job artifact (#4914): a merge request pipeline is built from the
|
|
20
|
+
* change's own files, so no job in it may hold the key. The signing job
|
|
21
|
+
* names the environment {@link GITLAB_EVIDENCE_ENVIRONMENT}, which the
|
|
22
|
+
* key's variable is scoped to, protected; the jobs that run the change
|
|
23
|
+
* name none, so GitLab never hands them the key.
|
|
19
24
|
* - A wave job (the waves pipeline) gets the key on its `chant run wave`
|
|
20
25
|
* step, and signs `plan:<wave>` and `policy:<wave>` once the wave is
|
|
21
|
-
* planned (../op/op-waves-evidence.ts).
|
|
26
|
+
* planned (../op/op-waves-evidence.ts). A wave with a policy runs it as a
|
|
27
|
+
* step of its own and a `<wave job>-evidence` job signs `policy:<wave>`
|
|
28
|
+
* from that step's result; a wave that trades cloud credentials and signs
|
|
29
|
+
* keyless signs `plan:<wave>` there too (#4926,
|
|
30
|
+
* ./op/op-waves-evidence-jobs.ts).
|
|
22
31
|
* - A product's check job runs `chant ci check` with the key in
|
|
23
32
|
* `CHANT_RUNNER_KEY`; the check runner signs each hook (./components/check-steps.ts).
|
|
24
33
|
*
|
|
@@ -45,7 +54,80 @@ export const EVIDENCE_ID_TOKEN_VAR = "CHANT_ID_TOKEN_SIGSTORE";
|
|
|
45
54
|
/** The audience a keyless signing job's token is requested for unless told: sigstore's. */
|
|
46
55
|
export const EVIDENCE_DEFAULT_AUDIENCE = "sigstore";
|
|
47
56
|
|
|
48
|
-
export { CHECK_EVIDENCE_FLOOR, KEYLESS_EVIDENCE_FLOOR, LOCAL_EVIDENCE_FLOOR } from "./release-floors";
|
|
57
|
+
export { CHECK_EVIDENCE_FLOOR, CHECK_JOB_FLOOR, GITLAB_OPEN_EVIDENCE_FLOOR, GITLAB_WAVE_EVIDENCE_RETRY_FLOOR, GITLAB_WAVE_KEY_SCOPE_FLOOR, KEYLESS_EVIDENCE_FLOOR, LOCAL_EVIDENCE_FLOOR, MEMBER_SIGNED_CHECKS_FLOOR, PR_LOOP_EVIDENCE_FLOOR, REF_GATE_STATUS_JOB_FLOOR, TARGET_SIGNED_CHECKS_FLOOR, WAVE_EVIDENCE_JOB_FLOOR } from "./release-floors";
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The GitLab environment every signing job names (#4914), with `action:
|
|
61
|
+
* access`, so it creates no deployment. Scope the runner key's CI/CD
|
|
62
|
+
* variable to it and protect it: GitLab then hands the key only to the
|
|
63
|
+
* signing jobs of a protected branch's pipeline, and to none of the jobs
|
|
64
|
+
* that run a merge request's code.
|
|
65
|
+
*/
|
|
66
|
+
export const GITLAB_EVIDENCE_ENVIRONMENT = "chant-evidence";
|
|
67
|
+
|
|
68
|
+
/** Where a GitLab signing job keeps what it signed for each merge request (#4914): `.chant/evidence/<job>/<iid>/evidence.json`. */
|
|
69
|
+
export function gitlabOpenEvidenceDir(job: string): string {
|
|
70
|
+
return `.chant/evidence/${job}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The lines of a GitLab signing job in the target branch's plan notes
|
|
75
|
+
* pipeline (#4914): `chant ci evidence sign --open` finds every open merge
|
|
76
|
+
* request's newest `job`, reads its report from the job's artifact at
|
|
77
|
+
* `dir`, fetches the head and signs it against the policy at the branch's
|
|
78
|
+
* commit, and keeps each merge request's `evidence.json` under `out`.
|
|
79
|
+
* With `noForks`, a merge request from a fork is not signed for, as a
|
|
80
|
+
* product plan with `forks: "skip"` plans none.
|
|
81
|
+
*/
|
|
82
|
+
export function openEvidenceLines(opts: { job: string; dir: string; out: string; bin?: string; noForks?: boolean; member?: string }): string[] {
|
|
83
|
+
const chant = opts.bin ?? "chant";
|
|
84
|
+
return [`${chant} ci evidence sign --open --job ${opts.job} --from-report ${opts.dir}${memberFlag(opts.member)} --base "$CI_COMMIT_SHA" --output ${opts.out}${opts.noForks ? " --no-forks" : ""}`];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The check a workspace member's pipeline signs for one of the plan job's
|
|
89
|
+
* two (#4964): `plan:<member>`, `policy:<member>`. A member's plan job plans
|
|
90
|
+
* that member alone, so its pass says nothing of another member's plan; a
|
|
91
|
+
* `refs` rule names each member's checks. The root pipeline's are `plan`
|
|
92
|
+
* and `policy`.
|
|
93
|
+
*/
|
|
94
|
+
export function memberEvidenceCheck(check: "plan" | "policy", member?: string): string {
|
|
95
|
+
return member ? `${check}:${member}` : check;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The check a product plan target's note job signs for one of its plan
|
|
100
|
+
* job's two (#4978): `plan:<target>`, `policy:<target>`. Each target has a
|
|
101
|
+
* plan job of its own, so its pass says nothing of another target's plan,
|
|
102
|
+
* and a `refs` rule names each target's checks. A product plan without
|
|
103
|
+
* targets signs `plan` and `policy`.
|
|
104
|
+
*/
|
|
105
|
+
export function targetEvidenceCheck(check: "plan" | "policy", target?: string): string {
|
|
106
|
+
return memberEvidenceCheck(check, target);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The checks a product plan's note jobs sign (#4978), in the order a `refs`
|
|
111
|
+
* rule lists them: `plan` and `policy`, or with `targets` each target's
|
|
112
|
+
* `plan:<target>` and `policy:<target>`.
|
|
113
|
+
*/
|
|
114
|
+
export function productPlanEvidenceChecks(targets?: readonly string[]): string[] {
|
|
115
|
+
if (!targets || targets.length === 0) return ["plan", "policy"];
|
|
116
|
+
return targets.flatMap((t) => [targetEvidenceCheck("plan", t), targetEvidenceCheck("policy", t)]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The name `--member` takes (#4964): a workspace member's or (#4978) a
|
|
121
|
+
* product plan target's, which a check name carries after `plan:`.
|
|
122
|
+
*/
|
|
123
|
+
export const EVIDENCE_MEMBER_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
124
|
+
|
|
125
|
+
/** ` --member <name>` on a signing line of a member's or a target's plan evidence (#4964, #4978), or nothing. */
|
|
126
|
+
function memberFlag(member: string | undefined): string {
|
|
127
|
+
if (member === undefined) return "";
|
|
128
|
+
if (!EVIDENCE_MEMBER_NAME.test(member)) throw new Error(`the name ${JSON.stringify(member)} is not one a check name can carry: letters, digits, - and _`);
|
|
129
|
+
return ` --member ${member}`;
|
|
130
|
+
}
|
|
49
131
|
|
|
50
132
|
/**
|
|
51
133
|
* A pipeline's runner identity (#4870): a runner key's secret, or (#4869)
|
|
@@ -96,10 +178,10 @@ export function evidenceKeyEnv(forge: ForgeKind, evidence: PipelineEvidence): Re
|
|
|
96
178
|
* the report directory. `result` is the plan job's result as the shell
|
|
97
179
|
* reads it.
|
|
98
180
|
*/
|
|
99
|
-
export function planEvidenceLines(opts: { dir: string; at: string; base: string; result: string; bin?: string }): string[] {
|
|
181
|
+
export function planEvidenceLines(opts: { dir: string; at: string; base: string; result: string; bin?: string; member?: string }): string[] {
|
|
100
182
|
const chant = opts.bin ?? "chant";
|
|
101
183
|
return [
|
|
102
184
|
`git fetch --quiet --no-tags --depth=1 origin ${opts.at} || true`,
|
|
103
|
-
`${chant} ci evidence sign --from-report ${opts.dir} --result ${opts.result} --at ${opts.at} --base ${opts.base}`,
|
|
185
|
+
`${chant} ci evidence sign --from-report ${opts.dir}${memberFlag(opts.member)} --result ${opts.result} --at ${opts.at} --base ${opts.base}`,
|
|
104
186
|
];
|
|
105
187
|
}
|