@intentius/chant 0.124.55 → 0.124.57
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/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +1 -2
- 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 +11 -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.map +1 -1
- package/dist/ci-control.js +3 -4
- package/dist/ci-estate.d.ts +24 -0
- package/dist/ci-estate.d.ts.map +1 -1
- package/dist/ci-estate.js +1 -2
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +2 -3
- 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 +7 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +38 -4
- package/dist/ci-product.d.ts +35 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +38 -4
- 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/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 +81 -0
- 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.map +1 -1
- package/dist/cli/handlers/ci-check.js +38 -9
- 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/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +14 -0
- package/dist/cli/handlers/pr.d.ts +5 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +346 -36
- package/dist/cli/handlers/run-wave.js +89 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +56 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +107 -0
- package/dist/cli/registry.d.ts +38 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/adoption.d.ts.map +1 -1
- package/dist/components/adoption.js +1 -2
- package/dist/components/auto-release.d.ts +5 -2
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +9 -4
- package/dist/components/capability.d.ts +47 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/capability.js +25 -0
- package/dist/components/check-hooks.d.ts +4 -1
- package/dist/components/check-hooks.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/components/ci-services.js +1 -2
- package/dist/components/deploy-units.d.ts +12 -0
- package/dist/components/deploy-units.d.ts.map +1 -1
- package/dist/components/deploy-units.js +20 -1
- package/dist/components/driver.d.ts +12 -0
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +35 -1
- package/dist/components/groups.d.ts.map +1 -1
- package/dist/components/groups.js +4 -3
- package/dist/components/pr-env-ledger.d.ts.map +1 -1
- package/dist/components/pr-env-ledger.js +1 -2
- package/dist/components/pr-environment.d.ts +1 -1
- package/dist/components/pr-environment.d.ts.map +1 -1
- package/dist/components/pr-environment.js +1 -1
- package/dist/components/pr-pipeline.d.ts +137 -5
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +164 -20
- package/dist/components/pr-run.d.ts +8 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +9 -4
- package/dist/components/product-pipeline.d.ts +35 -2
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +24 -5
- package/dist/components/row-lease.d.ts +22 -1
- package/dist/components/row-lease.d.ts.map +1 -1
- package/dist/components/row-lease.js +32 -6
- package/dist/components/wave-plan.d.ts +8 -0
- package/dist/components/wave-plan.d.ts.map +1 -1
- package/dist/components/wave-plan.js +18 -2
- 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 +47 -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/exit-codes.d.ts +7 -1
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +7 -1
- package/dist/lexicon.d.ts +55 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +2 -3
- package/dist/lifecycle/gated-request.d.ts.map +1 -1
- package/dist/lifecycle/gated-request.js +1 -2
- package/dist/lifecycle/git.d.ts +39 -3
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +223 -15
- package/dist/lifecycle/lock-rows.d.ts +23 -0
- package/dist/lifecycle/lock-rows.d.ts.map +1 -1
- package/dist/lifecycle/lock-rows.js +47 -8
- package/dist/lifecycle/query.d.ts.map +1 -1
- package/dist/lifecycle/query.js +4 -5
- package/dist/lifecycle/release-catalog.d.ts.map +1 -1
- package/dist/lifecycle/release-catalog.js +1 -1
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +1 -2
- package/dist/lifecycle/release-status.d.ts +20 -0
- package/dist/lifecycle/release-status.d.ts.map +1 -1
- package/dist/lifecycle/release-status.js +1 -22
- package/dist/lifecycle/resource-lock.d.ts +70 -0
- package/dist/lifecycle/resource-lock.d.ts.map +1 -1
- package/dist/lifecycle/resource-lock.js +241 -5
- 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/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.js +21 -4
- package/dist/op/index.d.ts +1 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -1
- package/dist/op/op-waves-capability-spec.d.ts +8 -0
- package/dist/op/op-waves-capability-spec.d.ts.map +1 -1
- package/dist/op/op-waves-capability-spec.js +21 -0
- package/dist/op/op-waves-release-port.js +1 -1
- package/dist/op/op-waves-release.d.ts +2 -1
- package/dist/op/op-waves-release.d.ts.map +1 -1
- package/dist/op/op-waves-release.js +1 -2
- package/dist/op/op-waves-run.d.ts +15 -2
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +195 -31
- package/dist/op/op-waves-stand-down.d.ts.map +1 -1
- package/dist/op/op-waves-stand-down.js +1 -2
- package/dist/op/op-waves.d.ts +53 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +62 -6
- package/dist/op/runtime.d.ts +4 -0
- package/dist/op/runtime.d.ts.map +1 -1
- package/dist/op/runtime.js +2 -3
- package/dist/otlp.d.ts.map +1 -1
- package/dist/otlp.js +1 -2
- package/dist/parallelism.d.ts +17 -0
- package/dist/parallelism.d.ts.map +1 -0
- package/dist/parallelism.js +33 -0
- package/dist/policy-source.d.ts.map +1 -1
- package/dist/policy-source.js +1 -2
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +56 -39
- package/dist/pr-loop.d.ts +9 -0
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +22 -4
- 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 +70 -1
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +116 -5
- package/dist/pr-report-url.d.ts.map +1 -1
- package/dist/pr-report-url.js +1 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/run-event.d.ts.map +1 -1
- package/dist/run-event.js +1 -2
- 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/wave-runtime.mjs +351 -328
- package/dist/workspace/ci-lock-grain.d.ts +5 -0
- package/dist/workspace/ci-lock-grain.d.ts.map +1 -1
- package/dist/workspace/ci-lock-grain.js +1 -7
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +5 -1
- package/dist/workspace/pr-report.schema.json +5 -0
- package/package.json +1 -1
- package/src/ci-agent.ts +1 -2
- 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 +14 -0
- package/src/ci-audit/unrecorded.ts +140 -0
- package/src/ci-audit.ts +2 -0
- package/src/ci-control.ts +3 -4
- package/src/ci-estate.ts +1 -2
- package/src/ci-identity-database.test.ts +2 -3
- package/src/ci-identity-targets.test.ts +1 -3
- package/src/ci-identity.ts +2 -3
- 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.ts +35 -6
- package/src/ci-product.ts +55 -4
- 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/cli/handlers/audit-log.ts +74 -0
- package/src/cli/handlers/build-pr-loop-flags.test.ts +98 -0
- package/src/cli/handlers/build.ts +69 -0
- 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 +38 -8
- package/src/cli/handlers/e2e-safe-run.ts +27 -0
- package/src/cli/handlers/lifecycle.ts +13 -0
- package/src/cli/handlers/pr-before-merge.test.ts +1 -1
- package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
- package/src/cli/handlers/pr-endpoint.test.ts +1 -1
- package/src/cli/handlers/pr-green.test.ts +1 -1
- 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 +1 -1
- package/src/cli/handlers/pr-record.test.ts +34 -2
- package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
- package/src/cli/handlers/pr-waves.test.ts +1 -1
- package/src/cli/handlers/pr.test.ts +1 -1
- package/src/cli/handlers/pr.ts +311 -32
- package/src/cli/handlers/run-wave.ts +79 -1
- package/src/cli/main.test.ts +1 -1
- package/src/cli/main.ts +56 -2
- package/src/cli/parse-args.ts +77 -0
- package/src/cli/registry.ts +38 -0
- package/src/components/adoption.ts +1 -2
- package/src/components/auto-release.test.ts +4 -2
- package/src/components/auto-release.ts +9 -5
- package/src/components/capability.ts +60 -0
- package/src/components/check-hooks.ts +4 -1
- package/src/components/check-steps.test.ts +70 -0
- package/src/components/check-steps.ts +158 -0
- package/src/components/ci-services.ts +1 -2
- package/src/components/deploy-units.test.ts +18 -1
- package/src/components/deploy-units.ts +26 -1
- package/src/components/driver.ts +35 -1
- package/src/components/groups.ts +4 -2
- package/src/components/plan-flags.test.ts +46 -0
- package/src/components/pr-comment-preview-targets.test.ts +34 -0
- package/src/components/pr-env-ledger.ts +1 -2
- package/src/components/pr-env-run-bundle.test.ts +0 -20
- package/src/components/pr-environment.ts +1 -1
- package/src/components/pr-pipeline-runners.test.ts +80 -0
- package/src/components/pr-pipeline.ts +244 -20
- package/src/components/pr-run.ts +17 -6
- package/src/components/pr-stale-job.test.ts +34 -0
- package/src/components/product-pipeline.ts +50 -8
- package/src/components/row-lease.test.ts +61 -1
- package/src/components/row-lease.ts +48 -7
- package/src/components/wave-plan.ts +18 -2
- 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 +49 -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/exit-codes.test.ts +3 -2
- package/src/exit-codes.ts +7 -1
- package/src/gate-decision-bundle.test.ts +0 -2
- package/src/lexicon.ts +57 -0
- package/src/lifecycle/control-entries-ledger.test.ts +2 -3
- package/src/lifecycle/gate-ledger.ts +2 -3
- package/src/lifecycle/gated-request.ts +1 -2
- package/src/lifecycle/git.test.ts +155 -0
- package/src/lifecycle/git.ts +213 -17
- package/src/lifecycle/lock-rows.test.ts +6 -1
- package/src/lifecycle/lock-rows.ts +58 -7
- package/src/lifecycle/query.ts +4 -5
- package/src/lifecycle/release-catalog.test.ts +3 -4
- package/src/lifecycle/release-catalog.ts +1 -1
- package/src/lifecycle/release-ledger.ts +1 -2
- package/src/lifecycle/release-status.test.ts +3 -4
- package/src/lifecycle/release-status.ts +1 -2
- package/src/lifecycle/resource-lock-wait.test.ts +292 -0
- package/src/lifecycle/resource-lock.ts +261 -7
- package/src/lifecycle/wave-plans.ts +33 -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.test.ts +7 -5
- package/src/op/gate.ts +20 -4
- package/src/op/index.ts +2 -0
- package/src/op/op-waves-after-plan.test.ts +11 -0
- package/src/op/op-waves-capability-spec.ts +20 -0
- package/src/op/op-waves-ledger-lock.test.ts +208 -0
- package/src/op/op-waves-parallelism.test.ts +89 -0
- package/src/op/op-waves-pull-request.test.ts +78 -1
- package/src/op/op-waves-release-port.ts +1 -1
- package/src/op/op-waves-release.ts +2 -3
- package/src/op/op-waves-run.ts +196 -31
- package/src/op/op-waves-stand-down.ts +1 -2
- package/src/op/op-waves.ts +81 -6
- package/src/op/runtime.ts +6 -3
- package/src/otlp.ts +1 -2
- package/src/parallelism.test.ts +38 -0
- package/src/parallelism.ts +33 -0
- package/src/policy-source.ts +1 -2
- package/src/pr-forge-bundle.test.ts +1 -1
- package/src/pr-forge.ts +54 -35
- package/src/pr-loop-bundle.test.ts +0 -2
- package/src/pr-loop-narrowed.test.ts +63 -0
- package/src/pr-loop.ts +30 -4
- 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 +159 -5
- package/src/pr-report-url.ts +1 -2
- package/src/product-subpaths-plain-node.e2e.test.ts +1 -0
- package/src/release-floors.ts +1 -1
- package/src/run-event.ts +1 -2
- package/src/scheduled-op-cloud.ts +68 -0
- package/src/stage-hooks-bundle.test.ts +0 -2
- package/src/workspace/ci-lock-grain.ts +1 -2
- package/src/workspace/ci-run.ts +5 -1
- package/src/workspace/pr-report.schema.json +5 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responses to pipeline events (#4629), in CI core so terragucci and plywood
|
|
3
|
+
* answer the same events the same way, each in its own words.
|
|
4
|
+
*
|
|
5
|
+
* - `wave-refused: diff`: a wave that applied nothing because its plan moved
|
|
6
|
+
* since the approval, another run held it, or its decision point declined
|
|
7
|
+
* it posts which members moved and what moved in them, from the approved
|
|
8
|
+
* change set and the current one.
|
|
9
|
+
* - `apply-failed: triage`: a failed apply posts the members and resources
|
|
10
|
+
* that failed with the engine's error, from the run record (an op wave's)
|
|
11
|
+
* or the apply report (`pr-apply`'s).
|
|
12
|
+
* - `description: check`: with a decide service set, the plan-note job asks
|
|
13
|
+
* whether the pull request's title and description leave out what its
|
|
14
|
+
* change set destroys or replaces, and posts the finding. It never
|
|
15
|
+
* approves, gates or blocks anything.
|
|
16
|
+
*
|
|
17
|
+
* The first two are on by default and the third is off. Each one is turned
|
|
18
|
+
* off (or on) with a list such as `wave-refused=off,description=check`: the
|
|
19
|
+
* `--respond` flag, the `CHANT_RESPOND` variable a generated job sets, or an
|
|
20
|
+
* op waves spec's `respond`.
|
|
21
|
+
*
|
|
22
|
+
* Every post is one comment per event and place, found again by its marker,
|
|
23
|
+
* so a job that runs twice edits its comment. Delivery never throws and never
|
|
24
|
+
* changes a job's exit code.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type { ChangeSetAttribute, ChangeSetDocument, ChangeSetEntry } from "./change-set";
|
|
28
|
+
import { activeProductWords, type CiProductWords } from "./ci-product-words";
|
|
29
|
+
import type { PrForge } from "./pr-forge";
|
|
30
|
+
|
|
31
|
+
/** The events chant answers. */
|
|
32
|
+
export type CiRespondEvent = "wave-refused" | "apply-failed" | "description";
|
|
33
|
+
|
|
34
|
+
/** Each event's modes; the first is its default. */
|
|
35
|
+
export const CI_RESPONSES = {
|
|
36
|
+
"wave-refused": ["diff", "off"],
|
|
37
|
+
"apply-failed": ["triage", "off"],
|
|
38
|
+
description: ["off", "check"],
|
|
39
|
+
} as const satisfies Record<CiRespondEvent, readonly string[]>;
|
|
40
|
+
|
|
41
|
+
export type CiResponses = { [E in CiRespondEvent]?: (typeof CI_RESPONSES)[E][number] };
|
|
42
|
+
|
|
43
|
+
/** The variable a generated job carries its responses in. */
|
|
44
|
+
export const CI_RESPOND_ENV = "CHANT_RESPOND";
|
|
45
|
+
|
|
46
|
+
/** Every event at its default. */
|
|
47
|
+
export const CI_RESPOND_DEFAULTS: Required<CiResponses> = { "wave-refused": "diff", "apply-failed": "triage", description: "off" };
|
|
48
|
+
|
|
49
|
+
/** `wave-refused=off,description=check` as responses, or why it is not a list of them. */
|
|
50
|
+
export function parseRespondList(text: string | readonly string[]): CiResponses | { error: string } {
|
|
51
|
+
const parts = (typeof text === "string" ? text.split(",") : text.flatMap((t) => t.split(","))).map((p) => p.trim()).filter(Boolean);
|
|
52
|
+
const out: Record<string, string> = {};
|
|
53
|
+
for (const part of parts) {
|
|
54
|
+
const eq = part.indexOf("=");
|
|
55
|
+
const event = eq < 0 ? part : part.slice(0, eq);
|
|
56
|
+
const mode = eq < 0 ? "" : part.slice(eq + 1);
|
|
57
|
+
if (!(event in CI_RESPONSES)) return { error: `--respond names no event ${JSON.stringify(event)}; the events are ${Object.keys(CI_RESPONSES).join(", ")}` };
|
|
58
|
+
const modes = CI_RESPONSES[event as CiRespondEvent] as readonly string[];
|
|
59
|
+
if (!modes.includes(mode)) return { error: `--respond ${event} takes ${modes.join(" or ")}, not ${JSON.stringify(mode)}` };
|
|
60
|
+
out[event] = mode;
|
|
61
|
+
}
|
|
62
|
+
return out as CiResponses;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The list form of `responses`, for `--respond` and {@link CI_RESPOND_ENV}. Empty when every event is at its default. */
|
|
66
|
+
export function respondList(responses: CiResponses): string {
|
|
67
|
+
return (Object.keys(CI_RESPONSES) as CiRespondEvent[])
|
|
68
|
+
.filter((e) => responses[e] !== undefined && responses[e] !== CI_RESPOND_DEFAULTS[e])
|
|
69
|
+
.map((e) => `${e}=${responses[e]}`)
|
|
70
|
+
.join(",");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The responses in force: the defaults, then `CHANT_RESPOND`, then the
|
|
75
|
+
* spec's or the flag's. A malformed variable is ignored with a warning,
|
|
76
|
+
* since a response never stops a job.
|
|
77
|
+
*/
|
|
78
|
+
export function resolveResponses(given: CiResponses | undefined, env: Record<string, string | undefined> = process.env, warn: (line: string) => void = () => {}): Required<CiResponses> {
|
|
79
|
+
let fromEnv: CiResponses = {};
|
|
80
|
+
const raw = env[CI_RESPOND_ENV];
|
|
81
|
+
if (raw) {
|
|
82
|
+
const parsed = parseRespondList(raw);
|
|
83
|
+
if ("error" in parsed) warn(`${CI_RESPOND_ENV} is ignored: ${parsed.error}`);
|
|
84
|
+
else fromEnv = parsed;
|
|
85
|
+
}
|
|
86
|
+
return { ...CI_RESPOND_DEFAULTS, ...fromEnv, ...(given ?? {}) } as Required<CiResponses>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The hidden marker of one response's comment. */
|
|
90
|
+
export function respondMarker(event: CiRespondEvent, place: string): string {
|
|
91
|
+
return `<!-- chant:respond:${event}:${place.replace(/[^A-Za-z0-9._/-]/g, "_")} -->`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// wave-refused: diff
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
/** Why a wave applied nothing. */
|
|
99
|
+
export type RefusedReason = "moved" | "held" | "declined";
|
|
100
|
+
|
|
101
|
+
/** One entry whose plan moved between the approved change set and the current one. */
|
|
102
|
+
export interface RefusedEntryDiff {
|
|
103
|
+
address: string;
|
|
104
|
+
/** Its action in the approved plan; absent when the entry is new. */
|
|
105
|
+
was?: string;
|
|
106
|
+
/** Its action now; absent when it is gone. */
|
|
107
|
+
now?: string;
|
|
108
|
+
/** Attributes whose planned value differs. */
|
|
109
|
+
attributes: string[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** One member whose plan moved. */
|
|
113
|
+
export interface RefusedMemberDiff {
|
|
114
|
+
member: string;
|
|
115
|
+
approved: string | null;
|
|
116
|
+
current: string | null;
|
|
117
|
+
/** Entry by entry, when both change sets were read; empty otherwise. */
|
|
118
|
+
changes: RefusedEntryDiff[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface RefusedDiff {
|
|
122
|
+
/** How the post names the wave or the apply, such as `wave 2 (prod) of plywood-up`. */
|
|
123
|
+
label: string;
|
|
124
|
+
reason: RefusedReason;
|
|
125
|
+
approved: string | null;
|
|
126
|
+
current: string | null;
|
|
127
|
+
members: RefusedMemberDiff[];
|
|
128
|
+
/** The holder or the decision, for `held` and `declined`. */
|
|
129
|
+
detail?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const shown = (a: ChangeSetAttribute | undefined): string | undefined =>
|
|
133
|
+
a === undefined ? undefined : a.sensitive ? "(sensitive)" : a.unknown ? "(known after apply)" : JSON.stringify(a.after ?? null);
|
|
134
|
+
|
|
135
|
+
function entryDiffs(was: readonly ChangeSetEntry[], now: readonly ChangeSetEntry[]): RefusedEntryDiff[] {
|
|
136
|
+
const key = (e: ChangeSetEntry) => `${e.address}\u0000${e.deposed ?? ""}`;
|
|
137
|
+
const before = new Map(was.map((e) => [key(e), e]));
|
|
138
|
+
const after = new Map(now.map((e) => [key(e), e]));
|
|
139
|
+
const out: RefusedEntryDiff[] = [];
|
|
140
|
+
for (const k of [...new Set([...before.keys(), ...after.keys()])].sort()) {
|
|
141
|
+
const b = before.get(k);
|
|
142
|
+
const a = after.get(k);
|
|
143
|
+
const paths = new Set([...(b?.attributes ?? []).map((x) => x.path), ...(a?.attributes ?? []).map((x) => x.path)]);
|
|
144
|
+
const moved = [...paths].filter((p) => shown(b?.attributes.find((x) => x.path === p)) !== shown(a?.attributes.find((x) => x.path === p))).sort();
|
|
145
|
+
if (b?.action === a?.action && moved.length === 0) continue;
|
|
146
|
+
out.push({ address: (a ?? b)!.address, ...(b ? { was: b.action } : {}), ...(a ? { now: a.action } : {}), attributes: moved });
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The members whose plan digest differs between the approved change set and
|
|
153
|
+
* the current one, entry by entry. `only` narrows to the members a wave
|
|
154
|
+
* holds. A member that planned the same in both is left out.
|
|
155
|
+
*/
|
|
156
|
+
export function changeSetDiff(approved: ChangeSetDocument | undefined, current: ChangeSetDocument | undefined, only?: readonly string[]): RefusedMemberDiff[] {
|
|
157
|
+
const names = new Set([...(approved?.members ?? []).map((m) => m.member), ...(current?.members ?? []).map((m) => m.member)]);
|
|
158
|
+
const keep = only ? new Set(only) : undefined;
|
|
159
|
+
const out: RefusedMemberDiff[] = [];
|
|
160
|
+
for (const member of [...names].sort()) {
|
|
161
|
+
if (keep && !keep.has(member)) continue;
|
|
162
|
+
const was = approved?.members.find((m) => m.member === member)?.planDigest ?? null;
|
|
163
|
+
const now = current?.members.find((m) => m.member === member)?.planDigest ?? null;
|
|
164
|
+
if (was === now && was !== null) continue;
|
|
165
|
+
const changes = approved && current ? entryDiffs(approved.entries.filter((e) => e.member === member), current.entries.filter((e) => e.member === member)) : [];
|
|
166
|
+
out.push({ member, approved: was, current: now, changes });
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The members whose plan digest differs, when only the digests are known (an op wave's decision against its share job's plans). */
|
|
172
|
+
export function digestDiff(approved: Readonly<Record<string, string | null>>, current: Readonly<Record<string, string | null>>): RefusedMemberDiff[] {
|
|
173
|
+
return [...new Set([...Object.keys(approved), ...Object.keys(current)])]
|
|
174
|
+
.sort()
|
|
175
|
+
.filter((m) => approved[m] !== current[m] || approved[m] == null)
|
|
176
|
+
.map((member) => ({ member, approved: approved[member] ?? null, current: current[member] ?? null, changes: [] }));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** A digest's first 12 hex characters past its scheme; `none` when there is none. */
|
|
180
|
+
export const shortDigest = (d: string | null | undefined): string => (d ? d.slice(d.lastIndexOf(":") + 1).slice(0, 12) : "none");
|
|
181
|
+
|
|
182
|
+
/** The post for a refused wave or apply, in the product's words. */
|
|
183
|
+
export function renderRefusedDiff(d: RefusedDiff, words: CiProductWords = activeProductWords()): string {
|
|
184
|
+
const [, applied] = words.verbs.apply;
|
|
185
|
+
const [nounOne, nounMany] = words.noun;
|
|
186
|
+
const lines: string[] = [];
|
|
187
|
+
if (d.reason === "moved") {
|
|
188
|
+
lines.push(`${capital(d.label)} ${applied} nothing: its plans changed after the approval (approved ${shortDigest(d.approved)}, now ${shortDigest(d.current)}).`);
|
|
189
|
+
} else if (d.reason === "held") {
|
|
190
|
+
lines.push(`${capital(d.label)} ${applied} nothing: another run holds what it changes${d.detail ? ` (${d.detail})` : ""}.`);
|
|
191
|
+
} else {
|
|
192
|
+
lines.push(`${capital(d.label)} ${applied} nothing: its decision point declined it${d.detail ? ` (${d.detail})` : ""}.`);
|
|
193
|
+
}
|
|
194
|
+
if (d.members.length === 0) {
|
|
195
|
+
if (d.reason === "moved") lines.push("", `No ${nounOne}'s plan differs from the approved change set that could be read.`);
|
|
196
|
+
} else {
|
|
197
|
+
lines.push("", `${d.members.length === 1 ? capital(nounOne) : capital(nounMany)} whose plan differs from the approved one:`, "");
|
|
198
|
+
for (const m of d.members) {
|
|
199
|
+
lines.push(`- \`${m.member}\`: plan ${shortDigest(m.approved)} -> ${shortDigest(m.current)}`);
|
|
200
|
+
for (const c of m.changes) {
|
|
201
|
+
const action = c.was === c.now ? c.now : `${c.was ?? "none"} -> ${c.now ?? "none"}`;
|
|
202
|
+
lines.push(` - \`${c.address}\` ${action}${c.attributes.length ? `: ${c.attributes.join(", ")}` : ""}`);
|
|
203
|
+
}
|
|
204
|
+
if (m.current === null) lines.push(` - it did not ${words.verbs.plan[0]} this time`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (d.reason === "moved") lines.push("", "Approve again only once the new plan is the one you want.");
|
|
208
|
+
else if (d.reason === "held") lines.push("", `Run it again once the other run is done; the approval still stands.`);
|
|
209
|
+
return lines.join("\n");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ---------------------------------------------------------------------------
|
|
213
|
+
// apply-failed: triage
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
/** One member that failed to apply. */
|
|
217
|
+
export interface FailedMember {
|
|
218
|
+
member: string;
|
|
219
|
+
/** The engine's error, as the run record or the report has it. */
|
|
220
|
+
error?: string;
|
|
221
|
+
/** The resources the engine reported failed, when it reports per resource. */
|
|
222
|
+
resources?: string[];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface FailedApply {
|
|
226
|
+
label: string;
|
|
227
|
+
exitCode: number;
|
|
228
|
+
members: FailedMember[];
|
|
229
|
+
/** A failure outside any member: a hook, the job's own error. */
|
|
230
|
+
error?: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The longest error kept per member, so one engine's dump cannot fill the comment. */
|
|
234
|
+
const ERROR_LIMIT = 2000;
|
|
235
|
+
|
|
236
|
+
const clip = (text: string): string => (text.length > ERROR_LIMIT ? `${text.slice(0, ERROR_LIMIT)}\n... (cut at ${ERROR_LIMIT} characters; the job's log has the rest)` : text);
|
|
237
|
+
|
|
238
|
+
/** The post for a failed apply, in the product's words. */
|
|
239
|
+
export function renderTriage(f: FailedApply, words: CiProductWords = activeProductWords()): string {
|
|
240
|
+
const [apply] = words.verbs.apply;
|
|
241
|
+
const [nounOne, nounMany] = words.noun;
|
|
242
|
+
const lines = [`${capital(f.label)} failed (exit ${f.exitCode}).`];
|
|
243
|
+
if (f.members.length > 0) {
|
|
244
|
+
lines.push("", `${f.members.length === 1 ? capital(nounOne) : capital(nounMany)} that did not ${apply}:`);
|
|
245
|
+
for (const m of f.members) {
|
|
246
|
+
lines.push("", `- \`${m.member}\``);
|
|
247
|
+
if (m.resources?.length) lines.push(` - failed resources: ${m.resources.map((r) => `\`${r}\``).join(", ")}`);
|
|
248
|
+
if (m.error) lines.push("", "```", clip(m.error).replaceAll("```", "'''"), "```");
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (f.error) lines.push("", "```", clip(f.error).replaceAll("```", "'''"), "```");
|
|
252
|
+
lines.push("", `What applied before the failure stays applied. Fix the cause and ${apply} again; the run record keeps every ${nounOne}'s outcome.`);
|
|
253
|
+
return lines.join("\n");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ---------------------------------------------------------------------------
|
|
257
|
+
// description: check
|
|
258
|
+
// ---------------------------------------------------------------------------
|
|
259
|
+
|
|
260
|
+
/** What the model reads: the pull request's text and the change set's summary. No planned values. */
|
|
261
|
+
export interface DescriptionState {
|
|
262
|
+
title: string;
|
|
263
|
+
description: string;
|
|
264
|
+
plan: { counts: Record<"create" | "update" | "replace" | "delete", number>; destroys: string[]; replacements: string[] };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const MAX_TEXT = 4000;
|
|
268
|
+
const MAX_LISTED = 50;
|
|
269
|
+
|
|
270
|
+
const named = (e: Pick<ChangeSetEntry, "member" | "address">): string => `${e.member}: ${e.address}`;
|
|
271
|
+
|
|
272
|
+
/** The destroys and replacements of a change set. */
|
|
273
|
+
export function destructiveEntries(doc: ChangeSetDocument): { destroys: ChangeSetEntry[]; replacements: ChangeSetEntry[] } {
|
|
274
|
+
return { destroys: doc.entries.filter((e) => e.action === "delete"), replacements: doc.entries.filter((e) => e.action === "replace") };
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function descriptionState(doc: ChangeSetDocument, title: string, description: string): DescriptionState {
|
|
278
|
+
const { destroys, replacements } = destructiveEntries(doc);
|
|
279
|
+
const a = doc.summary.actions;
|
|
280
|
+
return {
|
|
281
|
+
title: title.slice(0, MAX_TEXT),
|
|
282
|
+
description: description.slice(0, MAX_TEXT),
|
|
283
|
+
plan: {
|
|
284
|
+
counts: { create: a.create ?? 0, update: a.update ?? 0, replace: a.replace ?? 0, delete: a.delete ?? 0 },
|
|
285
|
+
destroys: destroys.slice(0, MAX_LISTED).map(named),
|
|
286
|
+
replacements: replacements.slice(0, MAX_LISTED).map(named),
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Whether the text names an entry by its address, its type or its member. */
|
|
292
|
+
function mentions(text: string, e: ChangeSetEntry): boolean {
|
|
293
|
+
const hay = text.toLowerCase();
|
|
294
|
+
return [e.address, e.address.replace(/\[.*$/, ""), e.name, e.type].some((s) => typeof s === "string" && s.length > 2 && hay.includes(s.toLowerCase()));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** The destroys and replacements the text does not mention; every one when it names them all, since the model found the text leaves something out. */
|
|
298
|
+
export function unmentioned(doc: ChangeSetDocument, text: string): ChangeSetEntry[] {
|
|
299
|
+
const { destroys, replacements } = destructiveEntries(doc);
|
|
300
|
+
const all = [...destroys, ...replacements];
|
|
301
|
+
const left = all.filter((e) => !mentions(text, e));
|
|
302
|
+
return left.length > 0 ? left : all;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** The question asked. A Noul: the probability the answer is yes. */
|
|
306
|
+
export const DESCRIPTION_QUESTION = {
|
|
307
|
+
type: "noul",
|
|
308
|
+
instructions:
|
|
309
|
+
"Read the pull request's title and description and the summary of its plan. Answer true when the plan destroys or replaces resources that the title and description do not mention or that they contradict. Answer false when the text covers every destroy and replacement, or the plan has none.",
|
|
310
|
+
criteria: {
|
|
311
|
+
true: "the plan destroys or replaces something the text leaves out or contradicts",
|
|
312
|
+
false: "the text describes every destroy and replacement, or there are none",
|
|
313
|
+
},
|
|
314
|
+
} as const;
|
|
315
|
+
|
|
316
|
+
/** The default probability a yes needs before the finding is posted. */
|
|
317
|
+
export const DESCRIPTION_THRESHOLD = 0.8;
|
|
318
|
+
|
|
319
|
+
/** The model call: the backend's answer to {@link DESCRIPTION_QUESTION} over the state, as a probability of yes. */
|
|
320
|
+
export type DescriptionAsk = (state: DescriptionState) => Promise<{ model: string; probability: number; reason?: string }>;
|
|
321
|
+
|
|
322
|
+
export interface DescriptionFinding {
|
|
323
|
+
/** `flagged`: the finding was posted. `clear`: the model said no, or not confidently. `skipped`: nothing to check. `error`: the service did not answer. */
|
|
324
|
+
status: "flagged" | "clear" | "skipped" | "error";
|
|
325
|
+
probability?: number;
|
|
326
|
+
model?: string;
|
|
327
|
+
reason?: string;
|
|
328
|
+
unmentioned: string[];
|
|
329
|
+
/** The post, when flagged. */
|
|
330
|
+
body?: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Ask whether the description leaves out a destroy or replacement. Never throws. */
|
|
334
|
+
export async function checkDescription(input: {
|
|
335
|
+
doc: ChangeSetDocument;
|
|
336
|
+
title: string;
|
|
337
|
+
description: string;
|
|
338
|
+
ask: DescriptionAsk;
|
|
339
|
+
threshold?: number;
|
|
340
|
+
words?: CiProductWords;
|
|
341
|
+
}): Promise<DescriptionFinding> {
|
|
342
|
+
const { destroys, replacements } = destructiveEntries(input.doc);
|
|
343
|
+
if (destroys.length + replacements.length === 0) return { status: "skipped", reason: "the plan destroys and replaces nothing", unmentioned: [] };
|
|
344
|
+
let answer: Awaited<ReturnType<DescriptionAsk>>;
|
|
345
|
+
try {
|
|
346
|
+
answer = await input.ask(descriptionState(input.doc, input.title, input.description));
|
|
347
|
+
} catch (err) {
|
|
348
|
+
return { status: "error", reason: err instanceof Error ? err.message : String(err), unmentioned: [] };
|
|
349
|
+
}
|
|
350
|
+
const threshold = input.threshold ?? DESCRIPTION_THRESHOLD;
|
|
351
|
+
const base = { probability: answer.probability, model: answer.model, ...(answer.reason ? { reason: answer.reason } : {}) };
|
|
352
|
+
if (!(answer.probability >= threshold)) return { status: "clear", ...base, unmentioned: [] };
|
|
353
|
+
const left = unmentioned(input.doc, `${input.title}\n${input.description}`);
|
|
354
|
+
const names = left.map(named);
|
|
355
|
+
return { status: "flagged", ...base, unmentioned: names, body: renderDescriptionFinding(left, base, input.words ?? activeProductWords()) };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function renderDescriptionFinding(left: readonly ChangeSetEntry[], answer: { probability: number; model: string; reason?: string }, words: CiProductWords): string {
|
|
359
|
+
const list = left.slice(0, 10).map((e) => `- \`${named(e).replaceAll("`", "'")}\` (${e.action === "replace" ? "replace" : "destroy"})`);
|
|
360
|
+
if (left.length > 10) list.push(`- and ${left.length - 10} more in the plan note`);
|
|
361
|
+
return [
|
|
362
|
+
`Check the description of this pull request. The ${words.verbs.plan[0]} makes changes it does not mention:`,
|
|
363
|
+
"",
|
|
364
|
+
...list,
|
|
365
|
+
"",
|
|
366
|
+
`${answer.model} answered yes with probability ${answer.probability.toFixed(2)}${answer.reason ? `: ${answer.reason}` : ""}. This finding approves nothing and never blocks a merge.`,
|
|
367
|
+
].join("\n");
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// ---------------------------------------------------------------------------
|
|
371
|
+
// Posting
|
|
372
|
+
// ---------------------------------------------------------------------------
|
|
373
|
+
|
|
374
|
+
/** Where a response goes: a pull request, or a tracking issue when the run has none. */
|
|
375
|
+
export type RespondPlace = { pr: number } | { issue: string };
|
|
376
|
+
|
|
377
|
+
/** What {@link postResponse} did. */
|
|
378
|
+
export interface RespondPost {
|
|
379
|
+
posted: boolean;
|
|
380
|
+
url?: string;
|
|
381
|
+
warning?: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Post one response's body, editing its earlier comment. On a pull request
|
|
386
|
+
* the comment carries the marker as its first line; with no pull request it
|
|
387
|
+
* goes to a tracking issue titled `issue`. Never throws.
|
|
388
|
+
*/
|
|
389
|
+
export async function postResponse(
|
|
390
|
+
forge: Pick<PrForge, "upsertComment" | "trackIssue">,
|
|
391
|
+
event: CiRespondEvent,
|
|
392
|
+
place: string,
|
|
393
|
+
where: RespondPlace,
|
|
394
|
+
body: string,
|
|
395
|
+
): Promise<RespondPost> {
|
|
396
|
+
const marker = respondMarker(event, place);
|
|
397
|
+
const text = `${marker}\n${body}${body.endsWith("\n") ? "" : "\n"}`;
|
|
398
|
+
try {
|
|
399
|
+
if ("pr" in where) {
|
|
400
|
+
const r = await forge.upsertComment(where.pr, marker, text);
|
|
401
|
+
return { posted: true, ...(r.url ? { url: r.url } : {}) };
|
|
402
|
+
}
|
|
403
|
+
const r = await forge.trackIssue(marker, { title: where.issue, body: text }, { match: "anywhere" });
|
|
404
|
+
return { posted: true, ...(r.url ? { url: r.url } : {}) };
|
|
405
|
+
} catch (err) {
|
|
406
|
+
return { posted: false, warning: `could not post the ${event} response: ${err instanceof Error ? err.message : String(err)}` };
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function capital(s: string): string {
|
|
411
|
+
return s.length === 0 ? s : s[0]!.toUpperCase() + s.slice(1);
|
|
412
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant audit-log attribute` and `chant audit-log unrecorded` (#4632): the
|
|
3
|
+
* CI core reads of `../../ci-audit`. `attribute` reads a drift document
|
|
4
|
+
* (`chant workspace drift -o <file>`) and names who changed each drifted
|
|
5
|
+
* attribute; `unrecorded` reads the audit log's writes over a window and
|
|
6
|
+
* reports those no recorded apply on the run ledger made. Both read the
|
|
7
|
+
* log with the credentials the job holds and write nothing.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { resolve } from "node:path";
|
|
12
|
+
import { formatError } from "../format";
|
|
13
|
+
import type { CommandContext } from "../registry";
|
|
14
|
+
|
|
15
|
+
const fail = (message: string, hint?: string): number => {
|
|
16
|
+
console.error(formatError({ message, ...(hint ? { hint } : {}) }));
|
|
17
|
+
return 1;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export async function runAuditLogAttribute(ctx: CommandContext): Promise<number> {
|
|
21
|
+
const { args } = ctx;
|
|
22
|
+
if (!args.input) return fail("audit-log attribute reads a drift document: --input <file>", "Write one with chant workspace drift -o <file>.");
|
|
23
|
+
const audit = await import("../../ci-audit");
|
|
24
|
+
const { parseDriftDocument } = await import("../../drift-record");
|
|
25
|
+
let doc;
|
|
26
|
+
try {
|
|
27
|
+
doc = parseDriftDocument(JSON.parse(readFileSync(resolve(args.input), "utf-8")));
|
|
28
|
+
} catch (err) {
|
|
29
|
+
return fail(`--input ${args.input} is not a drift document: ${err instanceof Error ? err.message : String(err)}`);
|
|
30
|
+
}
|
|
31
|
+
let auditLogs: import("../../ci-audit").AuditLogSettings | undefined;
|
|
32
|
+
if (args.auditLog) {
|
|
33
|
+
const setting = audit.parseAuditLogSetting(args.auditLog);
|
|
34
|
+
if ("error" in setting) return fail(setting.error);
|
|
35
|
+
auditLogs = { "*": setting };
|
|
36
|
+
}
|
|
37
|
+
const attributed = await audit.attributeDrift(doc, { ...(auditLogs ? { auditLogs } : {}) });
|
|
38
|
+
if (args.json) {
|
|
39
|
+
console.log(JSON.stringify(attributed, null, 2));
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
for (const n of attributed.notes) console.error(n);
|
|
43
|
+
const routed = audit.routeAttributions(attributed.attributions);
|
|
44
|
+
console.log(routed.lines.length > 0 ? routed.lines.join("\n") : "no drifted attribute to attribute");
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function runAuditLogUnrecorded(ctx: CommandContext): Promise<number> {
|
|
49
|
+
const { args } = ctx;
|
|
50
|
+
if (!args.auditLog) return fail("audit-log unrecorded reads a cloud's audit log: --audit-log aws[:<region>]");
|
|
51
|
+
if (!args.op) return fail("audit-log unrecorded compares against the applies of the ops named: --op <op>[,<op>...]");
|
|
52
|
+
if (!args.since || !Number.isFinite(Date.parse(args.since))) return fail("audit-log unrecorded reads the writes since a time: --since <ISO-8601>");
|
|
53
|
+
const audit = await import("../../ci-audit");
|
|
54
|
+
const setting = audit.parseAuditLogSetting(args.auditLog);
|
|
55
|
+
if ("error" in setting) return fail(setting.error);
|
|
56
|
+
const { readRunLedger } = await import("../../lifecycle/run-ledger");
|
|
57
|
+
const { requireLifecycleLedger } = await import("../../lifecycle/git");
|
|
58
|
+
const env = args.env ?? "local";
|
|
59
|
+
const windows: import("../../ci-audit").ApplyWindow[] = [];
|
|
60
|
+
try {
|
|
61
|
+
await requireLifecycleLedger({ cwd: process.cwd() });
|
|
62
|
+
for (const op of args.op.split(",").map((o) => o.trim()).filter(Boolean)) {
|
|
63
|
+
windows.push(...audit.applyWindowsFromRuns((await readRunLedger(env, op)).records));
|
|
64
|
+
}
|
|
65
|
+
} catch (err) {
|
|
66
|
+
return fail(`could not read the run ledger: ${err instanceof Error ? err.message : String(err)}`);
|
|
67
|
+
}
|
|
68
|
+
const until = new Date().toISOString();
|
|
69
|
+
const report = await audit.unrecordedWrites(audit.auditLogOf(setting), windows, { since: new Date(args.since).toISOString(), until });
|
|
70
|
+
if (args.json) console.log(JSON.stringify(report, null, 2));
|
|
71
|
+
else console.log(audit.renderUnrecorded(report));
|
|
72
|
+
if (report.unavailable) return 1;
|
|
73
|
+
return report.unrecorded.length > 0 ? 2 : 0;
|
|
74
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant build --pr-loop` carries the merge (#4636), the responses and the
|
|
3
|
+
* description check's service (#4629) into the generated pull request jobs,
|
|
4
|
+
* and refuses a value the jobs would refuse on their own line.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
import { prLoopFlagsProblem } from "./build";
|
|
8
|
+
import { prLoopJobs, prLoopPostJob, prCommentPreviewJob } from "../../components/pr-pipeline";
|
|
9
|
+
import { productPipelineJobs } from "../../components/product-pipeline";
|
|
10
|
+
|
|
11
|
+
const loop = { prLoop: true, applyBeforeMerge: true } as const;
|
|
12
|
+
|
|
13
|
+
describe("prLoopFlagsProblem", () => {
|
|
14
|
+
test("a whole merge, respond and decide line holds", () => {
|
|
15
|
+
expect(prLoopFlagsProblem({ ...loop, merge: "auto", mergeTokenEnv: "CHANT_MERGE_TOKEN", mergeMethod: "squash", respond: ["description=check"], decideBackend: "review", decideModel: "m-1" })).toBeUndefined();
|
|
16
|
+
expect(prLoopFlagsProblem({ prLoop: true })).toBeUndefined();
|
|
17
|
+
expect(prLoopFlagsProblem({ prLoop: true, merge: "manual" })).toBeUndefined();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("the flags need --pr-loop", () => {
|
|
21
|
+
expect(prLoopFlagsProblem({ respond: ["apply-failed=off"] })).toMatch(/--respond .*needs --pr-loop/);
|
|
22
|
+
expect(prLoopFlagsProblem({ merge: "auto", mergeTokenEnv: "T" })).toMatch(/--merge, --merge-token-env .*need --pr-loop/);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("the merge's values are refused by name", () => {
|
|
26
|
+
expect(prLoopFlagsProblem({ ...loop, merge: "later" })).toMatch(/--merge takes manual or auto, not later/);
|
|
27
|
+
expect(prLoopFlagsProblem({ ...loop, merge: "auto", mergeTokenEnv: "T", mergeMethod: "fast-forward" })).toMatch(/--merge-method takes merge, squash, rebase, not fast-forward/);
|
|
28
|
+
expect(prLoopFlagsProblem({ ...loop, merge: "auto" })).toMatch(/--merge-token-env <VAR>/);
|
|
29
|
+
expect(prLoopFlagsProblem({ ...loop, merge: "auto", mergeTokenEnv: "not a name" })).toMatch(/variable name/);
|
|
30
|
+
expect(prLoopFlagsProblem({ prLoop: true, merge: "auto", mergeTokenEnv: "T" })).toMatch(/needs --apply-before-merge/);
|
|
31
|
+
expect(prLoopFlagsProblem({ ...loop, mergeTokenEnv: "T" })).toMatch(/go with --merge auto/);
|
|
32
|
+
expect(prLoopFlagsProblem({ ...loop, merge: "manual", mergeMethod: "squash" })).toMatch(/--merge manual/);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("the responses and the decide service are refused by name", () => {
|
|
36
|
+
expect(prLoopFlagsProblem({ prLoop: true, respond: ["wave-moved=off"] })).toMatch(/names no event "wave-moved"/);
|
|
37
|
+
expect(prLoopFlagsProblem({ prLoop: true, respond: ["apply-failed=loud"] })).toMatch(/apply-failed takes triage or off/);
|
|
38
|
+
expect(prLoopFlagsProblem({ prLoop: true, respond: ["description=check"], decideBackend: "review" })).toMatch(/--decide-backend <name> and --decide-model <id>/);
|
|
39
|
+
expect(prLoopFlagsProblem({ prLoop: true, decideBackend: "review", decideModel: "m-1" })).toMatch(/go with --respond description=check/);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("--target-dependents is refused, since the plan job plans with no target", () => {
|
|
43
|
+
expect(prLoopFlagsProblem({ prLoop: true, targetDependents: true })).toMatch(/--target-dependents/);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("the responses and the decide service in the pull request jobs", () => {
|
|
48
|
+
const respond = { "apply-failed": "off", description: "check" } as const;
|
|
49
|
+
const decide = { backend: "review", model: "m-1" };
|
|
50
|
+
|
|
51
|
+
test("the apply job carries CHANT_RESPOND, before merge and on merge", () => {
|
|
52
|
+
const [plan, early, record] = prLoopJobs("github", "prod", { applyBeforeMerge: true, respond, decide });
|
|
53
|
+
expect(early!.env.CHANT_RESPOND).toBe("apply-failed=off,description=check");
|
|
54
|
+
expect(early!.run.env.CHANT_RESPOND).toBe("apply-failed=off,description=check");
|
|
55
|
+
expect(plan!.env.CHANT_RESPOND).toBeUndefined();
|
|
56
|
+
expect(record!.env.CHANT_RESPOND).toBeUndefined();
|
|
57
|
+
const [, green] = prLoopJobs("gitlab", "prod", { applyOnMerge: true, respond: { "apply-failed": "off" } });
|
|
58
|
+
expect(green!.run.env.CHANT_RESPOND).toBe("apply-failed=off");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("defaults set no variable", () => {
|
|
62
|
+
const [, apply] = prLoopJobs("github", "prod", { applyBeforeMerge: true, respond: { "apply-failed": "triage" } });
|
|
63
|
+
expect(apply!.env.CHANT_RESPOND).toBeUndefined();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("the note job's line asks the decide service", () => {
|
|
67
|
+
for (const forge of ["github", "gitlab"] as const) {
|
|
68
|
+
const post = prLoopPostJob(forge, "prod", undefined, undefined, { respond, decide });
|
|
69
|
+
expect(post.command).toMatch(/pr-post .* --decide-backend "review" --decide-model "m-1"$/);
|
|
70
|
+
expect(post.env.CHANT_RESPOND).toBe("apply-failed=off,description=check");
|
|
71
|
+
}
|
|
72
|
+
expect(prLoopPostJob("github", "prod").command).not.toMatch(/--decide-backend/);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("a description check with no service is refused", () => {
|
|
76
|
+
expect(() => prLoopJobs("github", "prod", { respond: { description: "check" } })).toThrow(/decide/);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("the comment preview's plan takes neither", () => {
|
|
80
|
+
const preview = prCommentPreviewJob("github", "prod", { previewComment: true, respond, decide, refresh: true, words: { product: "plywood", stages: { plan: "preview", apply: "up" }, commands: { preview: "plan" } } });
|
|
81
|
+
expect(preview!.plan.env.CHANT_RESPOND).toBeUndefined();
|
|
82
|
+
expect(preview!.plan.command).toMatch(/--refresh/);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("productPipelineJobs gives the same jobs as the loop", () => {
|
|
86
|
+
const product = productPipelineJobs("github", "prod", { words: { product: "plywood" }, applyBeforeMerge: true, respond, decide });
|
|
87
|
+
expect(product.post.command).toMatch(/--decide-backend "review" --decide-model "m-1"$/);
|
|
88
|
+
expect(product.post.env.CHANT_RESPOND).toBe("apply-failed=off,description=check");
|
|
89
|
+
expect(product.applyBeforeMerge!.env.CHANT_RESPOND).toBe("apply-failed=off,description=check");
|
|
90
|
+
expect(() => productPipelineJobs("github", "prod", { words: { product: "plywood" }, applyBeforeMerge: true, respond: { description: "check" } })).toThrow(/decide/);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("the merge reaches the apply job's lines", () => {
|
|
94
|
+
const [, apply] = prLoopJobs("github", "prod", { applyBeforeMerge: true, applyMerge: { tokenEnv: "CHANT_MERGE_TOKEN", method: "squash" } });
|
|
95
|
+
expect(apply!.command).toMatch(/pr-apply --before-merge --merge auto --merge-token-env CHANT_MERGE_TOKEN --merge-method squash/);
|
|
96
|
+
expect(apply!.run.command).toMatch(/--apply-before-merge --merge auto --merge-token-env CHANT_MERGE_TOKEN --merge-method squash/);
|
|
97
|
+
});
|
|
98
|
+
});
|