@intentius/chant 0.124.108 → 0.124.110
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/__golden__/wave-loop/fan-out-applied.json +12 -6
- package/dist/__golden__/wave-loop/fan-out-apply-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-gated.json +4 -2
- package/dist/__golden__/wave-loop/fan-out-no-members.json +16 -8
- package/dist/__golden__/wave-loop/fan-out-plan-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-same-root.json +4 -2
- package/dist/agent-facts.d.ts +130 -0
- package/dist/agent-facts.js +196 -0
- package/dist/change-risk.d.ts +216 -0
- package/dist/change-risk.js +304 -0
- package/dist/change-set.d.ts +8 -0
- package/dist/ci-agent-alert.d.ts +139 -0
- package/dist/ci-agent-alert.js +342 -0
- package/dist/ci-agent-triggers.d.ts +152 -0
- package/dist/ci-agent-triggers.js +232 -0
- package/dist/ci-agent-verify-failed.d.ts +149 -0
- package/dist/ci-agent-verify-failed.js +191 -0
- package/dist/ci-agent.d.ts +136 -8
- package/dist/ci-agent.js +353 -26
- package/dist/ci-comment-commands.d.ts +8 -0
- package/dist/ci-comment-commands.js +17 -1
- package/dist/ci-comment-reject.d.ts +70 -0
- package/dist/ci-comment-reject.js +135 -0
- package/dist/ci-comment-replies.d.ts +3 -1
- package/dist/ci-comment-replies.js +6 -0
- package/dist/ci-estate/delivery.d.ts +25 -3
- package/dist/ci-estate/delivery.js +28 -9
- package/dist/ci-estate/page.d.ts +7 -3
- package/dist/ci-estate/page.js +19 -4
- package/dist/ci-estate/rows.d.ts +14 -2
- package/dist/ci-estate/rows.js +9 -1
- package/dist/ci-estate.d.ts +5 -2
- package/dist/ci-estate.js +3 -2
- package/dist/ci-handover.d.ts +2 -7
- package/dist/ci-handover.js +3 -20
- package/dist/ci-jobs.d.ts +6 -0
- package/dist/ci-jobs.js +17 -0
- package/dist/ci-note-commands.d.ts +2 -0
- package/dist/ci-note-commands.js +12 -1
- package/dist/ci-product-words.d.ts +151 -1
- package/dist/ci-product-words.js +1390 -3
- package/dist/ci-product.d.ts +100 -4
- package/dist/ci-product.js +99 -3
- package/dist/ci-respond-run.d.ts +9 -0
- package/dist/ci-respond-run.js +35 -4
- package/dist/ci-respond-summary-env.d.ts +56 -0
- package/dist/ci-respond-summary-env.js +81 -0
- package/dist/ci-respond-summary.d.ts +103 -0
- package/dist/ci-respond-summary.js +243 -0
- package/dist/ci-respond.d.ts +4 -2
- package/dist/ci-respond.js +4 -2
- package/dist/cli/command-group.js +1 -1
- package/dist/cli/commands/lint.js +21 -3
- package/dist/cli/handlers/agent.js +49 -4
- package/dist/cli/handlers/approve.js +3 -1
- package/dist/cli/handlers/build.d.ts +97 -1
- package/dist/cli/handlers/build.js +251 -3
- package/dist/cli/handlers/fan-out.js +55 -0
- package/dist/cli/handlers/graph.d.ts +14 -0
- package/dist/cli/handlers/graph.js +58 -3
- package/dist/cli/handlers/lifecycle-health.d.ts +7 -0
- package/dist/cli/handlers/lifecycle-health.js +47 -9
- package/dist/cli/handlers/lifecycle.js +4 -1
- package/dist/cli/handlers/notify-relay.d.ts +2 -2
- package/dist/cli/handlers/notify-relay.js +67 -7
- package/dist/cli/handlers/pipeline-agent.d.ts +30 -0
- package/dist/cli/handlers/pipeline-agent.js +255 -0
- package/dist/cli/handlers/pipeline-artifacts.d.ts +39 -0
- package/dist/cli/handlers/pipeline-artifacts.js +203 -0
- package/dist/cli/handlers/pipeline.d.ts +16 -0
- package/dist/cli/handlers/pipeline.js +112 -0
- package/dist/cli/handlers/pr-comment.js +4 -0
- package/dist/cli/handlers/pr-notes.js +4 -1
- package/dist/cli/handlers/pr.d.ts +20 -0
- package/dist/cli/handlers/pr.js +114 -11
- package/dist/cli/handlers/promote.js +792 -47
- package/dist/cli/handlers/reject.d.ts +84 -0
- package/dist/cli/handlers/reject.js +216 -0
- package/dist/cli/handlers/release.js +4 -2
- package/dist/cli/handlers/replan.d.ts +54 -0
- package/dist/cli/handlers/replan.js +177 -0
- package/dist/cli/handlers/run-generate.d.ts +5 -0
- package/dist/cli/handlers/run-generate.js +31 -4
- package/dist/cli/handlers/run-wave.js +15 -2
- package/dist/cli/handlers/run.js +4 -2
- package/dist/cli/handlers/stage.d.ts +35 -0
- package/dist/cli/handlers/stage.js +90 -0
- package/dist/cli/lsp/server.js +4 -0
- package/dist/cli/main.js +88 -8
- package/dist/cli/parse-args.js +35 -2
- package/dist/cli/registry.d.ts +12 -0
- package/dist/components/auto-release.d.ts +2 -0
- package/dist/components/auto-release.js +1 -0
- package/dist/components/capability.d.ts +40 -0
- package/dist/components/cli-support.d.ts +21 -1
- package/dist/components/cli-support.js +28 -6
- package/dist/components/component.d.ts +23 -4
- package/dist/components/component.schema.json +28 -0
- package/dist/components/declared-reads.d.ts +44 -4
- package/dist/components/declared-reads.js +80 -3
- package/dist/components/discover.d.ts +8 -0
- package/dist/components/discover.js +1 -1
- package/dist/components/driver.d.ts +13 -0
- package/dist/components/driver.js +23 -2
- package/dist/components/environment-sets.d.ts +229 -0
- package/dist/components/environment-sets.js +338 -0
- package/dist/components/fan-out-canary.d.ts +47 -0
- package/dist/components/fan-out-canary.js +58 -0
- package/dist/components/fan-out-run.d.ts +17 -0
- package/dist/components/fan-out-run.js +14 -1
- package/dist/components/fan-out-support.d.ts +7 -0
- package/dist/components/fan-out-support.js +1 -1
- package/dist/components/groups.d.ts +8 -1
- package/dist/components/groups.js +19 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +4 -1
- package/dist/components/pr-cost.d.ts +28 -0
- package/dist/components/pr-cost.js +53 -0
- package/dist/components/pr-pipeline.d.ts +33 -0
- package/dist/components/pr-pipeline.js +32 -5
- package/dist/components/pr-policy.d.ts +33 -2
- package/dist/components/pr-policy.js +5 -2
- package/dist/components/pr-risk.d.ts +42 -0
- package/dist/components/pr-risk.js +74 -0
- package/dist/components/product-pipeline.d.ts +43 -0
- package/dist/components/product-pipeline.js +67 -1
- package/dist/components/promote.d.ts +6 -0
- package/dist/components/promote.js +13 -0
- package/dist/components/release-compile.js +3 -1
- package/dist/components/release-gate.d.ts +6 -1
- package/dist/components/release-gate.js +10 -2
- package/dist/components/step-environments.d.ts +236 -0
- package/dist/components/step-environments.js +392 -0
- package/dist/components/upstream-replan.d.ts +201 -0
- package/dist/components/upstream-replan.js +249 -0
- package/dist/components/verify-step.d.ts +30 -0
- package/dist/components/verify-step.js +27 -0
- package/dist/components/wave-plan.js +6 -2
- package/dist/config-environments.d.ts +4 -2
- package/dist/control/dispatch.d.ts +15 -0
- package/dist/control/dispatch.js +28 -4
- package/dist/cost-estimate.d.ts +188 -0
- package/dist/cost-estimate.js +363 -0
- package/dist/drift-record.d.ts +36 -0
- package/dist/drift-record.js +44 -0
- package/dist/engine-facts.d.ts +105 -0
- package/dist/engine-facts.js +111 -0
- package/dist/exit-codes.d.ts +4 -3
- package/dist/exit-codes.js +4 -3
- package/dist/flag-params.d.ts +2 -2
- package/dist/flag-params.js +9 -4
- package/dist/floor-table.data.js +53 -0
- package/dist/forge-token-vars.d.ts +12 -0
- package/dist/forge-token-vars.js +25 -0
- package/dist/gate-decision.d.ts +3 -1
- package/dist/gate-decision.js +3 -1
- package/dist/gated-waves.d.ts +2 -0
- package/dist/gated-waves.js +1 -0
- package/dist/graph-ir.d.ts +30 -0
- package/dist/graph-ir.js +33 -1
- package/dist/graph-refs.d.ts +26 -0
- package/dist/graph-refs.js +34 -3
- package/dist/graph-schema/graph.schema.json +136 -0
- package/dist/health.d.ts +65 -0
- package/dist/health.js +62 -0
- package/dist/lexicon.d.ts +188 -1
- package/dist/lifecycle/disruption.d.ts +14 -1
- package/dist/lifecycle/disruption.js +5 -1
- package/dist/lifecycle/gate-change-set.d.ts +8 -0
- package/dist/lifecycle/gate-change-set.js +2 -1
- package/dist/lifecycle/gate-ledger.d.ts +26 -0
- package/dist/lifecycle/gate-rejection.d.ts +82 -0
- package/dist/lifecycle/gate-rejection.js +93 -0
- package/dist/lifecycle/gate-seal.d.ts +3 -3
- package/dist/lifecycle/gate-seal.js +5 -5
- package/dist/lifecycle/observe.d.ts +17 -0
- package/dist/lifecycle/observe.js +10 -1
- package/dist/lifecycle/release-cut.js +4 -0
- package/dist/lifecycle/release-ledger.d.ts +8 -0
- package/dist/lifecycle/release-risk.d.ts +137 -0
- package/dist/lifecycle/release-risk.js +214 -0
- package/dist/lifecycle/release-store.d.ts +9 -0
- package/dist/lifecycle/release-store.js +4 -0
- package/dist/lifecycle/stage-log.d.ts +85 -0
- package/dist/lifecycle/stage-log.js +141 -0
- package/dist/lint/canary-checks.d.ts +31 -0
- package/dist/lint/canary-checks.js +45 -0
- package/dist/lint/rule.d.ts +1 -0
- package/dist/lint/rules/evl012-pipeline-fold.d.ts +14 -0
- package/dist/lint/rules/evl012-pipeline-fold.js +30 -0
- package/dist/lint/rules/index.d.ts +1 -0
- package/dist/lint/rules/index.js +3 -0
- package/dist/notify-relay-repo.d.ts +54 -0
- package/dist/notify-relay-repo.js +84 -0
- package/dist/notify-relay.d.ts +53 -3
- package/dist/notify-relay.js +96 -3
- package/dist/notify.d.ts +57 -1
- package/dist/notify.js +7 -1
- package/dist/notify.schema.json +61 -3
- package/dist/observation.d.ts +34 -0
- package/dist/observation.js +14 -1
- package/dist/op/activities/review-agent.d.ts +39 -2
- package/dist/op/activities/review-agent.js +88 -5
- package/dist/op/agent-permit.d.ts +88 -0
- package/dist/op/agent-permit.js +97 -0
- package/dist/op/gate-approval-base.d.ts +8 -0
- package/dist/op/gate-approval-base.js +9 -0
- package/dist/op/gate-approval.d.ts +30 -1
- package/dist/op/gate-approval.js +23 -2
- package/dist/op/gate-quorum.d.ts +114 -8
- package/dist/op/gate-quorum.js +198 -21
- package/dist/op/gate-reject.d.ts +79 -0
- package/dist/op/gate-reject.js +96 -0
- package/dist/op/gate-summary.js +1 -1
- package/dist/op/gate.d.ts +28 -3
- package/dist/op/gate.js +55 -13
- package/dist/op/generate-pipeline.d.ts +15 -1
- package/dist/op/generate-pipeline.js +32 -5
- package/dist/op/index.d.ts +11 -6
- package/dist/op/index.js +10 -5
- package/dist/op/local-executor.d.ts +2 -0
- package/dist/op/local-executor.js +23 -4
- package/dist/op/op-waves-after-plan.d.ts +23 -0
- package/dist/op/op-waves-after-plan.js +12 -1
- package/dist/op/op-waves-capability-spec.d.ts +14 -0
- package/dist/op/op-waves-capability-spec.js +46 -6
- package/dist/op/op-waves-capability.d.ts +21 -13
- package/dist/op/op-waves-capability.js +22 -59
- package/dist/op/op-waves-environment-sets.d.ts +41 -0
- package/dist/op/op-waves-environment-sets.js +82 -0
- package/dist/op/op-waves-quorum-warnings.d.ts +53 -0
- package/dist/op/op-waves-quorum-warnings.js +90 -0
- package/dist/op/op-waves-release-port.d.ts +7 -0
- package/dist/op/op-waves-release-port.js +15 -3
- package/dist/op/op-waves-release.d.ts +15 -0
- package/dist/op/op-waves-release.js +15 -0
- package/dist/op/op-waves-run.d.ts +37 -3
- package/dist/op/op-waves-run.js +141 -18
- package/dist/op/op-waves-soak.d.ts +57 -0
- package/dist/op/op-waves-soak.js +111 -0
- package/dist/op/op-waves-split.d.ts +4 -0
- package/dist/op/op-waves-split.js +4 -0
- package/dist/op/op-waves.d.ts +67 -4
- package/dist/op/op-waves.js +71 -3
- package/dist/pipeline/agent-ajv.d.ts +4 -0
- package/dist/pipeline/agent-ajv.js +14 -0
- package/dist/pipeline/agent-steps.d.ts +329 -0
- package/dist/pipeline/agent-steps.js +602 -0
- package/dist/pipeline/artifacts.d.ts +264 -0
- package/dist/pipeline/artifacts.js +425 -0
- package/dist/pipeline/diff.d.ts +45 -0
- package/dist/pipeline/diff.js +177 -0
- package/dist/pipeline/fold.d.ts +43 -0
- package/dist/pipeline/fold.js +140 -0
- package/dist/pipeline/generate.d.ts +52 -0
- package/dist/pipeline/generate.js +120 -0
- package/dist/pipeline/product.d.ts +225 -0
- package/dist/pipeline/product.js +257 -0
- package/dist/pipeline/promote.d.ts +404 -0
- package/dist/pipeline/promote.js +694 -0
- package/dist/pipeline/read.d.ts +37 -0
- package/dist/pipeline/read.js +58 -0
- package/dist/pipeline/rendered.d.ts +25 -0
- package/dist/pipeline/rendered.js +53 -0
- package/dist/pipeline/soak-checks.d.ts +80 -0
- package/dist/pipeline/soak-checks.js +254 -0
- package/dist/pipeline/soak-gate.d.ts +97 -0
- package/dist/pipeline/soak-gate.js +176 -0
- package/dist/pipeline/soak-sources.d.ts +17 -0
- package/dist/pipeline/soak-sources.js +42 -0
- package/dist/pipeline/soak.d.ts +260 -0
- package/dist/pipeline/soak.js +378 -0
- package/dist/pipeline/spec.d.ts +724 -0
- package/dist/pipeline/spec.js +567 -0
- package/dist/pipeline/stage-ledger.d.ts +187 -0
- package/dist/pipeline/stage-ledger.js +185 -0
- package/dist/pipeline/stage-waves.d.ts +114 -0
- package/dist/pipeline/stage-waves.js +161 -0
- package/dist/pipeline/stages.d.ts +64 -0
- package/dist/pipeline/stages.js +174 -0
- package/dist/pipeline/verify-rollback.d.ts +277 -0
- package/dist/pipeline/verify-rollback.js +393 -0
- package/dist/pipeline.d.ts +142 -0
- package/dist/pipeline.js +143 -0
- package/dist/pr-loop.d.ts +22 -0
- package/dist/pr-loop.js +8 -0
- package/dist/pr-plan-note.d.ts +15 -1
- package/dist/pr-plan-note.js +8 -0
- package/dist/pr-post.d.ts +31 -0
- package/dist/pr-post.js +89 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/report-store/audit.schema.json +50 -0
- package/dist/report-store/dora.schema.json +331 -0
- package/dist/report-store/estate.schema.json +96 -0
- package/dist/report-store/run.schema.json +14 -0
- package/dist/report-store.d.ts +151 -0
- package/dist/report-store.js +344 -0
- package/dist/run-event.d.ts +7 -2
- package/dist/wave-runtime.mjs +458 -404
- package/dist/workspace/catalog-edges.js +3 -3
- package/dist/workspace/change-set.schema.json +4 -0
- package/dist/workspace/ci-cloud-identity.d.ts +4 -0
- package/dist/workspace/ci-cloud-identity.js +30 -0
- package/dist/workspace/ci-run.js +17 -2
- package/dist/workspace/ci-secrets.d.ts +3 -1
- package/dist/workspace/ci-secrets.js +7 -1
- package/dist/workspace/compose-graph.d.ts +1 -1
- package/dist/workspace/compose-graph.js +3 -1
- package/dist/workspace/declaration.d.ts +27 -0
- package/dist/workspace/declaration.js +35 -0
- package/dist/workspace/declaration.schema.json +56 -0
- package/dist/workspace/graph-cli.js +26 -0
- package/dist/workspace/graph.schema.json +5 -1
- package/dist/workspace/identity-gate-rule.d.ts +4 -0
- package/dist/workspace/identity-gate-rule.js +2 -2
- package/dist/workspace/identity-reject-rule.d.ts +14 -0
- package/dist/workspace/identity-reject-rule.js +24 -0
- package/dist/workspace/identity.d.ts +3 -0
- package/dist/workspace/identity.js +2 -1
- package/dist/workspace/nested-graph.js +2 -0
- package/dist/workspace/pr-report.schema.json +65 -0
- package/dist/workspace/promotion-order.d.ts +19 -4
- package/dist/workspace/promotion-order.js +26 -4
- package/dist/workspace/release-train.d.ts +14 -0
- package/dist/workspace/release-train.js +32 -0
- package/dist/workspace/run-event.schema.json +2 -2
- package/dist/workspace/stack-read-edges.d.ts +19 -0
- package/dist/workspace/stack-read-edges.js +54 -0
- package/dist/workspace/status-gates.d.ts +51 -1
- package/dist/workspace/status-gates.js +60 -0
- package/dist/workspace/status-stages.d.ts +223 -0
- package/dist/workspace/status-stages.js +279 -0
- package/dist/workspace/status.d.ts +45 -1
- package/dist/workspace/status.js +109 -5
- package/dist/workspace/status.schema.json +283 -2
- package/dist/workspace/train-cut.js +5 -2
- package/dist/workspace/train-shell.d.ts +18 -0
- package/dist/workspace/train-shell.js +43 -0
- package/dist/workspace/trust/seal.d.ts +7 -0
- package/dist/workspace/trust/seal.js +9 -0
- package/package.json +5 -1
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A step's inputs per environment (#5360): one component carries a release's
|
|
3
|
+
* commit to each environment's own target.
|
|
4
|
+
*
|
|
5
|
+
* A step may carry `environments`, keyed by environment name, each entry a
|
|
6
|
+
* map of the step's inputs for that environment:
|
|
7
|
+
*
|
|
8
|
+
* {
|
|
9
|
+
* kind: "pulumi-up",
|
|
10
|
+
* dir: "infra/shop",
|
|
11
|
+
* environments: {
|
|
12
|
+
* dev: { stack: "acme/shop/dev" },
|
|
13
|
+
* staging: { stack: "acme/shop/staging" },
|
|
14
|
+
* prod: { stack: "acme/shop/prod" },
|
|
15
|
+
* },
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* Core resolves it for the run's environment before the capability sees the
|
|
19
|
+
* input: the entry's keys replace the step's keys of the same name, one level
|
|
20
|
+
* deep, and `environments` itself is removed. So `pulumi-up` takes its stack
|
|
21
|
+
* this way, `terraform-apply` its `root` and `vars`, and any other engine
|
|
22
|
+
* step whatever input picks its target. A step with no `environments` is
|
|
23
|
+
* passed on as it is.
|
|
24
|
+
*
|
|
25
|
+
* The map is plain data in the composition, so it is the same in every
|
|
26
|
+
* environment: `chant components promote --to staging` deploys the
|
|
27
|
+
* component it loaded with the staging entry, and records it under staging;
|
|
28
|
+
* `rollback` and `redeploy` pick the entry of the environment they act on.
|
|
29
|
+
*
|
|
30
|
+
* An environment the map does not name is refused before anything runs,
|
|
31
|
+
* naming the environments it does name. A pull request's environment
|
|
32
|
+
* `pr-<n>` takes the entry of its template environment, the one `pr-env up`
|
|
33
|
+
* sets in `CHANT_ENV_TEMPLATE` (`ci.prEnvironment.template`); a template
|
|
34
|
+
* that names a stack, `<project>/<stack>`, picks the entry its last segment
|
|
35
|
+
* names. The step's own review-stack handling then runs on that entry, as
|
|
36
|
+
* it does on a fixed stack.
|
|
37
|
+
*
|
|
38
|
+
* The callers resolve early, where the environment is known and before a
|
|
39
|
+
* plan, a release pin or a run reads the steps: `chant run --components`
|
|
40
|
+
* (./cli-support.ts), promote, rollback and redeploy
|
|
41
|
+
* (../cli/handlers/promote.ts), a release cut's compile
|
|
42
|
+
* (./release-compile.ts), and the fan-out a pull request's plan and `chant
|
|
43
|
+
* components fan-out` derive (./fan-out-support.ts), whose declared reads
|
|
44
|
+
* (./declared-reads.ts) a capability such as `pulumi-up` answers from the
|
|
45
|
+
* resolved stack. A group's members reach `planGroup`, `groupReads` and
|
|
46
|
+
* `groupFallback` resolved (./groups.ts), so terraform's composition reads
|
|
47
|
+
* each member's resolved root. The driver refuses a component still carrying a
|
|
48
|
+
* map that does not name its environment before its first wave
|
|
49
|
+
* (`runInterpretDriver`), and each place that hands a capability its input
|
|
50
|
+
* resolves the step again, which is a no-op on a resolved one.
|
|
51
|
+
*
|
|
52
|
+
* An environment's config and secret set (./environment-sets.ts, #5348)
|
|
53
|
+
* picks its entry with {@link environmentEntryName}, the same lookup.
|
|
54
|
+
*
|
|
55
|
+
* ## Gate steps (#5401)
|
|
56
|
+
*
|
|
57
|
+
* A gate step takes `environments` too, naming the environments it applies
|
|
58
|
+
* in: a list of names, or a map whose entries may set the gate's `gate`,
|
|
59
|
+
* `description` and `timeout` there.
|
|
60
|
+
*
|
|
61
|
+
* { kind: "gate", gate: "release", environments: ["staging", "prod"] }
|
|
62
|
+
*
|
|
63
|
+
* The same resolution reads it, with the same lookup (a pull request's
|
|
64
|
+
* environment takes its template's entry). In an environment the gate
|
|
65
|
+
* names, the gate stays, its entry merged over it and `environments`
|
|
66
|
+
* removed. In any other, the gate is taken out of its phase and listed on
|
|
67
|
+
* the phase's `skippedGates`, so every reader past this point (the release
|
|
68
|
+
* gate's plan and binding, the gate names a promote prints, the driver)
|
|
69
|
+
* sees only the gates that apply, and the driver records each skip
|
|
70
|
+
* (`gateSkipped` on its step record, a `step-settle` with
|
|
71
|
+
* `skip: "environment"`). A gate step with no `environments` applies in
|
|
72
|
+
* every environment, as before. `chant build` refuses a gate that names an
|
|
73
|
+
* environment the member does not declare ({@link unknownGateEnvironments}).
|
|
74
|
+
*
|
|
75
|
+
* This module imports only the release floors at run time.
|
|
76
|
+
*/
|
|
77
|
+
/** The step key that holds its inputs per environment. */
|
|
78
|
+
export const STEP_ENVIRONMENTS_KEY = "environments";
|
|
79
|
+
/**
|
|
80
|
+
* The first chant that resolves a component step's `environments` for the
|
|
81
|
+
* run's environment before its capability sees the input (#5360), for
|
|
82
|
+
* `pulumi-up`'s stack, `terraform-apply`'s root and vars and every other
|
|
83
|
+
* engine step, in `run --components`, promote, rollback, redeploy, a
|
|
84
|
+
* release cut, and a pull request's plan, its declared reads and its groups.
|
|
85
|
+
*/
|
|
86
|
+
export const STEP_ENVIRONMENTS_FLOOR = "0.124.110";
|
|
87
|
+
/**
|
|
88
|
+
* The first chant that applies a gate step only in the environments its
|
|
89
|
+
* `environments` names (#5401): in any other the gate is skipped and the
|
|
90
|
+
* skip recorded on the run's step records, its run events, the release
|
|
91
|
+
* records and `chant workspace status`, and a promote's plan lists it; a
|
|
92
|
+
* gate naming an environment the member does not declare fails `chant
|
|
93
|
+
* build`.
|
|
94
|
+
*/
|
|
95
|
+
export const GATE_ENVIRONMENTS_FLOOR = "0.124.110";
|
|
96
|
+
/** The keys a gate step's `environments` entry may set (#5401). */
|
|
97
|
+
export const GATE_ENVIRONMENT_KEYS = ["gate", "description", "timeout"];
|
|
98
|
+
/** The variable `pr-env up` sets to the pull request environment's template (`PR_ENV_TEMPLATE_VAR` in ./pr-environment.ts). */
|
|
99
|
+
const TEMPLATE_VAR = "CHANT_ENV_TEMPLATE";
|
|
100
|
+
/** A pull request's environment name (`isPrEnvironmentName` in ./pr-environment.ts). */
|
|
101
|
+
const PR_ENV = /^pr-[1-9][0-9]*$/;
|
|
102
|
+
/** Thrown when a step's `environments` does not name the run's environment. */
|
|
103
|
+
export class StepEnvironmentRefusedError extends Error {
|
|
104
|
+
constructor(refusals) {
|
|
105
|
+
super(refusals.map((r) => r.message).join("\n"));
|
|
106
|
+
this.refusals = refusals;
|
|
107
|
+
this.name = "StepEnvironmentRefusedError";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const isMap = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
111
|
+
/** Whether `step` carries inputs per environment. */
|
|
112
|
+
export function hasStepEnvironments(step) {
|
|
113
|
+
return Object.prototype.hasOwnProperty.call(step, STEP_ENVIRONMENTS_KEY);
|
|
114
|
+
}
|
|
115
|
+
/** The environments a step names, in the order it names them; empty for a step with none. */
|
|
116
|
+
export function stepEnvironmentNames(step) {
|
|
117
|
+
const map = step[STEP_ENVIRONMENTS_KEY];
|
|
118
|
+
return isMap(map) ? Object.keys(map) : [];
|
|
119
|
+
}
|
|
120
|
+
/** Why the map itself cannot be read, or undefined. */
|
|
121
|
+
function malformed(map) {
|
|
122
|
+
if (!isMap(map) || Object.keys(map).length === 0)
|
|
123
|
+
return "takes a map from environment name to the step's inputs there";
|
|
124
|
+
for (const [env, entry] of Object.entries(map)) {
|
|
125
|
+
if (!isMap(entry))
|
|
126
|
+
return `names ${env} with ${Array.isArray(entry) ? "a list" : typeof entry}, where it takes a map of the step's inputs`;
|
|
127
|
+
for (const key of ["kind", STEP_ENVIRONMENTS_KEY]) {
|
|
128
|
+
if (key in entry)
|
|
129
|
+
return `sets \`${key}\` under ${env}, which is the same in every environment`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The name of the entry `env` takes in a map keyed by environment name:
|
|
136
|
+
* itself, or for a pull request environment `pr-<n>` its template's (the
|
|
137
|
+
* template's name, or the last segment of a template that names a stack).
|
|
138
|
+
* Undefined when the map names neither. A step's `environments` and an
|
|
139
|
+
* environment's config and secret set (./environment-sets.ts, #5348) pick
|
|
140
|
+
* their entry with it, so both read the run's environment the same way.
|
|
141
|
+
*/
|
|
142
|
+
export function environmentEntryName(map, env, options = {}) {
|
|
143
|
+
if (env in map)
|
|
144
|
+
return env;
|
|
145
|
+
if (!PR_ENV.test(env))
|
|
146
|
+
return undefined;
|
|
147
|
+
const template = options.template ?? (options.processEnv ?? process.env)[TEMPLATE_VAR];
|
|
148
|
+
if (!template)
|
|
149
|
+
return undefined;
|
|
150
|
+
if (template in map)
|
|
151
|
+
return template;
|
|
152
|
+
const last = template.split("/").pop();
|
|
153
|
+
return last !== undefined && last in map ? last : undefined;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* `step` with its `environments` resolved for `env`, or the reason it
|
|
157
|
+
* cannot run there. A step with no `environments` comes back as it is.
|
|
158
|
+
*/
|
|
159
|
+
export function stepForEnvironment(step, env, options = {}) {
|
|
160
|
+
if (!hasStepEnvironments(step))
|
|
161
|
+
return { step };
|
|
162
|
+
const map = step[STEP_ENVIRONMENTS_KEY];
|
|
163
|
+
const bad = malformed(map);
|
|
164
|
+
if (bad !== undefined)
|
|
165
|
+
return { error: `its \`${STEP_ENVIRONMENTS_KEY}\` ${bad}`, named: [] };
|
|
166
|
+
const named = Object.keys(map);
|
|
167
|
+
const name = environmentEntryName(map, env, options);
|
|
168
|
+
if (name === undefined) {
|
|
169
|
+
const template = PR_ENV.test(env) ? options.template ?? (options.processEnv ?? process.env)[TEMPLATE_VAR] : undefined;
|
|
170
|
+
const via = template ? `, nor its template ${template}` : "";
|
|
171
|
+
return { error: `its \`${STEP_ENVIRONMENTS_KEY}\` names ${named.join(", ")}, and not ${env}${via}`, named };
|
|
172
|
+
}
|
|
173
|
+
const { [STEP_ENVIRONMENTS_KEY]: _map, ...rest } = step;
|
|
174
|
+
return { step: { ...rest, ...(map[name]) } };
|
|
175
|
+
}
|
|
176
|
+
/** A gate's name, from `gate` or the deprecated `signalName` (`gateName` in ../op/gate-name.ts). */
|
|
177
|
+
const gateNameOf = (step) => typeof step.gate === "string" ? step.gate : typeof step.signalName === "string" ? step.signalName : "";
|
|
178
|
+
/** A gate's `environments` as a map, or why it cannot be read. A list names environments with empty entries. */
|
|
179
|
+
function gateEnvironmentMap(value) {
|
|
180
|
+
if (Array.isArray(value)) {
|
|
181
|
+
if (value.length === 0)
|
|
182
|
+
return { error: "takes a list of environment names, or a map from environment name to the gate's keys there" };
|
|
183
|
+
const seen = new Set();
|
|
184
|
+
for (const name of value) {
|
|
185
|
+
if (typeof name !== "string" || name === "")
|
|
186
|
+
return { error: `lists ${JSON.stringify(name)}, where it takes environment names` };
|
|
187
|
+
if (seen.has(name))
|
|
188
|
+
return { error: `lists ${name} twice` };
|
|
189
|
+
seen.add(name);
|
|
190
|
+
}
|
|
191
|
+
return { map: Object.fromEntries(value.map((name) => [name, {}])) };
|
|
192
|
+
}
|
|
193
|
+
if (!isMap(value) || Object.keys(value).length === 0) {
|
|
194
|
+
return { error: "takes a list of environment names, or a map from environment name to the gate's keys there" };
|
|
195
|
+
}
|
|
196
|
+
for (const [env, entry] of Object.entries(value)) {
|
|
197
|
+
if (!isMap(entry))
|
|
198
|
+
return { error: `names ${env} with ${Array.isArray(entry) ? "a list" : typeof entry}, where it takes a map of the gate's keys` };
|
|
199
|
+
const other = Object.keys(entry).find((k) => !GATE_ENVIRONMENT_KEYS.includes(k));
|
|
200
|
+
if (other !== undefined)
|
|
201
|
+
return { error: `sets \`${other}\` under ${env}, where a gate's entry sets ${GATE_ENVIRONMENT_KEYS.map((k) => `\`${k}\``).join(", ")}` };
|
|
202
|
+
}
|
|
203
|
+
return { map: value };
|
|
204
|
+
}
|
|
205
|
+
/** The environments a gate step names, in the order it names them; empty for a gate with none or a malformed one. */
|
|
206
|
+
export function gateEnvironmentNames(step) {
|
|
207
|
+
if (!hasStepEnvironments(step))
|
|
208
|
+
return [];
|
|
209
|
+
const read = gateEnvironmentMap(step[STEP_ENVIRONMENTS_KEY]);
|
|
210
|
+
return "map" in read ? Object.keys(read.map) : [];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* A gate step resolved for `env` (#5401): the gate with its entry merged and
|
|
214
|
+
* `environments` removed when it applies there, the skip when it does not,
|
|
215
|
+
* or why its `environments` cannot be read. A gate with no `environments`
|
|
216
|
+
* comes back as it is.
|
|
217
|
+
*/
|
|
218
|
+
export function gateForEnvironment(step, env, options = {}) {
|
|
219
|
+
if (!hasStepEnvironments(step))
|
|
220
|
+
return { step };
|
|
221
|
+
const read = gateEnvironmentMap(step[STEP_ENVIRONMENTS_KEY]);
|
|
222
|
+
if ("error" in read)
|
|
223
|
+
return { error: `its \`${STEP_ENVIRONMENTS_KEY}\` ${read.error}`, named: [] };
|
|
224
|
+
const name = environmentEntryName(read.map, env, options);
|
|
225
|
+
if (name === undefined)
|
|
226
|
+
return { skipped: { gate: gateNameOf(step), environments: Object.keys(read.map) } };
|
|
227
|
+
const { [STEP_ENVIRONMENTS_KEY]: _map, ...rest } = step;
|
|
228
|
+
return { step: { ...rest, ...read.map[name] } };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* A step's input with its `environments` resolved for `env`. Throws a
|
|
232
|
+
* {@link StepEnvironmentRefusedError} when the step does not name it. For
|
|
233
|
+
* the places that hand a capability its input; a resolved step comes back
|
|
234
|
+
* as it is.
|
|
235
|
+
*/
|
|
236
|
+
export function stepInputForEnvironment(input, env, at, options = {}) {
|
|
237
|
+
const resolved = stepForEnvironment(input, env, options);
|
|
238
|
+
if ("step" in resolved)
|
|
239
|
+
return resolved.step;
|
|
240
|
+
throw new StepEnvironmentRefusedError([refusalOf(at, env, resolved)]);
|
|
241
|
+
}
|
|
242
|
+
function refusalOf(at, env, failed) {
|
|
243
|
+
return {
|
|
244
|
+
...at,
|
|
245
|
+
env,
|
|
246
|
+
named: failed.named,
|
|
247
|
+
message: `component "${at.component}": its ${at.kind} step in phase "${at.phase}" can't run in ${env}: ${failed.error}`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
const isPhase = (s) => isMap(s) && typeof s.phase === "string" && Array.isArray(s.steps);
|
|
251
|
+
/**
|
|
252
|
+
* `component` with every step's `environments` resolved for `env`, through
|
|
253
|
+
* `deploy`, `verify`, `rollback`, nested phases and `onFailure`, and the
|
|
254
|
+
* steps that cannot run there. A step that cannot is left as it is, so a
|
|
255
|
+
* caller that does not run the component can still read it. A gate step
|
|
256
|
+
* that does not apply in `env` is taken out of its phase and listed on the
|
|
257
|
+
* phase's `skippedGates` and in `skippedGates` here (#5401). A component
|
|
258
|
+
* with no such step comes back as the same object.
|
|
259
|
+
*/
|
|
260
|
+
export function componentForEnvironment(component, env, options = {}) {
|
|
261
|
+
const refusals = [];
|
|
262
|
+
const skippedGates = [];
|
|
263
|
+
let changed = false;
|
|
264
|
+
const walkPhase = (phase) => {
|
|
265
|
+
let touched = false;
|
|
266
|
+
const skippedHere = [];
|
|
267
|
+
const steps = phase.steps.flatMap((step) => {
|
|
268
|
+
if (isPhase(step)) {
|
|
269
|
+
const next = walkPhase(step);
|
|
270
|
+
if (next !== step)
|
|
271
|
+
touched = true;
|
|
272
|
+
return [next];
|
|
273
|
+
}
|
|
274
|
+
if (!isMap(step) || !hasStepEnvironments(step))
|
|
275
|
+
return [step];
|
|
276
|
+
const at = { component: component.name, phase: phase.phase, kind: String(step.kind) };
|
|
277
|
+
if (step.kind === "gate") {
|
|
278
|
+
const gate = gateForEnvironment(step, env, options);
|
|
279
|
+
if ("error" in gate) {
|
|
280
|
+
refusals.push(refusalOf({ ...at, kind: `gate "${gateNameOf(step)}"` }, env, gate));
|
|
281
|
+
return [step];
|
|
282
|
+
}
|
|
283
|
+
touched = true;
|
|
284
|
+
if ("step" in gate)
|
|
285
|
+
return [gate.step];
|
|
286
|
+
skippedHere.push(gate.skipped);
|
|
287
|
+
skippedGates.push({ component: component.name, phase: phase.phase, ...gate.skipped });
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
const resolved = stepForEnvironment(step, env, options);
|
|
291
|
+
if ("error" in resolved) {
|
|
292
|
+
refusals.push(refusalOf(at, env, resolved));
|
|
293
|
+
return [step];
|
|
294
|
+
}
|
|
295
|
+
touched = true;
|
|
296
|
+
return [resolved.step];
|
|
297
|
+
});
|
|
298
|
+
const onFailure = phase.onFailure?.map(walkPhase);
|
|
299
|
+
if (onFailure?.some((p, i) => p !== phase.onFailure[i]))
|
|
300
|
+
touched = true;
|
|
301
|
+
if (!touched)
|
|
302
|
+
return phase;
|
|
303
|
+
changed = true;
|
|
304
|
+
return {
|
|
305
|
+
...phase,
|
|
306
|
+
steps,
|
|
307
|
+
...(onFailure ? { onFailure } : {}),
|
|
308
|
+
...(skippedHere.length > 0 ? { skippedGates: [...(phase.skippedGates ?? []), ...skippedHere] } : {}),
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
const walk = (phases) => phases?.map(walkPhase);
|
|
312
|
+
const deploy = walk(component.deploy);
|
|
313
|
+
const verify = walk(component.verify);
|
|
314
|
+
const rollback = walk(component.rollback);
|
|
315
|
+
if (!changed)
|
|
316
|
+
return { component, refusals, skippedGates };
|
|
317
|
+
return {
|
|
318
|
+
component: { ...component, deploy, ...(verify ? { verify } : {}), ...(rollback ? { rollback } : {}) },
|
|
319
|
+
refusals,
|
|
320
|
+
skippedGates,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/** The gate steps a component skips, read off its resolved phases' `skippedGates`, nested phases and `onFailure` included (#5401). */
|
|
324
|
+
export function skippedGatesOf(component) {
|
|
325
|
+
const out = [];
|
|
326
|
+
const walk = (phase) => {
|
|
327
|
+
for (const s of phase.skippedGates ?? [])
|
|
328
|
+
out.push({ component: component.name, phase: phase.phase, ...s });
|
|
329
|
+
for (const step of phase.steps)
|
|
330
|
+
if (isPhase(step))
|
|
331
|
+
walk(step);
|
|
332
|
+
phase.onFailure?.forEach(walk);
|
|
333
|
+
};
|
|
334
|
+
for (const phases of [component.deploy, component.verify, component.rollback])
|
|
335
|
+
phases?.forEach(walk);
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Every gate step whose `environments` names an environment outside
|
|
340
|
+
* `declared`, or cannot be read, for `chant build` to refuse (#5401). A gate
|
|
341
|
+
* that names a misspelt environment would otherwise be skipped in the one it
|
|
342
|
+
* was meant for. `declared` holds the member's `environments`, its
|
|
343
|
+
* pipeline's stages and each component's own `environments`.
|
|
344
|
+
*/
|
|
345
|
+
export function unknownGateEnvironments(components, declared) {
|
|
346
|
+
const out = [];
|
|
347
|
+
const known = [...declared].sort();
|
|
348
|
+
const knownText = known.length > 0 ? `the member declares ${known.join(", ")}` : "the member declares no environments";
|
|
349
|
+
for (const component of components) {
|
|
350
|
+
const walk = (phase) => {
|
|
351
|
+
for (const step of phase.steps) {
|
|
352
|
+
if (isPhase(step)) {
|
|
353
|
+
walk(step);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (!isMap(step) || step.kind !== "gate" || !hasStepEnvironments(step))
|
|
357
|
+
continue;
|
|
358
|
+
const gate = gateNameOf(step);
|
|
359
|
+
const where = `component "${component.name}": gate "${gate}" in phase "${phase.phase}"`;
|
|
360
|
+
const read = gateEnvironmentMap(step[STEP_ENVIRONMENTS_KEY]);
|
|
361
|
+
if ("error" in read) {
|
|
362
|
+
out.push({ component: component.name, phase: phase.phase, gate, unknown: [], message: `${where}: its \`${STEP_ENVIRONMENTS_KEY}\` ${read.error}` });
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const unknown = Object.keys(read.map).filter((name) => !declared.has(name));
|
|
366
|
+
if (unknown.length > 0) {
|
|
367
|
+
out.push({ component: component.name, phase: phase.phase, gate, unknown, message: `${where} names ${unknown.join(", ")} in \`${STEP_ENVIRONMENTS_KEY}\`, and ${knownText}` });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
phase.onFailure?.forEach(walk);
|
|
371
|
+
};
|
|
372
|
+
for (const phases of [component.deploy, component.verify, component.rollback])
|
|
373
|
+
phases?.forEach(walk);
|
|
374
|
+
}
|
|
375
|
+
return out;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Every component resolved for `env`. Throws a
|
|
379
|
+
* {@link StepEnvironmentRefusedError} naming each step that cannot run
|
|
380
|
+
* there, with the environments it names, before anything runs.
|
|
381
|
+
*/
|
|
382
|
+
export function componentsForEnvironment(components, env, options = {}) {
|
|
383
|
+
const refusals = [];
|
|
384
|
+
const out = components.map((c) => {
|
|
385
|
+
const resolved = componentForEnvironment(c, env, options);
|
|
386
|
+
refusals.push(...resolved.refusals);
|
|
387
|
+
return resolved.component;
|
|
388
|
+
});
|
|
389
|
+
if (refusals.length > 0)
|
|
390
|
+
throw new StepEnvironmentRefusedError(refusals);
|
|
391
|
+
return out;
|
|
392
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning dependents again when an upstream's outputs change (#5345).
|
|
3
|
+
*
|
|
4
|
+
* Waves order a member after the members it reads, so a change that touches
|
|
5
|
+
* both plans and applies them in turn. A dependent the change does not touch
|
|
6
|
+
* is not planned: once its upstream applies with an output it reads changed,
|
|
7
|
+
* it holds a value from before. This module finds those dependents and, for
|
|
8
|
+
* the members that opt in, plans them. It never applies.
|
|
9
|
+
*
|
|
10
|
+
* - After an apply, each applied member's outputs are digested, one digest
|
|
11
|
+
* per output ({@link outputDigests}), and compared with the digests its
|
|
12
|
+
* last apply recorded on the environment's ledger
|
|
13
|
+
* (`<env>/outputs.jsonl` on `chant/lifecycle`, {@link OUTPUT_RECORDS_FILE}).
|
|
14
|
+
* Only digests are kept, never a value. A member with no record yet has
|
|
15
|
+
* nothing to compare with, and its first record is written.
|
|
16
|
+
* - An output the engine marks sensitive or secret (`markedOutputs`: a
|
|
17
|
+
* Terraform output with `sensitive = true`, a Pulumi secret) gets no
|
|
18
|
+
* digest at all, since a digest of a short secret can be guessed back. Its
|
|
19
|
+
* name is recorded, and it counts as changed whenever its member applied.
|
|
20
|
+
* - The reads between members come from every source chant orders waves by
|
|
21
|
+
* ({@link upstreamReadsOf}): `stackOutput()` references in a step's input,
|
|
22
|
+
* a capability's `groupReads` (a Terraform root's `terraform_remote_state`)
|
|
23
|
+
* and its `declaredReads` or `graphReads` (a Pulumi program's
|
|
24
|
+
* `StackReference`, after #5331). A read that names no output counts as a
|
|
25
|
+
* read of every output.
|
|
26
|
+
* - The dependents of a changed output are listed for every applied member
|
|
27
|
+
* ({@link dependentsOfChange}). Members that applied in the same run are
|
|
28
|
+
* left out, since waves already ran them after their upstreams.
|
|
29
|
+
* - For each applied member that `replanDependents` names (member names, or
|
|
30
|
+
* patterns where `*` matches within one path segment and `**` across), its
|
|
31
|
+
* dependents are planned with `planPrSet`, as a pull request's members are,
|
|
32
|
+
* and the set's digest goes to the gate the caller decides
|
|
33
|
+
* ({@link ReplanOptions.decide}): the pending fact's description names the
|
|
34
|
+
* upstream change. Nothing here calls a capability's `run`. An apply of the
|
|
35
|
+
* plan goes through the dependent's own pipeline and its gate.
|
|
36
|
+
*
|
|
37
|
+
* Off by default: with no member named, the dependents are listed and
|
|
38
|
+
* nothing is planned.
|
|
39
|
+
*/
|
|
40
|
+
import type { PrApproval, PrMember } from "../pr-loop.js";
|
|
41
|
+
import type { CapabilityRegistry, DeployContext } from "./capability.js";
|
|
42
|
+
import { type DriverComponent } from "./driver.js";
|
|
43
|
+
import { type FanOutPlan } from "./fan-out.js";
|
|
44
|
+
import type { PrPlanSet } from "./pr-run.js";
|
|
45
|
+
/**
|
|
46
|
+
* The first chant that compares a member's outputs after an apply with the
|
|
47
|
+
* ones its last apply recorded, lists the dependents that read a changed
|
|
48
|
+
* output, and plans them for the members `replanDependents` names: in a wave
|
|
49
|
+
* job once the wave applied, with `chant components replan`, and with
|
|
50
|
+
* `replanAfterApply`. A sensitive or secret output gets no digest (#5345).
|
|
51
|
+
*/
|
|
52
|
+
export declare const UPSTREAM_REPLAN_FLOOR = "0.124.110";
|
|
53
|
+
/** The ledger file an environment's output records are kept in, beside its `releases.jsonl`. */
|
|
54
|
+
export declare const OUTPUT_RECORDS_FILE = "outputs.jsonl";
|
|
55
|
+
/** The suffix of the gate a re-plan waits at: `<gate>-replan`. */
|
|
56
|
+
export declare function replanGate(gate: string): string;
|
|
57
|
+
/** One line of `<env>/outputs.jsonl`: a member's output digests after an apply. */
|
|
58
|
+
export interface OutputRecord {
|
|
59
|
+
version: 1;
|
|
60
|
+
kind: "outputs";
|
|
61
|
+
member: string;
|
|
62
|
+
env: string;
|
|
63
|
+
/** Output name to its digest. Never a value, and never a sensitive output. */
|
|
64
|
+
digests: Record<string, string>;
|
|
65
|
+
/** The outputs the engine marked sensitive or secret: named, never digested. */
|
|
66
|
+
sensitive?: string[];
|
|
67
|
+
at: string;
|
|
68
|
+
/** The commit the apply ran at, when known. */
|
|
69
|
+
gitSha?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Where output records are read and written. */
|
|
72
|
+
export interface OutputRecordPort {
|
|
73
|
+
read(env: string): Promise<OutputRecord[]>;
|
|
74
|
+
append(env: string, records: readonly OutputRecord[]): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/** {@link OutputRecordPort} on `chant/lifecycle`, at `<env>/outputs.jsonl`. */
|
|
77
|
+
export declare function gitOutputRecordPort(opts?: {
|
|
78
|
+
cwd?: string;
|
|
79
|
+
}): OutputRecordPort;
|
|
80
|
+
/** The records in a ledger file's text, malformed lines left out. */
|
|
81
|
+
export declare function parseOutputRecords(text: string): OutputRecord[];
|
|
82
|
+
/** Each output's digest, by name, the `sensitive` ones left out. Values are digested, never kept. */
|
|
83
|
+
export declare function outputDigests(outputs: Record<string, unknown>, sensitive?: readonly string[]): Record<string, string>;
|
|
84
|
+
/** The outputs whose digest differs between `before` and `after`, added and removed ones too, sorted. */
|
|
85
|
+
export declare function changedOutputs(before: Record<string, string>, after: Record<string, string>): string[];
|
|
86
|
+
/** A read of one member's output by another, and where chant found it. */
|
|
87
|
+
export interface UpstreamRead {
|
|
88
|
+
reader: string;
|
|
89
|
+
upstream: string;
|
|
90
|
+
/** The output read. Absent when the source names none: the read counts for every output. */
|
|
91
|
+
output?: string;
|
|
92
|
+
/** `wiring`: a `stackOutput()` in the step. `group`: `groupReads`. `declared`: `declaredReads` or `graphReads`. */
|
|
93
|
+
via: "wiring" | "group" | "declared";
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Every read between `components` (#5345): `stackOutput()` references in
|
|
97
|
+
* their steps, the reads capabilities report through `groupReads`, and those
|
|
98
|
+
* they report through `graphReads` or `declaredReads`, each step read for
|
|
99
|
+
* `env`. A capability that throws reports none. Sorted, each once.
|
|
100
|
+
*/
|
|
101
|
+
export declare function upstreamReadsOf(components: readonly DriverComponent[], registry: CapabilityRegistry, root: string, ctxOf: (component: string) => DeployContext, env: string): Promise<UpstreamRead[]>;
|
|
102
|
+
/**
|
|
103
|
+
* A component's outputs as its steps' capabilities read them now, with the
|
|
104
|
+
* names they mark sensitive (#5345): `markedOutputs` where a capability has
|
|
105
|
+
* it, else `outputs` with none marked. Undefined when no step can say.
|
|
106
|
+
*/
|
|
107
|
+
export declare function readMarkedOutputs(component: DriverComponent, registry: CapabilityRegistry, ctx: DeployContext): Promise<{
|
|
108
|
+
outputs: Record<string, unknown>;
|
|
109
|
+
sensitive: string[];
|
|
110
|
+
} | undefined>;
|
|
111
|
+
/** A dependent of a changed upstream: the changed outputs it reads. */
|
|
112
|
+
export interface ChangedDependent {
|
|
113
|
+
member: string;
|
|
114
|
+
/** The changed outputs it reads, sorted. A read naming no output lists every changed one. */
|
|
115
|
+
outputs: string[];
|
|
116
|
+
}
|
|
117
|
+
/** The members that read one of `changed` of `upstream`, each with the outputs, sorted by member. */
|
|
118
|
+
export declare function dependentsOfChange(upstream: string, changed: readonly string[], reads: readonly UpstreamRead[]): ChangedDependent[];
|
|
119
|
+
/** Whether `patterns` names `member`. */
|
|
120
|
+
export declare function replanNames(patterns: readonly string[], member: string): boolean;
|
|
121
|
+
/** What changed in one applied member, and who reads it. */
|
|
122
|
+
export interface UpstreamChange {
|
|
123
|
+
member: string;
|
|
124
|
+
/** The outputs whose digest moved since the last record, sorted. */
|
|
125
|
+
changed: string[];
|
|
126
|
+
/** No record stood before this apply, so nothing was compared. */
|
|
127
|
+
first?: true;
|
|
128
|
+
/** The members outside the apply that read a changed output. */
|
|
129
|
+
dependents: ChangedDependent[];
|
|
130
|
+
/** Whether `replanDependents` names the member, so its dependents are planned. */
|
|
131
|
+
replan: boolean;
|
|
132
|
+
}
|
|
133
|
+
/** The plan of the dependents, and where its gate stands. */
|
|
134
|
+
export interface ReplanPlanned {
|
|
135
|
+
gate: string;
|
|
136
|
+
digest: string;
|
|
137
|
+
/** The planned components, in plan order. */
|
|
138
|
+
components: string[];
|
|
139
|
+
members: PrMember[];
|
|
140
|
+
approval: PrApproval;
|
|
141
|
+
/** A component failed to plan; nothing was sent to the gate. */
|
|
142
|
+
failed: boolean;
|
|
143
|
+
/** The pending fact's description: the upstream change that started the plan. */
|
|
144
|
+
description: string;
|
|
145
|
+
}
|
|
146
|
+
/** What {@link replanAfterApply} found and did. */
|
|
147
|
+
export interface ReplanResult {
|
|
148
|
+
env: string;
|
|
149
|
+
changes: UpstreamChange[];
|
|
150
|
+
/** Absent when no member that opted in changed an output a dependent reads, or under `dryRun`. */
|
|
151
|
+
planned?: ReplanPlanned;
|
|
152
|
+
/** Records written for the applied members whose digests moved, or that had none. */
|
|
153
|
+
recorded: string[];
|
|
154
|
+
}
|
|
155
|
+
/** How {@link replanAfterApply} plans the dependents. */
|
|
156
|
+
export type ReplanPlanner = (input: {
|
|
157
|
+
components: DriverComponent[];
|
|
158
|
+
plan: FanOutPlan;
|
|
159
|
+
registry: CapabilityRegistry;
|
|
160
|
+
env: string;
|
|
161
|
+
vars?: Record<string, unknown>;
|
|
162
|
+
}) => Promise<PrPlanSet>;
|
|
163
|
+
export interface ReplanOptions {
|
|
164
|
+
/** Every component in the project, declared reads applied. */
|
|
165
|
+
components: DriverComponent[];
|
|
166
|
+
registry: CapabilityRegistry;
|
|
167
|
+
root: string;
|
|
168
|
+
env: string;
|
|
169
|
+
vars?: Record<string, unknown>;
|
|
170
|
+
/** The members that applied, each with the outputs standing after the apply. */
|
|
171
|
+
applied: Record<string, Record<string, unknown>>;
|
|
172
|
+
/** Per applied member, the outputs the engine marks sensitive or secret: no digest, and changed on every apply. */
|
|
173
|
+
sensitive?: Record<string, readonly string[]>;
|
|
174
|
+
/** The members whose dependents are planned (`replanDependents`). Empty: list only. */
|
|
175
|
+
replanDependents: readonly string[];
|
|
176
|
+
records: OutputRecordPort;
|
|
177
|
+
/** The gate the plan waits at, before {@link replanGate}. */
|
|
178
|
+
gate: string;
|
|
179
|
+
/**
|
|
180
|
+
* Record the plan at its gate and say where the approval stands. Called
|
|
181
|
+
* once with the set's digest and a description naming the upstream
|
|
182
|
+
* change. The plan never applies here, whatever it answers.
|
|
183
|
+
*/
|
|
184
|
+
decide: (input: {
|
|
185
|
+
gate: string;
|
|
186
|
+
set: PrPlanSet;
|
|
187
|
+
description: string;
|
|
188
|
+
}) => Promise<PrApproval>;
|
|
189
|
+
/** Plans the dependents. Default `planPrSet`. */
|
|
190
|
+
planner?: ReplanPlanner;
|
|
191
|
+
/** List and record nothing, plan nothing. */
|
|
192
|
+
dryRun?: boolean;
|
|
193
|
+
gitSha?: string;
|
|
194
|
+
now?: () => string;
|
|
195
|
+
}
|
|
196
|
+
/** The description a re-plan's pending fact carries: each upstream change, and who reads it. */
|
|
197
|
+
export declare function replanDescription(changes: readonly UpstreamChange[], gitSha?: string): string;
|
|
198
|
+
/** Compare, record, list, and for the members that opt in, plan the dependents. Never applies. */
|
|
199
|
+
export declare function replanAfterApply(options: ReplanOptions): Promise<ReplanResult>;
|
|
200
|
+
/** The note a re-plan leaves: each upstream change, who reads it, and the plan's gate. Markdown. */
|
|
201
|
+
export declare function replanNote(result: ReplanResult, op: string): string;
|