@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,249 @@
|
|
|
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 { computePlanDigest } from "../lifecycle/plan-digest.js";
|
|
41
|
+
import { opWaveRunMatches } from "../op/op-waves.js";
|
|
42
|
+
import { graphReadsOf } from "./declared-reads.js";
|
|
43
|
+
import { wiringReferencesAt } from "./driver.js";
|
|
44
|
+
import { planFanOut } from "./fan-out.js";
|
|
45
|
+
import { capabilityGroupReads } from "./groups.js";
|
|
46
|
+
import { componentForEnvironment } from "./step-environments.js";
|
|
47
|
+
import { capabilitySteps } from "./wave-plan.js";
|
|
48
|
+
/**
|
|
49
|
+
* The first chant that compares a member's outputs after an apply with the
|
|
50
|
+
* ones its last apply recorded, lists the dependents that read a changed
|
|
51
|
+
* output, and plans them for the members `replanDependents` names: in a wave
|
|
52
|
+
* job once the wave applied, with `chant components replan`, and with
|
|
53
|
+
* `replanAfterApply`. A sensitive or secret output gets no digest (#5345).
|
|
54
|
+
*/
|
|
55
|
+
export const UPSTREAM_REPLAN_FLOOR = "0.124.110";
|
|
56
|
+
/** The ledger file an environment's output records are kept in, beside its `releases.jsonl`. */
|
|
57
|
+
export const OUTPUT_RECORDS_FILE = "outputs.jsonl";
|
|
58
|
+
/** The suffix of the gate a re-plan waits at: `<gate>-replan`. */
|
|
59
|
+
export function replanGate(gate) {
|
|
60
|
+
return `${gate}-replan`;
|
|
61
|
+
}
|
|
62
|
+
/** {@link OutputRecordPort} on `chant/lifecycle`, at `<env>/outputs.jsonl`. */
|
|
63
|
+
export function gitOutputRecordPort(opts = {}) {
|
|
64
|
+
return {
|
|
65
|
+
async read(env) {
|
|
66
|
+
const { readBlobFromPath } = await import("../lifecycle/git.js");
|
|
67
|
+
return parseOutputRecords((await readBlobFromPath(env, OUTPUT_RECORDS_FILE, opts)) ?? "");
|
|
68
|
+
},
|
|
69
|
+
async append(env, records) {
|
|
70
|
+
const { appendLedgerLine } = await import("../lifecycle/git.js");
|
|
71
|
+
for (const r of records)
|
|
72
|
+
await appendLedgerLine(env, OUTPUT_RECORDS_FILE, JSON.stringify(r), `chant: outputs of ${r.member} in ${env}`, opts);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** The records in a ledger file's text, malformed lines left out. */
|
|
77
|
+
export function parseOutputRecords(text) {
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const line of text.split("\n")) {
|
|
80
|
+
if (line.trim() === "")
|
|
81
|
+
continue;
|
|
82
|
+
try {
|
|
83
|
+
const r = JSON.parse(line);
|
|
84
|
+
if (r.kind === "outputs" && typeof r.member === "string" && typeof r.env === "string" && r.digests && typeof r.digests === "object")
|
|
85
|
+
out.push(r);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// A line that does not read is skipped.
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** Each output's digest, by name, the `sensitive` ones left out. Values are digested, never kept. */
|
|
94
|
+
export function outputDigests(outputs, sensitive = []) {
|
|
95
|
+
const secret = new Set(sensitive);
|
|
96
|
+
return Object.fromEntries(Object.keys(outputs)
|
|
97
|
+
.filter((name) => !secret.has(name))
|
|
98
|
+
.sort()
|
|
99
|
+
.map((name) => [name, computePlanDigest("output", outputs[name] ?? null)]));
|
|
100
|
+
}
|
|
101
|
+
/** The outputs whose digest differs between `before` and `after`, added and removed ones too, sorted. */
|
|
102
|
+
export function changedOutputs(before, after) {
|
|
103
|
+
const names = new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
104
|
+
return [...names].filter((n) => before[n] !== after[n]).sort();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Every read between `components` (#5345): `stackOutput()` references in
|
|
108
|
+
* their steps, the reads capabilities report through `groupReads`, and those
|
|
109
|
+
* they report through `graphReads` or `declaredReads`, each step read for
|
|
110
|
+
* `env`. A capability that throws reports none. Sorted, each once.
|
|
111
|
+
*/
|
|
112
|
+
export async function upstreamReadsOf(components, registry, root, ctxOf, env) {
|
|
113
|
+
const names = new Set(components.map((c) => c.name));
|
|
114
|
+
const found = new Map();
|
|
115
|
+
const add = (r) => {
|
|
116
|
+
if (r.reader === r.upstream || !names.has(r.reader) || !names.has(r.upstream))
|
|
117
|
+
return;
|
|
118
|
+
found.set(`${r.reader}\u0000${r.upstream}\u0000${r.output ?? ""}\u0000${r.via}`, r);
|
|
119
|
+
};
|
|
120
|
+
for (const c of components) {
|
|
121
|
+
const resolved = componentForEnvironment(c, env).component;
|
|
122
|
+
for (const step of capabilitySteps(resolved.deploy)) {
|
|
123
|
+
const { kind: _kind, ...rest } = step;
|
|
124
|
+
for (const ref of wiringReferencesAt(rest))
|
|
125
|
+
add({ reader: c.name, upstream: ref.source, ...(ref.output ? { output: ref.output } : {}), via: "wiring" });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (const r of await capabilityGroupReads(components, registry, env, ctxOf))
|
|
129
|
+
add({ reader: r.reader, upstream: r.upstream, ...(r.output ? { output: r.output } : {}), via: "group" });
|
|
130
|
+
for (const r of await graphReadsOf(components, registry, root, { env })) {
|
|
131
|
+
if (r.upstream !== undefined)
|
|
132
|
+
add({ reader: r.reader, upstream: r.upstream, ...(r.output ? { output: r.output } : {}), via: "declared" });
|
|
133
|
+
}
|
|
134
|
+
return [...found.values()].sort((a, b) => a.reader.localeCompare(b.reader) || a.upstream.localeCompare(b.upstream) || (a.output ?? "").localeCompare(b.output ?? "") || a.via.localeCompare(b.via));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A component's outputs as its steps' capabilities read them now, with the
|
|
138
|
+
* names they mark sensitive (#5345): `markedOutputs` where a capability has
|
|
139
|
+
* it, else `outputs` with none marked. Undefined when no step can say.
|
|
140
|
+
*/
|
|
141
|
+
export async function readMarkedOutputs(component, registry, ctx) {
|
|
142
|
+
let found;
|
|
143
|
+
for (const step of capabilitySteps(componentForEnvironment(component, ctx.env).component.deploy)) {
|
|
144
|
+
if (!registry.has(step.kind))
|
|
145
|
+
continue;
|
|
146
|
+
const capability = registry.resolve(step.kind);
|
|
147
|
+
const { kind: _kind, ...input } = step;
|
|
148
|
+
if (typeof capability.markedOutputs === "function") {
|
|
149
|
+
const got = await capability.markedOutputs(ctx, input);
|
|
150
|
+
found = { outputs: { ...found?.outputs, ...got.outputs }, sensitive: [...new Set([...(found?.sensitive ?? []), ...got.sensitive])].sort() };
|
|
151
|
+
}
|
|
152
|
+
else if (typeof capability.outputs === "function") {
|
|
153
|
+
found = { outputs: { ...found?.outputs, ...(await capability.outputs(ctx, input)) }, sensitive: found?.sensitive ?? [] };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return found;
|
|
157
|
+
}
|
|
158
|
+
/** The members that read one of `changed` of `upstream`, each with the outputs, sorted by member. */
|
|
159
|
+
export function dependentsOfChange(upstream, changed, reads) {
|
|
160
|
+
if (changed.length === 0)
|
|
161
|
+
return [];
|
|
162
|
+
const by = new Map();
|
|
163
|
+
for (const r of reads) {
|
|
164
|
+
if (r.upstream !== upstream)
|
|
165
|
+
continue;
|
|
166
|
+
const hit = r.output === undefined ? changed : changed.filter((o) => o === r.output);
|
|
167
|
+
if (hit.length === 0)
|
|
168
|
+
continue;
|
|
169
|
+
const set = by.get(r.reader) ?? new Set();
|
|
170
|
+
for (const o of hit)
|
|
171
|
+
set.add(o);
|
|
172
|
+
by.set(r.reader, set);
|
|
173
|
+
}
|
|
174
|
+
return [...by].map(([member, outputs]) => ({ member, outputs: [...outputs].sort() })).sort((a, b) => a.member.localeCompare(b.member));
|
|
175
|
+
}
|
|
176
|
+
/** Whether `patterns` names `member`. */
|
|
177
|
+
export function replanNames(patterns, member) {
|
|
178
|
+
return patterns.some((p) => opWaveRunMatches(p, member));
|
|
179
|
+
}
|
|
180
|
+
/** The description a re-plan's pending fact carries: each upstream change, and who reads it. */
|
|
181
|
+
export function replanDescription(changes, gitSha) {
|
|
182
|
+
const parts = changes
|
|
183
|
+
.filter((c) => c.replan && c.dependents.length > 0)
|
|
184
|
+
.map((c) => `${c.member} applied${gitSha ? ` at ${gitSha.slice(0, 12)}` : ""} with ${c.changed.join(", ")} changed, read by ${c.dependents.map((d) => d.member).join(", ")}`);
|
|
185
|
+
return `planned again after an upstream output changed: ${parts.join("; ")}`;
|
|
186
|
+
}
|
|
187
|
+
/** Compare, record, list, and for the members that opt in, plan the dependents. Never applies. */
|
|
188
|
+
export async function replanAfterApply(options) {
|
|
189
|
+
const now = options.now ?? (() => new Date().toISOString());
|
|
190
|
+
const ctxOf = (component) => ({ env: options.env, component, ...(options.vars ? { vars: options.vars } : {}) });
|
|
191
|
+
const reads = await upstreamReadsOf(options.components, options.registry, options.root, ctxOf, options.env);
|
|
192
|
+
const prior = new Map();
|
|
193
|
+
for (const r of await options.records.read(options.env))
|
|
194
|
+
if (r.env === options.env)
|
|
195
|
+
prior.set(r.member, r);
|
|
196
|
+
const appliedNames = new Set(Object.keys(options.applied));
|
|
197
|
+
const changes = [];
|
|
198
|
+
const toRecord = [];
|
|
199
|
+
for (const member of [...appliedNames].sort()) {
|
|
200
|
+
const secret = [...(options.sensitive?.[member] ?? [])].filter((n) => n in options.applied[member]).sort();
|
|
201
|
+
const digests = outputDigests(options.applied[member], secret);
|
|
202
|
+
const before = prior.get(member);
|
|
203
|
+
const moved = before ? changedOutputs(before.digests, digests) : [];
|
|
204
|
+
const changed = before ? [...new Set([...moved, ...secret])].sort() : [];
|
|
205
|
+
const sameSecrets = JSON.stringify(before?.sensitive ?? []) === JSON.stringify(secret);
|
|
206
|
+
if (!before || moved.length > 0 || !sameSecrets) {
|
|
207
|
+
toRecord.push({ version: 1, kind: "outputs", member, env: options.env, digests, ...(secret.length > 0 ? { sensitive: secret } : {}), at: now(), ...(options.gitSha ? { gitSha: options.gitSha } : {}) });
|
|
208
|
+
}
|
|
209
|
+
const dependents = dependentsOfChange(member, changed, reads).filter((d) => !appliedNames.has(d.member));
|
|
210
|
+
changes.push({ member, changed, ...(before ? {} : { first: true }), dependents, replan: replanNames(options.replanDependents, member) });
|
|
211
|
+
}
|
|
212
|
+
if (options.dryRun)
|
|
213
|
+
return { env: options.env, changes, recorded: [] };
|
|
214
|
+
await options.records.append(options.env, toRecord);
|
|
215
|
+
const starting = changes.filter((c) => c.replan && c.dependents.length > 0);
|
|
216
|
+
const result = { env: options.env, changes, recorded: toRecord.map((r) => r.member) };
|
|
217
|
+
if (starting.length === 0)
|
|
218
|
+
return result;
|
|
219
|
+
const dependents = [...new Set(starting.flatMap((c) => c.dependents.map((d) => d.member)))].sort();
|
|
220
|
+
const plan = planFanOut({ components: options.components, changed: dependents });
|
|
221
|
+
const planner = options.planner ?? (async (input) => (await import("./pr-run.js")).planPrSet(input));
|
|
222
|
+
const set = await planner({ components: options.components, plan, registry: options.registry, env: options.env, ...(options.vars ? { vars: options.vars } : {}) });
|
|
223
|
+
const gate = replanGate(options.gate);
|
|
224
|
+
const description = replanDescription(changes, options.gitSha);
|
|
225
|
+
const approval = set.failed ? { status: "pending" } : await options.decide({ gate, set, description });
|
|
226
|
+
result.planned = { gate, digest: set.doc.digest, components: plan.order, members: set.members, approval, failed: set.failed, description };
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
/** The note a re-plan leaves: each upstream change, who reads it, and the plan's gate. Markdown. */
|
|
230
|
+
export function replanNote(result, op) {
|
|
231
|
+
const lines = [`### Dependents of changed outputs in ${result.env}`, ""];
|
|
232
|
+
const moved = result.changes.filter((c) => c.dependents.length > 0);
|
|
233
|
+
if (moved.length === 0)
|
|
234
|
+
lines.push("No applied member changed an output another member reads.");
|
|
235
|
+
for (const c of moved) {
|
|
236
|
+
lines.push(`- \`${c.member}\` changed ${c.changed.map((o) => `\`${o}\``).join(", ")}, read by ${c.dependents.map((d) => `\`${d.member}\` (${d.outputs.join(", ")})`).join(", ")}${c.replan ? "" : "; its dependents are listed, and `replanDependents` names it to plan them"}.`);
|
|
237
|
+
}
|
|
238
|
+
const p = result.planned;
|
|
239
|
+
if (p) {
|
|
240
|
+
lines.push("", `Planned again because ${p.description.replace(/^planned again after an upstream output changed: /, "")}.`);
|
|
241
|
+
if (p.failed)
|
|
242
|
+
lines.push("", `A dependent failed to plan, so the plan was not sent to the gate.`);
|
|
243
|
+
else {
|
|
244
|
+
lines.push("", `Plan \`${p.digest}\` over ${p.components.map((c) => `\`${c}\``).join(", ")} waits at gate \`${p.gate}\`: ${p.approval.status}.`);
|
|
245
|
+
lines.push("", `It applies through the dependents' own pipeline once approved: \`chant approve ${op} ${p.gate} --plan ${p.digest}\`.`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return `${lines.join("\n")}\n`;
|
|
249
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What chant counts as a failed verify (#5339, #5328): one definition, which
|
|
3
|
+
* the verify-failed agent trigger (`../ci-agent-verify-failed.ts`) and a
|
|
4
|
+
* stage's requested rollback (`../pipeline/verify-rollback.ts`) both read, so
|
|
5
|
+
* the two agree on the same failure.
|
|
6
|
+
*
|
|
7
|
+
* A verify step is a step in a phase named `Verify`, or a step of a
|
|
8
|
+
* wait-and-verify kind ({@link VERIFY_STEP_KINDS}) wherever its phase is. A
|
|
9
|
+
* run that failed at any other step, such as an apply, failed but did not
|
|
10
|
+
* fail its verify.
|
|
11
|
+
*
|
|
12
|
+
* Bundle-safe: this module imports nothing.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The step kinds a failed promote counts as a failed verify wherever their
|
|
16
|
+
* phase is: core's wait-and-verify verbs (`STARTER_VERB_FAMILIES.waitVerify`
|
|
17
|
+
* in `./starter-plugin.ts`) and the HTTP check.
|
|
18
|
+
*/
|
|
19
|
+
export declare const VERIFY_STEP_KINDS: readonly string[];
|
|
20
|
+
/** Whether a step is a verify step: in a phase named `Verify`, or of a kind in {@link VERIFY_STEP_KINDS}. */
|
|
21
|
+
export declare function isVerifyStep(step: {
|
|
22
|
+
phase: string;
|
|
23
|
+
kind: string;
|
|
24
|
+
}): boolean;
|
|
25
|
+
/** Whether a run's step records hold a failed verify step: a record with status `fail` that {@link isVerifyStep} names. */
|
|
26
|
+
export declare function failedVerify(records: readonly {
|
|
27
|
+
phase: string;
|
|
28
|
+
kind: string;
|
|
29
|
+
status: string;
|
|
30
|
+
}[]): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What chant counts as a failed verify (#5339, #5328): one definition, which
|
|
3
|
+
* the verify-failed agent trigger (`../ci-agent-verify-failed.ts`) and a
|
|
4
|
+
* stage's requested rollback (`../pipeline/verify-rollback.ts`) both read, so
|
|
5
|
+
* the two agree on the same failure.
|
|
6
|
+
*
|
|
7
|
+
* A verify step is a step in a phase named `Verify`, or a step of a
|
|
8
|
+
* wait-and-verify kind ({@link VERIFY_STEP_KINDS}) wherever its phase is. A
|
|
9
|
+
* run that failed at any other step, such as an apply, failed but did not
|
|
10
|
+
* fail its verify.
|
|
11
|
+
*
|
|
12
|
+
* Bundle-safe: this module imports nothing.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The step kinds a failed promote counts as a failed verify wherever their
|
|
16
|
+
* phase is: core's wait-and-verify verbs (`STARTER_VERB_FAMILIES.waitVerify`
|
|
17
|
+
* in `./starter-plugin.ts`) and the HTTP check.
|
|
18
|
+
*/
|
|
19
|
+
export const VERIFY_STEP_KINDS = ["wait-cluster-healthy", "wait-endpoint", "health-gate", "http-check"];
|
|
20
|
+
/** Whether a step is a verify step: in a phase named `Verify`, or of a kind in {@link VERIFY_STEP_KINDS}. */
|
|
21
|
+
export function isVerifyStep(step) {
|
|
22
|
+
return /^verify$/i.test(step.phase.trim()) || VERIFY_STEP_KINDS.includes(step.kind);
|
|
23
|
+
}
|
|
24
|
+
/** Whether a run's step records hold a failed verify step: a record with status `fail` that {@link isVerifyStep} names. */
|
|
25
|
+
export function failedVerify(records) {
|
|
26
|
+
return records.some((r) => r.status === "fail" && isVerifyStep(r));
|
|
27
|
+
}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* `@<component>.publish.*`) resolves.
|
|
28
28
|
*/
|
|
29
29
|
import { resolvePlannedLock } from "../lifecycle/lock-rows.js";
|
|
30
|
+
import { stepInputForEnvironment } from "./step-environments.js";
|
|
30
31
|
import { assertPlanFlagsAccepted, assertTargetsAccepted, resolveStepInput, unresolvedWiringSources } from "./driver.js";
|
|
31
32
|
import { componentPlanDigest } from "./gate-plan.js";
|
|
32
33
|
import { componentDeployInputs } from "./deploy-inputs.js";
|
|
@@ -108,7 +109,9 @@ export async function planWaveComponent(component, registry, ctx, componentOutpu
|
|
|
108
109
|
const capability = registry.resolve(step.kind);
|
|
109
110
|
if (!capability.plan)
|
|
110
111
|
continue;
|
|
111
|
-
const { kind: _kind, ...
|
|
112
|
+
const { kind: _kind, ...declared } = step;
|
|
113
|
+
// #5360: the step's inputs for this environment.
|
|
114
|
+
const rest = stepInputForEnvironment(declared, ctx.env, { component: component.name, phase: "deploy", kind: step.kind });
|
|
112
115
|
const input = resolveStepInput(rest, {}, componentOutputs);
|
|
113
116
|
const planned = bindPlanFlags(ctx, bindTargets(step.kind, ctx, await capability.plan(planContext(ctx, rest, componentOutputs), input)));
|
|
114
117
|
const member = { member: planned.member, planDigest: planned.planDigest };
|
|
@@ -244,7 +247,8 @@ export async function readComponentOutputs(component, registry, ctx, componentOu
|
|
|
244
247
|
const capability = registry.resolve(step.kind);
|
|
245
248
|
if (!capability.outputs)
|
|
246
249
|
continue;
|
|
247
|
-
const { kind: _kind, ...
|
|
250
|
+
const { kind: _kind, ...declared } = step;
|
|
251
|
+
const rest = stepInputForEnvironment(declared, ctx.env, { component: component.name, phase: "deploy", kind: step.kind });
|
|
248
252
|
const input = resolveStepInput(rest, {}, componentOutputs);
|
|
249
253
|
found = { ...found, ...(await capability.outputs(ctx, input)) };
|
|
250
254
|
}
|
|
@@ -18,8 +18,10 @@ import type { ChantConfig } from "./config.js";
|
|
|
18
18
|
*
|
|
19
19
|
* The array's order is the member's promotion order (#4030, see
|
|
20
20
|
* `./workspace/promotion-order.ts`), and `canary: true` marks a step as the
|
|
21
|
-
* canary step of that order.
|
|
22
|
-
*
|
|
21
|
+
* canary step of that order. An `environments` entry carries no soak, so a
|
|
22
|
+
* canary here holds nothing, and `chant lint` warns (COR027,
|
|
23
|
+
* `./lint/canary-checks.ts`). The canary that holds the steps after it is a
|
|
24
|
+
* stage of `.chant/pipeline.ts` marked `canary`, with a soak (#5327).
|
|
23
25
|
*
|
|
24
26
|
* `executor` names the forge and the committed workflow that deploys the
|
|
25
27
|
* environment (#4402), so a reader such as behold knows a release there runs
|
|
@@ -136,6 +136,13 @@ export interface ControlSettingsInput {
|
|
|
136
136
|
ref?: string;
|
|
137
137
|
/** The REST base, when the host's usual one is not it (a loopback forge in a test). */
|
|
138
138
|
apiBase?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Carry the release digest the applied commit was cut into (#5356), so a
|
|
141
|
+
* downstream run pins to that release's artifacts. The dispatch step looks
|
|
142
|
+
* it up with `chant pipeline release-of <sha>`; a commit with no release
|
|
143
|
+
* sends none. Default off.
|
|
144
|
+
*/
|
|
145
|
+
release?: boolean;
|
|
139
146
|
}
|
|
140
147
|
/** The control settings with the defaults filled in and the forge settled. */
|
|
141
148
|
export interface ControlTarget {
|
|
@@ -149,6 +156,8 @@ export interface ControlTarget {
|
|
|
149
156
|
ref: string;
|
|
150
157
|
tokenSecret: string;
|
|
151
158
|
readTokenSecret: string;
|
|
159
|
+
/** `control.release` (#5356): the dispatch carries the release digest of the applied commit. Absent when off. */
|
|
160
|
+
release?: true;
|
|
152
161
|
}
|
|
153
162
|
/** The problems with `control`, each naming its key under `where`. terragucci's `controlProblems` (config.ts:494). */
|
|
154
163
|
export declare function controlSettingsProblems(input: unknown, where?: string): string[];
|
|
@@ -172,6 +181,12 @@ export interface ControlDispatch {
|
|
|
172
181
|
outcome?: ControlApplyOutcome;
|
|
173
182
|
/** The train the apply answers (#5119), when the member ran for one. */
|
|
174
183
|
train?: ControlTrainAnswer;
|
|
184
|
+
/**
|
|
185
|
+
* The release digest the applied commit was cut into (#5356), sent as
|
|
186
|
+
* `release` (`CHANT_CONTROL_RELEASE`) so a downstream run reads that
|
|
187
|
+
* release's artifacts. A train's answer carries its own.
|
|
188
|
+
*/
|
|
189
|
+
releaseDigest?: string;
|
|
175
190
|
}
|
|
176
191
|
/** Where the token goes in a {@link ControlDispatchRequest}. */
|
|
177
192
|
export type ControlTokenPlace = {
|
package/dist/control/dispatch.js
CHANGED
|
@@ -168,6 +168,8 @@ export function controlSettingsProblems(input, where = "control") {
|
|
|
168
168
|
out.push(`${where}.ref must be a branch name`);
|
|
169
169
|
if (v.apiBase !== undefined && !(typeof v.apiBase === "string" && /^https?:\/\/[^\s'"]+$/.test(v.apiBase)))
|
|
170
170
|
out.push(`${where}.apiBase must be an http(s) URL`);
|
|
171
|
+
if (v.release !== undefined && typeof v.release !== "boolean")
|
|
172
|
+
out.push(`${where}.release must be true or false`);
|
|
171
173
|
return out;
|
|
172
174
|
}
|
|
173
175
|
/** `control` with its defaults filled in. `fallbackMember` is the repo's name, used when `control.member` is unset. */
|
|
@@ -191,6 +193,7 @@ export function resolveControlTarget(input, fallbackMember) {
|
|
|
191
193
|
ref: input.ref ?? CONTROL_REF_DEFAULT,
|
|
192
194
|
tokenSecret: input.tokenSecret ?? CONTROL_TOKEN_SECRET,
|
|
193
195
|
readTokenSecret: input.readTokenSecret ?? CONTROL_READ_TOKEN_SECRET,
|
|
196
|
+
...(input.release === true ? { release: true } : {}),
|
|
194
197
|
};
|
|
195
198
|
}
|
|
196
199
|
/** The event type of the GitHub `repository_dispatch` a member sends: `<product>-applied`. */
|
|
@@ -220,6 +223,10 @@ function checkDispatch(d) {
|
|
|
220
223
|
throw new ControlConfigError(`the dispatch names no commit sha ("${d.sha}")`);
|
|
221
224
|
if (d.outcome !== undefined && !CONTROL_APPLY_OUTCOMES.includes(d.outcome))
|
|
222
225
|
throw new ControlConfigError(`the dispatch's outcome "${d.outcome}" is not one of ${CONTROL_APPLY_OUTCOMES.join(", ")}`);
|
|
226
|
+
if (d.releaseDigest !== undefined && !CONTROL_RELEASE_DIGEST.test(d.releaseDigest))
|
|
227
|
+
throw new ControlConfigError(`the dispatch's release "${d.releaseDigest}" is not a release digest`);
|
|
228
|
+
if (d.releaseDigest !== undefined && d.train !== undefined && d.train.releaseDigest !== d.releaseDigest)
|
|
229
|
+
throw new ControlConfigError("the dispatch names two releases: the train's and its own");
|
|
223
230
|
if (d.train !== undefined) {
|
|
224
231
|
if (d.outcome === undefined)
|
|
225
232
|
throw new ControlConfigError("a train's answer carries the outcome of the member's run");
|
|
@@ -230,7 +237,9 @@ function checkDispatch(d) {
|
|
|
230
237
|
}
|
|
231
238
|
/** A train's answer as payload fields (#5119): the same names in a GitHub `client_payload` and Forgejo `inputs`. */
|
|
232
239
|
function trainFields(d) {
|
|
233
|
-
|
|
240
|
+
if (d.train)
|
|
241
|
+
return { train: d.train.train, run: d.train.run, env: d.train.env, release: d.train.releaseDigest };
|
|
242
|
+
return d.releaseDigest ? { release: d.releaseDigest } : {};
|
|
234
243
|
}
|
|
235
244
|
/**
|
|
236
245
|
* The request that tells the control repo `d.member` applied: GitHub's
|
|
@@ -270,7 +279,9 @@ export function controlDispatchRequest(target, d, wordsIn = {}) {
|
|
|
270
279
|
[`variables[${CONTROL_ENV_VAR}]`, d.train.env],
|
|
271
280
|
[`variables[${CONTROL_RELEASE_VAR}]`, d.train.releaseDigest],
|
|
272
281
|
]
|
|
273
|
-
:
|
|
282
|
+
: d.releaseDigest
|
|
283
|
+
? [[`variables[${CONTROL_RELEASE_VAR}]`, d.releaseDigest]]
|
|
284
|
+
: []),
|
|
274
285
|
],
|
|
275
286
|
},
|
|
276
287
|
token: { in: "form", field: "token" },
|
|
@@ -369,6 +380,8 @@ export function controlDispatchScript(target, opts = {}) {
|
|
|
369
380
|
const label = words.product;
|
|
370
381
|
const req = controlDispatchRequest(target, { member: target.member, op: target.op, sha: "0000000" }, words);
|
|
371
382
|
const tok = CONTROL_TOKEN_ENV;
|
|
383
|
+
// A train's answer carries its release already.
|
|
384
|
+
const carryRelease = target.release === true && !opts.train;
|
|
372
385
|
const lines = [
|
|
373
386
|
"set -u",
|
|
374
387
|
`member=${sq(target.member, CONTROL_NAME)}`,
|
|
@@ -392,6 +405,15 @@ export function controlDispatchScript(target, opts = {}) {
|
|
|
392
405
|
`[[ $train =~ $train_re && $run =~ $run_re && $tenv =~ $name_re && $release =~ $release_re ]] || { echo "${label}: the train's fields are not usable (train=\\"$train\\", run=\\"$run\\", env=\\"$tenv\\", release=\\"$release\\"), so ${target.repo} was not told" >&2; exit 1; }`,
|
|
393
406
|
]
|
|
394
407
|
: []),
|
|
408
|
+
// #5356: the release the applied commit was cut into, looked up on the ledger; none is sent when no release names it.
|
|
409
|
+
...(carryRelease
|
|
410
|
+
? [
|
|
411
|
+
`release="$(${CONTROL_CHANT_COMMAND} pipeline release-of "$sha" 2>/dev/null)" || release=""`,
|
|
412
|
+
...shellPatterns({ release: CONTROL_RELEASE_DIGEST }),
|
|
413
|
+
'[[ $release =~ $release_re ]] || release=""',
|
|
414
|
+
`rfield=""; [ -z "$release" ] || rfield=',"release":"'"$release"'"'`,
|
|
415
|
+
]
|
|
416
|
+
: []),
|
|
395
417
|
`[ -n "\${${tok}:-}" ] || { echo "${label}: ${tok} is empty; map the ${target.tokenSecret} secret into it, so ${target.repo} can be told" >&2; exit 1; }`,
|
|
396
418
|
...(opts.sentCheck ? [`if [ "$(${opts.sentCheck} 2>/dev/null)" = 1 ]; then echo "${label}: ${target.repo} was told about \${sha:0:8} already"; exit 0; fi`] : []),
|
|
397
419
|
'answer="$(mktemp)"',
|
|
@@ -400,7 +422,7 @@ export function controlDispatchScript(target, opts = {}) {
|
|
|
400
422
|
if (opts.train && !opts.outcome)
|
|
401
423
|
throw new ControlConfigError("a train's answer carries the outcome of the member's run; set outcome too");
|
|
402
424
|
if ("json" in req.body) {
|
|
403
|
-
const carried = `${opts.outcome ? `,"outcome":"'"$outcome"'"` : ""}${opts.train ? `,"train":"'"$train"'","run":"'"$run"'","env":"'"$tenv"'","release":"'"$release"'"` : ""}`;
|
|
425
|
+
const carried = `${opts.outcome ? `,"outcome":"'"$outcome"'"` : ""}${opts.train ? `,"train":"'"$train"'","run":"'"$run"'","env":"'"$tenv"'","release":"'"$release"'"` : ""}${carryRelease ? `'"$rfield"'` : ""}`;
|
|
404
426
|
const json = target.forge === "github"
|
|
405
427
|
? `{"event_type":"${controlDispatchEvent(words)}","client_payload":{"member":"'"$member"'","op":"'"$op"'","sha":"'"$sha"'"${carried}}}`
|
|
406
428
|
: `{"ref":"${target.ref}","inputs":{"member":"'"$member"'","op":"'"$op"'","sha":"'"$sha"'"${carried}}}`;
|
|
@@ -423,7 +445,9 @@ export function controlDispatchScript(target, opts = {}) {
|
|
|
423
445
|
`--form "variables[${CONTROL_ENV_VAR}]=$tenv"`,
|
|
424
446
|
`--form "variables[${CONTROL_RELEASE_VAR}]=$release"`,
|
|
425
447
|
]
|
|
426
|
-
:
|
|
448
|
+
: carryRelease
|
|
449
|
+
? [`--form "variables[${CONTROL_RELEASE_VAR}]=$release"`]
|
|
450
|
+
: []),
|
|
427
451
|
];
|
|
428
452
|
send = `code="$(printf '%s' "$${tok}" | curl -sS -o "$answer" -w '%{http_code}' -X POST --form 'token=<-' ${fields.join(" ")} ${sqUrl(req.url)})"`;
|
|
429
453
|
}
|