@intentius/chant 0.124.54 → 0.124.56
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/__fixtures__/estate-ledger.d.ts +13 -0
- package/dist/__fixtures__/estate-ledger.d.ts.map +1 -0
- package/dist/__fixtures__/estate-ledger.js +67 -0
- package/dist/__fixtures__/oidc-emulator.d.ts +11 -1
- package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -1
- package/dist/__fixtures__/oidc-emulator.js +26 -2
- package/dist/__fixtures__/product-words.d.ts +78 -0
- package/dist/__fixtures__/product-words.d.ts.map +1 -0
- package/dist/__fixtures__/product-words.js +43 -0
- package/dist/__golden__/wave-loop/op-by-apply-after-fails.json +10 -2
- package/dist/__golden__/wave-loop/op-by-apply-hold.json +20 -4
- package/dist/__golden__/wave-loop/op-by-apply-ignored.json +10 -2
- package/dist/__golden__/wave-loop/op-by-apply-pass.json +10 -2
- package/dist/__golden__/wave-loop/op-by-apply-skip.json +10 -2
- package/dist/__golden__/wave-loop/op-discover-rest-stops.json +22 -6
- package/dist/__golden__/wave-loop/op-discover-rest.json +44 -12
- package/dist/__golden__/wave-loop/op-discover-wide.json +12 -3
- package/dist/__golden__/wave-loop/op-held-on.json +28 -7
- package/dist/__golden__/wave-loop/op-hooks-apply-fails.json +22 -6
- package/dist/__golden__/wave-loop/op-hooks-fail-after-apply.json +22 -6
- package/dist/__golden__/wave-loop/op-hooks-fail-before-apply.json +4 -2
- package/dist/__golden__/wave-loop/op-hooks-held.json +26 -8
- package/dist/__golden__/wave-loop/op-hooks-hold-before-apply.json +18 -4
- package/dist/__golden__/wave-loop/op-hooks-pass.json +22 -6
- package/dist/__golden__/wave-loop/op-hooks-share.json +20 -7
- package/dist/__golden__/wave-loop/op-outcome-held.json +12 -3
- package/dist/__golden__/wave-loop/op-outcome-replan-approved.json +16 -5
- package/dist/__golden__/wave-loop/op-outcome-replan-forever.json +48 -21
- package/dist/__golden__/wave-loop/op-outcome-replan.json +16 -5
- package/dist/__golden__/wave-loop/op-outcome-stood-down.json +12 -3
- package/dist/__golden__/wave-loop/op-outcome-unreadable.json +12 -3
- package/dist/__golden__/wave-loop/op-overridden.json +28 -7
- package/dist/__golden__/wave-loop/op-per-run.json +20 -4
- package/dist/__golden__/wave-loop/op-point.json +18 -4
- package/dist/__golden__/wave-loop/op-pr-review.json +10 -2
- package/dist/__golden__/wave-loop/op-spend-change-only.json +10 -2
- package/dist/__golden__/wave-loop/op-spend.json +10 -2
- package/dist/__golden__/wave-loop/op-wave-commands.json +56 -13
- package/dist/__golden__/wave-loop/op-wide.json +20 -4
- package/dist/bucket-check/azure.d.ts +108 -0
- package/dist/bucket-check/azure.d.ts.map +1 -0
- package/dist/bucket-check/azure.js +258 -0
- package/dist/bucket-check/fixtures/azure.json +153 -0
- package/dist/bucket-check/fixtures/gcs.json +148 -0
- package/dist/bucket-check/fixtures/s3.json +277 -0
- package/dist/bucket-check/gcs.d.ts +77 -0
- package/dist/bucket-check/gcs.d.ts.map +1 -0
- package/dist/bucket-check/gcs.js +202 -0
- package/dist/bucket-check/index.d.ts +48 -0
- package/dist/bucket-check/index.d.ts.map +1 -0
- package/dist/bucket-check/index.js +44 -0
- package/dist/bucket-check/s3.d.ts +116 -0
- package/dist/bucket-check/s3.d.ts.map +1 -0
- package/dist/bucket-check/s3.js +362 -0
- package/dist/bucket-check/types.d.ts +66 -0
- package/dist/bucket-check/types.d.ts.map +1 -0
- package/dist/bucket-check/types.js +31 -0
- package/dist/bucket-check/wire.d.ts +27 -0
- package/dist/bucket-check/wire.d.ts.map +1 -0
- package/dist/bucket-check/wire.js +32 -0
- package/dist/bucket-check.d.ts +6 -0
- package/dist/bucket-check.d.ts.map +1 -0
- package/dist/bucket-check.js +5 -0
- package/dist/capabilities/templates.d.ts.map +1 -1
- package/dist/capabilities/templates.js +1 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +2 -3
- package/dist/ci-agent.d.ts +381 -0
- package/dist/ci-agent.d.ts.map +1 -0
- package/dist/ci-agent.js +832 -0
- package/dist/ci-audit/attribution.d.ts +111 -0
- package/dist/ci-audit/attribution.d.ts.map +1 -0
- package/dist/ci-audit/attribution.js +194 -0
- package/dist/ci-audit/audit-log.d.ts +144 -0
- package/dist/ci-audit/audit-log.d.ts.map +1 -0
- package/dist/ci-audit/audit-log.js +149 -0
- package/dist/ci-audit/index.d.ts +12 -0
- package/dist/ci-audit/index.d.ts.map +1 -0
- package/dist/ci-audit/index.js +12 -0
- package/dist/ci-audit/unrecorded.d.ts +74 -0
- package/dist/ci-audit/unrecorded.d.ts.map +1 -0
- package/dist/ci-audit/unrecorded.js +95 -0
- package/dist/ci-audit.d.ts +3 -0
- package/dist/ci-audit.d.ts.map +1 -0
- package/dist/ci-audit.js +2 -0
- package/dist/ci-control.d.ts +42 -0
- package/dist/ci-control.d.ts.map +1 -0
- package/dist/ci-control.js +41 -0
- package/dist/ci-estate/delivery.d.ts +137 -0
- package/dist/ci-estate/delivery.d.ts.map +1 -0
- package/dist/ci-estate/delivery.js +311 -0
- package/dist/ci-estate/overdue.d.ts +34 -0
- package/dist/ci-estate/overdue.d.ts.map +1 -0
- package/dist/ci-estate/overdue.js +58 -0
- package/dist/ci-estate/page.d.ts +134 -0
- package/dist/ci-estate/page.d.ts.map +1 -0
- package/dist/ci-estate/page.js +233 -0
- package/dist/ci-estate/rows.d.ts +118 -0
- package/dist/ci-estate/rows.d.ts.map +1 -0
- package/dist/ci-estate/rows.js +126 -0
- package/dist/ci-estate.d.ts +92 -0
- package/dist/ci-estate.d.ts.map +1 -0
- package/dist/ci-estate.js +82 -0
- package/dist/ci-handover.d.ts +29 -5
- package/dist/ci-handover.d.ts.map +1 -1
- package/dist/ci-handover.js +50 -16
- package/dist/ci-identity.d.ts +82 -7
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +86 -15
- package/dist/ci-job-guard.d.ts +139 -0
- package/dist/ci-job-guard.d.ts.map +1 -0
- package/dist/ci-job-guard.js +287 -0
- package/dist/ci-jobs.d.ts +7 -0
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +7 -0
- package/dist/ci-product-words.d.ts +296 -0
- package/dist/ci-product-words.d.ts.map +1 -0
- package/dist/ci-product-words.js +407 -0
- package/dist/ci-product.d.ts +117 -0
- package/dist/ci-product.d.ts.map +1 -0
- package/dist/ci-product.js +113 -0
- package/dist/ci-respond-run.d.ts +73 -0
- package/dist/ci-respond-run.d.ts.map +1 -0
- package/dist/ci-respond-run.js +247 -0
- package/dist/ci-respond.d.ts +189 -0
- package/dist/ci-respond.d.ts.map +1 -0
- package/dist/ci-respond.js +285 -0
- package/dist/cli/commands/audit.d.ts +2 -2
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +3 -2
- package/dist/cli/commands/carve.js +2 -2
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +1 -1
- package/dist/cli/handlers/agent.d.ts +17 -0
- package/dist/cli/handlers/agent.d.ts.map +1 -0
- package/dist/cli/handlers/agent.js +114 -0
- package/dist/cli/handlers/approve-confirm.d.ts +84 -0
- package/dist/cli/handlers/approve-confirm.d.ts.map +1 -0
- package/dist/cli/handlers/approve-confirm.js +142 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +19 -1
- package/dist/cli/handlers/audit-log.d.ts +12 -0
- package/dist/cli/handlers/audit-log.d.ts.map +1 -0
- package/dist/cli/handlers/audit-log.js +81 -0
- package/dist/cli/handlers/build.d.ts +7 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +124 -1
- package/dist/cli/handlers/ci-check-job.d.ts +11 -0
- package/dist/cli/handlers/ci-check-job.d.ts.map +1 -0
- package/dist/cli/handlers/ci-check-job.js +27 -0
- package/dist/cli/handlers/ci-check.d.ts +3 -0
- package/dist/cli/handlers/ci-check.d.ts.map +1 -0
- package/dist/cli/handlers/ci-check.js +63 -0
- package/dist/cli/handlers/ci-forge-check.d.ts +3 -0
- package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -0
- package/dist/cli/handlers/ci-forge-check.js +89 -0
- package/dist/cli/handlers/e2e-safe-run.d.ts +12 -0
- package/dist/cli/handlers/e2e-safe-run.d.ts.map +1 -0
- package/dist/cli/handlers/e2e-safe-run.js +23 -0
- package/dist/cli/handlers/fan-out.js +4 -0
- package/dist/cli/handlers/gate-pending.d.ts +11 -0
- package/dist/cli/handlers/gate-pending.d.ts.map +1 -0
- package/dist/cli/handlers/gate-pending.js +44 -0
- package/dist/cli/handlers/init.d.ts.map +1 -1
- package/dist/cli/handlers/init.js +1 -0
- package/dist/cli/handlers/ledger.js +1 -1
- package/dist/cli/handlers/lifecycle-drift.d.ts +6 -2
- package/dist/cli/handlers/lifecycle-drift.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle-drift.js +7 -2
- package/dist/cli/handlers/lock.d.ts.map +1 -1
- package/dist/cli/handlers/lock.js +64 -5
- package/dist/cli/handlers/notify-relay.d.ts +15 -0
- package/dist/cli/handlers/notify-relay.d.ts.map +1 -0
- package/dist/cli/handlers/notify-relay.js +130 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -1
- package/dist/cli/handlers/pr-env.js +42 -11
- package/dist/cli/handlers/pr.d.ts +43 -3
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +908 -205
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +21 -2
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +3 -0
- package/dist/cli/handlers/run-wave.d.ts +8 -0
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +160 -2
- package/dist/cli/handlers/run.d.ts +6 -1
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +86 -1
- package/dist/cli/handlers/serve.d.ts.map +1 -1
- package/dist/cli/handlers/serve.js +10 -1
- package/dist/cli/main.d.ts +11 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +178 -13
- package/dist/cli/mcp/ledger-tools.d.ts +36 -0
- package/dist/cli/mcp/ledger-tools.d.ts.map +1 -0
- package/dist/cli/mcp/ledger-tools.js +122 -0
- package/dist/cli/mcp/product-tools.d.ts +78 -0
- package/dist/cli/mcp/product-tools.d.ts.map +1 -0
- package/dist/cli/mcp/product-tools.js +93 -0
- package/dist/cli/mcp/read-only.d.ts +34 -0
- package/dist/cli/mcp/read-only.d.ts.map +1 -0
- package/dist/cli/mcp/read-only.js +61 -0
- package/dist/cli/mcp/report-tools.d.ts +48 -0
- package/dist/cli/mcp/report-tools.d.ts.map +1 -0
- package/dist/cli/mcp/report-tools.js +128 -0
- package/dist/cli/mcp/server.d.ts +28 -1
- package/dist/cli/mcp/server.d.ts.map +1 -1
- package/dist/cli/mcp/server.js +86 -15
- package/dist/cli/mcp-config.d.ts +9 -2
- package/dist/cli/mcp-config.d.ts.map +1 -1
- package/dist/cli/mcp-config.js +8 -3
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +164 -3
- package/dist/cli/registry.d.ts +73 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cloud-lister/sigv4.d.ts +42 -7
- package/dist/cloud-lister/sigv4.d.ts.map +1 -1
- package/dist/cloud-lister/sigv4.js +72 -22
- package/dist/components/adoption.d.ts +69 -0
- package/dist/components/adoption.d.ts.map +1 -0
- package/dist/components/adoption.js +92 -0
- package/dist/components/apply-lease.d.ts +19 -0
- package/dist/components/apply-lease.d.ts.map +1 -0
- package/dist/components/apply-lease.js +41 -0
- package/dist/components/capability.d.ts +159 -5
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/capability.js +39 -6
- package/dist/components/check-hooks.d.ts +116 -0
- package/dist/components/check-hooks.d.ts.map +1 -0
- package/dist/components/check-hooks.js +192 -0
- package/dist/components/check-steps.d.ts +74 -0
- package/dist/components/check-steps.d.ts.map +1 -0
- package/dist/components/check-steps.js +102 -0
- package/dist/components/ci-services.d.ts +57 -0
- package/dist/components/ci-services.d.ts.map +1 -0
- package/dist/components/ci-services.js +60 -0
- package/dist/components/cli-support.d.ts +13 -0
- package/dist/components/cli-support.d.ts.map +1 -1
- package/dist/components/cli-support.js +10 -2
- package/dist/components/driver.d.ts +32 -3
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +59 -5
- package/dist/components/fan-out-run.d.ts +12 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +56 -16
- package/dist/components/groups.d.ts.map +1 -1
- package/dist/components/groups.js +23 -5
- package/dist/components/pr-env-ledger.d.ts +32 -0
- package/dist/components/pr-env-ledger.d.ts.map +1 -0
- package/dist/components/pr-env-ledger.js +38 -0
- package/dist/components/pr-env-ports.d.ts +12 -0
- package/dist/components/pr-env-ports.d.ts.map +1 -1
- package/dist/components/pr-env-ports.js +13 -3
- package/dist/components/pr-env-run.d.ts +6 -0
- package/dist/components/pr-env-run.d.ts.map +1 -1
- package/dist/components/pr-env-run.js +3 -2
- package/dist/components/pr-environment.d.ts +32 -4
- package/dist/components/pr-environment.d.ts.map +1 -1
- package/dist/components/pr-environment.js +26 -8
- package/dist/components/pr-pipeline.d.ts +297 -5
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +329 -18
- package/dist/components/pr-policy.d.ts +26 -2
- package/dist/components/pr-policy.d.ts.map +1 -1
- package/dist/components/pr-policy.js +41 -7
- package/dist/components/pr-run.d.ts +71 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +91 -7
- package/dist/components/pr-targets.d.ts +24 -0
- package/dist/components/pr-targets.d.ts.map +1 -0
- package/dist/components/pr-targets.js +48 -0
- package/dist/components/product-pipeline.d.ts +250 -0
- package/dist/components/product-pipeline.d.ts.map +1 -0
- package/dist/components/product-pipeline.js +212 -0
- package/dist/components/promote.d.ts +6 -0
- package/dist/components/promote.d.ts.map +1 -1
- package/dist/components/promote.js +4 -1
- package/dist/components/release-compile.d.ts +22 -1
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +85 -0
- package/dist/components/release-promote.d.ts +15 -1
- package/dist/components/release-promote.d.ts.map +1 -1
- package/dist/components/release-promote.js +67 -2
- package/dist/components/repo-lock.d.ts +27 -0
- package/dist/components/repo-lock.d.ts.map +1 -0
- package/dist/components/repo-lock.js +49 -0
- package/dist/components/row-lease.d.ts +84 -0
- package/dist/components/row-lease.d.ts.map +1 -0
- package/dist/components/row-lease.js +110 -0
- package/dist/components/wave-plan.d.ts +42 -0
- package/dist/components/wave-plan.d.ts.map +1 -1
- package/dist/components/wave-plan.js +72 -4
- package/dist/control/applied.d.ts +89 -0
- package/dist/control/applied.d.ts.map +1 -0
- package/dist/control/applied.js +175 -0
- package/dist/control/consumers.d.ts +78 -0
- package/dist/control/consumers.d.ts.map +1 -0
- package/dist/control/consumers.js +172 -0
- package/dist/control/dispatch.d.ts +334 -0
- package/dist/control/dispatch.d.ts.map +1 -0
- package/dist/control/dispatch.js +519 -0
- package/dist/control/edges.d.ts +75 -0
- package/dist/control/edges.d.ts.map +1 -0
- package/dist/control/edges.js +133 -0
- package/dist/control/reconcile.d.ts +120 -0
- package/dist/control/reconcile.d.ts.map +1 -0
- package/dist/control/reconcile.js +178 -0
- package/dist/control/records.d.ts +187 -0
- package/dist/control/records.d.ts.map +1 -0
- package/dist/control/records.js +307 -0
- package/dist/discovery/sandbox/bundle.d.ts.map +1 -1
- package/dist/discovery/sandbox/bundle.js +25 -1
- package/dist/e2e-harness/bucket.d.ts +21 -0
- package/dist/e2e-harness/bucket.d.ts.map +1 -0
- package/dist/e2e-harness/bucket.js +61 -0
- package/dist/e2e-harness/claim.d.ts +70 -0
- package/dist/e2e-harness/claim.d.ts.map +1 -0
- package/dist/e2e-harness/claim.js +98 -0
- package/dist/e2e-harness/driver.d.ts +64 -0
- package/dist/e2e-harness/driver.d.ts.map +1 -0
- package/dist/e2e-harness/driver.js +243 -0
- package/dist/e2e-harness/forgejo.d.ts +77 -0
- package/dist/e2e-harness/forgejo.d.ts.map +1 -0
- package/dist/e2e-harness/forgejo.js +205 -0
- package/dist/e2e-harness/git.d.ts +32 -0
- package/dist/e2e-harness/git.d.ts.map +1 -0
- package/dist/e2e-harness/git.js +67 -0
- package/dist/e2e-harness/index.d.ts +22 -0
- package/dist/e2e-harness/index.d.ts.map +1 -0
- package/dist/e2e-harness/index.js +48 -0
- package/dist/e2e-harness/jobs.d.ts +8 -0
- package/dist/e2e-harness/jobs.d.ts.map +1 -0
- package/dist/e2e-harness/jobs.js +34 -0
- package/dist/e2e-harness/pins.d.ts +45 -0
- package/dist/e2e-harness/pins.d.ts.map +1 -0
- package/dist/e2e-harness/pins.js +44 -0
- package/dist/e2e-harness/ports.d.ts +113 -0
- package/dist/e2e-harness/ports.d.ts.map +1 -0
- package/dist/e2e-harness/ports.js +4 -0
- package/dist/e2e-harness/reports.d.ts +45 -0
- package/dist/e2e-harness/reports.d.ts.map +1 -0
- package/dist/e2e-harness/reports.js +57 -0
- package/dist/e2e-harness/safe-run-cli.d.ts +17 -0
- package/dist/e2e-harness/safe-run-cli.d.ts.map +1 -0
- package/dist/e2e-harness/safe-run-cli.js +43 -0
- package/dist/e2e-harness/safe-run.d.ts +61 -0
- package/dist/e2e-harness/safe-run.d.ts.map +1 -0
- package/dist/e2e-harness/safe-run.js +172 -0
- package/dist/e2e-harness/scenario.d.ts +11 -0
- package/dist/e2e-harness/scenario.d.ts.map +1 -0
- package/dist/e2e-harness/scenario.js +89 -0
- package/dist/e2e-harness/schemas/demo-cycle.schema.json +282 -0
- package/dist/e2e-harness/schemas/demo-step.schema.json +245 -0
- package/dist/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
- package/dist/e2e-harness/schemas/e2e-claims.schema.json +18 -0
- package/dist/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
- package/dist/e2e-harness/schemas/index.d.ts +191 -0
- package/dist/e2e-harness/schemas/index.d.ts.map +1 -0
- package/dist/e2e-harness/schemas/index.js +62 -0
- package/dist/e2e-harness/stack.d.ts +124 -0
- package/dist/e2e-harness/stack.d.ts.map +1 -0
- package/dist/e2e-harness/stack.js +207 -0
- package/dist/e2e-harness/steps.d.ts +11 -0
- package/dist/e2e-harness/steps.d.ts.map +1 -0
- package/dist/e2e-harness/steps.js +22 -0
- package/dist/e2e-harness.d.ts +3 -0
- package/dist/e2e-harness.d.ts.map +1 -0
- package/dist/e2e-harness.js +2 -0
- package/dist/engine-facts.d.ts.map +1 -1
- package/dist/engine-facts.js +1 -2
- package/dist/exit-codes.d.ts +54 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +55 -0
- package/dist/forge-check/check.d.ts +63 -0
- package/dist/forge-check/check.d.ts.map +1 -0
- package/dist/forge-check/check.js +139 -0
- package/dist/forge-check/contract.d.ts +152 -0
- package/dist/forge-check/contract.d.ts.map +1 -0
- package/dist/forge-check/contract.js +118 -0
- package/dist/forge-check/forge.d.ts +42 -0
- package/dist/forge-check/forge.d.ts.map +1 -0
- package/dist/forge-check/forge.js +338 -0
- package/dist/forge-check/index.d.ts +24 -0
- package/dist/forge-check/index.d.ts.map +1 -0
- package/dist/forge-check/index.js +23 -0
- package/dist/forge-check/pulumi.d.ts +44 -0
- package/dist/forge-check/pulumi.d.ts.map +1 -0
- package/dist/forge-check/pulumi.js +184 -0
- package/dist/forge-check/read-only.d.ts +26 -0
- package/dist/forge-check/read-only.d.ts.map +1 -0
- package/dist/forge-check/read-only.js +53 -0
- package/dist/forge-check/trust.d.ts +94 -0
- package/dist/forge-check/trust.d.ts.map +1 -0
- package/dist/forge-check/trust.js +532 -0
- package/dist/forge-check/types.d.ts +80 -0
- package/dist/forge-check/types.d.ts.map +1 -0
- package/dist/forge-check/types.js +18 -0
- package/dist/forge-check.d.ts +6 -0
- package/dist/forge-check.d.ts.map +1 -0
- package/dist/forge-check.js +5 -0
- package/dist/gate-decision.d.ts +1 -0
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +2 -0
- package/dist/gate-policy.d.ts +47 -1
- package/dist/gate-policy.d.ts.map +1 -1
- package/dist/gate-policy.js +50 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lexicon.d.ts +152 -6
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/adoption-file.d.ts +24 -0
- package/dist/lifecycle/adoption-file.d.ts.map +1 -1
- package/dist/lifecycle/adoption-file.js +1 -2
- package/dist/lifecycle/cloud-index.d.ts.map +1 -1
- package/dist/lifecycle/cloud-index.js +1 -2
- package/dist/lifecycle/gate-applied.d.ts +6 -0
- package/dist/lifecycle/gate-applied.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.d.ts +29 -0
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +10 -1
- package/dist/lifecycle/gate-pending-by-plan.d.ts +75 -0
- package/dist/lifecycle/gate-pending-by-plan.d.ts.map +1 -0
- package/dist/lifecycle/gate-pending-by-plan.js +96 -0
- package/dist/lifecycle/gated-request-digest.d.ts +28 -0
- package/dist/lifecycle/gated-request-digest.d.ts.map +1 -0
- package/dist/lifecycle/gated-request-digest.js +35 -0
- package/dist/lifecycle/gated-request.d.ts +126 -0
- package/dist/lifecycle/gated-request.d.ts.map +1 -0
- package/dist/lifecycle/gated-request.js +204 -0
- package/dist/lifecycle/identity-match.d.ts +15 -0
- package/dist/lifecycle/identity-match.d.ts.map +1 -1
- package/dist/lifecycle/identity-match.js +11 -6
- package/dist/lifecycle/index-diff.d.ts +40 -0
- package/dist/lifecycle/index-diff.d.ts.map +1 -1
- package/dist/lifecycle/index-diff.js +1 -2
- package/dist/lifecycle/index-document.d.ts.map +1 -1
- package/dist/lifecycle/index-document.js +1 -2
- package/dist/lifecycle/index-import.d.ts +4 -1
- package/dist/lifecycle/index-import.d.ts.map +1 -1
- package/dist/lifecycle/index-import.js +29 -32
- package/dist/lifecycle/ledger-read.d.ts.map +1 -1
- package/dist/lifecycle/ledger-read.js +7 -3
- package/dist/lifecycle/lock-rows.d.ts +76 -0
- package/dist/lifecycle/lock-rows.d.ts.map +1 -0
- package/dist/lifecycle/lock-rows.js +140 -0
- package/dist/lifecycle/query.d.ts +50 -3
- package/dist/lifecycle/query.d.ts.map +1 -1
- package/dist/lifecycle/query.js +97 -7
- package/dist/lifecycle/release-catalog-site.d.ts +66 -0
- package/dist/lifecycle/release-catalog-site.d.ts.map +1 -0
- package/dist/lifecycle/release-catalog-site.js +232 -0
- package/dist/lifecycle/release-catalog.d.ts +201 -0
- package/dist/lifecycle/release-catalog.d.ts.map +1 -0
- package/dist/lifecycle/release-catalog.js +198 -0
- package/dist/lifecycle/release-changelog.d.ts +41 -0
- package/dist/lifecycle/release-changelog.d.ts.map +1 -0
- package/dist/lifecycle/release-changelog.js +38 -0
- package/dist/lifecycle/release-cut.d.ts +1 -0
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +1 -1
- package/dist/lifecycle/release-ledger.d.ts +16 -0
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +9 -0
- package/dist/lifecycle/release-publish.d.ts +43 -22
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-read.d.ts.map +1 -1
- package/dist/lifecycle/release-read.js +3 -0
- package/dist/lifecycle/release-status.d.ts +106 -0
- package/dist/lifecycle/release-status.d.ts.map +1 -0
- package/dist/lifecycle/release-status.js +115 -0
- package/dist/lifecycle/resource-lock.d.ts +120 -0
- package/dist/lifecycle/resource-lock.d.ts.map +1 -0
- package/dist/lifecycle/resource-lock.js +317 -0
- package/dist/lifecycle/retention.d.ts.map +1 -1
- package/dist/lifecycle/retention.js +3 -0
- package/dist/lifecycle/run-ledger.d.ts.map +1 -1
- package/dist/lifecycle/run-ledger.js +9 -1
- package/dist/lifecycle/snapshot-store-s3.d.ts +36 -3
- package/dist/lifecycle/snapshot-store-s3.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store-s3.js +9 -44
- package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.js +1 -2
- package/dist/lifecycle/target-lock.d.ts +15 -0
- package/dist/lifecycle/target-lock.d.ts.map +1 -1
- package/dist/lifecycle/target-lock.js +25 -10
- package/dist/lifecycle/wave-plans.d.ts +23 -7
- package/dist/lifecycle/wave-plans.d.ts.map +1 -1
- package/dist/lifecycle/wave-plans.js +9 -2
- package/dist/mcp/types.d.ts +7 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/notify-product.d.ts +43 -0
- package/dist/notify-product.d.ts.map +1 -0
- package/dist/notify-product.js +58 -0
- package/dist/notify-relay.d.ts +197 -0
- package/dist/notify-relay.d.ts.map +1 -0
- package/dist/notify-relay.js +321 -0
- package/dist/notify.d.ts +44 -4
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +77 -14
- package/dist/object-store/azure-blob.d.ts +129 -0
- package/dist/object-store/azure-blob.d.ts.map +1 -0
- package/dist/object-store/azure-blob.js +341 -0
- package/dist/object-store/common.d.ts +108 -0
- package/dist/object-store/common.d.ts.map +1 -0
- package/dist/object-store/common.js +80 -0
- package/dist/object-store/errors.d.ts +28 -0
- package/dist/object-store/errors.d.ts.map +1 -0
- package/dist/object-store/errors.js +21 -0
- package/dist/object-store/from-env.d.ts +18 -0
- package/dist/object-store/from-env.d.ts.map +1 -0
- package/dist/object-store/from-env.js +22 -0
- package/dist/object-store/gcs.d.ts +106 -0
- package/dist/object-store/gcs.d.ts.map +1 -0
- package/dist/object-store/gcs.js +393 -0
- package/dist/object-store/index.d.ts +9 -0
- package/dist/object-store/index.d.ts.map +1 -0
- package/dist/object-store/index.js +8 -0
- package/dist/object-store/s3.d.ts +146 -0
- package/dist/object-store/s3.d.ts.map +1 -0
- package/dist/object-store/s3.js +306 -0
- package/dist/op/activities/converge.d.ts.map +1 -1
- package/dist/op/activities/converge.js +2 -1
- package/dist/op/activities/index.d.ts +1 -1
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/index.js +1 -1
- package/dist/op/activities/review-agent.d.ts +55 -2
- package/dist/op/activities/review-agent.d.ts.map +1 -1
- package/dist/op/activities/review-agent.js +65 -5
- package/dist/op/approval-status.d.ts +103 -0
- package/dist/op/approval-status.d.ts.map +1 -0
- package/dist/op/approval-status.js +197 -0
- package/dist/op/gate.d.ts +29 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +59 -23
- package/dist/op/generate-pipeline.d.ts.map +1 -1
- package/dist/op/generate-pipeline.js +7 -1
- package/dist/op/index.d.ts +12 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +7 -1
- package/dist/op/op-waves-after-plan.d.ts +137 -0
- package/dist/op/op-waves-after-plan.d.ts.map +1 -0
- package/dist/op/op-waves-after-plan.js +163 -0
- package/dist/op/op-waves-capability-spec.d.ts +63 -0
- package/dist/op/op-waves-capability-spec.d.ts.map +1 -0
- package/dist/op/op-waves-capability-spec.js +115 -0
- package/dist/op/op-waves-capability.d.ts +197 -0
- package/dist/op/op-waves-capability.d.ts.map +1 -0
- package/dist/op/op-waves-capability.js +311 -0
- package/dist/op/op-waves-events.d.ts +54 -0
- package/dist/op/op-waves-events.d.ts.map +1 -0
- package/dist/op/op-waves-events.js +122 -0
- package/dist/op/op-waves-notify.d.ts +7 -1
- package/dist/op/op-waves-notify.d.ts.map +1 -1
- package/dist/op/op-waves-notify.js +35 -16
- package/dist/op/op-waves-release-port.d.ts +18 -0
- package/dist/op/op-waves-release-port.d.ts.map +1 -0
- package/dist/op/op-waves-release-port.js +61 -0
- package/dist/op/op-waves-release.d.ts +92 -0
- package/dist/op/op-waves-release.d.ts.map +1 -0
- package/dist/op/op-waves-release.js +96 -0
- package/dist/op/op-waves-run.d.ts +182 -6
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +1076 -44
- package/dist/op/op-waves-stand-down.d.ts +60 -0
- package/dist/op/op-waves-stand-down.d.ts.map +1 -0
- package/dist/op/op-waves-stand-down.js +96 -0
- package/dist/op/op-waves.d.ts +187 -8
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +203 -19
- package/dist/op/runtime.d.ts +95 -0
- package/dist/op/runtime.d.ts.map +1 -1
- package/dist/op/runtime.js +18 -0
- package/dist/op/stage-hooks.d.ts +45 -7
- package/dist/op/stage-hooks.d.ts.map +1 -1
- package/dist/op/stage-hooks.js +61 -3
- package/dist/op/steward-beside.d.ts.map +1 -1
- package/dist/op/steward-beside.js +2 -1
- package/dist/op/types.d.ts +2 -2
- package/dist/op/types.d.ts.map +1 -1
- package/dist/op/types.js +3 -2
- package/dist/otlp-metrics.d.ts +38 -0
- package/dist/otlp-metrics.d.ts.map +1 -0
- package/dist/otlp-metrics.js +82 -0
- package/dist/otlp.d.ts +249 -0
- package/dist/otlp.d.ts.map +1 -0
- package/dist/otlp.js +425 -0
- package/dist/override-gate.d.ts.map +1 -1
- package/dist/override-gate.js +5 -0
- package/dist/parallelism.d.ts +17 -0
- package/dist/parallelism.d.ts.map +1 -0
- package/dist/parallelism.js +33 -0
- package/dist/policy-packs.d.ts +69 -0
- package/dist/policy-packs.d.ts.map +1 -0
- package/dist/policy-packs.js +205 -0
- package/dist/policy-source.d.ts +51 -0
- package/dist/policy-source.d.ts.map +1 -0
- package/dist/policy-source.js +102 -0
- package/dist/pr-forge.d.ts +40 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +146 -37
- package/dist/pr-loop.d.ts +158 -11
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +302 -44
- package/dist/pr-merge.d.ts +64 -0
- package/dist/pr-merge.d.ts.map +1 -0
- package/dist/pr-merge.js +78 -0
- package/dist/pr-post.d.ts +86 -1
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +141 -5
- package/dist/pr-report-url.d.ts +32 -4
- package/dist/pr-report-url.d.ts.map +1 -1
- package/dist/pr-report-url.js +45 -5
- package/dist/pr-requires.d.ts +13 -2
- package/dist/pr-requires.d.ts.map +1 -1
- package/dist/pr-requires.js +14 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/run-event.d.ts +26 -1
- package/dist/run-event.d.ts.map +1 -1
- package/dist/run-event.js +3 -1
- package/dist/scheduled-op-cloud.d.ts +32 -0
- package/dist/scheduled-op-cloud.d.ts.map +1 -0
- package/dist/scheduled-op-cloud.js +69 -0
- package/dist/sorted-json.d.ts +10 -0
- package/dist/sorted-json.d.ts.map +1 -0
- package/dist/sorted-json.js +14 -0
- package/dist/terraform/credentials.d.ts +59 -0
- package/dist/terraform/credentials.d.ts.map +1 -0
- package/dist/terraform/credentials.js +149 -0
- package/dist/utils.d.ts +1 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -9
- package/dist/wave-runtime.d.ts +1 -1
- package/dist/wave-runtime.js +2 -2
- package/dist/wave-runtime.mjs +405 -287
- package/dist/workspace/chant-migrations/chud-lexicon-exit.d.ts.map +1 -1
- package/dist/workspace/chant-migrations/chud-lexicon-exit.js +4 -1
- package/dist/workspace/ci-lock-grain.d.ts +17 -0
- package/dist/workspace/ci-lock-grain.d.ts.map +1 -0
- package/dist/workspace/ci-lock-grain.js +21 -0
- package/dist/workspace/ci-run.d.ts +2 -1
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +10 -3
- package/dist/workspace/declaration.d.ts +16 -4
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +5 -2
- package/dist/workspace/declaration.schema.json +27 -3
- package/dist/workspace/drift-cli.d.ts.map +1 -1
- package/dist/workspace/drift-cli.js +8 -3
- package/dist/workspace/exit-cli.d.ts +1 -1
- package/dist/workspace/exit-cli.d.ts.map +1 -1
- package/dist/workspace/exit-cli.js +2 -1
- package/dist/workspace/import-fetch.d.ts +4 -2
- package/dist/workspace/import-fetch.d.ts.map +1 -1
- package/dist/workspace/import-fetch.js +4 -2
- package/dist/workspace/import-init.d.ts.map +1 -1
- package/dist/workspace/import-init.js +4 -2
- package/dist/workspace/ledger.schema.json +7 -3
- package/dist/workspace/lineage-upgrade-cli.d.ts +1 -1
- package/dist/workspace/lineage-upgrade-cli.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade-cli.js +2 -1
- package/dist/workspace/pr-report.schema.json +79 -3
- package/dist/workspace/promote.d.ts +1 -1
- package/dist/workspace/promote.d.ts.map +1 -1
- package/dist/workspace/promote.js +2 -1
- package/dist/workspace/records-cli.d.ts +2 -2
- package/dist/workspace/records-cli.d.ts.map +1 -1
- package/dist/workspace/records-cli.js +3 -2
- package/dist/workspace/release-catalog.schema.json +277 -0
- package/dist/workspace/run-event.schema.json +18 -1
- package/dist/workspace/work-cli.d.ts +3 -1
- package/dist/workspace/work-cli.d.ts.map +1 -1
- package/dist/workspace/work-cli.js +7 -2
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -1
- package/package.json +21 -1
- package/src/__fixtures__/estate-ledger.ts +101 -0
- package/src/__fixtures__/oidc-emulator.ts +31 -2
- package/src/__fixtures__/product-words.ts +44 -0
- package/src/__golden__/wave-loop/op-by-apply-after-fails.json +10 -2
- package/src/__golden__/wave-loop/op-by-apply-hold.json +20 -4
- package/src/__golden__/wave-loop/op-by-apply-ignored.json +10 -2
- package/src/__golden__/wave-loop/op-by-apply-pass.json +10 -2
- package/src/__golden__/wave-loop/op-by-apply-skip.json +10 -2
- package/src/__golden__/wave-loop/op-discover-rest-stops.json +22 -6
- package/src/__golden__/wave-loop/op-discover-rest.json +44 -12
- package/src/__golden__/wave-loop/op-discover-wide.json +12 -3
- package/src/__golden__/wave-loop/op-held-on.json +28 -7
- package/src/__golden__/wave-loop/op-hooks-apply-fails.json +22 -6
- package/src/__golden__/wave-loop/op-hooks-fail-after-apply.json +22 -6
- package/src/__golden__/wave-loop/op-hooks-fail-before-apply.json +4 -2
- package/src/__golden__/wave-loop/op-hooks-held.json +26 -8
- package/src/__golden__/wave-loop/op-hooks-hold-before-apply.json +18 -4
- package/src/__golden__/wave-loop/op-hooks-pass.json +22 -6
- package/src/__golden__/wave-loop/op-hooks-share.json +20 -7
- package/src/__golden__/wave-loop/op-outcome-held.json +12 -3
- package/src/__golden__/wave-loop/op-outcome-replan-approved.json +16 -5
- package/src/__golden__/wave-loop/op-outcome-replan-forever.json +48 -21
- package/src/__golden__/wave-loop/op-outcome-replan.json +16 -5
- package/src/__golden__/wave-loop/op-outcome-stood-down.json +12 -3
- package/src/__golden__/wave-loop/op-outcome-unreadable.json +12 -3
- package/src/__golden__/wave-loop/op-overridden.json +28 -7
- package/src/__golden__/wave-loop/op-per-run.json +20 -4
- package/src/__golden__/wave-loop/op-point.json +18 -4
- package/src/__golden__/wave-loop/op-pr-review.json +10 -2
- package/src/__golden__/wave-loop/op-spend-change-only.json +10 -2
- package/src/__golden__/wave-loop/op-spend.json +10 -2
- package/src/__golden__/wave-loop/op-wave-commands.json +56 -13
- package/src/__golden__/wave-loop/op-wide.json +20 -4
- package/src/bucket-check/azure.ts +307 -0
- package/src/bucket-check/bucket-check.test.ts +210 -0
- package/src/bucket-check/fixtures/azure.json +153 -0
- package/src/bucket-check/fixtures/gcs.json +148 -0
- package/src/bucket-check/fixtures/s3.json +277 -0
- package/src/bucket-check/gcs.ts +257 -0
- package/src/bucket-check/index.ts +61 -0
- package/src/bucket-check/s3.ts +433 -0
- package/src/bucket-check/types.ts +75 -0
- package/src/bucket-check/wire.ts +50 -0
- package/src/bucket-check.ts +5 -0
- package/src/capabilities/templates.test.ts +2 -3
- package/src/capabilities/templates.ts +1 -2
- package/src/cdk/advise.test.ts +1 -1
- package/src/change-set-bundle.test.ts +0 -1
- package/src/change-set.ts +2 -3
- package/src/ci-agent.test.ts +348 -0
- package/src/ci-agent.ts +1025 -0
- package/src/ci-audit/__fixtures__/cloudtrail-lookup-bucket.json +37 -0
- package/src/ci-audit/__fixtures__/cloudtrail-writes-window.json +59 -0
- package/src/ci-audit/attribution.ts +260 -0
- package/src/ci-audit/audit-log.ts +220 -0
- package/src/ci-audit/ci-audit.test.ts +175 -0
- package/src/ci-audit/index.ts +15 -0
- package/src/ci-audit/unrecorded.ts +140 -0
- package/src/ci-audit.ts +2 -0
- package/src/ci-control.ts +173 -0
- package/src/ci-estate/delivery.ts +433 -0
- package/src/ci-estate/overdue.ts +81 -0
- package/src/ci-estate/page.ts +343 -0
- package/src/ci-estate/rows.ts +251 -0
- package/src/ci-estate.test.ts +281 -0
- package/src/ci-estate.ts +175 -0
- package/src/ci-handover.ts +67 -16
- package/src/ci-identity-database.test.ts +54 -0
- package/src/ci-identity-pulumi.test.ts +163 -0
- package/src/ci-identity-targets.test.ts +3 -1
- package/src/ci-identity.ts +123 -22
- package/src/ci-job-guard.test.ts +154 -0
- package/src/ci-job-guard.ts +319 -0
- package/src/ci-jobs.ts +8 -0
- package/src/ci-product-comment-targets.test.ts +45 -0
- package/src/ci-product-words.test.ts +101 -0
- package/src/ci-product-words.ts +565 -0
- package/src/ci-product.ts +226 -0
- package/src/ci-respond-run.ts +291 -0
- package/src/ci-respond.test.ts +264 -0
- package/src/ci-respond.ts +412 -0
- package/src/ci-shared-reads.test.ts +145 -0
- package/src/cli/commands/audit.test.ts +1 -1
- package/src/cli/commands/audit.ts +3 -2
- package/src/cli/commands/carve.test.ts +1 -1
- package/src/cli/commands/carve.ts +2 -2
- package/src/cli/commands/init.ts +3 -1
- package/src/cli/component-wave-args.test.ts +16 -0
- package/src/cli/handlers/agent.ts +126 -0
- package/src/cli/handlers/approve-confirm.test.ts +276 -0
- package/src/cli/handlers/approve-confirm.ts +200 -0
- package/src/cli/handlers/approve.ts +18 -1
- package/src/cli/handlers/audit-log.ts +74 -0
- package/src/cli/handlers/build-pr-loop-flags.test.ts +98 -0
- package/src/cli/handlers/build.test.ts +7 -0
- package/src/cli/handlers/build.ts +113 -1
- package/src/cli/handlers/ci-check-job.test.ts +114 -0
- package/src/cli/handlers/ci-check-job.ts +33 -0
- package/src/cli/handlers/ci-check.ts +63 -0
- package/src/cli/handlers/ci-forge-check.ts +91 -0
- package/src/cli/handlers/e2e-safe-run.ts +27 -0
- package/src/cli/handlers/fan-out.test.ts +10 -10
- package/src/cli/handlers/fan-out.ts +5 -0
- package/src/cli/handlers/gate-pending.ts +46 -0
- package/src/cli/handlers/init.ts +1 -0
- package/src/cli/handlers/ledger.ts +1 -1
- package/src/cli/handlers/lifecycle-drift.ts +7 -2
- package/src/cli/handlers/lock.test.ts +29 -2
- package/src/cli/handlers/lock.ts +66 -6
- package/src/cli/handlers/notify-relay.ts +130 -0
- package/src/cli/handlers/pr-before-merge.test.ts +2 -1
- package/src/cli/handlers/pr-deploy-inputs.test.ts +7 -7
- package/src/cli/handlers/pr-env.ts +48 -11
- package/src/cli/handlers/pr-plan-comment-targets.test.ts +166 -0
- package/src/cli/handlers/pr-plan-flags.test.ts +161 -0
- package/src/cli/handlers/pr-plan-targets.test.ts +155 -0
- package/src/cli/handlers/pr-waves-blocked.test.ts +5 -0
- package/src/cli/handlers/pr-waves.test.ts +8 -2
- package/src/cli/handlers/pr.test.ts +8 -8
- package/src/cli/handlers/pr.ts +879 -205
- package/src/cli/handlers/promote.test.ts +5 -5
- package/src/cli/handlers/promote.ts +22 -2
- package/src/cli/handlers/release.ts +2 -0
- package/src/cli/handlers/run-components-exit.test.ts +7 -7
- package/src/cli/handlers/run-wave.ts +144 -2
- package/src/cli/handlers/run.test.ts +6 -4
- package/src/cli/handlers/run.ts +86 -1
- package/src/cli/handlers/serve.ts +10 -1
- package/src/cli/main.test.ts +1 -1
- package/src/cli/main.ts +180 -13
- package/src/cli/mcp/ledger-tools.ts +126 -0
- package/src/cli/mcp/product-tools.test.ts +123 -0
- package/src/cli/mcp/product-tools.ts +129 -0
- package/src/cli/mcp/read-only.test.ts +134 -0
- package/src/cli/mcp/read-only.ts +68 -0
- package/src/cli/mcp/report-tools.ts +135 -0
- package/src/cli/mcp/server.test.ts +5 -4
- package/src/cli/mcp/server.ts +90 -16
- package/src/cli/mcp-config.ts +8 -3
- package/src/cli/parse-args.ts +119 -2
- package/src/cli/registry.ts +73 -0
- package/src/cloud-lister/sigv4.ts +80 -23
- package/src/components/adoption.test.ts +140 -0
- package/src/components/adoption.ts +140 -0
- package/src/components/apply-lease.ts +49 -0
- package/src/components/capability.ts +180 -6
- package/src/components/check-hooks.test.ts +66 -0
- package/src/components/check-hooks.ts +255 -0
- package/src/components/check-steps.test.ts +70 -0
- package/src/components/check-steps.ts +158 -0
- package/src/components/ci-services.test.ts +51 -0
- package/src/components/ci-services.ts +82 -0
- package/src/components/cli-support.ts +23 -2
- package/src/components/driver.test.ts +3 -3
- package/src/components/driver.ts +73 -6
- package/src/components/fan-out-run.ts +68 -18
- package/src/components/groups.ts +21 -4
- package/src/components/plan-flags.test.ts +46 -0
- package/src/components/pr-comment-preview-targets.test.ts +34 -0
- package/src/components/pr-comment-preview.test.ts +54 -0
- package/src/components/pr-env-ledger.test.ts +9 -0
- package/src/components/pr-env-ledger.ts +42 -0
- package/src/components/pr-env-ports.ts +29 -4
- package/src/components/pr-env-run-bundle.test.ts +2 -14
- package/src/components/pr-env-run.test.ts +19 -0
- package/src/components/pr-env-run.ts +12 -2
- package/src/components/pr-environment.test.ts +29 -0
- package/src/components/pr-environment.ts +40 -8
- package/src/components/pr-pipeline-runners.test.ts +80 -0
- package/src/components/pr-pipeline.test.ts +15 -0
- package/src/components/pr-pipeline.ts +498 -18
- package/src/components/pr-policy.ts +45 -7
- package/src/components/pr-run.test.ts +1 -1
- package/src/components/pr-run.ts +138 -11
- package/src/components/pr-stale-job.test.ts +34 -0
- package/src/components/pr-targets.test.ts +35 -0
- package/src/components/pr-targets.ts +45 -0
- package/src/components/product-pipeline.test.ts +200 -0
- package/src/components/product-pipeline.ts +383 -0
- package/src/components/promote.ts +10 -1
- package/src/components/release-compile.ts +87 -1
- package/src/components/release-promote.ts +65 -1
- package/src/components/repo-lock.ts +52 -0
- package/src/components/row-lease.test.ts +490 -0
- package/src/components/row-lease.ts +167 -0
- package/src/components/wave-plan-policy.test.ts +19 -0
- package/src/components/wave-plan.ts +96 -6
- package/src/control/__fixtures__/consumers/apps/consumers.json +15 -0
- package/src/control/__fixtures__/consumers/infra/consumers.json +23 -0
- package/src/control/applied.test.ts +148 -0
- package/src/control/applied.ts +191 -0
- package/src/control/consumers.test.ts +129 -0
- package/src/control/consumers.ts +192 -0
- package/src/control/control.test.ts +302 -0
- package/src/control/dispatch.ts +699 -0
- package/src/control/edges.test.ts +112 -0
- package/src/control/edges.ts +164 -0
- package/src/control/note-checkout.test.ts +91 -0
- package/src/control/reconcile.ts +250 -0
- package/src/control/records.ts +395 -0
- package/src/discovery/sandbox/bundle.ts +25 -1
- package/src/e2e-harness/__project__/chant.config.ts +4 -0
- package/src/e2e-harness/__project__/src/compose.ts +33 -0
- package/src/e2e-harness/bucket.ts +69 -0
- package/src/e2e-harness/claim.test.ts +150 -0
- package/src/e2e-harness/claim.ts +140 -0
- package/src/e2e-harness/driver.test.ts +304 -0
- package/src/e2e-harness/driver.ts +294 -0
- package/src/e2e-harness/forgejo.ts +267 -0
- package/src/e2e-harness/git.ts +96 -0
- package/src/e2e-harness/index.ts +50 -0
- package/src/e2e-harness/jobs.ts +35 -0
- package/src/e2e-harness/pins.ts +52 -0
- package/src/e2e-harness/ports.ts +130 -0
- package/src/e2e-harness/reports.ts +79 -0
- package/src/e2e-harness/safe-run-cli.test.ts +102 -0
- package/src/e2e-harness/safe-run-cli.ts +54 -0
- package/src/e2e-harness/safe-run.ts +198 -0
- package/src/e2e-harness/scenario.ts +89 -0
- package/src/e2e-harness/schemas/README.md +62 -0
- package/src/e2e-harness/schemas/demo-cycle.schema.json +282 -0
- package/src/e2e-harness/schemas/demo-step.schema.json +245 -0
- package/src/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
- package/src/e2e-harness/schemas/e2e-claims.schema.json +18 -0
- package/src/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
- package/src/e2e-harness/schemas/index.ts +220 -0
- package/src/e2e-harness/schemas.test.ts +145 -0
- package/src/e2e-harness/stack.test.ts +124 -0
- package/src/e2e-harness/stack.ts +306 -0
- package/src/e2e-harness/steps.ts +30 -0
- package/src/e2e-harness.ts +2 -0
- package/src/engine-facts.test.ts +2 -3
- package/src/engine-facts.ts +1 -2
- package/src/exit-codes.test.ts +32 -0
- package/src/exit-codes.ts +61 -0
- package/src/forge-check/check.ts +155 -0
- package/src/forge-check/contract.ts +215 -0
- package/src/forge-check/forge-check.test.ts +427 -0
- package/src/forge-check/forge.ts +318 -0
- package/src/forge-check/index.ts +43 -0
- package/src/forge-check/pulumi.ts +192 -0
- package/src/forge-check/read-only.ts +56 -0
- package/src/forge-check/trust.ts +527 -0
- package/src/forge-check/types.ts +78 -0
- package/src/forge-check.ts +5 -0
- package/src/gate-decision-bundle.test.ts +11 -0
- package/src/gate-decision.ts +3 -0
- package/src/gate-policy.ts +92 -3
- package/src/gated-waves-bundle.test.ts +0 -1
- package/src/index.ts +2 -0
- package/src/lexicon.ts +143 -6
- package/src/lifecycle/adoption-file.ts +1 -2
- package/src/lifecycle/cloud-index.test.ts +2 -3
- package/src/lifecycle/cloud-index.ts +1 -2
- package/src/lifecycle/control-entries-ledger.test.ts +69 -0
- package/src/lifecycle/gate-applied.ts +6 -0
- package/src/lifecycle/gate-ledger.ts +35 -1
- package/src/lifecycle/gate-pending-by-plan.test.ts +69 -0
- package/src/lifecycle/gate-pending-by-plan.ts +133 -0
- package/src/lifecycle/gated-request-digest.ts +49 -0
- package/src/lifecycle/gated-request-ledger.test.ts +53 -0
- package/src/lifecycle/gated-request.ts +279 -0
- package/src/lifecycle/identity-match.ts +25 -6
- package/src/lifecycle/index-diff.ts +1 -2
- package/src/lifecycle/index-document.ts +1 -2
- package/src/lifecycle/index-import.test.ts +14 -0
- package/src/lifecycle/index-import.ts +54 -34
- package/src/lifecycle/ledger-read.ts +7 -3
- package/src/lifecycle/lock-rows.test.ts +109 -0
- package/src/lifecycle/lock-rows.ts +167 -0
- package/src/lifecycle/publish-target-context.test.ts +108 -0
- package/src/lifecycle/query.test.ts +2 -3
- package/src/lifecycle/query.ts +109 -8
- package/src/lifecycle/release-catalog-site.test.ts +142 -0
- package/src/lifecycle/release-catalog-site.ts +291 -0
- package/src/lifecycle/release-catalog.test.ts +192 -0
- package/src/lifecycle/release-catalog.ts +353 -0
- package/src/lifecycle/release-changelog.test.ts +70 -0
- package/src/lifecycle/release-changelog.ts +71 -0
- package/src/lifecycle/release-cut.ts +2 -2
- package/src/lifecycle/release-ledger.ts +19 -0
- package/src/lifecycle/release-publish.ts +45 -22
- package/src/lifecycle/release-read.ts +2 -0
- package/src/lifecycle/release-status.test.ts +185 -0
- package/src/lifecycle/release-status.ts +175 -0
- package/src/lifecycle/resource-lock.test.ts +175 -0
- package/src/lifecycle/resource-lock.ts +354 -0
- package/src/lifecycle/retention.ts +2 -0
- package/src/lifecycle/run-ledger.ts +7 -1
- package/src/lifecycle/snapshot-store-s3.ts +9 -45
- package/src/lifecycle/snapshot-store.ts +1 -2
- package/src/lifecycle/target-lock.ts +24 -9
- package/src/lifecycle/wave-plans.ts +33 -5
- package/src/mcp/types.ts +7 -0
- package/src/notify-product.ts +76 -0
- package/src/notify-relay.test.ts +213 -0
- package/src/notify-relay.ts +407 -0
- package/src/notify.ts +95 -14
- package/src/object-store/azure-blob.ts +374 -0
- package/src/object-store/common.ts +133 -0
- package/src/object-store/errors.ts +26 -0
- package/src/object-store/from-env.ts +36 -0
- package/src/object-store/gcs.ts +436 -0
- package/src/object-store/index.ts +8 -0
- package/src/object-store/object-store.test.ts +130 -0
- package/src/object-store/s3.ts +350 -0
- package/src/op/activities/converge.ts +2 -1
- package/src/op/activities/index.ts +1 -1
- package/src/op/activities/review-agent.open.test.ts +78 -0
- package/src/op/activities/review-agent.test.ts +13 -0
- package/src/op/activities/review-agent.ts +89 -5
- package/src/op/approval-status.test.ts +134 -0
- package/src/op/approval-status.ts +235 -0
- package/src/op/gate-review.test.ts +2 -1
- package/src/op/gate.ts +81 -22
- package/src/op/generate-pipeline.ts +7 -1
- package/src/op/index.ts +23 -0
- package/src/op/op-waves-after-plan.test.ts +288 -0
- package/src/op/op-waves-after-plan.ts +238 -0
- package/src/op/op-waves-capability-spec.ts +133 -0
- package/src/op/op-waves-capability.test.ts +217 -0
- package/src/op/op-waves-capability.ts +370 -0
- package/src/op/op-waves-events.ts +135 -0
- package/src/op/op-waves-notify-words.test.ts +149 -0
- package/src/op/op-waves-notify.ts +41 -16
- package/src/op/op-waves-parallelism.test.ts +89 -0
- package/src/op/op-waves-pull-request.test.ts +219 -0
- package/src/op/op-waves-release-port.ts +64 -0
- package/src/op/op-waves-release.test.ts +209 -0
- package/src/op/op-waves-release.ts +132 -0
- package/src/op/op-waves-run-record.test.ts +32 -0
- package/src/op/op-waves-run.ts +1235 -52
- package/src/op/op-waves-stand-down.test.ts +240 -0
- package/src/op/op-waves-stand-down.ts +107 -0
- package/src/op/op-waves-trace.test.ts +205 -0
- package/src/op/op-waves.test.ts +112 -0
- package/src/op/op-waves.ts +320 -22
- package/src/op/runtime.ts +107 -0
- package/src/op/stage-hooks-hold-record.test.ts +41 -0
- package/src/op/stage-hooks.ts +91 -12
- package/src/op/steward-beside.ts +2 -1
- package/src/op/types.ts +3 -2
- package/src/otlp-metrics.ts +96 -0
- package/src/otlp.test.ts +243 -0
- package/src/otlp.ts +543 -0
- package/src/override-gate-bundle.test.ts +2 -0
- package/src/override-gate.ts +4 -0
- package/src/parallelism.test.ts +38 -0
- package/src/parallelism.ts +33 -0
- package/src/policy-packs.ts +230 -0
- package/src/policy-source.test.ts +256 -0
- package/src/policy-source.ts +111 -0
- package/src/pr-forge-bundle.test.ts +1 -1
- package/src/pr-forge.ts +175 -33
- package/src/pr-loop-bundle.test.ts +7 -3
- package/src/pr-loop-narrowed.test.ts +63 -0
- package/src/pr-loop-words.test.ts +155 -0
- package/src/pr-loop.ts +398 -52
- package/src/pr-merge.test.ts +100 -0
- package/src/pr-merge.ts +105 -0
- package/src/pr-post-stale.test.ts +163 -0
- package/src/pr-post.ts +190 -5
- package/src/pr-report-url.ts +61 -6
- package/src/pr-requires.test.ts +37 -1
- package/src/pr-requires.ts +16 -2
- package/src/product-subpaths-plain-node.e2e.test.ts +212 -0
- package/src/release-floors.ts +1 -1
- package/src/run-event.ts +28 -1
- package/src/scheduled-op-cloud.ts +68 -0
- package/src/sorted-json.ts +17 -0
- package/src/stage-hooks-bundle.test.ts +6 -0
- package/src/terraform/credentials.test.ts +77 -0
- package/src/terraform/credentials.ts +162 -0
- package/src/utils.ts +2 -11
- package/src/wave-loop-golden.test.ts +2 -1
- package/src/wave-runtime.ts +2 -2
- package/src/workspace/chant-migrations/chud-lexicon-exit.ts +4 -1
- package/src/workspace/ci-lock-grain.test.ts +31 -0
- package/src/workspace/ci-lock-grain.ts +29 -0
- package/src/workspace/ci-report-url.test.ts +1 -1
- package/src/workspace/ci-run.test.ts +1 -1
- package/src/workspace/ci-run.ts +10 -3
- package/src/workspace/declaration.schema.json +27 -3
- package/src/workspace/declaration.test.ts +1 -1
- package/src/workspace/declaration.ts +26 -10
- package/src/workspace/drift-cli.ts +8 -3
- package/src/workspace/exit-cli.ts +2 -1
- package/src/workspace/import-fetch.ts +4 -2
- package/src/workspace/import-init.ts +4 -2
- package/src/workspace/ledger.schema.json +7 -3
- package/src/workspace/lineage-upgrade-cli.ts +2 -1
- package/src/workspace/pr-report.schema.json +79 -3
- package/src/workspace/promote.ts +2 -1
- package/src/workspace/records-cli.ts +3 -2
- package/src/workspace/release-catalog.schema.json +277 -0
- package/src/workspace/run-event.schema.json +18 -1
- package/src/workspace/work-cli.ts +8 -2
- package/src/workspace/workspace-run.ts +2 -1
package/src/op/op-waves-run.ts
CHANGED
|
@@ -50,8 +50,11 @@
|
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
52
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
53
|
+
import { createHash } from "node:crypto";
|
|
53
54
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
54
55
|
import { dirname, isAbsolute, join, posix } from "node:path";
|
|
56
|
+
import { CHANT_EXIT } from "../exit-codes";
|
|
57
|
+
import type { ResolvedGatePolicySource } from "../policy-source";
|
|
55
58
|
import {
|
|
56
59
|
decideWaveGate,
|
|
57
60
|
runWaveLoop,
|
|
@@ -74,16 +77,49 @@ import {
|
|
|
74
77
|
type WaveMemberOutcome,
|
|
75
78
|
} from "../wave-blocked";
|
|
76
79
|
import { approveCommand, evaluateGate, gitGateLedgerPort, type GateCheck, type GateDigestMismatch, type GateLedgerPort } from "./gate";
|
|
77
|
-
import type { GateAnswerRef, PendingGateRecord } from "../lifecycle/gate-ledger";
|
|
80
|
+
import type { GateAnswerRef, PendingGateInput, PendingGateRecord } from "../lifecycle/gate-ledger";
|
|
78
81
|
import type { GatePointAsker } from "../point-decision";
|
|
79
82
|
import type { WaitingPoint } from "./steward-points";
|
|
80
|
-
import { isApprovalSpent, type AppliedGateRecord } from "../lifecycle/gate-applied";
|
|
83
|
+
import { isApprovalSpent, type AppliedGateRecord, type FinishedGateRecord } from "../lifecycle/gate-applied";
|
|
81
84
|
import { samePlanDigest } from "../lifecycle/plan-digest";
|
|
82
85
|
import { isLifecycleLocalNote } from "../lifecycle/local-note";
|
|
83
86
|
import type { HeadPlans, MergedReview, ReviewSource } from "./gate-review";
|
|
84
87
|
import type { TrustPolicy } from "../workspace/trust/policy";
|
|
85
88
|
import type { GateSigners } from "../lifecycle/gate-seal";
|
|
86
89
|
import { ciRunIdFromEnv } from "./gate-run-locator";
|
|
90
|
+
import { appendRunRecord, DEFAULT_RUN_ENV } from "../lifecycle/run-ledger";
|
|
91
|
+
import { pushLifecycleReport } from "../lifecycle/git";
|
|
92
|
+
import { resolveCiJob } from "../lifecycle/release-ledger";
|
|
93
|
+
import type { OpRunPolicyRow, OpRunRecordInput, OpRunStepRecord, OpRunWave, OpRunWavePlan, OpRunWaveTarget } from "./runtime";
|
|
94
|
+
import { foldPolicyRows, opWaveAfterPlanProblems, runOpWaveAfterPlanHooks, type OpWaveAfterPlanHook, type OpWaveAfterPlanRun } from "./op-waves-after-plan";
|
|
95
|
+
import { activeOtlp, RunEventTrace, type CapabilityTraceFacts, type OtlpExporter } from "../otlp";
|
|
96
|
+
import { joinRunEventSinks, resolveRunEventRun, type RunEventSink } from "../run-event-stream";
|
|
97
|
+
import { OpWaveRunEvents } from "./op-waves-events";
|
|
98
|
+
import type { ChangeSetDocument, ChangeSetPart } from "../change-set";
|
|
99
|
+
import type { CapabilityRegistry } from "../components/capability";
|
|
100
|
+
import type { RunEventResource } from "../run-event";
|
|
101
|
+
import { opWaveReleaseNames, type OpWaveReleaseOutcome, type OpWaveReleasePort, type OpWaveReleaseRequest } from "./op-waves-release";
|
|
102
|
+
import { gitOpWaveReleasePort } from "./op-waves-release-port";
|
|
103
|
+
import type { LockGrain } from "../lifecycle/lock-rows";
|
|
104
|
+
import type { LockLiveness } from "../lifecycle/resource-lock";
|
|
105
|
+
import type { GatePolicyExec } from "../gate-policy";
|
|
106
|
+
import { gitOpWaveNewerCommit, opWaveStandDownReason, tipAppliesTargets, type OpWaveNewerCommitPort } from "./op-waves-stand-down";
|
|
107
|
+
import { mapLimited } from "../parallelism";
|
|
108
|
+
import {
|
|
109
|
+
applyOpWaveStep,
|
|
110
|
+
opWaveCosts,
|
|
111
|
+
opWaveCostVerdict,
|
|
112
|
+
opWaveHoldsAt,
|
|
113
|
+
opWaveHoldsProblems,
|
|
114
|
+
opWavePolicyVerdicts,
|
|
115
|
+
opWaveRegistry,
|
|
116
|
+
opWaveStepChangeSet,
|
|
117
|
+
planJsonOf,
|
|
118
|
+
planOpWaveStep,
|
|
119
|
+
type OpWaveHolds,
|
|
120
|
+
type OpWaveStepPlan,
|
|
121
|
+
} from "./op-waves-capability";
|
|
122
|
+
import { NEXT_RELEASE } from "../release-floors";
|
|
87
123
|
import {
|
|
88
124
|
changeInvolvement, quorumProblems, quorumRuleLine, quorumRulesFor, quorumWaiting, recordedReviewApprovals, ruleNeedsProof, samePrincipal, trustQuorumJudge,
|
|
89
125
|
type GateQuorumJudge, type GateQuorumRule, type GateQuorumRuleProgress, type QuorumJudgement,
|
|
@@ -123,8 +159,11 @@ import {
|
|
|
123
159
|
OP_WAVE_PENDING_RESERVED,
|
|
124
160
|
opWaveArgv,
|
|
125
161
|
pendingFields,
|
|
162
|
+
holdFinishedPath,
|
|
163
|
+
readHoldFinished,
|
|
126
164
|
readHoldRequest,
|
|
127
165
|
runHookList,
|
|
166
|
+
runHookListAsync,
|
|
128
167
|
runStageHooks,
|
|
129
168
|
runStageHooksAsync,
|
|
130
169
|
spawnExec,
|
|
@@ -132,6 +171,7 @@ import {
|
|
|
132
171
|
type HookPlace,
|
|
133
172
|
type OpWaveAsyncExec,
|
|
134
173
|
type OpWaveExec,
|
|
174
|
+
type OpWaveHoldFinished,
|
|
135
175
|
type OpWaveHoldRequest,
|
|
136
176
|
type OpWaveHookOutcome,
|
|
137
177
|
type OpWaveHookRun,
|
|
@@ -142,7 +182,7 @@ import {
|
|
|
142
182
|
} from "./stage-hooks";
|
|
143
183
|
|
|
144
184
|
export { OP_WAVE_PENDING_RESERVED, opWaveArgv, runStageHooks, runStageHooksAsync, spawnExecAsync };
|
|
145
|
-
export type { OpWaveAsyncExec, OpWaveExec, OpWaveHoldRequest, OpWaveHookOutcome, OpWaveHookRun, RunStageHooksAsyncOptions, RunStageHooksOptions, StageHooksRun };
|
|
185
|
+
export type { OpWaveAsyncExec, OpWaveExec, OpWaveHoldFinished, OpWaveHoldRequest, OpWaveHookOutcome, OpWaveHookRun, RunStageHooksAsyncOptions, RunStageHooksOptions, StageHooksRun };
|
|
146
186
|
|
|
147
187
|
/** What a run's plan command writes to `{plan}`. */
|
|
148
188
|
export interface OpWavePlanFile {
|
|
@@ -164,6 +204,8 @@ export interface OpWavePlanFile {
|
|
|
164
204
|
* approve` holds it. `@intentius/chant/gate-policy` gives the rules.
|
|
165
205
|
*/
|
|
166
206
|
held?: { rules: string[]; reason?: string };
|
|
207
|
+
/** The run's change-set part (#4545), which a `holds.policy` hold runs the policy over. A `step` writes it itself. */
|
|
208
|
+
changeSet?: ChangeSetPart;
|
|
167
209
|
}
|
|
168
210
|
|
|
169
211
|
/** What a wave-level plan command writes to `{plans}` (#3762): one plan per run, by target. The array alone is read too. */
|
|
@@ -190,6 +232,15 @@ export interface OpWavePlansFile {
|
|
|
190
232
|
members?: WaveMember[];
|
|
191
233
|
/** On a discovering wave (#3821): how many waves the product found, which a `rest` wave walks to. */
|
|
192
234
|
waves?: number;
|
|
235
|
+
/**
|
|
236
|
+
* The change-set document the product composed for the wave's plans
|
|
237
|
+
* (#4551, `composeChangeSet`). chant stores it under its digest in
|
|
238
|
+
* `_change-sets/` before the wave's pending fact, which cites it as
|
|
239
|
+
* `changeSet`, so the plans an approval was asked for stay readable. A
|
|
240
|
+
* document whose content does not hash to its digest is logged and left
|
|
241
|
+
* out; it never blocks the gate.
|
|
242
|
+
*/
|
|
243
|
+
changeSet?: ChangeSetDocument;
|
|
193
244
|
}
|
|
194
245
|
|
|
195
246
|
/** What chant writes to `{runs}` for a wave-level command or a hook (#3762). */
|
|
@@ -244,8 +295,16 @@ export interface OpWaveDecision {
|
|
|
244
295
|
*/
|
|
245
296
|
status: "approved" | "not-required" | "waiting" | "refused";
|
|
246
297
|
approvedBy?: string;
|
|
247
|
-
/**
|
|
248
|
-
|
|
298
|
+
/**
|
|
299
|
+
* How the approval arrived: a resolution on the ledger, the merged pull
|
|
300
|
+
* request's review (#3684), a decision point's answer (#3836), or the pull
|
|
301
|
+
* request's approval covering the wave's plans (#4550).
|
|
302
|
+
*/
|
|
303
|
+
via?: "ledger" | "pr-review" | "point" | "pull-request";
|
|
304
|
+
/** Under `pull-request` (#4550): the gate the pull request's approval is recorded at, read at base. */
|
|
305
|
+
pullRequestGate?: string;
|
|
306
|
+
/** Under `pull-request`: the approved change set that covered the wave, or why none did. */
|
|
307
|
+
coveredBy?: { digest?: string; reason?: string };
|
|
249
308
|
/**
|
|
250
309
|
* The decision point the gate asks, as read at base (#3836), and what it
|
|
251
310
|
* said: the open `question` while the wave waits, the `answer` once it is
|
|
@@ -287,6 +346,8 @@ export interface OpWaveDecision {
|
|
|
287
346
|
digestOver?: "changing";
|
|
288
347
|
/** The fields the plans file added to the pending fact (#3821). */
|
|
289
348
|
pending?: Record<string, unknown>;
|
|
349
|
+
/** The digest of the change set the plans file gave, stored in `_change-sets/` and cited by the pending fact (#4551). */
|
|
350
|
+
changeSet?: string;
|
|
290
351
|
/** The pending fact carries `neverOverMcp`, set by the spec here or at base (#3821). */
|
|
291
352
|
neverOverMcp?: true;
|
|
292
353
|
/** While waiting (#3821): the pending fact that stands for the digest, this run's own when `recorded`. */
|
|
@@ -322,6 +383,13 @@ export interface OpWaveDecision {
|
|
|
322
383
|
extras?: WaveMember[];
|
|
323
384
|
/** On a discovering wave (#3821): how many waves the plan command found. */
|
|
324
385
|
discovered?: { waves?: number };
|
|
386
|
+
/**
|
|
387
|
+
* `ci.policy.source` as `holds.policy` fetched it (#4613): the shared
|
|
388
|
+
* repository, its ref and the commit the ref named, so the decision names
|
|
389
|
+
* the rules its runs were judged by. Absent when the rules came from the
|
|
390
|
+
* workspace at base, or no policy ran.
|
|
391
|
+
*/
|
|
392
|
+
ciPolicySource?: ResolvedGatePolicySource;
|
|
325
393
|
}
|
|
326
394
|
|
|
327
395
|
/**
|
|
@@ -511,6 +579,12 @@ export interface OpWaveBaseRules {
|
|
|
511
579
|
reviewLedger?: string;
|
|
512
580
|
/** `approvals.involved` at base (#4333). */
|
|
513
581
|
involved?: OpWavesInvolved;
|
|
582
|
+
/** `holds` at base (#4545): the policy and cost holds the wave runs over its plans. */
|
|
583
|
+
holds?: OpWaveHolds;
|
|
584
|
+
/** Set when `holds` at base cannot be read: none runs, and the wave waits for a person. */
|
|
585
|
+
holdsRefused?: string;
|
|
586
|
+
/** `approvals.pullRequest.gate` at base (#4550): the pull request's gate a `pull-request` wave takes its approval from. */
|
|
587
|
+
pullRequestGate?: string;
|
|
514
588
|
}
|
|
515
589
|
|
|
516
590
|
const noHooks = (): Record<OpWaveHookMoment, OpWaveHook[]> =>
|
|
@@ -543,7 +617,7 @@ export function readOpWavePolicy(
|
|
|
543
617
|
const spend = (spec as { approvals?: { spend?: unknown } }).approvals?.spend === true;
|
|
544
618
|
const neverOverMcp = (spec as { neverOverMcp?: unknown }).neverOverMcp === true;
|
|
545
619
|
// #3836: the gate's decision point, the spec's for a wave the base does not have yet.
|
|
546
|
-
const asks = { ...pointAtBase(spec, name, `${specFile} at ${sha.slice(0, 12)}`), ...quorumAtBase(spec, `${specFile} at ${sha.slice(0, 12)}`) };
|
|
620
|
+
const asks = { ...pointAtBase(spec, name, `${specFile} at ${sha.slice(0, 12)}`), ...quorumAtBase(spec, `${specFile} at ${sha.slice(0, 12)}`), ...holdsAtBase(spec, `${specFile} at ${sha.slice(0, 12)}`), ...pullRequestGateAtBase(spec) };
|
|
547
621
|
const wave = spec.waves.find((w) => w.name === name);
|
|
548
622
|
if (!wave) return { ...absent, spend, neverOverMcp, ...asks };
|
|
549
623
|
const policy = wave.gate ?? "always";
|
|
@@ -562,6 +636,12 @@ export function readOpWavePolicy(
|
|
|
562
636
|
return rules;
|
|
563
637
|
}
|
|
564
638
|
|
|
639
|
+
/** `approvals.pullRequest.gate` at base (#4550), when it names a gate. */
|
|
640
|
+
function pullRequestGateAtBase(spec: OpWavesSpec): Pick<OpWaveBaseRules, "pullRequestGate"> {
|
|
641
|
+
const gate = (spec as { approvals?: { pullRequest?: { gate?: unknown } } }).approvals?.pullRequest?.gate;
|
|
642
|
+
return typeof gate === "string" && OP_LEDGER_NAME.test(gate) ? { pullRequestGate: gate } : {};
|
|
643
|
+
}
|
|
644
|
+
|
|
565
645
|
/** The approval rules at base (#4290), or why they cannot be read. A spec at base with none has none. */
|
|
566
646
|
function quorumAtBase(spec: OpWavesSpec, where: string): Pick<OpWaveBaseRules, "quorum" | "quorumRefused" | "reviewLedger" | "involved"> {
|
|
567
647
|
const a = (spec as { approvals?: { quorum?: unknown; reviewLedger?: unknown; involved?: unknown } }).approvals;
|
|
@@ -583,6 +663,15 @@ function quorumAtBase(spec: OpWavesSpec, where: string): Pick<OpWaveBaseRules, "
|
|
|
583
663
|
return (raw as GateQuorumRule[]).length > 0 ? { quorum: raw as GateQuorumRule[], ...extra } : {};
|
|
584
664
|
}
|
|
585
665
|
|
|
666
|
+
/** The holds at base (#4545), or why they cannot be read. */
|
|
667
|
+
function holdsAtBase(spec: OpWavesSpec, where: string): Pick<OpWaveBaseRules, "holds" | "holdsRefused"> {
|
|
668
|
+
const raw = (spec as { holds?: unknown }).holds;
|
|
669
|
+
if (raw === undefined) return {};
|
|
670
|
+
const problems = opWaveHoldsProblems(raw);
|
|
671
|
+
if (problems.length > 0) return { holdsRefused: `the holds in ${where} cannot be read (${problems.join("; ")})` };
|
|
672
|
+
return { holds: structuredClone(raw as OpWaveHolds) };
|
|
673
|
+
}
|
|
674
|
+
|
|
586
675
|
/** The point wave `name` asks at base (#3836), or why it cannot be asked. */
|
|
587
676
|
function pointAtBase(spec: OpWavesSpec, name: string, where: string): Pick<OpWaveBaseRules, "point" | "pointRefused"> {
|
|
588
677
|
const raw = spec.waves.find((w) => w.name === name)?.point ?? spec.point;
|
|
@@ -592,7 +681,10 @@ function pointAtBase(spec: OpWavesSpec, name: string, where: string): Pick<OpWav
|
|
|
592
681
|
return { point: opWavePointAt(spec, name)! };
|
|
593
682
|
}
|
|
594
683
|
|
|
595
|
-
/**
|
|
684
|
+
/** The first chant whose op entry exports {@link opWavePlanPath} (terragucci#1304). */
|
|
685
|
+
export const OP_WAVE_PLAN_PATH_FLOOR = NEXT_RELEASE;
|
|
686
|
+
|
|
687
|
+
/** Where a run's plan file goes: one target's plan, as opposed to {@link opWavePlansPath}, the wave's `plans.json`. */
|
|
596
688
|
export function opWavePlanPath(spec: Pick<OpWavesSpec, "name">, wave: number, target: string): string {
|
|
597
689
|
return `.chant/op-waves/${spec.name}/wave-${wave}/${target.replace(/[^A-Za-z0-9._-]/g, "_")}.plan.json`;
|
|
598
690
|
}
|
|
@@ -635,6 +727,12 @@ export interface RunOpWaveOptions {
|
|
|
635
727
|
reviews?: ReviewSource;
|
|
636
728
|
/** The plans recorded for a pull request's head. Default: read from `chant/lifecycle`. */
|
|
637
729
|
headPlans?: (name: string, head: string) => Promise<HeadPlans | null>;
|
|
730
|
+
/**
|
|
731
|
+
* The change set stored under a digest, for a `pull-request` gate (#4550):
|
|
732
|
+
* the one the pull request's approval names. Default: `_change-sets/` on
|
|
733
|
+
* the local `chant/lifecycle`.
|
|
734
|
+
*/
|
|
735
|
+
changeSets?: (digest: string) => Promise<ChangeSetDocument | undefined>;
|
|
638
736
|
/** The signers policy at base, for a `sealed` gate. Default: read from the base commit. */
|
|
639
737
|
trust?: (base: string) => TrustPolicy;
|
|
640
738
|
/** The signers at base, for a sealed override of a policy denial (#3821). Default: `gateSignersAt` from `@intentius/chant/gate-decision`. */
|
|
@@ -649,6 +747,96 @@ export interface RunOpWaveOptions {
|
|
|
649
747
|
outcomeDir?: string;
|
|
650
748
|
/** The commits after base up to the applied head, for `Requested-by:` trailers (#4333). Default: `git log`. */
|
|
651
749
|
commits?: (base: string, head: string) => { sha: string; message: string }[];
|
|
750
|
+
/**
|
|
751
|
+
* Where the job's run record goes (#4551): one record per job, on every
|
|
752
|
+
* way it ends. Default {@link gitOpWaveRunPort} over `cwd` when `gates` is
|
|
753
|
+
* not given; a caller that passes its own `gates` port passes this too, or
|
|
754
|
+
* the job records no run.
|
|
755
|
+
*/
|
|
756
|
+
runs?: OpWaveRunPort;
|
|
757
|
+
/**
|
|
758
|
+
* Where the release records of the runs a `step` applied go (#4615), so
|
|
759
|
+
* `chant components rollback` reads them. Default
|
|
760
|
+
* {@link gitOpWaveReleasePort} over `cwd` when `gates` is not given, as
|
|
761
|
+
* `runs` defaults; `false` writes none. See `./op-waves-release.ts`.
|
|
762
|
+
*/
|
|
763
|
+
releases?: OpWaveReleasePort | false;
|
|
764
|
+
/**
|
|
765
|
+
* The capabilities a spec's `step` plans and applies through (#4545).
|
|
766
|
+
* Default: the project's at `cwd`, as `chant run --components` builds it.
|
|
767
|
+
* A product that runs chant in process passes its own.
|
|
768
|
+
*/
|
|
769
|
+
capabilities?: CapabilityRegistry;
|
|
770
|
+
/** How a hold's policy engine and cost estimator run (#4545). Default: spawned in `cwd`. */
|
|
771
|
+
holdExec?: GatePolicyExec;
|
|
772
|
+
/**
|
|
773
|
+
* How the `planWave` and `applyWave` commands run (#4588), when the caller
|
|
774
|
+
* runs them itself, such as `pr-apply --wave-gate` running the component
|
|
775
|
+
* plan-wave and apply-wave steps in its own process. Default: `exec`.
|
|
776
|
+
*/
|
|
777
|
+
waveExec?: OpWaveAsyncExec;
|
|
778
|
+
/**
|
|
779
|
+
* The lock grain a `step`'s runs take (#4552). Default: `ci.lockGrain` of
|
|
780
|
+
* the member holding `cwd`, read from the declaration at the wave's base,
|
|
781
|
+
* else each run's lexicon default.
|
|
782
|
+
*/
|
|
783
|
+
lockGrain?: LockGrain;
|
|
784
|
+
/**
|
|
785
|
+
* The gate whose rows file (`_locks/rows/<gate>.json`, #4552) a `step`'s
|
|
786
|
+
* runs lease on the resource grain. Default `pr-apply`, the pull-request
|
|
787
|
+
* loop's, so an apply on merge and an apply before merge read one file; a
|
|
788
|
+
* pipeline whose loop names another gate passes it.
|
|
789
|
+
*/
|
|
790
|
+
lockGate?: string;
|
|
791
|
+
/** Whether a run holding rows still runs (#4552). Default: the forge's answer, with the lease's age. */
|
|
792
|
+
lockLiveness?: LockLiveness;
|
|
793
|
+
/** Overrides the spec's `standDown` (#4581). */
|
|
794
|
+
standDown?: boolean;
|
|
795
|
+
/** How the job finds a newer commit on its branch (#4581). Default: fetch the branch from `origin` ({@link gitOpWaveNewerCommit}). */
|
|
796
|
+
newerCommit?: OpWaveNewerCommitPort;
|
|
797
|
+
/**
|
|
798
|
+
* Where the job's run events go (#4555), on the run-event contract: a
|
|
799
|
+
* phase `wave-<k>` per wave and a step per run target, settled as the
|
|
800
|
+
* run record says. `chant run wave --events-json` passes its stream.
|
|
801
|
+
*/
|
|
802
|
+
events?: RunEventSink;
|
|
803
|
+
/**
|
|
804
|
+
* The OTLP exporter the job's trace goes through (#4555). Default: the
|
|
805
|
+
* process's ({@link activeOtlp}), which is off unless the environment
|
|
806
|
+
* names an endpoint. `false` sends none.
|
|
807
|
+
*/
|
|
808
|
+
otlp?: OtlpExporter | false;
|
|
809
|
+
/**
|
|
810
|
+
* After-plan hooks in the job's own process (#4614): each is called once
|
|
811
|
+
* per planned run, in order, after the wave's holds and before the set
|
|
812
|
+
* digest and the gate, with the run's plan digest, `{plan}` and
|
|
813
|
+
* `{planJson}`. Its policy rows deny or hold the run, and its rows and
|
|
814
|
+
* files go on the run record. See `./op-waves-after-plan.ts`.
|
|
815
|
+
*/
|
|
816
|
+
afterPlan?: OpWaveAfterPlanHook | readonly OpWaveAfterPlanHook[];
|
|
817
|
+
/**
|
|
818
|
+
* How the spec's command hooks run (#4614), when they call back into the
|
|
819
|
+
* caller's own process: a product that runs the wave in process and serves
|
|
820
|
+
* its hooks from that process passes an exec that lets the event loop run
|
|
821
|
+
* while a hook does. Default: `exec`, which waits with `spawnSync`.
|
|
822
|
+
*/
|
|
823
|
+
hookExec?: OpWaveAsyncExec;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/** Where an op wave job's run record goes (#4551). */
|
|
827
|
+
export interface OpWaveRunPort {
|
|
828
|
+
append(record: OpRunRecordInput): Promise<{ pushWarning?: string } | void>;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/** The run ledger on `chant/lifecycle` (#4551): `appendRunRecord`, then a push. Honours `--no-record` through the git layer. */
|
|
832
|
+
export function gitOpWaveRunPort(opts?: { cwd?: string }): OpWaveRunPort {
|
|
833
|
+
return {
|
|
834
|
+
async append(record) {
|
|
835
|
+
await appendRunRecord(record, opts);
|
|
836
|
+
const { pushWarning } = await pushLifecycleReport(opts);
|
|
837
|
+
return pushWarning ? { pushWarning } : {};
|
|
838
|
+
},
|
|
839
|
+
};
|
|
652
840
|
}
|
|
653
841
|
|
|
654
842
|
export interface RunOpWaveResult {
|
|
@@ -665,6 +853,8 @@ export interface RunOpWaveResult {
|
|
|
665
853
|
outcome?: OpWaveApplyOutcome;
|
|
666
854
|
/** Set when the apply asked to plan again (#3821); {@link runOpWave} does, so a caller sees it only on a pass that gave up. */
|
|
667
855
|
replan?: { reason?: string };
|
|
856
|
+
/** The newer commit on the branch the apply stood down for (#4581), with `outcome` `stood-down` and exit 6. */
|
|
857
|
+
supersededBy?: { branch: string; commit: string };
|
|
668
858
|
/** The waves a `rest` wave's job ran (#3821), in order, with how each ended. */
|
|
669
859
|
rest?: Array<{ wave: number; exitCode: number; digest?: string }>;
|
|
670
860
|
decision?: OpWaveDecision;
|
|
@@ -680,6 +870,10 @@ export interface RunOpWaveResult {
|
|
|
680
870
|
blocked?: Record<string, string>;
|
|
681
871
|
/** The hooks that ran (#3762). */
|
|
682
872
|
hooks: OpWaveHookOutcome[];
|
|
873
|
+
/** Each target the job applied or tried to (#4555): when, how long, and what its capability knew. */
|
|
874
|
+
targets?: Record<string, OpRunWaveTarget>;
|
|
875
|
+
/** Each planned run with policy rows or an after-plan hook's files (#4614), as the run record's `wave.plans`. */
|
|
876
|
+
plans?: Record<string, OpRunWavePlan>;
|
|
683
877
|
}
|
|
684
878
|
|
|
685
879
|
/** What one wave job works with. */
|
|
@@ -694,6 +888,10 @@ interface WaveContext {
|
|
|
694
888
|
options: RunOpWaveOptions;
|
|
695
889
|
/** How another gate a hook holds the wave on is decided (#3821): the approval mode and base the wave's rules were read at, and whether pending facts carry neverOverMcp. */
|
|
696
890
|
gateRule: { approval: GateApprovalSource; base: string; neverOverMcp: boolean };
|
|
891
|
+
/** With a `step` (#4545): each run's plan through it, by target, which its apply hands back. */
|
|
892
|
+
steps?: Map<string, OpWaveStepPlan>;
|
|
893
|
+
/** The plans file's change set (#4551), which a `pull-request` gate checks the pull request's approval against (#4550). */
|
|
894
|
+
changeSetDoc?: ChangeSetDocument;
|
|
697
895
|
}
|
|
698
896
|
|
|
699
897
|
function planRun(opts: { spec: OpWavesSpec; wave: number; cwd: string; exec: OpWaveExec }, waveName: string, run: OpWaveRun): OpWaveMember {
|
|
@@ -767,13 +965,22 @@ function writeRunsFile(
|
|
|
767
965
|
* for all of them (#3762). A wave plan is written out as each run's plan file
|
|
768
966
|
* too, so a per-run `apply` or hook reads `{plan}` either way.
|
|
769
967
|
*/
|
|
770
|
-
function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string; exec: OpWaveExec }, runs: readonly OpWaveRun[], discover = false): PlannedRuns {
|
|
968
|
+
async function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string; exec: OpWaveExec; waveExec?: OpWaveAsyncExec }, runs: readonly OpWaveRun[], discover = false): Promise<PlannedRuns> {
|
|
771
969
|
const { spec, k, wave, cwd, exec } = at;
|
|
772
|
-
if (!spec.planWave)
|
|
970
|
+
if (!spec.planWave) {
|
|
971
|
+
const members = runs.map((run) => planRun({ spec, wave: k, cwd, exec }, wave.name, run));
|
|
972
|
+
// #4545: a plan file's `changeSet` part, which a policy hold reads.
|
|
973
|
+
const parts = new Map(runs.flatMap((run) => {
|
|
974
|
+
const part = partOf(readPlanFileField(join(cwd, opWavePlanPath(spec, k, run.target)), "changeSet"));
|
|
975
|
+
return part ? [[run.target, part] as const] : [];
|
|
976
|
+
}));
|
|
977
|
+
return { members, ...(parts.size > 0 ? { parts } : {}) };
|
|
978
|
+
}
|
|
773
979
|
const runsPath = writeRunsFile(at, runs, undefined, undefined, undefined, discover);
|
|
774
980
|
const plans = opWavePlansPath(spec, k);
|
|
775
981
|
rmSync(join(cwd, plans), { force: true });
|
|
776
|
-
const
|
|
982
|
+
const planArgv = opWaveArgv(spec.planWave, { op: spec.op, wave: wave.name, runs: runsPath, plans });
|
|
983
|
+
const code = at.waveExec ? await at.waveExec(planArgv, cwd) : exec(planArgv, cwd);
|
|
777
984
|
if (code !== 0) throw new Error(`planning wave ${k} (${wave.name}) exited ${code}`);
|
|
778
985
|
let parsed: unknown;
|
|
779
986
|
try {
|
|
@@ -808,6 +1015,14 @@ function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string;
|
|
|
808
1015
|
const count = Array.isArray(parsed) ? undefined : (parsed as { waves?: unknown }).waves;
|
|
809
1016
|
if (count !== undefined && (!Number.isInteger(count) || (count as number) < 0)) throw new Error(`the plans file of wave ${k} (${plans}): \`waves\` must be the number of waves found, a whole number`);
|
|
810
1017
|
const pending = Array.isArray(parsed) ? undefined : pendingFields((parsed as { pending?: unknown }).pending, `the plans file of wave ${k} (${plans})`);
|
|
1018
|
+
const changeSetDoc = Array.isArray(parsed) ? undefined : (parsed as { changeSet?: unknown }).changeSet;
|
|
1019
|
+
if (changeSetDoc !== undefined && (changeSetDoc === null || typeof changeSetDoc !== "object" || Array.isArray(changeSetDoc))) {
|
|
1020
|
+
throw new Error(`the plans file of wave ${k} (${plans}): \`changeSet\` must be a change-set document`);
|
|
1021
|
+
}
|
|
1022
|
+
const parts = new Map(runs.flatMap((run) => {
|
|
1023
|
+
const part = partOf((byTarget.get(run.target) as { changeSet?: unknown } | undefined)?.changeSet);
|
|
1024
|
+
return part ? [[run.target, part] as const] : [];
|
|
1025
|
+
}));
|
|
811
1026
|
const members = runs.map((run) => {
|
|
812
1027
|
const m = member(run.target, run.op ?? spec.op, byTarget.get(run.target)!);
|
|
813
1028
|
const path = join(cwd, opWavePlanPath(spec, k, run.target));
|
|
@@ -824,17 +1039,261 @@ function planRuns(at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string;
|
|
|
824
1039
|
}
|
|
825
1040
|
return {
|
|
826
1041
|
members,
|
|
1042
|
+
...(parts.size > 0 ? { parts } : {}),
|
|
827
1043
|
...(pending ? { pending } : {}),
|
|
828
1044
|
...(overriders ? { overriders: overriders as string[] } : {}),
|
|
829
1045
|
...(overriders && overridersSource ? { overridersSource: overridersSource as string } : {}),
|
|
830
1046
|
...(extras ? { extras } : {}),
|
|
831
1047
|
...(count !== undefined ? { waves: count as number } : {}),
|
|
1048
|
+
...(changeSetDoc !== undefined ? { changeSet: changeSetDoc as ChangeSetDocument } : {}),
|
|
832
1049
|
};
|
|
833
1050
|
}
|
|
834
1051
|
|
|
1052
|
+
/**
|
|
1053
|
+
* Plan `runs` of wave `k` (#4545): through the spec's `step` when it names
|
|
1054
|
+
* one, each run's plan kept on `at.steps` for its apply, else with the
|
|
1055
|
+
* commands ({@link planRuns}).
|
|
1056
|
+
*/
|
|
1057
|
+
async function planWaveRuns(
|
|
1058
|
+
at: { spec: OpWavesSpec; k: number; wave: OpWave; cwd: string; exec: OpWaveExec; options: Pick<RunOpWaveOptions, "capabilities" | "lockGrain" | "base" | "waveExec">; steps?: Map<string, OpWaveStepPlan> },
|
|
1059
|
+
runs: readonly OpWaveRun[],
|
|
1060
|
+
discover = false,
|
|
1061
|
+
): Promise<PlannedRuns> {
|
|
1062
|
+
const { spec, k, wave, cwd } = at;
|
|
1063
|
+
if (!spec.step) return planRuns({ ...at, ...(at.options.waveExec ? { waveExec: at.options.waveExec } : {}) }, runs, discover);
|
|
1064
|
+
const registry = await opWaveRegistry(at.options, cwd, at.options.capabilities);
|
|
1065
|
+
const base = (at as { gateRule?: { base: string } }).gateRule?.base ?? at.options.base;
|
|
1066
|
+
const lockGrain = at.options.lockGrain ?? (await declaredLockGrain(cwd, base));
|
|
1067
|
+
// #4613: a step's own policy engine (CrossGuard) reads its packs at the base the wave's rules were read at.
|
|
1068
|
+
const policyBase = base && base !== "HEAD" ? base : undefined;
|
|
1069
|
+
const plans: OpWaveStepPlan[] = [];
|
|
1070
|
+
for (const run of runs) {
|
|
1071
|
+
const plan = await planOpWaveStep({ spec, wave, cwd, registry, planPath: opWavePlanPath(spec, k, run.target), lockGrain, ...(policyBase ? { policyBase } : {}) }, run);
|
|
1072
|
+
at.steps?.set(run.target, plan);
|
|
1073
|
+
plans.push(plan);
|
|
1074
|
+
}
|
|
1075
|
+
const members = plans.map((p) => ({
|
|
1076
|
+
member: p.target,
|
|
1077
|
+
planDigest: p.planDigest,
|
|
1078
|
+
op: runs.find((r) => r.target === p.target)?.op ?? spec.op,
|
|
1079
|
+
...(p.destructive ? { destructive: true } : {}),
|
|
1080
|
+
...(p.empty ? { empty: true } : {}),
|
|
1081
|
+
}));
|
|
1082
|
+
const parts = new Map(plans.flatMap((p) => (p.part ? [[p.target, p.part] as const] : [])));
|
|
1083
|
+
const changeSet = opWaveStepChangeSet(plans);
|
|
1084
|
+
return { members, ...(parts.size > 0 ? { parts } : {}), ...(changeSet ? { changeSet } : {}) };
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* `ci.lockGrain` of the member holding `cwd` (#4552), read at `base`, behind
|
|
1089
|
+
* a dynamic import so the wave-job runtime bundle leaves the declaration
|
|
1090
|
+
* reader out. Null when none is declared or the declaration cannot be read
|
|
1091
|
+
* there: each run then takes its lexicon's default.
|
|
1092
|
+
*/
|
|
1093
|
+
async function declaredLockGrain(cwd: string, base: string | undefined): Promise<LockGrain | null> {
|
|
1094
|
+
try {
|
|
1095
|
+
const { ciLockGrainAt } = await import("../workspace/ci-lock-grain");
|
|
1096
|
+
return ciLockGrainAt(cwd, base);
|
|
1097
|
+
} catch {
|
|
1098
|
+
return null;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Lease the rows of a wave's runs on the resource grain (#4552), before
|
|
1104
|
+
* anything of the wave applies, all in one take. A held row makes the wave
|
|
1105
|
+
* apply nothing with the `held` outcome, exit 5, naming the run that holds it.
|
|
1106
|
+
*/
|
|
1107
|
+
async function leaseWaveRows(
|
|
1108
|
+
options: RunOpWaveOptions,
|
|
1109
|
+
ctx: WaveContext,
|
|
1110
|
+
runs: readonly OpWaveRun[],
|
|
1111
|
+
): Promise<{ release(): Promise<boolean> } | OpWaveApplyOutcome | { failed: string } | undefined> {
|
|
1112
|
+
const rows = runs.flatMap((r) => {
|
|
1113
|
+
const lock = ctx.steps?.get(r.target)?.lock;
|
|
1114
|
+
return lock?.grain === "resource" ? lock.rows : [];
|
|
1115
|
+
});
|
|
1116
|
+
if (rows.length === 0) return undefined;
|
|
1117
|
+
const { leaseLockRows } = await import("../lifecycle/resource-lock");
|
|
1118
|
+
const { PR_APPLY_GATE } = await import("../pr-loop");
|
|
1119
|
+
const gate = options.lockGate ?? PR_APPLY_GATE;
|
|
1120
|
+
let leased: Awaited<ReturnType<typeof leaseLockRows>>;
|
|
1121
|
+
try {
|
|
1122
|
+
leased = await leaseLockRows(gate, rows, { cwd: ctx.cwd, ...(options.lockLiveness ? { alive: options.lockLiveness } : {}) });
|
|
1123
|
+
} catch (err) {
|
|
1124
|
+
return { failed: `wave ${ctx.k} (${ctx.wave.name}): could not hold the rows its runs change in ${gate}, so nothing was applied: ${err instanceof Error ? err.message : String(err)}` };
|
|
1125
|
+
}
|
|
1126
|
+
if (!leased.ok) {
|
|
1127
|
+
const first = leased.held[0]!.holder;
|
|
1128
|
+
return { outcome: "held", reason: leased.message, holder: { run: first.run, ...(first.url ? { url: first.url } : {}) } };
|
|
1129
|
+
}
|
|
1130
|
+
for (const h of leased.tookOver) ctx.log(`wave ${ctx.k} (${ctx.wave.name}): took over the rows of run ${h.run}, which is gone`);
|
|
1131
|
+
ctx.log(`wave ${ctx.k} (${ctx.wave.name}): holds ${leased.lease.keys.length} row${leased.lease.keys.length === 1 ? "" : "s"} of ${gate} while it applies`);
|
|
1132
|
+
return leased.lease;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/** A wave's cost hold over its plans (#4545): each changing run priced, the sum against `approveAbove`. */
|
|
1136
|
+
function costVerdictOf(
|
|
1137
|
+
hold: NonNullable<OpWaveHolds["cost"]>,
|
|
1138
|
+
spec: OpWavesSpec,
|
|
1139
|
+
k: number,
|
|
1140
|
+
members: readonly OpWaveMember[],
|
|
1141
|
+
steps: ReadonlyMap<string, OpWaveStepPlan> | undefined,
|
|
1142
|
+
cwd: string,
|
|
1143
|
+
exec?: GatePolicyExec,
|
|
1144
|
+
) {
|
|
1145
|
+
const runs = members.map((m) => ({ target: m.member, plan: opWavePlanPath(spec, k, m.member), artifact: steps?.get(m.member)?.artifact, empty: m.empty === true }));
|
|
1146
|
+
return opWaveCostVerdict(hold, opWaveCosts(hold, runs, cwd, exec));
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Run a wave's holds over its plans (#4545): the policy marks each run it
|
|
1151
|
+
* denies or holds (the gate then settles them as a product's plan file
|
|
1152
|
+
* would), and the cost adds its digest member and, over its amount, a hold.
|
|
1153
|
+
* `failed` when the policy cannot run, or a run gave it no change set.
|
|
1154
|
+
*/
|
|
1155
|
+
async function runWaveHolds(
|
|
1156
|
+
ctx: WaveContext,
|
|
1157
|
+
holds: OpWaveHolds | undefined,
|
|
1158
|
+
members: OpWaveMember[],
|
|
1159
|
+
parts: ReadonlyMap<string, ChangeSetPart> | undefined,
|
|
1160
|
+
base: string,
|
|
1161
|
+
): Promise<{ holds: string[]; extras: WaveMember[]; rows: Map<string, OpRunPolicyRow>; policySource?: ResolvedGatePolicySource } | { failed: string }> {
|
|
1162
|
+
const { spec, k, wave, cwd, log, options } = ctx;
|
|
1163
|
+
// #4614: each run's ci.policy row, which the after-plan hooks and the run record read.
|
|
1164
|
+
const out: { holds: string[]; extras: WaveMember[]; rows: Map<string, OpRunPolicyRow>; policySource?: ResolvedGatePolicySource } = { holds: [], extras: [], rows: new Map<string, OpRunPolicyRow>() };
|
|
1165
|
+
if (!holds) return out;
|
|
1166
|
+
if (holds.policy) {
|
|
1167
|
+
const missing = members.filter((m) => !parts?.has(m.member)).map((m) => m.member);
|
|
1168
|
+
if (missing.length > 0) return { failed: `wave ${k} (${wave.name}): holds.policy reads each run's change set, and the plans of ${missing.join(", ")} gave none, so nothing in it was applied` };
|
|
1169
|
+
let head = options.head;
|
|
1170
|
+
if (!head) {
|
|
1171
|
+
try {
|
|
1172
|
+
head = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
1173
|
+
} catch {
|
|
1174
|
+
head = "";
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
let got: Awaited<ReturnType<typeof opWavePolicyVerdicts>>;
|
|
1178
|
+
try {
|
|
1179
|
+
got = await opWavePolicyVerdicts({ spec, gate: opWaveGateName(spec, k), env: spec.labels?.Env ?? wave.name, base, head, cwd, ...(options.holdExec ? { exec: options.holdExec } : {}) }, parts!);
|
|
1180
|
+
} catch (err) {
|
|
1181
|
+
return { failed: `wave ${k} (${wave.name}): ${err instanceof Error ? err.message : String(err)}, so nothing in it was applied` };
|
|
1182
|
+
}
|
|
1183
|
+
if ("note" in got) log(`wave ${k} (${wave.name}): ${got.note}`);
|
|
1184
|
+
else {
|
|
1185
|
+
if (got.source) {
|
|
1186
|
+
out.policySource = got.source;
|
|
1187
|
+
log(`wave ${k} (${wave.name}): ci.policy read from ${got.source.repo}@${got.source.ref} at commit ${got.source.commit}`);
|
|
1188
|
+
}
|
|
1189
|
+
for (const m of members) {
|
|
1190
|
+
const v = got.verdicts.get(m.member);
|
|
1191
|
+
if (v && v.result !== "error") {
|
|
1192
|
+
const rules = v.result === "held" ? v.holds : v.result === "denied" ? v.rules : [];
|
|
1193
|
+
out.rows.set(m.member, { source: "ci.policy", result: v.result, rules, ...(v.reason ? { reason: v.reason } : {}) });
|
|
1194
|
+
}
|
|
1195
|
+
if (!v || v.result === "passed") continue;
|
|
1196
|
+
if (v.result === "error") return { failed: `wave ${k} (${wave.name}): the policy did not run on ${m.member} (${v.reason ?? "no answer"}), so nothing in it was applied` };
|
|
1197
|
+
if (v.result === "denied") m.denied = { rules: v.rules, ...(v.reason ? { reason: v.reason } : {}) };
|
|
1198
|
+
else m.held = { rules: v.holds, ...(v.reason ? { reason: v.reason } : {}) };
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
if (holds.cost) {
|
|
1203
|
+
const verdict = costVerdictOf(holds.cost, spec, k, members, ctx.steps, cwd, options.holdExec);
|
|
1204
|
+
out.extras.push(verdict.member);
|
|
1205
|
+
log(`wave ${k} (${wave.name}): cost ${verdict.monthlyDelta >= 0 ? "+" : ""}${verdict.monthlyDelta.toFixed(2)} ${verdict.currency} a month${verdict.unestimated.length ? `, ${verdict.unestimated.length} run${verdict.unestimated.length === 1 ? "" : "s"} not priced` : ""}`);
|
|
1206
|
+
if (verdict.hold) out.holds.push(verdict.hold);
|
|
1207
|
+
}
|
|
1208
|
+
return out;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
/** The job's after-plan hooks (#4614), as a list. */
|
|
1212
|
+
function afterPlanHooks(options: RunOpWaveOptions): readonly OpWaveAfterPlanHook[] {
|
|
1213
|
+
const given = options.afterPlan;
|
|
1214
|
+
if (given === undefined) return [];
|
|
1215
|
+
return Array.isArray(given) ? (given as readonly OpWaveAfterPlanHook[]) : [given as OpWaveAfterPlanHook];
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Run the after-plan hooks in the job's process over a wave's plans (#4614),
|
|
1220
|
+
* fold their policy rows into each run's denial and hold, and put each run's
|
|
1221
|
+
* rows and files on the result for the run record. With no hook, the rows
|
|
1222
|
+
* chant's `holds.policy` gave still go on the result.
|
|
1223
|
+
*/
|
|
1224
|
+
async function runAfterPlan(
|
|
1225
|
+
ctx: WaveContext,
|
|
1226
|
+
members: OpWaveMember[],
|
|
1227
|
+
parts: ReadonlyMap<string, ChangeSetPart> | undefined,
|
|
1228
|
+
policyRows: ReadonlyMap<string, OpRunPolicyRow>,
|
|
1229
|
+
): Promise<{ failed?: string; holds: string[] }> {
|
|
1230
|
+
const { spec, k, wave, cwd, options, result } = ctx;
|
|
1231
|
+
const hooks = afterPlanHooks(options);
|
|
1232
|
+
const job: OpWaveAfterPlanRun["job"] = options.decide ? "decide" : options.group !== undefined ? "group" : options.share !== undefined ? "share" : "wave";
|
|
1233
|
+
const runs: OpWaveAfterPlanRun[] = members.map((m) => {
|
|
1234
|
+
const plan = opWavePlanPath(spec, k, m.member);
|
|
1235
|
+
const step = ctx.steps?.get(m.member);
|
|
1236
|
+
const planJson = runPlanJson(ctx, m.member, plan);
|
|
1237
|
+
const part = parts?.get(m.member) ?? step?.part;
|
|
1238
|
+
const row = policyRows.get(m.member);
|
|
1239
|
+
return {
|
|
1240
|
+
spec: spec.name,
|
|
1241
|
+
op: spec.op,
|
|
1242
|
+
wave: k,
|
|
1243
|
+
waveName: wave.name,
|
|
1244
|
+
job,
|
|
1245
|
+
target: m.member,
|
|
1246
|
+
runOp: m.op,
|
|
1247
|
+
planDigest: m.planDigest,
|
|
1248
|
+
plan,
|
|
1249
|
+
...(planJson ? { planJson } : {}),
|
|
1250
|
+
...(step?.artifact !== undefined ? { artifact: step.artifact } : {}),
|
|
1251
|
+
...(part ? { changeSet: part } : {}),
|
|
1252
|
+
empty: m.empty === true,
|
|
1253
|
+
destructive: m.destructive === true,
|
|
1254
|
+
policy: row ? [row] : [],
|
|
1255
|
+
cwd,
|
|
1256
|
+
};
|
|
1257
|
+
});
|
|
1258
|
+
const out = hooks.length > 0 && runs.length > 0 ? await runOpWaveAfterPlanHooks(hooks, runs, ctx.log) : undefined;
|
|
1259
|
+
if (out) result.hooks.push(...out.outcomes);
|
|
1260
|
+
const plans: Record<string, OpRunWavePlan> = { ...(result.plans ?? {}) };
|
|
1261
|
+
for (const m of members) {
|
|
1262
|
+
const mine = out?.runs.get(m.member);
|
|
1263
|
+
const chant = policyRows.get(m.member);
|
|
1264
|
+
const rows = [...(chant ? [chant] : []), ...(mine?.policy ?? [])];
|
|
1265
|
+
if (mine?.policy.length) {
|
|
1266
|
+
const folded = foldPolicyRows(mine.policy, { ...(m.denied ? { denied: m.denied } : {}), ...(m.held ? { held: m.held } : {}) });
|
|
1267
|
+
if (folded.denied) m.denied = folded.denied;
|
|
1268
|
+
if (folded.held) m.held = folded.held;
|
|
1269
|
+
}
|
|
1270
|
+
if (rows.length === 0 && !mine?.files.length) continue;
|
|
1271
|
+
plans[m.member] = { planDigest: m.planDigest, ...(rows.length ? { policy: rows } : {}), ...(mine?.files.length ? { files: [...mine.files] } : {}) };
|
|
1272
|
+
}
|
|
1273
|
+
if (Object.keys(plans).length > 0) result.plans = plans;
|
|
1274
|
+
return { ...(out?.failed ? { failed: out.failed } : {}), holds: out?.holds ?? [] };
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/** One field of a plan file, or undefined when the file or the field is missing. */
|
|
1278
|
+
function readPlanFileField(path: string, field: string): unknown {
|
|
1279
|
+
try {
|
|
1280
|
+
return (JSON.parse(readFileSync(path, "utf-8")) as Record<string, unknown>)[field];
|
|
1281
|
+
} catch {
|
|
1282
|
+
return undefined;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
/** A plan file's change-set part (#4545), when it gives one of the right shape. */
|
|
1287
|
+
function partOf(value: unknown): ChangeSetPart | undefined {
|
|
1288
|
+
const p = value as Partial<ChangeSetPart> | undefined;
|
|
1289
|
+
return p && typeof p === "object" && p.member && typeof p.member.member === "string" && Array.isArray(p.entries) ? (p as ChangeSetPart) : undefined;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
835
1292
|
/** What planning a wave's runs gave: each run's plan, and the product's pending-fact fields (#3821). */
|
|
836
1293
|
interface PlannedRuns {
|
|
837
1294
|
members: OpWaveMember[];
|
|
1295
|
+
/** Each run's change-set part, by target, when its plan gave one (#4545): what a policy hold reads. */
|
|
1296
|
+
parts?: Map<string, ChangeSetPart>;
|
|
838
1297
|
pending?: Record<string, unknown>;
|
|
839
1298
|
/** The plans file's overriders (#3821). */
|
|
840
1299
|
overriders?: string[];
|
|
@@ -842,6 +1301,8 @@ interface PlannedRuns {
|
|
|
842
1301
|
overridersSource?: string;
|
|
843
1302
|
/** Digest members that are not runs, such as the wave's cost (#3821). */
|
|
844
1303
|
extras?: WaveMember[];
|
|
1304
|
+
/** The change-set document the plans file gave (#4551). */
|
|
1305
|
+
changeSet?: ChangeSetDocument;
|
|
845
1306
|
/** How many waves the product found (#3821), for a `rest` wave. */
|
|
846
1307
|
waves?: number;
|
|
847
1308
|
}
|
|
@@ -884,8 +1345,22 @@ interface HooksOutcome {
|
|
|
884
1345
|
|
|
885
1346
|
const placeOf = (ctx: WaveContext): HookPlace => ({ name: ctx.spec.name, op: ctx.spec.op, waveName: ctx.wave.name, k: ctx.k, cwd: ctx.cwd, exec: ctx.exec, log: ctx.log });
|
|
886
1347
|
|
|
887
|
-
const hookRuns = (
|
|
888
|
-
runs.map((run) =>
|
|
1348
|
+
const hookRuns = (ctx: WaveContext, runs: readonly OpWaveRun[], members?: ReadonlyMap<string, OpWaveMember>): OpWaveHookRun[] =>
|
|
1349
|
+
runs.map((run) => {
|
|
1350
|
+
const { spec, k } = ctx;
|
|
1351
|
+
const m = members?.get(run.target);
|
|
1352
|
+
if (!m) return { target: run.target, op: run.op ?? spec.op };
|
|
1353
|
+
const plan = opWavePlanPath(spec, k, run.target);
|
|
1354
|
+
// #4614: the engine's plan document, from the step's artifact or the plan file's.
|
|
1355
|
+
const planJson = runPlanJson(ctx, run.target, plan);
|
|
1356
|
+
return { target: run.target, op: run.op ?? spec.op, plan, planDigest: m.planDigest, ...(planJson ? { planJson } : {}) };
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1359
|
+
/** The engine's plan document a run's plan names (#4614): the step's artifact, else the plan file's `artifact`. */
|
|
1360
|
+
function runPlanJson(ctx: Pick<WaveContext, "cwd" | "steps">, target: string, plan: string): string | undefined {
|
|
1361
|
+
const artifact = ctx.steps?.get(target)?.artifact ?? readPlanFileField(join(ctx.cwd, plan), "artifact");
|
|
1362
|
+
return planJsonOf(artifact, ctx.cwd);
|
|
1363
|
+
}
|
|
889
1364
|
|
|
890
1365
|
/**
|
|
891
1366
|
* Run one moment's hooks in the wave job (#3762), recording each outcome on
|
|
@@ -906,7 +1381,10 @@ async function runHooks(
|
|
|
906
1381
|
): Promise<HooksOutcome> {
|
|
907
1382
|
if (!hooks || hooks.length === 0) return { holds: [] };
|
|
908
1383
|
const runsPath = writeRunsFile(ctx, runs, members, digest);
|
|
909
|
-
const
|
|
1384
|
+
const hookExec = ctx.options.hookExec;
|
|
1385
|
+
const out = hookExec
|
|
1386
|
+
? await runHookListAsync({ ...placeOf(ctx), exec: hookExec }, moment, hooks, hookRuns(ctx, runs, members), runsPath, extraEnv)
|
|
1387
|
+
: runHookList(placeOf(ctx), moment, hooks, hookRuns(ctx, runs, members), runsPath, extraEnv);
|
|
910
1388
|
ctx.result.hooks.push(...out.outcomes);
|
|
911
1389
|
const back: HooksOutcome = { holds: out.holds, ...(out.failed ? { failed: out.failed } : {}) };
|
|
912
1390
|
if (out.failed) return back;
|
|
@@ -923,7 +1401,8 @@ async function runHooks(
|
|
|
923
1401
|
}
|
|
924
1402
|
const now: OpWaveHeldOnApproval = { op: held.op, gate: held.gate, digest: held.digest, approvedBy: held.approvedBy!, approvedAt: held.approvedAt! };
|
|
925
1403
|
approved.push(now);
|
|
926
|
-
const
|
|
1404
|
+
const target = hold.target ? { target: hold.target } : {};
|
|
1405
|
+
const approvedEnv: Record<string, string> = {
|
|
927
1406
|
...hold.env,
|
|
928
1407
|
CHANT_HOLD_APPROVED: JSON.stringify(now),
|
|
929
1408
|
// Every hold this hook call was approved through so far, oldest first (#3847).
|
|
@@ -931,14 +1410,31 @@ async function runHooks(
|
|
|
931
1410
|
};
|
|
932
1411
|
const holdPath = join(ctx.cwd, hold.env.CHANT_HOLD!);
|
|
933
1412
|
rmSync(holdPath, { force: true });
|
|
1413
|
+
// #4623: a hold that asks chant to record its gate is spent here, before the re-run acts under the approval.
|
|
1414
|
+
let spent: AppliedGateRecord | undefined;
|
|
1415
|
+
let finishedAt: string | undefined;
|
|
1416
|
+
if (hold.request.record) {
|
|
1417
|
+
const got = await spendHeldGate(ctx, hold, now);
|
|
1418
|
+
if ("failed" in got) {
|
|
1419
|
+
ctx.result.hooks.push({ moment, name: hold.name, ...target, exit: 1, outcome: "failed" });
|
|
1420
|
+
back.failed = got.failed;
|
|
1421
|
+
ctx.log(back.failed);
|
|
1422
|
+
return back;
|
|
1423
|
+
}
|
|
1424
|
+
spent = got.record;
|
|
1425
|
+
const finishedRel = holdFinishedPath(hold.env.CHANT_HOLD!);
|
|
1426
|
+
finishedAt = join(ctx.cwd, finishedRel);
|
|
1427
|
+
rmSync(finishedAt, { force: true });
|
|
1428
|
+
approvedEnv.CHANT_HOLD_FINISHED = finishedRel;
|
|
1429
|
+
}
|
|
934
1430
|
let code: number;
|
|
935
1431
|
try {
|
|
936
|
-
code = ctx.exec(hold.argv, ctx.cwd, approvedEnv);
|
|
1432
|
+
code = hookExec ? await hookExec(hold.argv, ctx.cwd, approvedEnv) : ctx.exec(hold.argv, ctx.cwd, approvedEnv);
|
|
937
1433
|
} catch (err) {
|
|
938
1434
|
ctx.log(`${hold.label} did not run: ${err instanceof Error ? err.message : String(err)}`);
|
|
939
1435
|
code = 127;
|
|
940
1436
|
}
|
|
941
|
-
|
|
1437
|
+
if (spent && finishedAt) await finishHeldGate(ctx, hold, spent, readHoldFinished(finishedAt, ctx.log, hold.label), code);
|
|
942
1438
|
if (code === 0) {
|
|
943
1439
|
ctx.result.hooks.push({ moment, name: hold.name, ...target, exit: code, outcome: "passed" });
|
|
944
1440
|
ctx.log(`${hold.label}: ${held.approvedBy} approved ${held.op} / ${held.gate} at ${held.digest}, and the hook ran again and passed`);
|
|
@@ -1011,6 +1507,73 @@ function logRefused(log: (line: string) => void, label: string, check: GateCheck
|
|
|
1011
1507
|
for (const { resolution: r, reason } of check.refused ?? []) log(`${label}: the approval by ${r.resolvedBy} at ${r.timestamp} does not count: ${reason}`);
|
|
1012
1508
|
}
|
|
1013
1509
|
|
|
1510
|
+
/**
|
|
1511
|
+
* Spend a held gate's approval before the hook runs again under it (#4623),
|
|
1512
|
+
* when the hold asked chant to `record` the gate: an applied line in
|
|
1513
|
+
* `_gates/<op>/applied.jsonl`, as a gated request's (#4551). A digest that
|
|
1514
|
+
* already applied under this gate does not apply again, and a line that did
|
|
1515
|
+
* not reach the remote stops the re-run, so two jobs never act on one
|
|
1516
|
+
* approval.
|
|
1517
|
+
*/
|
|
1518
|
+
async function spendHeldGate(ctx: WaveContext, hold: OtherGateHold, approval: OpWaveHeldOnApproval): Promise<{ record: AppliedGateRecord } | { failed: string }> {
|
|
1519
|
+
const { k, wave, cwd, options } = ctx;
|
|
1520
|
+
const port = options.gates ?? gitGateLedgerPort({ cwd });
|
|
1521
|
+
const label = `${approval.op} / ${approval.gate}`;
|
|
1522
|
+
try {
|
|
1523
|
+
if (!port.appendApplied) throw new Error("this gate ledger cannot record an applied approval");
|
|
1524
|
+
const prior = ((await port.readApplied?.(approval.op)) ?? []).filter((a) => a.gate === approval.gate && samePlanDigest(a.planDigest, approval.digest)).at(-1);
|
|
1525
|
+
if (prior) return { failed: `${hold.label}: ${label} at ${approval.digest} applied already under the approval by ${prior.approvedBy} (${prior.timestamp}); a held request applies once, so the hook did not run again` };
|
|
1526
|
+
const commit = typeof hold.request.pending?.commit === "string" ? hold.request.pending.commit : undefined;
|
|
1527
|
+
const runId = ciRunIdFromEnv();
|
|
1528
|
+
const record: AppliedGateRecord = {
|
|
1529
|
+
version: 1,
|
|
1530
|
+
kind: "applied",
|
|
1531
|
+
op: approval.op,
|
|
1532
|
+
gate: approval.gate,
|
|
1533
|
+
planDigest: approval.digest,
|
|
1534
|
+
approvedAt: approval.approvedAt,
|
|
1535
|
+
approvedBy: approval.approvedBy,
|
|
1536
|
+
timestamp: options.now ?? new Date().toISOString(),
|
|
1537
|
+
wave: { number: k, name: wave.name },
|
|
1538
|
+
...(runId ? { runId } : {}),
|
|
1539
|
+
...(commit ? { commit } : {}),
|
|
1540
|
+
};
|
|
1541
|
+
requireSpendPushed(await port.appendApplied(record));
|
|
1542
|
+
ctx.log(`${hold.label}: ${label} applies under the approval by ${record.approvedBy} at ${record.approvedAt}, which is now spent`);
|
|
1543
|
+
return { record };
|
|
1544
|
+
} catch (err) {
|
|
1545
|
+
return { failed: `${hold.label}: could not record that ${label} applies under the approval by ${approval.approvedBy}, so the hook did not run again: ${err instanceof Error ? err.message : String(err)}` };
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
/**
|
|
1550
|
+
* Write the finished line of a held gate the hook ran again under (#4623):
|
|
1551
|
+
* how it ended, from the hook's `CHANT_HOLD_FINISHED` file, else from its
|
|
1552
|
+
* exit code, with the file's detail. A line that is not written is logged;
|
|
1553
|
+
* the work under the approval is done either way.
|
|
1554
|
+
*/
|
|
1555
|
+
async function finishHeldGate(ctx: WaveContext, hold: OtherGateHold, spent: AppliedGateRecord, wrote: OpWaveHoldFinished | undefined, code: number): Promise<void> {
|
|
1556
|
+
const port = ctx.options.gates ?? gitGateLedgerPort({ cwd: ctx.cwd });
|
|
1557
|
+
const record: FinishedGateRecord = {
|
|
1558
|
+
version: 1,
|
|
1559
|
+
kind: "finished",
|
|
1560
|
+
op: spent.op,
|
|
1561
|
+
gate: spent.gate,
|
|
1562
|
+
planDigest: spent.planDigest,
|
|
1563
|
+
applied: spent.timestamp,
|
|
1564
|
+
result: wrote?.result ?? (code === 0 ? "applied" : "failed"),
|
|
1565
|
+
timestamp: ctx.options.now ?? new Date().toISOString(),
|
|
1566
|
+
...(wrote?.detail ? { detail: wrote.detail } : {}),
|
|
1567
|
+
};
|
|
1568
|
+
try {
|
|
1569
|
+
if (!port.appendFinished) throw new Error("this gate ledger keeps no finished lines");
|
|
1570
|
+
const pushed = await port.appendFinished(record);
|
|
1571
|
+
if (!pushed.pushed && pushed.pushWarning && !isLifecycleLocalNote(pushed.pushWarning)) ctx.log(`${hold.label}: the finished line of ${spent.op} / ${spent.gate} was written and not pushed: ${pushed.pushWarning}`);
|
|
1572
|
+
} catch (err) {
|
|
1573
|
+
ctx.log(`${hold.label}: the finished line of ${spent.op} / ${spent.gate} was not written: ${err instanceof Error ? err.message : String(err)}`);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1014
1577
|
/**
|
|
1015
1578
|
* Settle a hold on another gate (#3821): an approval of that gate and digest
|
|
1016
1579
|
* under the wave's approval mode (`pr-review` counts the ledger alone, since
|
|
@@ -1024,6 +1587,17 @@ async function settleOtherGate(ctx: WaveContext, hold: OtherGateHold): Promise<O
|
|
|
1024
1587
|
const { port } = await gatePort(ctx.options, ctx.cwd, hold.request.gate, mode, rules.base);
|
|
1025
1588
|
const neverOverMcp = rules.neverOverMcp;
|
|
1026
1589
|
const now = ctx.options.now ?? new Date().toISOString();
|
|
1590
|
+
// #4623: the file the request carries, stored once before the pending fact, which names its SHA-256.
|
|
1591
|
+
const attachment = hold.request.attachment;
|
|
1592
|
+
if (attachment !== undefined) {
|
|
1593
|
+
try {
|
|
1594
|
+
if (!port.storeRequestAttachment) throw new Error("this gate ledger keeps no request files");
|
|
1595
|
+
await port.storeRequestAttachment(op, hold.request.digest, attachment);
|
|
1596
|
+
} catch (err) {
|
|
1597
|
+
log(`${op} / ${hold.request.gate}: the file ${hold.label} attached was not stored beside the pending fact: ${err instanceof Error ? err.message : String(err)}`);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
const proof = attachment !== undefined ? { proof: `sha256:${createHash("sha256").update(attachment).digest("hex")}` } : {};
|
|
1027
1601
|
const check = await evaluateGate(port, {
|
|
1028
1602
|
op,
|
|
1029
1603
|
gate: hold.request.gate,
|
|
@@ -1031,7 +1605,7 @@ async function settleOtherGate(ctx: WaveContext, hold: OtherGateHold): Promise<O
|
|
|
1031
1605
|
description: hold.request.description ?? `wave ${k} (${wave.name}) of ${spec.name} is held on it by ${hold.label}`,
|
|
1032
1606
|
now,
|
|
1033
1607
|
// #3839: the wave a hold belongs to, as a field, whatever the hook's own description says.
|
|
1034
|
-
fields: { ...hold.request.pending, approvalMode: rules.approval, wave: { number: k, name: wave.name, op: spec.name }, heldBy: { hook: hold.name, moment: hold.moment, ...(hold.target ? { target: hold.target } : {}) } },
|
|
1608
|
+
fields: { ...hold.request.pending, ...proof, approvalMode: rules.approval, wave: { number: k, name: wave.name, op: spec.name }, heldBy: { hook: hold.name, moment: hold.moment, ...(hold.target ? { target: hold.target } : {}) } },
|
|
1035
1609
|
...(neverOverMcp ? { neverOverMcp: true } : {}),
|
|
1036
1610
|
});
|
|
1037
1611
|
const base = { op, gate: hold.request.gate, digest: hold.request.digest, hook: hold.label };
|
|
@@ -1195,8 +1769,232 @@ function noteHooksAtBase(ctx: WaveContext, rules: OpWaveBaseRules): void {
|
|
|
1195
1769
|
* its plan command found.
|
|
1196
1770
|
*/
|
|
1197
1771
|
export async function runOpWave(options: RunOpWaveOptions): Promise<RunOpWaveResult> {
|
|
1772
|
+
assertOpWavesSpec(options.spec);
|
|
1773
|
+
const afterPlanWrong = opWaveAfterPlanProblems(options.afterPlan);
|
|
1774
|
+
if (afterPlanWrong.length > 0) throw new Error(`Op waves "${options.spec.name}": ${afterPlanWrong.join("; ")}`);
|
|
1775
|
+
// #4551: one run record per job, on every way the job ends.
|
|
1776
|
+
const started = new Date().toISOString();
|
|
1777
|
+
// #4555: the job's run events and its trace, when a reader or an exporter wants them.
|
|
1778
|
+
const events = await openOpWaveEvents(options);
|
|
1779
|
+
if (events) jobEvents.set(options, events);
|
|
1780
|
+
events?.start();
|
|
1781
|
+
let result: RunOpWaveResult;
|
|
1782
|
+
try {
|
|
1783
|
+
result = await runOpWaveJob(options);
|
|
1784
|
+
} catch (err) {
|
|
1785
|
+
const record = await recordOpWaveRun(options, started, { error: err });
|
|
1786
|
+
await closeOpWaveEvents(options, events, record);
|
|
1787
|
+
throw err;
|
|
1788
|
+
}
|
|
1789
|
+
const record = await recordOpWaveRun(options, started, { result });
|
|
1790
|
+
await closeOpWaveEvents(options, events, record, result);
|
|
1791
|
+
return result;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
/** Each running job's events (#4555), by its options, which every step of the job is handed. */
|
|
1795
|
+
const jobEvents = new WeakMap<RunOpWaveOptions, OpWaveRunEvents>();
|
|
1796
|
+
|
|
1797
|
+
/** The job's run events (#4555): to `options.events`, and to a trace when the exporter is on. Undefined when neither wants them. */
|
|
1798
|
+
async function openOpWaveEvents(options: RunOpWaveOptions): Promise<OpWaveRunEvents | undefined> {
|
|
1799
|
+
const log = options.log ?? ((line: string) => console.error(line));
|
|
1800
|
+
let exporter: OtlpExporter | undefined;
|
|
1801
|
+
try {
|
|
1802
|
+
exporter = options.otlp === false ? undefined : (options.otlp ?? activeOtlp());
|
|
1803
|
+
} catch (err) {
|
|
1804
|
+
log(`wave ${options.wave}: no trace is sent: ${err instanceof Error ? err.message : String(err)}`);
|
|
1805
|
+
}
|
|
1806
|
+
if (!options.events && !exporter) return undefined;
|
|
1807
|
+
let trace: RunEventTrace | undefined;
|
|
1808
|
+
if (exporter) {
|
|
1809
|
+
const run = await resolveRunEventRun({ kind: "op", name: options.spec.name, cwd: options.cwd ?? process.cwd() });
|
|
1810
|
+
trace = new RunEventTrace(run, { exporter });
|
|
1811
|
+
}
|
|
1812
|
+
return new OpWaveRunEvents(joinRunEventSinks(options.events, trace?.sink)!, trace);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
/** Settle the job's events from its run record and send its trace (#4555). A trace that does not go out is a line in the log, never a change of exit code. */
|
|
1816
|
+
async function closeOpWaveEvents(options: RunOpWaveOptions, events: OpWaveRunEvents | undefined, record: OpRunRecordInput, result?: RunOpWaveResult): Promise<void> {
|
|
1817
|
+
if (!events) return;
|
|
1818
|
+
jobEvents.delete(options);
|
|
1819
|
+
events.finish(record, { ...(result ? { moved: result.moved } : {}), ...(result?.blocked ? { blocked: result.blocked } : {}) });
|
|
1820
|
+
const problem = await events.trace?.flush();
|
|
1821
|
+
if (problem) (options.log ?? ((line: string) => console.error(line)))(`wave ${options.wave}: the trace was not sent: ${problem}`);
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
/** A target's apply began (#4555): its start time for the record, and its `step-start`. */
|
|
1825
|
+
function targetStarted(options: RunOpWaveOptions, k: number, target: string): number {
|
|
1826
|
+
jobEvents.get(options)?.stepStart(k, target);
|
|
1827
|
+
return Date.now();
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
/** A target's apply ended (#4555): its time and facts on the result, and its `step-settle`. */
|
|
1831
|
+
function targetSettled(options: RunOpWaveOptions, result: RunOpWaveResult, k: number, target: string, startedMs: number, status: "ok" | "failed" | "skipped", opts: { error?: string; facts?: CapabilityTraceFacts } = {}): void {
|
|
1832
|
+
const durationMs = Math.max(0, Date.now() - startedMs);
|
|
1833
|
+
result.targets = {
|
|
1834
|
+
...result.targets,
|
|
1835
|
+
[target]: {
|
|
1836
|
+
startedAt: new Date(startedMs).toISOString(),
|
|
1837
|
+
durationMs,
|
|
1838
|
+
...(opts.facts?.attributes ? { attributes: opts.facts.attributes } : {}),
|
|
1839
|
+
...(opts.facts?.spans?.length ? { spans: opts.facts.spans } : {}),
|
|
1840
|
+
// #4629: what the failed-apply triage reads back from the run record.
|
|
1841
|
+
...(status === "failed" && opts.error ? { error: opts.error } : {}),
|
|
1842
|
+
...(status === "failed" && opts.facts?.resources?.some((r) => r.status === "failed")
|
|
1843
|
+
? { failedResources: opts.facts.resources.filter((r) => r.status === "failed").map((r) => r.name ?? r.resource) }
|
|
1844
|
+
: {}),
|
|
1845
|
+
},
|
|
1846
|
+
};
|
|
1847
|
+
jobEvents.get(options)?.stepSettle(k, target, status, durationMs, opts);
|
|
1848
|
+
// #4615: one log line per resource the engine reported.
|
|
1849
|
+
if (opts.facts?.resources?.length) {
|
|
1850
|
+
const log = options.log ?? ((line: string) => console.error(line));
|
|
1851
|
+
for (const line of opWaveResourceLines(target, opts.facts.resources)) log(line);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
/** The log lines for what a target's engine reported per resource (#4615): `<target>: <resource> (<type>) ok in 412 ms, 3 calls`. */
|
|
1856
|
+
export function opWaveResourceLines(target: string, resources: readonly RunEventResource[]): string[] {
|
|
1857
|
+
return resources.map((r) => {
|
|
1858
|
+
const what = r.name ? `${r.name}${r.type ? ` (${r.type})` : ""}` : `${r.resource}${r.type ? ` (${r.type})` : ""}`;
|
|
1859
|
+
const took = r.durationMs === null ? "" : ` in ${Math.round(r.durationMs)} ms`;
|
|
1860
|
+
const calls = r.calls !== undefined ? `, ${r.calls} call${r.calls === 1 ? "" : "s"}` : "";
|
|
1861
|
+
return `${target}: ${what} ${r.status === "ok" ? "ok" : "failed"}${took}${calls}`;
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
/** The run ledger's status and failure for a job's exit code (#4551), by chant's exit-code table. */
|
|
1866
|
+
function opWaveRunStatus(result: RunOpWaveResult): { status: OpRunRecordInput["status"]; failure?: { code: string; reason: string } } {
|
|
1867
|
+
const d = result.decision;
|
|
1868
|
+
switch (result.exitCode) {
|
|
1869
|
+
case CHANT_EXIT.done:
|
|
1870
|
+
case CHANT_EXIT.held:
|
|
1871
|
+
case CHANT_EXIT.superseded:
|
|
1872
|
+
return { status: "ok" };
|
|
1873
|
+
case CHANT_EXIT.waiting:
|
|
1874
|
+
return { status: d?.point?.question ? "waiting" : "gated" };
|
|
1875
|
+
case CHANT_EXIT.moved:
|
|
1876
|
+
return { status: "fail", failure: { code: "moved", reason: `plans moved since the decision: ${result.moved.join(", ") || "(none named)"}` } };
|
|
1877
|
+
case CHANT_EXIT.denied:
|
|
1878
|
+
return { status: "fail", failure: { code: "denied", reason: d?.refused?.message ?? `the policy denied ${d?.refused?.runs.join(", ") ?? "a run"}, and no override counts` } };
|
|
1879
|
+
case CHANT_EXIT.declined:
|
|
1880
|
+
return { status: "fail", failure: { code: "point-refused", reason: d?.refused?.message ?? "the gate's decision point was answered with an answer it does not pass on" } };
|
|
1881
|
+
default:
|
|
1882
|
+
return { status: "fail", failure: { code: "command-failed", reason: result.failed.length > 0 ? `failed: ${result.failed.join(", ")}` : "the wave job failed" } };
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
/**
|
|
1887
|
+
* The run record of one `chant run wave` job (#4551): one phase per wave the
|
|
1888
|
+
* job walked, one step per run target. A run that applied is `ok`, one that
|
|
1889
|
+
* failed `fail`, and one that moved, was blocked or waited `skipped`.
|
|
1890
|
+
*/
|
|
1891
|
+
export function opWaveRunRecord(
|
|
1892
|
+
options: Pick<RunOpWaveOptions, "spec" | "wave" | "decide" | "share" | "group">,
|
|
1893
|
+
times: { started: string; ended: string; gitSha?: string; runOrigin?: OpRunRecordInput["runOrigin"] },
|
|
1894
|
+
outcome: { result: RunOpWaveResult } | { error: unknown },
|
|
1895
|
+
): OpRunRecordInput {
|
|
1896
|
+
const { spec } = options;
|
|
1897
|
+
const result: RunOpWaveResult = "result" in outcome ? outcome.result : { exitCode: CHANT_EXIT.failed, applied: [], failed: [], moved: [], hooks: [] };
|
|
1898
|
+
const d = result.decision;
|
|
1899
|
+
const applied = new Set(result.applied);
|
|
1900
|
+
const failedRuns = new Set(result.failed);
|
|
1901
|
+
const walked = result.rest?.length ? result.rest.map((r) => r.wave) : [options.wave];
|
|
1902
|
+
const last = walked[walked.length - 1];
|
|
1903
|
+
const phases = walked.map((k) => {
|
|
1904
|
+
const targets = k === last && d ? d.members.map((m) => m.member) : (spec.waves[k - 1]?.runs ?? []).map((r) => r.target);
|
|
1905
|
+
const steps: OpRunStepRecord[] = targets.map((t) => ({
|
|
1906
|
+
fn: t,
|
|
1907
|
+
status: failedRuns.has(t) ? "fail" : applied.has(t) ? "ok" : "skipped",
|
|
1908
|
+
durationMs: result.targets?.[t]?.durationMs ?? 0,
|
|
1909
|
+
}));
|
|
1910
|
+
const status: "ok" | "fail" | "skipped" = steps.some((x) => x.status === "fail") ? "fail" : steps.length > 0 && steps.every((x) => x.status === "skipped") ? "skipped" : "ok";
|
|
1911
|
+
return { name: `wave-${k}`, status, steps };
|
|
1912
|
+
});
|
|
1913
|
+
const verdict: ReturnType<typeof opWaveRunStatus> = "error" in outcome
|
|
1914
|
+
? { status: "fail", failure: { code: "command-failed", reason: outcome.error instanceof Error ? outcome.error.message : String(outcome.error) } }
|
|
1915
|
+
: opWaveRunStatus(result);
|
|
1916
|
+
const wave: OpRunWave = {
|
|
1917
|
+
spec: spec.name,
|
|
1918
|
+
number: options.wave,
|
|
1919
|
+
name: spec.waves[options.wave - 1]?.name ?? `wave-${options.wave}`,
|
|
1920
|
+
job: options.decide ? "decide" : options.group !== undefined ? "group" : options.share !== undefined ? "share" : "wave",
|
|
1921
|
+
...(options.share !== undefined ? { share: options.share } : {}),
|
|
1922
|
+
...(options.group !== undefined ? { group: options.group } : {}),
|
|
1923
|
+
...(d?.digest ? { digest: d.digest } : {}),
|
|
1924
|
+
exitCode: result.exitCode,
|
|
1925
|
+
...(result.outcome && result.outcome.outcome !== "replan" ? { outcome: result.outcome.outcome } : {}),
|
|
1926
|
+
...(result.supersededBy ? { supersededBy: { ...result.supersededBy } } : {}),
|
|
1927
|
+
applied: [...result.applied],
|
|
1928
|
+
failed: [...result.failed],
|
|
1929
|
+
moved: [...result.moved],
|
|
1930
|
+
...(result.blocked && Object.keys(result.blocked).length > 0 ? { blocked: { ...result.blocked } } : {}),
|
|
1931
|
+
...(result.targets && Object.keys(result.targets).length > 0 ? { targets: { ...result.targets } } : {}),
|
|
1932
|
+
...(result.plans && Object.keys(result.plans).length > 0 ? { plans: { ...result.plans } } : {}),
|
|
1933
|
+
};
|
|
1934
|
+
const labels = { ...(spec.labels ?? {}) };
|
|
1935
|
+
return {
|
|
1936
|
+
op: spec.name,
|
|
1937
|
+
env: labels.Env ?? DEFAULT_RUN_ENV,
|
|
1938
|
+
started: times.started,
|
|
1939
|
+
ended: times.ended,
|
|
1940
|
+
status: verdict.status,
|
|
1941
|
+
labels,
|
|
1942
|
+
outcomes: {},
|
|
1943
|
+
phases,
|
|
1944
|
+
...(verdict.status === "gated" && d ? { gate: { name: d.gate, since: d.waitingSince ?? times.ended, ...(d.op !== spec.name ? { op: d.op } : {}) } } : {}),
|
|
1945
|
+
...(verdict.status === "waiting" && d?.point?.question ? { point: { ...d.point.question, since: d.waitingSince ?? times.ended } } : {}),
|
|
1946
|
+
...(times.gitSha ? { gitSha: times.gitSha } : {}),
|
|
1947
|
+
...(times.runOrigin ? { runOrigin: times.runOrigin } : {}),
|
|
1948
|
+
...(verdict.failure ? { failure: { ...verdict.failure, exitCode: result.exitCode } } : {}),
|
|
1949
|
+
wave,
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
/** Append the job's run record (#4551). A failed write warns and never changes the job's exit code. */
|
|
1954
|
+
async function recordOpWaveRun(options: RunOpWaveOptions, started: string, outcome: { result: RunOpWaveResult } | { error: unknown }): Promise<OpRunRecordInput> {
|
|
1955
|
+
const cwd = options.cwd ?? process.cwd();
|
|
1956
|
+
const port = options.runs ?? (options.gates ? undefined : gitOpWaveRunPort({ cwd }));
|
|
1957
|
+
const log = options.log ?? ((line: string) => console.error(line));
|
|
1958
|
+
let gitSha = options.head;
|
|
1959
|
+
if (gitSha === undefined) {
|
|
1960
|
+
try {
|
|
1961
|
+
gitSha = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
1962
|
+
} catch {
|
|
1963
|
+
gitSha = undefined;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
const ci = resolveCiJob();
|
|
1967
|
+
const record = opWaveRunRecord(options, { started, ended: new Date().toISOString(), ...(gitSha ? { gitSha } : {}), ...(ci ? { runOrigin: ci.runOrigin } : {}) }, outcome);
|
|
1968
|
+
// The record is built either way: the job's run events settle from it (#4555).
|
|
1969
|
+
if (!port) return record;
|
|
1970
|
+
try {
|
|
1971
|
+
const wrote = await port.append(record);
|
|
1972
|
+
if (wrote && wrote.pushWarning) log(`wave ${options.wave}: the run record was written and not pushed: ${wrote.pushWarning}`);
|
|
1973
|
+
} catch (err) {
|
|
1974
|
+
log(`wave ${options.wave}: could not record the run on the run ledger: ${err instanceof Error ? err.message : String(err)}`);
|
|
1975
|
+
}
|
|
1976
|
+
return record;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* Store the change-set document a wave's plans file gave (#4551), so the
|
|
1981
|
+
* pending fact can cite it. A document that is not one, or does not hash to
|
|
1982
|
+
* its digest, is logged and left out; it never blocks the gate.
|
|
1983
|
+
*/
|
|
1984
|
+
async function storeWaveChangeSet(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, doc: ChangeSetDocument): Promise<void> {
|
|
1985
|
+
const ledger = options.gates ?? gitGateLedgerPort({ cwd: ctx.cwd });
|
|
1986
|
+
if (!ledger.storeChangeSet) return;
|
|
1987
|
+
try {
|
|
1988
|
+
await ledger.storeChangeSet(doc);
|
|
1989
|
+
decision.changeSet = doc.digest;
|
|
1990
|
+
} catch (err) {
|
|
1991
|
+
ctx.log(`wave ${ctx.k} (${ctx.wave.name}): the plans file's change set was not stored, so the pending fact cites none: ${err instanceof Error ? err.message : String(err)}`);
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
/** One job's plan, decide and apply, which {@link runOpWave} records. */
|
|
1996
|
+
async function runOpWaveJob(options: RunOpWaveOptions): Promise<RunOpWaveResult> {
|
|
1198
1997
|
const { spec } = options;
|
|
1199
|
-
assertOpWavesSpec(spec);
|
|
1200
1998
|
const log = options.log ?? ((line: string) => console.error(line));
|
|
1201
1999
|
const cwd = options.cwd ?? process.cwd();
|
|
1202
2000
|
const outcomeDir = options.outcomeDir ?? opWaveOutcomeDir(spec);
|
|
@@ -1244,6 +2042,8 @@ async function runOpWaveLoop(options: RunOpWaveOptions, log: (line: string) => v
|
|
|
1244
2042
|
const { spec } = options;
|
|
1245
2043
|
const last = spec.waves[spec.waves.length - 1]!;
|
|
1246
2044
|
const rest: NonNullable<RunOpWaveResult["rest"]> = [];
|
|
2045
|
+
// #4555: each wave a `rest` job walks keeps its targets' times.
|
|
2046
|
+
const targets: Record<string, OpRunWaveTarget> = {};
|
|
1247
2047
|
const result = await runWaveLoop<OpWavePlanned, OpWaveDecided, RunOpWaveResult>({
|
|
1248
2048
|
first: options.wave,
|
|
1249
2049
|
plan: (at) => planOpWave(options, at, at.k === options.wave ? skip : undefined),
|
|
@@ -1263,6 +2063,7 @@ async function runOpWaveLoop(options: RunOpWaveOptions, log: (line: string) => v
|
|
|
1263
2063
|
},
|
|
1264
2064
|
onward(k, outcome) {
|
|
1265
2065
|
applied.push(...outcome.applied);
|
|
2066
|
+
Object.assign(targets, outcome.targets ?? {});
|
|
1266
2067
|
// #3821: a `rest` wave goes on through the waves its plan command found.
|
|
1267
2068
|
const found = outcome.decision?.discovered?.waves;
|
|
1268
2069
|
const onward = k >= spec.waves.length && last.rest === true && options.share === undefined && options.group === undefined && !options.decide && outcome.exitCode === 0 && found !== undefined && k < found;
|
|
@@ -1271,7 +2072,8 @@ async function runOpWaveLoop(options: RunOpWaveOptions, log: (line: string) => v
|
|
|
1271
2072
|
return onward;
|
|
1272
2073
|
},
|
|
1273
2074
|
});
|
|
1274
|
-
|
|
2075
|
+
const timed = { ...targets, ...(result.targets ?? {}) };
|
|
2076
|
+
return { ...result, applied, ...(rest.length > 0 ? { rest } : {}), ...(Object.keys(timed).length > 0 ? { targets: timed } : {}) };
|
|
1275
2077
|
}
|
|
1276
2078
|
|
|
1277
2079
|
/** What the earlier outcome files hold for a job (#4322): the runs they block, or why the job does not run at all. */
|
|
@@ -1324,7 +2126,7 @@ function opWaveBefore(options: RunOpWaveOptions, dir: string): OpWaveBefore {
|
|
|
1324
2126
|
? `Nothing in wave ${k} (${wave.name}) ran: ${shown} waits at its gate. Approve it and run that wave's job again, then this one.`
|
|
1325
2127
|
: `Nothing in wave ${k} (${wave.name}) ran: ${shown} did not apply, and only a failure lets the waves after it go on.`;
|
|
1326
2128
|
const status = waiting.length > 0 ? "waiting" : "not-applied";
|
|
1327
|
-
return { blocked: new Map(), stop: { exitCode: waiting.length > 0 ?
|
|
2129
|
+
return { blocked: new Map(), stop: { exitCode: waiting.length > 0 ? CHANT_EXIT.waiting : CHANT_EXIT.failed, line, members: Object.fromEntries((wave.runs ?? []).map((r) => [r.target, { status }])) } };
|
|
1328
2130
|
}
|
|
1329
2131
|
const runs = wave.runs ?? [];
|
|
1330
2132
|
const index = new Map(runs.map((r, i) => [r.target, i]));
|
|
@@ -1366,9 +2168,9 @@ function writeOpWaveOutcome(options: RunOpWaveOptions, dir: string, result: RunO
|
|
|
1366
2168
|
const moved = new Set(result.moved);
|
|
1367
2169
|
const otherwise: WaveMemberOutcome["status"] =
|
|
1368
2170
|
result.exitCode === 0 ? (options.decide ? "decided" : "unchanged")
|
|
1369
|
-
: result.exitCode ===
|
|
1370
|
-
: result.exitCode ===
|
|
1371
|
-
: result.exitCode >=
|
|
2171
|
+
: result.exitCode === CHANT_EXIT.waiting ? "waiting"
|
|
2172
|
+
: result.exitCode === CHANT_EXIT.denied || result.exitCode === CHANT_EXIT.declined ? "refused"
|
|
2173
|
+
: result.exitCode >= CHANT_EXIT.moved && result.exitCode <= CHANT_EXIT.superseded ? "not-applied"
|
|
1372
2174
|
: "failed";
|
|
1373
2175
|
for (const t of targets) {
|
|
1374
2176
|
const by = result.blocked?.[t];
|
|
@@ -1416,6 +2218,7 @@ type OpWavePlanned =
|
|
|
1416
2218
|
overriders?: string[];
|
|
1417
2219
|
overridersSource?: string;
|
|
1418
2220
|
extras?: WaveMember[];
|
|
2221
|
+
changeSet?: ChangeSetDocument;
|
|
1419
2222
|
}
|
|
1420
2223
|
| {
|
|
1421
2224
|
kind: "share";
|
|
@@ -1480,7 +2283,7 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
|
|
|
1480
2283
|
ctx.gateRule = { approval: decision.approval, base: decision.base, neverOverMcp: decision.neverOverMcp === true };
|
|
1481
2284
|
if (decision.status === "waiting" || decision.status === "refused") {
|
|
1482
2285
|
log(`wave ${k} (${wave.name}) is ${decision.status === "refused" ? "refused by its policy" : `waiting on ${decision.heldOn?.gate ?? decision.gate}`}; nothing applied. ${decision.approve ?? ""}`.trim());
|
|
1483
|
-
return { end: { ...result, exitCode: decision.status === "refused" ? refusedExit(decision) :
|
|
2286
|
+
return { end: { ...result, exitCode: decision.status === "refused" ? refusedExit(decision) : CHANT_EXIT.waiting } };
|
|
1484
2287
|
}
|
|
1485
2288
|
// The share runs the hooks its deciding job read at base, around its own slice.
|
|
1486
2289
|
if (wave.discover) {
|
|
@@ -1499,12 +2302,16 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
|
|
|
1499
2302
|
const before = await runBeforePlanHooks(ctx, decision.hooks, slice);
|
|
1500
2303
|
if (before.failed) return { end: failed(ctx, `a hook before the plan failed, so nothing in ${part} of wave ${k} was planned or applied`) };
|
|
1501
2304
|
if (before.waitingOn) return { end: await waitOnOther(ctx, decision, before.waitingOn) };
|
|
1502
|
-
|
|
2305
|
+
if (spec.step) ctx.steps = new Map();
|
|
2306
|
+
const { members, parts: sliceParts } = await planWaveRuns(ctx, slice);
|
|
2307
|
+
// #4614: the after-plan hooks in the job's process, over the share's own plans.
|
|
2308
|
+
const inProcess = await runAfterPlan(ctx, members, sliceParts, new Map());
|
|
2309
|
+
if (inProcess.failed) return { end: failed(ctx, `${inProcess.failed}, so nothing in ${part} of wave ${k} was applied`) };
|
|
1503
2310
|
const planned = new Map(members.map((m) => [m.member, m]));
|
|
1504
2311
|
const after = await runHooks(ctx, "after-plan", decision.hooks?.["after-plan"], slice, planned);
|
|
1505
2312
|
if (after.failed) return { end: failed(ctx, `a hook after the plan failed, so nothing in ${part} of wave ${k} was applied`) };
|
|
1506
2313
|
if (after.waitingOn) return { end: await waitOnOther(ctx, decision, after.waitingOn) };
|
|
1507
|
-
return { go: { kind: "share", ctx, decision, slice, planned, holds: [...before.holds, ...after.holds] } };
|
|
2314
|
+
return { go: { kind: "share", ctx, decision, slice, planned, holds: [...before.holds, ...inProcess.holds, ...after.holds] } };
|
|
1508
2315
|
}
|
|
1509
2316
|
|
|
1510
2317
|
// The policy, the approval mode and the hooks, read at base before anything runs.
|
|
@@ -1559,7 +2366,27 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
|
|
|
1559
2366
|
const before = await runBeforePlanHooks(ctx, rules.hooks, wave.runs);
|
|
1560
2367
|
if (before.failed) return { end: failed(ctx, `a hook before the plan failed, so nothing in wave ${k} was planned or applied`) };
|
|
1561
2368
|
if (before.waitingOn) return { end: await decided(ctx, decision, recordPath, before.waitingOn) };
|
|
1562
|
-
|
|
2369
|
+
if (spec.step) ctx.steps = new Map();
|
|
2370
|
+
const { members, pending, overriders, overridersSource, extras: planExtras, waves: found, changeSet, parts } = await planWaveRuns(ctx, wave.runs, wave.discover === true);
|
|
2371
|
+
// #4545: the holds at base (else the change's), run over the plans before the gate decides.
|
|
2372
|
+
let extras = planExtras;
|
|
2373
|
+
let policyRows = new Map<string, OpRunPolicyRow>();
|
|
2374
|
+
if (rules.holdsRefused) {
|
|
2375
|
+
holds.push(rules.holdsRefused);
|
|
2376
|
+
log(`wave ${k} (${wave.name}): ${rules.holdsRefused}, so none runs and the wave waits for an approval`);
|
|
2377
|
+
} else {
|
|
2378
|
+
const held = await runWaveHolds(ctx, opWaveHoldsAt(rules.holds, spec.holds), members, parts, base);
|
|
2379
|
+
if ("failed" in held) return { end: failed(ctx, held.failed) };
|
|
2380
|
+
holds.push(...held.holds);
|
|
2381
|
+
if (held.extras.length > 0) extras = [...(extras ?? []), ...held.extras];
|
|
2382
|
+
policyRows = held.rows;
|
|
2383
|
+
// #4613: the decision names the shared policy commit its runs were judged by.
|
|
2384
|
+
if (held.policySource) decision.ciPolicySource = held.policySource;
|
|
2385
|
+
}
|
|
2386
|
+
// #4614: the after-plan hooks in the job's process, before the set digest and the gate.
|
|
2387
|
+
const inProcess = await runAfterPlan(ctx, members, parts, policyRows);
|
|
2388
|
+
if (inProcess.failed) return { end: failed(ctx, `${inProcess.failed}, so nothing in wave ${k} was approved or applied`) };
|
|
2389
|
+
holds.push(...inProcess.holds);
|
|
1563
2390
|
if (wave.discover) {
|
|
1564
2391
|
wave = { ...wave, runs: members.map((m) => ({ target: m.member, ...(m.op !== spec.op ? { op: m.op } : {}) })) };
|
|
1565
2392
|
ctx.wave = wave;
|
|
@@ -1585,6 +2412,7 @@ async function planOpWave(options: RunOpWaveOptions, { k, pass }: WaveAttempt<Ru
|
|
|
1585
2412
|
...(overriders ? { overriders } : {}),
|
|
1586
2413
|
...(overridersSource ? { overridersSource } : {}),
|
|
1587
2414
|
...(extras ? { extras } : {}),
|
|
2415
|
+
...(changeSet ? { changeSet } : {}),
|
|
1588
2416
|
},
|
|
1589
2417
|
};
|
|
1590
2418
|
}
|
|
@@ -1639,6 +2467,10 @@ async function decideOpWave(
|
|
|
1639
2467
|
}
|
|
1640
2468
|
if (extras) decision.extras = extras;
|
|
1641
2469
|
if (pending) decision.pending = pending;
|
|
2470
|
+
if (planned.changeSet) await storeWaveChangeSet(options, ctx, decision, planned.changeSet);
|
|
2471
|
+
// #4550: a pull-request wave checks the pull request's approval against the plans file's change set.
|
|
2472
|
+
if (planned.changeSet) ctx.changeSetDoc = planned.changeSet;
|
|
2473
|
+
if (decision.approval === "pull-request" && planned.rules.pullRequestGate) decision.pullRequestGate = planned.rules.pullRequestGate;
|
|
1642
2474
|
const after = await runHooks(ctx, "after-plan", planned.rules.hooks["after-plan"], wave.runs, planned.planned, digest);
|
|
1643
2475
|
if (after.failed) return { end: failed(ctx, `a hook after the plan failed, so nothing in wave ${k} was applied`) };
|
|
1644
2476
|
holds.push(...planned.before, ...after.holds);
|
|
@@ -1683,7 +2515,7 @@ async function decideOpWave(
|
|
|
1683
2515
|
async function applyOpWave(options: RunOpWaveOptions, planned: OpWavePlanned, decidedWave: OpWaveDecided): Promise<RunOpWaveResult> {
|
|
1684
2516
|
const { ctx, decision } = planned;
|
|
1685
2517
|
await applyStage(options, ctx, decision, decidedWave.runs, planned.planned, decidedWave.earlierHolds, decidedWave.recordPath);
|
|
1686
|
-
if (planned.kind === "share" && ctx.result.exitCode === 0 && ctx.result.moved.length > 0) ctx.result.exitCode =
|
|
2518
|
+
if (planned.kind === "share" && ctx.result.exitCode === 0 && ctx.result.moved.length > 0) ctx.result.exitCode = CHANT_EXIT.moved;
|
|
1687
2519
|
return ctx.result;
|
|
1688
2520
|
}
|
|
1689
2521
|
|
|
@@ -1707,15 +2539,15 @@ async function decided(ctx: WaveContext, decision: OpWaveDecision, recordPath: s
|
|
|
1707
2539
|
const hook = await runGateHooks(ctx, decision, recordPath);
|
|
1708
2540
|
if (decision.status === "waiting") {
|
|
1709
2541
|
log(`Nothing in wave ${k} or after it ran. ${decision.heldOn ? `It waits on ${decision.heldOn.op} / ${decision.heldOn.gate}.` : "Read the plans, then"} approve: ${decision.approve} (with --resume, the approval also starts this job again)`);
|
|
1710
|
-
return { ...result, exitCode:
|
|
2542
|
+
return { ...result, exitCode: CHANT_EXIT.waiting };
|
|
1711
2543
|
}
|
|
1712
2544
|
if (decision.status === "refused" && decision.refused?.reason === "point") {
|
|
1713
2545
|
log(`Nothing in wave ${k} (${wave.name}) or after it ran: ${decision.refused.message}`);
|
|
1714
|
-
return { ...result, exitCode:
|
|
2546
|
+
return { ...result, exitCode: CHANT_EXIT.declined };
|
|
1715
2547
|
}
|
|
1716
2548
|
if (decision.status === "refused") {
|
|
1717
2549
|
log(`Nothing in wave ${k} (${wave.name}) or after it ran: the policy denied ${decision.refused?.runs.join(", ")}, and no override counts for ${decision.refused?.runs.length === 1 ? "it" : "them"}.`);
|
|
1718
|
-
return { ...result, exitCode:
|
|
2550
|
+
return { ...result, exitCode: CHANT_EXIT.denied };
|
|
1719
2551
|
}
|
|
1720
2552
|
if (hook.failed) return failed(ctx, `wave ${k} (${wave.name}): ${hook.failed}, so nothing in it was applied`);
|
|
1721
2553
|
return result;
|
|
@@ -1734,7 +2566,7 @@ function markHeldOn(decision: OpWaveDecision, heldOn: OpWaveHeldOn): void {
|
|
|
1734
2566
|
async function waitOnOther(ctx: WaveContext, decision: OpWaveDecision, heldOn: OpWaveHeldOn): Promise<RunOpWaveResult> {
|
|
1735
2567
|
markHeldOn(decision, heldOn);
|
|
1736
2568
|
ctx.log(`${shareLabel(ctx.options)} of wave ${ctx.k} (${ctx.wave.name}) waits on ${heldOn.op} / ${heldOn.gate}; nothing in it applied. Approve: ${heldOn.approve}`);
|
|
1737
|
-
return { ...ctx.result, decision, exitCode:
|
|
2569
|
+
return { ...ctx.result, decision, exitCode: CHANT_EXIT.waiting };
|
|
1738
2570
|
}
|
|
1739
2571
|
|
|
1740
2572
|
/**
|
|
@@ -1883,7 +2715,7 @@ async function spendOverrides(ctx: WaveContext, decision: OpWaveDecision): Promi
|
|
|
1883
2715
|
|
|
1884
2716
|
/** The exit code of a refused wave: 8 when its decision point refused it (#3836), 7 when the product's policy did (#3821). */
|
|
1885
2717
|
function refusedExit(decision: OpWaveDecision): number {
|
|
1886
|
-
return decision.refused?.reason === "point" ?
|
|
2718
|
+
return decision.refused?.reason === "point" ? CHANT_EXIT.declined : CHANT_EXIT.denied;
|
|
1887
2719
|
}
|
|
1888
2720
|
|
|
1889
2721
|
function failed(ctx: WaveContext, line: string): RunOpWaveResult {
|
|
@@ -1907,7 +2739,17 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
|
|
|
1907
2739
|
// #3784: under the spend rule at base, an approval a wave already applied under counts for nothing.
|
|
1908
2740
|
const spent: AppliedGateRecord[] | undefined = decision.spend === "base" ? ((await ledger.readApplied?.(spec.name)) ?? []).filter((a) => a.gate === gate) : undefined;
|
|
1909
2741
|
const held = decision.heldBy?.length ? `, held by ${decision.heldBy.join(", ")}` : "";
|
|
1910
|
-
|
|
2742
|
+
// Under the pull request's approval the pending fact waits for the coverage check: a wave the
|
|
2743
|
+
// pull request's approval covers applies with no pending line at its own gate (#4588).
|
|
2744
|
+
let deferred: PendingGateInput | undefined;
|
|
2745
|
+
const deciding: typeof port = approval !== "pull-request" ? port : {
|
|
2746
|
+
...port,
|
|
2747
|
+
async appendPending(input) {
|
|
2748
|
+
deferred = input;
|
|
2749
|
+
return { record: { version: 1, kind: "pending", ...input } as PendingGateRecord, pushed: false };
|
|
2750
|
+
},
|
|
2751
|
+
};
|
|
2752
|
+
const check = await decideWaveGate(deciding, {
|
|
1911
2753
|
op: spec.name,
|
|
1912
2754
|
gate,
|
|
1913
2755
|
digest,
|
|
@@ -1915,7 +2757,7 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
|
|
|
1915
2757
|
now,
|
|
1916
2758
|
...(spent ? { spent } : {}),
|
|
1917
2759
|
// #3861: the approval mode the wave asked under, for readers deciding which approvals count.
|
|
1918
|
-
fields: { ...decision.pending, approvalMode: approval },
|
|
2760
|
+
fields: { ...decision.pending, ...(decision.changeSet ? { changeSet: decision.changeSet } : {}), approvalMode: approval },
|
|
1919
2761
|
...(decision.neverOverMcp ? { neverOverMcp: true } : {}),
|
|
1920
2762
|
});
|
|
1921
2763
|
if (check.satisfied) {
|
|
@@ -1935,6 +2777,28 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
|
|
|
1935
2777
|
if (used) {
|
|
1936
2778
|
ctx.log(`wave ${k} (${wave.name}): the approval of ${digest} by ${used.approvedBy} at ${used.approvedAt} is spent: a wave applied under it at ${used.timestamp}. Applying it again needs a new approval`);
|
|
1937
2779
|
}
|
|
2780
|
+
if (approval === "pull-request") {
|
|
2781
|
+
const covered = await approveByPullRequest(options, ctx, decision, ledger);
|
|
2782
|
+
decision.coveredBy = covered.digest ? { digest: covered.digest } : { reason: covered.reason };
|
|
2783
|
+
if (covered.digest) {
|
|
2784
|
+
for (const key of ["pendingFact", "recorded", "waitingSince", "mismatch"] as const) delete decision[key];
|
|
2785
|
+
decision.status = "approved";
|
|
2786
|
+
decision.via = "pull-request";
|
|
2787
|
+
decision.approvedBy = covered.approvedBy;
|
|
2788
|
+
decision.approvedAt = covered.approvedAt;
|
|
2789
|
+
ctx.log(`wave ${k} (${wave.name}) applies under the pull request's approval of ${covered.digest} at ${decision.pullRequestGate}, which covers its plans`);
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
if (deferred) {
|
|
2793
|
+
const written = await port.appendPending(deferred);
|
|
2794
|
+
decision.pendingFact = written.record;
|
|
2795
|
+
decision.waitingSince = written.record.timestamp;
|
|
2796
|
+
}
|
|
2797
|
+
ctx.log(`wave ${k} (${wave.name}): the pull request's approval does not cover it (${covered.reason}), so it waits at its own gate ${gate}`);
|
|
2798
|
+
decision.status = "waiting";
|
|
2799
|
+
decision.approve = approveCommand(spec.name, gate, undefined, digest);
|
|
2800
|
+
return;
|
|
2801
|
+
}
|
|
1938
2802
|
if (approval === "pr-review") {
|
|
1939
2803
|
const byReview = await approveByReview(options, { op: spec.name, gate, k, digest, cwd, now, port: ledger, ...(spent ? { spent } : {}) });
|
|
1940
2804
|
decision.review = byReview.review;
|
|
@@ -1954,6 +2818,53 @@ async function settleGate(options: RunOpWaveOptions, ctx: WaveContext, decision:
|
|
|
1954
2818
|
decision.approve = approveCommand(spec.name, gate, undefined, digest, approval === "sealed");
|
|
1955
2819
|
}
|
|
1956
2820
|
|
|
2821
|
+
/**
|
|
2822
|
+
* Under `approval: "pull-request"` (#4550, ruling B): find an approval of the
|
|
2823
|
+
* pull request's gate, under the spec's op, whose change set covers every
|
|
2824
|
+
* member of this wave's plans (`planCoveredBy`, as a resume checks a wave
|
|
2825
|
+
* against the pull request's approval). The newest such approval wins. A
|
|
2826
|
+
* spent one counts for nothing under the spend rule. Needs the plans file's
|
|
2827
|
+
* change set; without one the wave waits at its own gate.
|
|
2828
|
+
*/
|
|
2829
|
+
async function approveByPullRequest(
|
|
2830
|
+
options: RunOpWaveOptions,
|
|
2831
|
+
ctx: WaveContext,
|
|
2832
|
+
decision: OpWaveDecision,
|
|
2833
|
+
ledger: GateLedgerPort,
|
|
2834
|
+
): Promise<{ digest?: string; approvedBy?: string; approvedAt?: string; reason: string }> {
|
|
2835
|
+
const prGate = decision.pullRequestGate;
|
|
2836
|
+
if (!prGate) return { reason: "the spec at base names no approvals.pullRequest.gate" };
|
|
2837
|
+
const fresh = ctx.changeSetDoc;
|
|
2838
|
+
if (!fresh) return { reason: "the plans file carries no change set to check the approval against" };
|
|
2839
|
+
const { planCoveredBy } = await import("../components/pr-run");
|
|
2840
|
+
const read = options.changeSets ?? (async (d: string) => {
|
|
2841
|
+
const { readStoredChangeSet } = await import("../lifecycle/change-set-store");
|
|
2842
|
+
const got = await readStoredChangeSet(d, { cwd: ctx.cwd });
|
|
2843
|
+
return got.status === "found" ? got.document : undefined;
|
|
2844
|
+
});
|
|
2845
|
+
const { resolutions } = await ledger.read(ctx.spec.name);
|
|
2846
|
+
const spent = decision.spend === "base" ? ((await ledger.readApplied?.(ctx.spec.name)) ?? []).filter((a) => a.gate === prGate) : [];
|
|
2847
|
+
const approvals = resolutions.filter((r) => r.gate === prGate && (r.changeSet ?? r.planDigest)).sort((a, b) => (a.timestamp < b.timestamp ? 1 : -1));
|
|
2848
|
+
if (approvals.length === 0) return { reason: `no approval stands at ${prGate}` };
|
|
2849
|
+
let reason = `no approval at ${prGate} covers it`;
|
|
2850
|
+
for (const r of approvals) {
|
|
2851
|
+
const digest = (r.changeSet ?? r.planDigest)!;
|
|
2852
|
+
if (spent.some((a) => a.planDigest === digest && a.approvedAt === r.timestamp)) {
|
|
2853
|
+
reason = `the approval of ${digest} at ${prGate} is spent`;
|
|
2854
|
+
continue;
|
|
2855
|
+
}
|
|
2856
|
+
const approved = await read(digest).catch(() => undefined);
|
|
2857
|
+
if (!approved) {
|
|
2858
|
+
reason = `the change set ${digest} the approval names is not stored`;
|
|
2859
|
+
continue;
|
|
2860
|
+
}
|
|
2861
|
+
const why = fresh.members.map((m) => planCoveredBy(approved, fresh, m.member)).find((w) => w !== undefined);
|
|
2862
|
+
if (why === undefined) return { digest, approvedBy: r.resolvedBy, approvedAt: r.timestamp, reason: "" };
|
|
2863
|
+
reason = why;
|
|
2864
|
+
}
|
|
2865
|
+
return { reason };
|
|
2866
|
+
}
|
|
2867
|
+
|
|
1957
2868
|
/** The commits after `base` up to `head`, merge commits left out, for the `Requested-by:` trailers on them (#4333). */
|
|
1958
2869
|
const gitCommitsBetween = (cwd: string) => (base: string, head: string): { sha: string; message: string }[] => {
|
|
1959
2870
|
try {
|
|
@@ -2088,7 +2999,7 @@ async function settleQuorumGate(options: RunOpWaveOptions, ctx: WaveContext, dec
|
|
|
2088
2999
|
description: (typeof decision.pending?.description === "string" ? decision.pending.description : undefined) ?? `wave ${k} (${wave.name}): ${members.length} run${members.length === 1 ? "" : "s"}, gate ${policy}, approval ${approval}${held}`,
|
|
2089
3000
|
now,
|
|
2090
3001
|
...(spent ? { spent } : {}),
|
|
2091
|
-
fields: { ...decision.pending, approvalMode: approval },
|
|
3002
|
+
fields: { ...decision.pending, ...(decision.changeSet ? { changeSet: decision.changeSet } : {}), approvalMode: approval },
|
|
2092
3003
|
...(decision.neverOverMcp ? { neverOverMcp: true } : {}),
|
|
2093
3004
|
approval: { quorum: rules, mode: "log-only" },
|
|
2094
3005
|
judge,
|
|
@@ -2141,7 +3052,7 @@ async function settlePointGate(options: RunOpWaveOptions, ctx: WaveContext, deci
|
|
|
2141
3052
|
planDigest: digest,
|
|
2142
3053
|
...(options.now ? { now: options.now } : {}),
|
|
2143
3054
|
// #3863: the plans file's pending fields and the spec's neverOverMcp, as settleGate passes them.
|
|
2144
|
-
fields: { ...decision.pending, approvalMode: decision.approval },
|
|
3055
|
+
fields: { ...decision.pending, ...(decision.changeSet ? { changeSet: decision.changeSet } : {}), approvalMode: decision.approval },
|
|
2145
3056
|
...(decision.neverOverMcp ? { neverOverMcp: true } : {}),
|
|
2146
3057
|
});
|
|
2147
3058
|
if (check.satisfied) {
|
|
@@ -2200,7 +3111,7 @@ async function settleHolds(
|
|
|
2200
3111
|
// #3821: the gate decided again, and the wave now waits: the after-gate hooks hear so.
|
|
2201
3112
|
if (recordPath) await runGateHooks(ctx, decision, recordPath);
|
|
2202
3113
|
log(`wave ${k} (${wave.name}) is held by ${holds.join(", ")}, and nobody approved ${decision.digest}; nothing applied. Approve: ${decision.approve}`);
|
|
2203
|
-
result.exitCode =
|
|
3114
|
+
result.exitCode = CHANT_EXIT.waiting;
|
|
2204
3115
|
return false;
|
|
2205
3116
|
}
|
|
2206
3117
|
log(`wave ${k} (${wave.name}) is held by ${holds.join(", ")}, and ${decision.approvedBy} approved its digest`);
|
|
@@ -2208,7 +3119,28 @@ async function settleHolds(
|
|
|
2208
3119
|
}
|
|
2209
3120
|
|
|
2210
3121
|
/** How one apply call came out. `applied` with a `problem`: the runs applied, and the wave still fails. `applied-nothing`: the apply said why (#3821). */
|
|
2211
|
-
type ApplyCall =
|
|
3122
|
+
type ApplyCall =
|
|
3123
|
+
| { outcome: "applied"; problem?: string }
|
|
3124
|
+
| { outcome: "failed"; applied?: string[] }
|
|
3125
|
+
| { outcome: "waiting" }
|
|
3126
|
+
| { outcome: "applied-nothing"; said: OpWaveApplyOutcome };
|
|
3127
|
+
|
|
3128
|
+
/**
|
|
3129
|
+
* The runs a failed `applyWave` call says it applied (#4291 on op waves):
|
|
3130
|
+
* `{ "applied": [<target>...] }` at `CHANT_APPLY_RUNS_RESULT`. Absent or
|
|
3131
|
+
* unreadable, none did, as before.
|
|
3132
|
+
*/
|
|
3133
|
+
function readAppliedRuns(path: string, label: string, log: (line: string) => void): string[] | undefined {
|
|
3134
|
+
if (!existsSync(path)) return undefined;
|
|
3135
|
+
try {
|
|
3136
|
+
const got = JSON.parse(readFileSync(path, "utf-8")) as { applied?: unknown };
|
|
3137
|
+
if (Array.isArray(got?.applied) && got.applied.every((t) => typeof t === "string")) return got.applied as string[];
|
|
3138
|
+
} catch {
|
|
3139
|
+
// Read as absent below.
|
|
3140
|
+
}
|
|
3141
|
+
log(`${label}: CHANT_APPLY_RUNS_RESULT is not { "applied": [<target>...] }, so no run counts as applied`);
|
|
3142
|
+
return undefined;
|
|
3143
|
+
}
|
|
2212
3144
|
|
|
2213
3145
|
/** Read what an apply wrote to `CHANT_APPLY_OUTCOME` (#3821), or undefined when it wrote nothing. A file that says something else is logged and ignored. */
|
|
2214
3146
|
function readApplyOutcome(path: string, label: string, log: (line: string) => void): OpWaveApplyOutcome | undefined {
|
|
@@ -2239,7 +3171,7 @@ async function callApply(
|
|
|
2239
3171
|
runs: readonly OpWaveRun[],
|
|
2240
3172
|
planned: ReadonlyMap<string, OpWaveMember>,
|
|
2241
3173
|
argv: string[],
|
|
2242
|
-
call: { label: string; key: string; runsPath: string },
|
|
3174
|
+
call: { label: string; key: string; runsPath: string; wave?: boolean },
|
|
2243
3175
|
recordPath?: string,
|
|
2244
3176
|
): Promise<ApplyCall> {
|
|
2245
3177
|
const { spec, k, wave, cwd, exec, log, result } = ctx;
|
|
@@ -2248,6 +3180,7 @@ async function callApply(
|
|
|
2248
3180
|
const filePath = `${dir}/${call.key}.json`;
|
|
2249
3181
|
const resultPath = `${dir}/${call.key}-result.json`;
|
|
2250
3182
|
const outcomePath = `${dir}/${call.key}-outcome.json`;
|
|
3183
|
+
const appliedRunsPath = `${dir}/${call.key}-runs-result.json`;
|
|
2251
3184
|
const handed: Partial<Record<OpWaveHookMoment, OpWaveHook[]>> = {};
|
|
2252
3185
|
if (byApply) {
|
|
2253
3186
|
for (const m of ["before-apply", "after-apply"] as const) if (decision.hooks?.[m]?.length) handed[m] = decision.hooks[m];
|
|
@@ -2265,7 +3198,7 @@ async function callApply(
|
|
|
2265
3198
|
approved,
|
|
2266
3199
|
...(decision.heldBy?.length ? { heldBy: decision.heldBy } : {}),
|
|
2267
3200
|
runBy: byApply ? "apply" : "chant",
|
|
2268
|
-
runs: hookRuns(
|
|
3201
|
+
runs: hookRuns(ctx, runs, planned),
|
|
2269
3202
|
runsFile: call.runsPath,
|
|
2270
3203
|
hooks: handed,
|
|
2271
3204
|
outcomes: [...result.hooks],
|
|
@@ -2275,9 +3208,12 @@ async function callApply(
|
|
|
2275
3208
|
writeFileSync(join(cwd, filePath), JSON.stringify(file, null, 2) + "\n");
|
|
2276
3209
|
rmSync(join(cwd, resultPath), { force: true });
|
|
2277
3210
|
rmSync(join(cwd, outcomePath), { force: true });
|
|
3211
|
+
if (call.wave) rmSync(join(cwd, appliedRunsPath), { force: true });
|
|
2278
3212
|
let code: number;
|
|
2279
3213
|
try {
|
|
2280
|
-
|
|
3214
|
+
const env = { CHANT_HOOKS: filePath, CHANT_APPLY_OUTCOME: outcomePath, ...(call.wave ? { CHANT_APPLY_RUNS_RESULT: appliedRunsPath } : {}), ...(byApply ? { CHANT_HOOKS_RESULT: resultPath } : {}) };
|
|
3215
|
+
// #4588: an applyWave its caller runs in process.
|
|
3216
|
+
code = call.wave && options.waveExec ? await options.waveExec(argv, cwd, env) : exec(argv, cwd, env);
|
|
2281
3217
|
} catch (err) {
|
|
2282
3218
|
log(`${call.label}: the apply did not run: ${err instanceof Error ? err.message : String(err)}`);
|
|
2283
3219
|
code = 127;
|
|
@@ -2296,7 +3232,12 @@ async function callApply(
|
|
|
2296
3232
|
log(`${call.label}: the apply applied nothing: ${said.outcome}${said.reason ? ` (${said.reason})` : ""}${said.holder ? `, held by run ${said.holder.run}` : ""}`);
|
|
2297
3233
|
return { outcome: "applied-nothing", said };
|
|
2298
3234
|
}
|
|
2299
|
-
|
|
3235
|
+
// #4291: a failed applyWave that says which runs applied fails only the others.
|
|
3236
|
+
const failedCall = (): ApplyCall => {
|
|
3237
|
+
const applied = call.wave ? readAppliedRuns(join(cwd, appliedRunsPath), call.label, log) : undefined;
|
|
3238
|
+
return { outcome: "failed", ...(applied?.length ? { applied } : {}) };
|
|
3239
|
+
};
|
|
3240
|
+
if (!byApply) return code === 0 ? { outcome: "applied" } : failedCall();
|
|
2300
3241
|
let back: OpWaveHooksResult | null = null;
|
|
2301
3242
|
try {
|
|
2302
3243
|
back = JSON.parse(readFileSync(join(cwd, resultPath), "utf-8")) as OpWaveHooksResult;
|
|
@@ -2319,7 +3260,7 @@ async function callApply(
|
|
|
2319
3260
|
}
|
|
2320
3261
|
const afterFailed = outcomes.find((o) => o.moment === "after-apply" && o.outcome === "failed");
|
|
2321
3262
|
if (afterFailed) return { outcome: "applied", problem: `${call.label} applied, and then the after-apply hook ${afterFailed.name} failed` };
|
|
2322
|
-
if (code !== 0) return
|
|
3263
|
+
if (code !== 0) return failedCall();
|
|
2323
3264
|
const skipped = (["before-apply", "after-apply"] as const).filter((m) => handed[m] && !moments.includes(m));
|
|
2324
3265
|
if (skipped.length > 0) {
|
|
2325
3266
|
return { outcome: "applied", problem: `${call.label}: the apply exited 0 without running its ${skipped.join(" and ")} hooks (runOpWaveApplyHooks with CHANT_HOOKS), which the spec at base hands it` };
|
|
@@ -2363,12 +3304,79 @@ async function applyStage(
|
|
|
2363
3304
|
await runGateHooks(ctx, decision, recordPath);
|
|
2364
3305
|
}
|
|
2365
3306
|
result.decision = decision;
|
|
2366
|
-
result.exitCode =
|
|
3307
|
+
result.exitCode = CHANT_EXIT.waiting;
|
|
2367
3308
|
return;
|
|
2368
3309
|
}
|
|
2369
3310
|
holds.push(...before.holds);
|
|
2370
3311
|
}
|
|
2371
3312
|
if (!(await settleHolds(options, ctx, decision, holds, recordPath))) return;
|
|
3313
|
+
// #4552: on the resource grain the wave holds the rows its runs change, before its approval is spent.
|
|
3314
|
+
const lease = spec.step ? await leaseWaveRows(options, ctx, runs) : undefined;
|
|
3315
|
+
if (lease && "failed" in lease) {
|
|
3316
|
+
failed(ctx, lease.failed);
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
if (lease && "outcome" in lease) {
|
|
3320
|
+
log(`wave ${k} (${wave.name}): applied nothing: ${lease.reason}`);
|
|
3321
|
+
result.outcome = lease;
|
|
3322
|
+
result.exitCode = CHANT_EXIT.held;
|
|
3323
|
+
if (recordPath) writeRecord(recordPath, decision, result);
|
|
3324
|
+
return;
|
|
3325
|
+
}
|
|
3326
|
+
try {
|
|
3327
|
+
// #4581: under the lease the grain took, a newer commit that applies the same targets makes this apply stand down.
|
|
3328
|
+
if (await standDownForNewer(options, ctx, decision, runs, recordPath)) return;
|
|
3329
|
+
await applyLeased(options, ctx, decision, runs, planned, byApply, recordPath);
|
|
3330
|
+
} finally {
|
|
3331
|
+
if (lease && !(await lease.release())) log(`wave ${k} (${wave.name}): could not let go of the rows it held; the next apply takes them over once this run is gone`);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
/**
|
|
3336
|
+
* Stand down for a newer commit (#4581), when the spec's `standDown` (or
|
|
3337
|
+
* the job's option) asks: a newer commit on the branch whose spec at the
|
|
3338
|
+
* tip applies every one of `runs` in this wave makes the wave apply
|
|
3339
|
+
* nothing, with the `stood-down` outcome and exit 6. The approval is left
|
|
3340
|
+
* unspent. True when it stood down.
|
|
3341
|
+
*/
|
|
3342
|
+
async function standDownForNewer(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, runs: readonly OpWaveRun[], recordPath?: string): Promise<boolean> {
|
|
3343
|
+
const { spec, k, wave, cwd, log, result } = ctx;
|
|
3344
|
+
if (!(options.standDown ?? spec.standDown === true)) return false;
|
|
3345
|
+
const newer = await (options.newerCommit ?? gitOpWaveNewerCommit)(cwd, options.head);
|
|
3346
|
+
if (!newer) return false;
|
|
3347
|
+
const targets = runs.map((r) => r.target);
|
|
3348
|
+
let atTip: OpWavesSpec | null;
|
|
3349
|
+
try {
|
|
3350
|
+
const { text } = (options.show ?? gitShowAtBase)(newer.tip, options.specFile.replace(/^\.\//, "").split("\\").join(posix.sep), cwd);
|
|
3351
|
+
atTip = text === null ? null : parseOpWavesSpec(text, `${options.specFile} at ${newer.tip.slice(0, 12)}`);
|
|
3352
|
+
} catch (err) {
|
|
3353
|
+
log(`wave ${k} (${wave.name}): ${newer.branch} has a newer commit ${newer.tip.slice(0, 12)}, and its spec cannot be read (${err instanceof Error ? err.message : String(err)}), so this job applies`);
|
|
3354
|
+
return false;
|
|
3355
|
+
}
|
|
3356
|
+
if (!tipAppliesTargets(atTip, newer.branch, wave.name, targets)) {
|
|
3357
|
+
log(`wave ${k} (${wave.name}): ${newer.branch} has a newer commit ${newer.tip.slice(0, 12)}, and its wave does not apply every target of this job, so this job applies`);
|
|
3358
|
+
return false;
|
|
3359
|
+
}
|
|
3360
|
+
const reason = opWaveStandDownReason(newer, targets);
|
|
3361
|
+
log(`wave ${k} (${wave.name}): standing down, nothing applied: ${reason}`);
|
|
3362
|
+
result.outcome = { outcome: "stood-down", reason };
|
|
3363
|
+
result.supersededBy = { branch: newer.branch, commit: newer.tip };
|
|
3364
|
+
result.exitCode = CHANT_EXIT.superseded;
|
|
3365
|
+
if (recordPath) writeRecord(recordPath, decision, result);
|
|
3366
|
+
return true;
|
|
3367
|
+
}
|
|
3368
|
+
|
|
3369
|
+
/** {@link applyStage} once its holds are settled and, on the resource grain, its rows held. */
|
|
3370
|
+
async function applyLeased(
|
|
3371
|
+
options: RunOpWaveOptions,
|
|
3372
|
+
ctx: WaveContext,
|
|
3373
|
+
decision: OpWaveDecision,
|
|
3374
|
+
runs: readonly OpWaveRun[],
|
|
3375
|
+
planned: ReadonlyMap<string, OpWaveMember>,
|
|
3376
|
+
byApply: boolean,
|
|
3377
|
+
recordPath?: string,
|
|
3378
|
+
): Promise<void> {
|
|
3379
|
+
const { spec, k, wave, log, result } = ctx;
|
|
2372
3380
|
if (!(await spendApproval(options, ctx, decision))) return;
|
|
2373
3381
|
if (!(await spendOverrides(ctx, decision))) return;
|
|
2374
3382
|
if (recordPath && (decision.spentAt || decision.overridesSpentAt)) writeRecord(recordPath, decision, result);
|
|
@@ -2378,16 +3386,31 @@ async function applyStage(
|
|
|
2378
3386
|
if (spec.applyWave) {
|
|
2379
3387
|
const runsPath = writeRunsFile(ctx, runs, planned, decision.digest);
|
|
2380
3388
|
const argv = opWaveArgv(spec.applyWave, { op: spec.op, wave: wave.name, runs: runsPath, plans: opWavePlansPath(spec, k) });
|
|
2381
|
-
|
|
3389
|
+
// #4555: one call applies every run, so each run's step spans that call.
|
|
3390
|
+
const startedMs = runs.map((r) => targetStarted(options, k, r.target))[0] ?? Date.now();
|
|
3391
|
+
const got = await callApply(options, ctx, decision, runs, planned, argv, { label: `wave ${k} (${wave.name})`, key: "hooks", runsPath, wave: true }, recordPath);
|
|
3392
|
+
const said = new Set(got.outcome === "failed" ? (got.applied ?? []) : []);
|
|
3393
|
+
const settle = (target: string): "ok" | "failed" | "skipped" => (got.outcome === "applied" || said.has(target) ? "ok" : got.outcome === "failed" ? "failed" : "skipped");
|
|
3394
|
+
for (const r of runs) targetSettled(options, result, k, r.target, startedMs, settle(r.target));
|
|
2382
3395
|
if (got.outcome === "applied-nothing") nothing = got.said;
|
|
2383
3396
|
else if (got.outcome === "applied") {
|
|
2384
3397
|
result.applied.push(...runs.map((r) => r.target));
|
|
2385
3398
|
if (got.problem) problems.push(got.problem);
|
|
2386
3399
|
} else if (got.outcome === "waiting") waiting = true;
|
|
2387
|
-
else {
|
|
3400
|
+
else if (said.size > 0) {
|
|
3401
|
+
// #4291: the apply said which runs applied, so a failure blocks only what depends on the others.
|
|
3402
|
+
const applied = runs.filter((r) => said.has(r.target)).map((r) => r.target);
|
|
3403
|
+
const failedRuns = runs.filter((r) => !said.has(r.target)).map((r) => r.target);
|
|
3404
|
+
log(`wave ${k} (${wave.name}): apply failed for ${failedRuns.join(", ")}; ${applied.join(", ")} applied`);
|
|
3405
|
+
result.applied.push(...applied);
|
|
3406
|
+
result.failed.push(...failedRuns);
|
|
3407
|
+
} else {
|
|
2388
3408
|
log(`wave ${k} (${wave.name}): apply failed, so none of ${runs.map((r) => r.target).join(", ")} counts as applied`);
|
|
2389
3409
|
result.failed.push(...runs.map((r) => r.target));
|
|
2390
3410
|
}
|
|
3411
|
+
} else if (spec.step && (wave.parallelism ?? spec.parallelism ?? 1) > 1) {
|
|
3412
|
+
// #4625: the step's runs apply several at once.
|
|
3413
|
+
await applyStepRunsAtOnce(options, ctx, runs, wave.parallelism ?? spec.parallelism!);
|
|
2391
3414
|
} else {
|
|
2392
3415
|
const order = new Map(runs.map((r, i) => [r.target, i]));
|
|
2393
3416
|
for (const [i, run] of runs.entries()) {
|
|
@@ -2399,11 +3422,38 @@ async function applyStage(
|
|
|
2399
3422
|
log(`${run.target}: blocked by ${by}, so not applied`);
|
|
2400
3423
|
continue;
|
|
2401
3424
|
}
|
|
3425
|
+
if (spec.step) {
|
|
3426
|
+
// #4545: the run applies through its step, with the plan the gate decided.
|
|
3427
|
+
const plan = ctx.steps?.get(run.target);
|
|
3428
|
+
if (!plan) {
|
|
3429
|
+
log(`${run.target}: this job holds no plan of it to apply`);
|
|
3430
|
+
result.failed.push(run.target);
|
|
3431
|
+
continue;
|
|
3432
|
+
}
|
|
3433
|
+
const registry = await opWaveRegistry(options, ctx.cwd, options.capabilities);
|
|
3434
|
+
const startedMs = targetStarted(options, k, run.target);
|
|
3435
|
+
const got = await applyOpWaveStep({ spec, wave, registry }, run, plan);
|
|
3436
|
+
targetSettled(options, result, k, run.target, startedMs, got.outcome === "applied" ? "ok" : got.outcome === "moved" ? "skipped" : "failed", {
|
|
3437
|
+
...(got.outcome !== "applied" ? { error: got.reason } : {}),
|
|
3438
|
+
...(got.facts ? { facts: got.facts } : {}),
|
|
3439
|
+
});
|
|
3440
|
+
if (got.outcome === "applied") result.applied.push(run.target);
|
|
3441
|
+
else if (got.outcome === "moved") {
|
|
3442
|
+
log(`${run.target}: its plan moved since wave ${k} was decided, so it was not applied: ${got.reason}`);
|
|
3443
|
+
result.moved.push(run.target);
|
|
3444
|
+
} else {
|
|
3445
|
+
log(`${run.target}: apply failed: ${got.reason}`);
|
|
3446
|
+
result.failed.push(run.target);
|
|
3447
|
+
}
|
|
3448
|
+
continue;
|
|
3449
|
+
}
|
|
2402
3450
|
const key = run.target.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
2403
3451
|
// Under runBy "apply" each run's apply runs its own apply-stage hooks, over a runs file of that run alone.
|
|
2404
3452
|
const runsPath = byApply ? writeRunsFile(ctx, [run], planned, decision.digest, `.chant/op-waves/${spec.name}/wave-${k}/${key}.runs.json`) : opWaveRunsPath(spec, k);
|
|
2405
3453
|
const argv = opWaveArgv(spec.apply ?? OP_WAVE_DEFAULT_APPLY, { op: run.op ?? spec.op, target: run.target, wave: wave.name, plan: opWavePlanPath(spec, k, run.target) });
|
|
3454
|
+
const startedMs = targetStarted(options, k, run.target);
|
|
2406
3455
|
const got = await callApply(options, ctx, decision, [run], planned, argv, { label: run.target, key: `${key}.hooks`, runsPath }, recordPath);
|
|
3456
|
+
targetSettled(options, result, k, run.target, startedMs, got.outcome === "applied" ? "ok" : got.outcome === "failed" ? "failed" : "skipped");
|
|
2407
3457
|
if (got.outcome === "applied-nothing") {
|
|
2408
3458
|
nothing = got.said;
|
|
2409
3459
|
break;
|
|
@@ -2421,6 +3471,7 @@ async function applyStage(
|
|
|
2421
3471
|
}
|
|
2422
3472
|
}
|
|
2423
3473
|
}
|
|
3474
|
+
if (spec.step) await recordStepReleases(options, ctx, decision, runs);
|
|
2424
3475
|
if (recordPath && byApply) writeRecord(recordPath, decision, result);
|
|
2425
3476
|
if (nothing) {
|
|
2426
3477
|
// #3821: no run counts as failed; the wave stops here, or plans again.
|
|
@@ -2429,18 +3480,23 @@ async function applyStage(
|
|
|
2429
3480
|
return;
|
|
2430
3481
|
}
|
|
2431
3482
|
result.outcome = nothing;
|
|
2432
|
-
result.exitCode = nothing.outcome === "stood-down" ?
|
|
3483
|
+
result.exitCode = nothing.outcome === "stood-down" ? CHANT_EXIT.superseded : CHANT_EXIT.held;
|
|
2433
3484
|
if (recordPath) writeRecord(recordPath, decision, result);
|
|
2434
3485
|
return;
|
|
2435
3486
|
}
|
|
2436
3487
|
if (waiting) {
|
|
2437
|
-
result.exitCode = decision.status === "refused" ? refusedExit(decision) :
|
|
3488
|
+
result.exitCode = decision.status === "refused" ? refusedExit(decision) : CHANT_EXIT.waiting;
|
|
2438
3489
|
return;
|
|
2439
3490
|
}
|
|
2440
3491
|
if (result.failed.length > 0) {
|
|
2441
3492
|
result.exitCode = 1;
|
|
2442
3493
|
return;
|
|
2443
3494
|
}
|
|
3495
|
+
// #4545: a run its step refused as moved applied nothing, so the wave exits moved and its after-apply hooks do not run.
|
|
3496
|
+
if (spec.step && result.moved.length > 0) {
|
|
3497
|
+
result.exitCode = CHANT_EXIT.moved;
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
2444
3500
|
if (problems.length > 0) {
|
|
2445
3501
|
for (const p of problems) log(p);
|
|
2446
3502
|
result.exitCode = 1;
|
|
@@ -2453,6 +3509,102 @@ async function applyStage(
|
|
|
2453
3509
|
if (recordPath && result.hooks.length > 0) writeRecord(recordPath, decision, result);
|
|
2454
3510
|
}
|
|
2455
3511
|
|
|
3512
|
+
/**
|
|
3513
|
+
* A wave's step runs applied at most `limit` at once (#4625). A run waits
|
|
3514
|
+
* for each run the wave lists before it that it depends on, and is blocked,
|
|
3515
|
+
* as one at a time, when that one failed or was blocked. The outcomes land
|
|
3516
|
+
* in the result in the wave's order.
|
|
3517
|
+
*/
|
|
3518
|
+
async function applyStepRunsAtOnce(options: RunOpWaveOptions, ctx: WaveContext, runs: readonly OpWaveRun[], limit: number): Promise<void> {
|
|
3519
|
+
const { spec, k, wave, log, result } = ctx;
|
|
3520
|
+
type Outcome = { applied: true } | { failed: true } | { moved: true } | { blockedBy: string };
|
|
3521
|
+
const order = new Map(runs.map((r, i) => [r.target, i]));
|
|
3522
|
+
const registry = await opWaveRegistry(options, ctx.cwd, options.capabilities);
|
|
3523
|
+
const settled = new Map<string, Promise<Outcome>>();
|
|
3524
|
+
const outcomes = await mapLimited(runs, limit, (run, i) => {
|
|
3525
|
+
const going = (async (): Promise<Outcome> => {
|
|
3526
|
+
const earlier = (run.dependsOn ?? []).filter((d) => (order.get(d) ?? Infinity) < i).sort();
|
|
3527
|
+
for (const dep of earlier) {
|
|
3528
|
+
const got = await settled.get(dep)!;
|
|
3529
|
+
if ("failed" in got || "blockedBy" in got) {
|
|
3530
|
+
const by = "blockedBy" in got ? got.blockedBy : dep;
|
|
3531
|
+
log(`${run.target}: blocked by ${by}, so not applied`);
|
|
3532
|
+
return { blockedBy: by };
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
const plan = ctx.steps?.get(run.target);
|
|
3536
|
+
if (!plan) {
|
|
3537
|
+
log(`${run.target}: this job holds no plan of it to apply`);
|
|
3538
|
+
return { failed: true };
|
|
3539
|
+
}
|
|
3540
|
+
const startedMs = targetStarted(options, k, run.target);
|
|
3541
|
+
const got = await applyOpWaveStep({ spec, wave, registry }, run, plan);
|
|
3542
|
+
targetSettled(options, result, k, run.target, startedMs, got.outcome === "applied" ? "ok" : got.outcome === "moved" ? "skipped" : "failed", {
|
|
3543
|
+
...(got.outcome !== "applied" ? { error: got.reason } : {}),
|
|
3544
|
+
...(got.facts ? { facts: got.facts } : {}),
|
|
3545
|
+
});
|
|
3546
|
+
if (got.outcome === "applied") return { applied: true };
|
|
3547
|
+
if (got.outcome === "moved") {
|
|
3548
|
+
log(`${run.target}: its plan moved since wave ${k} was decided, so it was not applied: ${got.reason}`);
|
|
3549
|
+
return { moved: true };
|
|
3550
|
+
}
|
|
3551
|
+
log(`${run.target}: apply failed: ${got.reason}`);
|
|
3552
|
+
return { failed: true };
|
|
3553
|
+
})();
|
|
3554
|
+
settled.set(run.target, going);
|
|
3555
|
+
return going;
|
|
3556
|
+
});
|
|
3557
|
+
for (const [i, got] of outcomes.entries()) {
|
|
3558
|
+
const target = runs[i]!.target;
|
|
3559
|
+
if ("applied" in got) result.applied.push(target);
|
|
3560
|
+
else if ("moved" in got) result.moved.push(target);
|
|
3561
|
+
else if ("failed" in got) result.failed.push(target);
|
|
3562
|
+
else result.blocked = { ...result.blocked, [target]: got.blockedBy };
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3566
|
+
/**
|
|
3567
|
+
* The release records of the runs this wave applied through its step
|
|
3568
|
+
* (#4615), one per run, on the environment ledger each names. A record that
|
|
3569
|
+
* is not written is a line in the log; the job's exit code stays.
|
|
3570
|
+
*/
|
|
3571
|
+
async function recordStepReleases(options: RunOpWaveOptions, ctx: WaveContext, decision: OpWaveDecision, runs: readonly OpWaveRun[]): Promise<void> {
|
|
3572
|
+
const { spec, k, wave, log, result } = ctx;
|
|
3573
|
+
if (options.releases === false) return;
|
|
3574
|
+
const port = options.releases ?? (options.gates ? undefined : gitOpWaveReleasePort({ cwd: ctx.cwd }));
|
|
3575
|
+
if (!port) return;
|
|
3576
|
+
const applied = new Set(result.applied);
|
|
3577
|
+
let gitSha = options.head;
|
|
3578
|
+
const requests: OpWaveReleaseRequest[] = [];
|
|
3579
|
+
for (const run of runs) {
|
|
3580
|
+
if (!applied.has(run.target)) continue;
|
|
3581
|
+
const names = opWaveReleaseNames(spec, wave, run);
|
|
3582
|
+
const plan = ctx.steps?.get(run.target);
|
|
3583
|
+
if (!names || !plan) continue;
|
|
3584
|
+
if (gitSha === undefined) {
|
|
3585
|
+
try {
|
|
3586
|
+
gitSha = execFileSync("git", ["rev-parse", "HEAD"], { cwd: ctx.cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
3587
|
+
} catch {
|
|
3588
|
+
gitSha = "";
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
requests.push({ ...names, target: run.target, planDigest: plan.planDigest, ...(gitSha ? { gitSha } : {}), ...(decision.approvedBy ? { approver: decision.approvedBy } : {}) });
|
|
3592
|
+
}
|
|
3593
|
+
if (requests.length === 0) return;
|
|
3594
|
+
let outcomes: OpWaveReleaseOutcome[];
|
|
3595
|
+
try {
|
|
3596
|
+
outcomes = await port.record(requests);
|
|
3597
|
+
} catch (err) {
|
|
3598
|
+
log(`wave ${k} (${wave.name}): applied, and no release record was written: ${err instanceof Error ? err.message : String(err)}`);
|
|
3599
|
+
return;
|
|
3600
|
+
}
|
|
3601
|
+
for (const [i, req] of requests.entries()) {
|
|
3602
|
+
const got = outcomes[i];
|
|
3603
|
+
if (got?.recorded) log(`${req.target}: recorded on the "${got.env}" release ledger as ${got.component} ${got.digest}${got.releaseDigest ? ` under release ${got.releaseDigest}` : ""}`);
|
|
3604
|
+
else log(`${req.target}: applied, and no release record was written for ${req.component} in "${req.env}": ${got?.reason ?? "the port gave no answer"}`);
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
|
|
2456
3608
|
/**
|
|
2457
3609
|
* Record that the wave applies under its approval (#3784), which spends it:
|
|
2458
3610
|
* one line in `_gates/<name>/applied.jsonl`, before anything applies, as
|
|
@@ -2562,6 +3714,12 @@ export interface RecordHeadPlansOptions {
|
|
|
2562
3714
|
now?: string;
|
|
2563
3715
|
/** Write the record. Default: append to `chant/lifecycle` and push. */
|
|
2564
3716
|
write?: (plans: HeadPlans) => Promise<void>;
|
|
3717
|
+
/** Store a wave's change set at the head (#4630). Default: `_change-sets/` on `chant/lifecycle`, pushed with the record. */
|
|
3718
|
+
storeChangeSet?: (doc: ChangeSetDocument) => Promise<void>;
|
|
3719
|
+
/** The capabilities a spec's `step` plans through (#4545). Default: the project's at `cwd`. */
|
|
3720
|
+
capabilities?: CapabilityRegistry;
|
|
3721
|
+
/** How a cost hold's estimator runs (#4545). */
|
|
3722
|
+
holdExec?: GatePolicyExec;
|
|
2565
3723
|
}
|
|
2566
3724
|
|
|
2567
3725
|
/**
|
|
@@ -2569,7 +3727,8 @@ export interface RecordHeadPlansOptions {
|
|
|
2569
3727
|
* pull request's head and record each wave's digest on `chant/lifecycle`,
|
|
2570
3728
|
* `_wave-plans/<name>/<head>.json`. A `pr-review` wave reads it after the
|
|
2571
3729
|
* merge: the review of that head approves the digests it planned, and only
|
|
2572
|
-
* those.
|
|
3730
|
+
* those. A wave whose plans file gives a change set records its digest and
|
|
3731
|
+
* stores it (#4630), for the approval status of a `pull-request` wave.
|
|
2573
3732
|
*/
|
|
2574
3733
|
export async function recordOpWaveHeadPlans(options: RecordHeadPlansOptions): Promise<HeadPlans> {
|
|
2575
3734
|
const { spec } = options;
|
|
@@ -2585,18 +3744,42 @@ export async function recordOpWaveHeadPlans(options: RecordHeadPlansOptions): Pr
|
|
|
2585
3744
|
timestamp: options.now ?? new Date().toISOString(),
|
|
2586
3745
|
waves: [],
|
|
2587
3746
|
};
|
|
3747
|
+
const changeSets: ChangeSetDocument[] = [];
|
|
2588
3748
|
// A `rest` wave (#3821) goes on through the waves the plan command found.
|
|
2589
3749
|
const last = spec.waves[spec.waves.length - 1]!;
|
|
2590
3750
|
for (let k = 1; ; k++) {
|
|
2591
3751
|
const wave = spec.waves[k - 1] ?? last;
|
|
2592
|
-
const
|
|
2593
|
-
|
|
3752
|
+
const steps = new Map<string, OpWaveStepPlan>();
|
|
3753
|
+
const { members, extras: planExtras, waves: found, changeSet } = await planWaveRuns({ spec, k, wave, cwd, exec, options, steps }, wave.runs, wave.discover === true);
|
|
3754
|
+
// #4545: a cost hold's member is in the digest the merged wave decides, so the head's digest carries it too.
|
|
3755
|
+
const cost = spec.holds?.cost ? costVerdictOf(spec.holds.cost, spec, k, members, steps, cwd, options.holdExec).member : undefined;
|
|
3756
|
+
const extras = cost ? [...(planExtras ?? []), cost] : planExtras;
|
|
3757
|
+
// #4630: the facts a gate policy reads, so the approval status before merge says which waves will wait.
|
|
3758
|
+
plans.waves.push({
|
|
3759
|
+
wave: k,
|
|
3760
|
+
name: wave.name,
|
|
3761
|
+
digest: opWaveSetDigest(spec, members, extras),
|
|
3762
|
+
changes: !members.every((m) => m.empty === true),
|
|
3763
|
+
destructive: members.some((m) => m.destructive === true),
|
|
3764
|
+
// #4630: a pull-request wave's change set, which the pull request's own approval must cover.
|
|
3765
|
+
...(changeSet ? { changeSet: changeSet.digest } : {}),
|
|
3766
|
+
});
|
|
3767
|
+
if (changeSet) changeSets.push(changeSet);
|
|
2594
3768
|
if (k >= spec.waves.length && !(last.rest && found !== undefined && k < found)) break;
|
|
2595
3769
|
}
|
|
3770
|
+
// The change sets go on the ledger first, so the record's push carries them.
|
|
3771
|
+
for (const doc of changeSets) await (options.storeChangeSet ?? ((d) => storeHeadChangeSet(d, cwd)))(doc);
|
|
2596
3772
|
await (options.write ?? ((p) => writeHeadPlans(p, cwd)))(plans);
|
|
2597
3773
|
return plans;
|
|
2598
3774
|
}
|
|
2599
3775
|
|
|
3776
|
+
async function storeHeadChangeSet(doc: ChangeSetDocument, cwd: string): Promise<void> {
|
|
3777
|
+
const { requireLifecycleLedger } = await import("../lifecycle/git");
|
|
3778
|
+
const { persistChangeSet } = await import("../lifecycle/change-set-store");
|
|
3779
|
+
await requireLifecycleLedger({ cwd });
|
|
3780
|
+
await persistChangeSet(doc, { cwd });
|
|
3781
|
+
}
|
|
3782
|
+
|
|
2600
3783
|
async function writeHeadPlans(plans: HeadPlans, cwd: string): Promise<void> {
|
|
2601
3784
|
const { pushLifecycle, requireLifecycleLedger, writeBlobToPath } = await import("../lifecycle/git");
|
|
2602
3785
|
const { headPlansPath } = await import("./gate-review");
|