Skip to content

Op Waves

llms.txt lists every page for an agent
Optional: hand this page to your coding agentThe steps work by hand too.
Show the whole prompt
Read https://intentius.io/chant/guide/op-waves/.
Write the waves spec I describe as `waves.json`, with a `gate` on every wave past the first and the `plan` command for each target.
Run `npx chant run --generate <forge> --spec waves.json` for this repository's forge, check the generated pipeline file, and open a pull request with the spec and the pipeline.
In its description, list each wave's gate name and the `chant approve` command a person runs for it. Do not run them, and do not run `chant run wave` or `chant run resume` yourself.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.

This guide is for a project that applies the same Op to several places in order, such as dev before staging before prod, or one environment made of many databases. Each place is a run of the Op against one target. Runs that go out together form a wave, and each wave waits on one gate before it applies. chant run --generate renders the waves as a pipeline for GitHub, GitLab or Forgejo, and every job in it runs chant run wave.

The spec is a JSON file committed to the repository. Its jobs read it at run time, so the pipeline and the runs never disagree.

op names an Op that must already exist in the project, or the run stops with Unknown Op(s).

{
"name": "migrations",
"op": "migrate",
"plan": ["./bin/plan", "{target}", "{plan}"],
"apply": ["./bin/apply", "{target}", "{plan}"],
"waves": [
{ "name": "dev", "runs": [{ "target": "dev" }], "gate": "never" },
{ "name": "staging", "runs": [{ "target": "staging" }], "gate": "on-destructive" },
{ "name": "prod", "runs": [{ "target": "prod" }], "gate": "always", "environment": { "name": "production" } }
]
}
FieldMeaning
nameThe pipeline’s name, and the op every wave gate is recorded under
opThe Op a run runs when the run names none (runs[].op overrides it)
planPlans one run and writes its plan file to {plan}. Give this or planWave
applyApplies one run. Default chant run {op} --env {target}
planWavePlans every run of a wave in one call (Plan a wave in one call)
applyWaveApplies a wave’s approved set in one call, in place of apply
hooksCommands run before and after each wave’s plan and apply, read at the base commit (Stage hooks). hooks.apply.runBy: "apply" has the apply command run the apply-stage hooks under its own lock (Hooks under the apply’s lock)
approvals{ "spend": true } makes an approval good for one apply (Spend an approval). { "preview": true } makes a merged wave apply the plans its pull request previewed, or refuse (Apply what the pull request previewed). Read at the base commit
gateThe base gate name. Default: name
gateNameThe pattern of wave k’s gate name: {gate} and {k} are filled in. Default {gate}-wave-{k} (Keep a product’s gate names)
digest{ "over": "changing" } makes the set digest cover only the runs whose plan is not empty. Default { "over": "all" }
override{ "overriders": "<file>" }: who may override a run the product’s policy denied, read at the base commit. Default .chant/overriders (Policy denials)
pointA decision point every wave’s gate asks in place of the ledger, read at the base commit (Ask a decision point)
neverOverMcpThe waves’ pending facts carry neverOverMcp, so their gates are never approved over MCP or ACP. Read at the base commit too
branchesPushes to these branches run the waves. Default ["main"]
baseThe commit the gate policy is read from. Default HEAD^1
waves[].runsOne entry per target. A target appears once per wave
waves[].discoverThe runs come from planWave, or the step’s capability, at plan time, not the spec (Runs found at plan time)
waves[].togetherWith a step: plan the wave’s runs in one call of the capability and apply them in one (A wave planned as one)
waves[].restOn the last, discovering wave: once it applies, the job goes on through every wave the plan found
waves[].gatealways, on-destructive or never. Default always
waves[].approvalledger, pr-review, sealed or pull-request: which approvals count (Which approvals count). Default ledger
waves[].pointThis wave’s own decision point, in place of the spec’s
waves[].sharesSplit a wide wave into a deciding job and this many share jobs
waves[].hooksThis wave’s own hooks, run after the spec’s
waves[].environment, variables, setupThe wave’s forge environment, its jobs’ variables, and steps run after the checkout
runner, waves[].runnerWhere the jobs run: a label, a list of labels, or { "group", "labels"? } (GitHub only). runs-on on GitHub and Forgejo, tags on GitLab. A wave’s wins over the spec’s. Default: the forge’s default runner (Runners and job groups)
parallelism, waves[].parallelismHow many runs of a wave plan and apply at once, a wave’s winning over the spec’s (#4625, #4864). Default 1. Over 1 it needs step. The plans start in the wave’s order and the digest, plan files and after-plan hooks see them in that order. A run waits for each run listed before it in the wave that it depends on to apply, and is blocked when that run failed. terraform-apply and terragrunt-apply take their inits one at a time when the runs share a provider cache (TF_PLUGIN_CACHE_DIR), through the wave’s serial section (DeployContext.serial)
waves[].idTokens{ "<VARIABLE>": "<audience>" }: the OIDC tokens the wave’s jobs get (Runners and job groups)
waves[].jobsJob groups: the wave’s apply split into one job per group, each with the runs it applies and its own runner, environment, variables, setup, idTokens and shares (Runners and job groups)
resume{ "schedule": "<cron>" } renders a scheduled job that resumes waiting waves whose approval arrived (Resume the waiting job)
notifyThe environment variables holding Slack, Teams or signed webhook URLs that hear when a wave waits, is refused or fails (Notify)

The commands are argv templates. {op}, {target}, {wave} and {plan} are filled in per run. The plan command writes JSON:

{ "planDigest": "jcs1-sha256:...", "destructive": false, "empty": false }

planDigest names the plan; two plans that would do the same thing share one. destructive is what on-destructive waits on. A run whose plan is empty changes nothing, and a wave whose runs are all empty never waits.

Terminal window
chant run --generate github --spec waves.json
chant run --generate gitlab --spec waves.json
chant run --generate forgejo --spec waves.json

Run it from the repository root. GitHub and Forgejo get <name>.yml in their workflow directory, and GitLab gets <name>.gitlab-ci.yml at the root for .gitlab-ci.yml to include. The file can also hold { "waves": <spec>, "options": { ... } }, where options sets the image, beforeScript, extraScript and variables for every job. The default image is node:22, which has git; install chant in it with beforeScript. From code, generateOpWavesPipeline(spec, lexicon, { specFile }) in @intentius/chant/op does the same thing. Its bin option puts a CI product’s command in place of chant in every job line, and a product’s bin that runs the generator in process gets its own bin there without passing it (#4607).

Each wave is one job, wave-<k>-<name>, and it needs the job before it. A push to the branch runs wave 1. If a wave waits at its gate, the waves after it do not run. If a run in it fails, the next wave’s job still runs and blocks only the runs that depend on the failed one (below).

A run can list the runs it needs applied first:

{ "target": "app", "dependsOn": ["net"] }

Each entry is a target of an earlier wave, or of a run listed before it in the same wave (assertOpWaveDependsOn, packages/core/src/op/op-waves.ts:745). Inside one wave this needs a single job to apply it, so a wave with shares or jobs takes only dependencies on earlier waves.

Each wave job writes an outcome file, .chant/op-waves/<name>/outcomes/outcome-wave-<k>.json, and the forge keeps it whatever the job’s exit code. The next wave’s job downloads them and reads them (opWaveBefore, packages/core/src/op/op-waves-run.ts:1623). A run that failed, or was blocked, blocks the runs that depend on it. A blocked run is neither planned nor applied, and the log names the failed run it traces back to. A run with no failed dependency applies. Exit 1 means one of the job’s own runs failed or was blocked.

A run that waits at its gate (exit 3), or one that was refused or held, still stops the waves after it, because those runs did not apply. On GitHub and Forgejo the later jobs get if: !cancelled() (lexicons/github/src/components/generate-op-waves-pipeline.ts:139). On GitLab each job is allow_failure: { exit_codes: [1] }, so only exit 1 lets the next wave run (lexicons/gitlab/src/components/generate-op-waves-pipeline.ts). Each job starts with the apply-job guard, which checks that the job runs where the spec set it to run before any credential is traded. A refused guard exits 9, so on GitLab the job fails and the waves after it stop (#4624). Regenerate the pipeline to get them (#4322).

A wave job runs four commands: run wave, run resume, approve and workspace points. @intentius/chant also ships those four bundled into one file, dist/wave-runtime.mjs. The file is about 1.5 MB, 440 KB gzipped. Its only imports are Node’s built-in modules, so plain node 20 or later runs it with nothing installed beside it. No TypeScript compiler or bundler is in it; the libraries it does use, zod and ajv among them, are inlined.

Installing chant puts about 70 MB in node_modules. The compiler and the bundler are regular dependencies of the package, so --omit=optional and --omit=peer leave them in. To keep them out of an image, copy in the one file instead of installing chant. npm pack fetches the package without installing it:

Terminal window
npm pack @intentius/chant@<version>
tar -xzf intentius-chant-<version>.tgz package/dist/wave-runtime.mjs
install -D -m 755 package/dist/wave-runtime.mjs /opt/chant/wave-runtime.mjs
printf '#!/bin/sh\nexec node /opt/chant/wave-runtime.mjs "$@"\n' > /usr/local/bin/chant
chmod +x /usr/local/bin/chant

With that chant on the PATH, the generated jobs run unchanged. Where chant is installed anyway, run the file as node node_modules/@intentius/chant/dist/wave-runtime.mjs run wave ... or through the chant-wave bin. Its package export is @intentius/chant/wave-runtime.mjs.

The four commands are the CLI’s own code behind the same argument parser. Their flags and exit codes match chant’s, and so do the ledger lines they write. A gate ledger written by one is read by the other. Build the image from the same chant version the rest of the product runs; node wave-runtime.mjs --version prints the version the file was built from. Any other command exits 1 and says it needs the full CLI. Three things need a TypeScript loader, and the file doesn’t do them:

  • It never evaluates chant.config.ts, so --env isn’t checked against the declared environments.
  • approve can’t load *.op.ts files, so it warns that the op was not found among them and records the resolution anyway, as it does for every wave gate.
  • An approval of a gate whose approval block names a lexicon’s policy can’t load that lexicon, so approve refuses it, as it would in a checkout without the lexicon.

The file is built by the package’s build script, which npm pack runs before every publish, so it ships in the @intentius/chant tarball at the package’s version. It needs no package or trusted-publisher record of its own.

chant run wave --spec waves.json --wave <k> does three things:

  1. Reads the wave’s gate, approval, point and hooks from the spec file at the base commit.
  2. Plans every run in wave k with the plan command (or once with planWave), and decides.
  3. Runs apply for each run, or applyWave once for the set.

The hooks run around steps 2 and 3.

When the policy asks for an approval, the wave waits on gate <gate>-wave-<k> under op <name>. The gate is bound to the wave’s set digest: one digest over every run’s { target, planDigest }, the same set digest a component fan-out’s wave binds. An approval of that digest lets the wave apply. If any run’s plan changes, the digest changes, and so does what has to be approved.

PolicyThe wave waits when
alwaysat least one run’s plan changes something
on-destructiveat least one run’s plan is destructive
nevernever

A waiting wave applies nothing and exits 3. It records a pending fact on chant/lifecycle and prints the approval command:

Terminal window
chant approve migrations migrations-wave-3 --plan jcs1-sha256:...

The pending fact carries approvalMode, the approval mode the wave asked under (ledger, pr-review or sealed). It is read at base and not from the quorum block in approval. A reader such as behold or a gate audit uses it to decide which approvals count, so a pipeline that passes --approval is not guessed from config (#3861). A decision point’s pending fact and the pending fact of a hold on another gate carry it too.

A hold on another gate also carries wave: { number, name, op } and heldBy: { hook, moment, target? }. heldBy names the hook that asked and the moment it ran at, plus its run for a perRun hook (#3886). A reader names the holder from heldBy and not from description, which the hook writes. PendingGateRecord and readGateLedger type wave, heldBy and approvalMode (#3887); a wave or heldBy of the wrong shape is dropped on read. deriveGateAudit surfaces heldBy and approvalMode on the request entry beside wave. A product’s pending fields may not set wave, heldBy or approvalMode.

Approve it, then start the job again: by hand in the forge (GitHub and Forgejo call it re-running failed jobs, GitLab calls it a retry), or with --resume as the next section shows. The wave plans again and applies once it finds the approval for its digest.

Some tools plan a whole wave at once: Terragrunt’s run --all plan over a wave’s units, or an apply that works through a table of rows. For those, give planWave in place of plan, and applyWave in place of apply if the apply is one call too:

{
"name": "roots",
"op": "tf-apply",
"planWave": ["./bin/plan-wave", "{wave}", "{runs}", "{plans}"],
"applyWave": ["./bin/apply-wave", "{wave}", "{runs}", "{plans}"],
"waves": [
{ "name": "network", "runs": [{ "target": "network/vpc" }, { "target": "network/dns" }], "gate": "on-destructive" },
{ "name": "apps", "runs": [{ "target": "apps/api" }, { "target": "apps/web" }] }
]
}

chant writes the runs file at {runs} before the call:

{ "wave": "network", "number": 1, "runs": [{ "target": "network/vpc", "op": "tf-apply" }, { "target": "network/dns", "op": "tf-apply" }] }

The planWave command writes {plans} with one entry per run:

{ "runs": [
{ "target": "network/vpc", "planDigest": "jcs1-sha256:...", "destructive": true },
{ "target": "network/dns", "planDigest": "jcs1-sha256:...", "empty": true }
] }

The array alone is read too. Each entry means what a per-run plan file means. The wave’s set digest and its gate decision come from this list exactly as they would from per-run plans, so an approval reads the same either way. A list that leaves out a run, names a target it was not asked to plan, or names one twice fails the wave. chant also writes each entry to the run’s own plan file, so a per-run apply or hook still gets {plan}.

The plans file may also carry pending, an object of fields the product adds to the wave’s pending fact when the wave waits, such as the commit it planned or the members its own readers expect:

{ "runs": [...], "pending": { "commit": "4f1c...", "members": [{ "member": "network/vpc", "planDigest": "jcs1-sha256:..." }] } }

chant’s own fields win. A pending that sets one of them (op, gate, planDigest, timestamp, expiresAt and the rest) fails the wave; description is the one it may set.

A product can hand chant the change-set document it composed for the wave’s plans as changeSet in the same file (#4551). chant stores it under its digest in _change-sets/ before the pending fact, and the fact cites that digest as changeSet. A refusal or a respond job then reads the plans the approval was asked for with chant change-set show <digest>. chant approve copies changeSet onto an approval of the fact’s plan. A document whose content does not hash to its digest is logged and left out, and the wave still waits.

The plans file may also carry members: digest members that are not runs, each with a name no run has. A product whose approval depends on more than the plans puts that in the digest this way. With a cost threshold, for example, the wave’s monthly cost goes in, so an approval at one cost does not apply at another:

{ "runs": [...], "members": [{ "member": "cost", "planDigest": "usd-monthly:1240.50" }] }

They are in the digest whatever digest.over says, and they never run.

applyWave gets a runs file that lists the approved set: each run with the planDigest it was approved or let through at, and the wave’s digest. A non-zero exit counts every run in the set as failed, unless the call writes { "applied": [<target>...] } to CHANT_APPLY_RUNS_RESULT, a path it gets. Then only the other runs count as failed, and a later wave blocks only the runs that depend on them. chant components apply-wave writes it.

Every apply call, apply or applyWave, also gets CHANT_APPLY_OUTCOME, a path. An apply that applied nothing, for a reason that is not a failure, writes one of these there:

outcomeWhenThe wave
stood-downa newer run (a newer push on the branch) applies insteadexits 6. No run counts as failed, and no notification goes out
heldanother run holds what the apply changes, and the apply does not wait for it. holder: { run, url? } names itexits 5. No run counts as failed. Notify sends refused with status held
replanthe run the apply waited for let go, so the plans may have movedplans the wave again in the same job, up to 10 times. Planned again to the same digest, the approval the job found still holds, and it is not spent twice

reason is optional text. An apply that applied or failed writes nothing. Its exit code decides as before.

plan and planWave cannot both be given, and neither can apply and applyWave. Either kind of plan can go with either kind of apply.

shares keeps working. The deciding job plans the whole wave in one call. Each share job calls planWave with a runs file of its own slice, and calls applyWave with only the runs whose plan digest still matches the decision.

A spec can take its waves from a project’s component graph, with each run a component (#4588). componentWavesSpec in @intentius/chant/ci-product builds one wave per layer of dependsOn. Its planWave and applyWave come from componentWaveSteps:

{
"planWave": ["chant", "components", "plan-wave", "--runs", "{runs}", "--plans", "{plans}", "--env", "prod", "--base", "HEAD^1", "--wave-outputs", ".chant/op-waves/release/outputs.json"],
"applyWave": ["chant", "components", "apply-wave", "--runs", "{runs}", "--plans", "{plans}", "--env", "prod", "--base", "HEAD^1", "--wave-outputs", ".chant/op-waves/release/outputs.json"]
}

chant components plan-wave plans the wave’s components through their capabilities, against the outputs the waves before it left in the --wave-outputs file. It writes one digest per component over its members’ plans, and the wave’s change set. chant components apply-wave plans the approved runs again and exits 4 when a component’s plan is not the one approved. Otherwise it leases the rows on the resource lock grain and applies the wave. Each applied component’s release is recorded, and its outputs go into the file for the next wave.

pr-apply --wave-gate runs its waves on this spec, with both steps in its own process against the change it already derived. The spec is chant’s own, so the job reads it from memory rather than from the base commit. Its op is the apply’s own, pr-<n> or green-<sha>. Every wave takes approval: pull-request with the pull request’s gate. A wave whose plan the approved change set covers applies under that approval, and a wave whose plan moved waits at <gate>-wave-<k>. A product’s productPipelineJobs takes the same waves with componentWaves: { components } when it has no spec of its own.

A spec can name a step in place of plan and apply (#4545). Each run is then planned and applied in the wave’s own process, through the capability a component’s deploy step would name: terraform-apply from the terraform lexicon, pulumi-up from the pulumi lexicon, or any kind a capability plugin adds.

{
"name": "tf-apply",
"op": "tf-apply",
"step": { "kind": "terraform-apply", "root": "{target}", "lockTimeout": "5m" },
"waves": [
{ "name": "network", "runs": [{ "target": "network" }] },
{ "name": "apps", "runs": [{ "target": "api", "input": { "vars": { "size": "small" } } }, { "target": "web" }] }
]
}

The step is { kind, ...input }. chant fills {target}, {op} and {wave} in each string of the input for every run, and lays the run’s own input over it, so one step covers every root of the pipeline and a run adds its own vars or reads.

  • The plan is capability.plan for each run. Its planDigest is the run’s member digest. The run is empty when its change-set part has no entry but no-op and read, and destructive when one entry deletes or replaces. A member with holes and no artifact fails the plan with the holes’ reasons. The parts are composed into the wave’s change-set document, and the pending fact cites it as the plans file’s changeSet would.
  • The apply is capability.run with the plan’s artifact in ctx.plans, so the run applies the plan the gate decided. A run the capability refuses as moved applies nothing, the job lists it under moved and exits 4. Any other error fails the run.
  • Each run’s plan file at {plan} carries planDigest, member, artifact and changeSet, so a perRun hook can read the plan.
  • The capability gets the wave’s cwd, absolute, as ctx.cwd (DeployContext.cwd, GroupContext.cwd and RunDiscoveryContext.cwd, #4854). terraform-apply starts its chant.config.* search there when the step names no cwd, and terragrunt-apply runs there when it names no dir, so a product that calls runOpWave({ cwd }) for another directory gets that directory’s config, not its own process’s.

The capabilities are the project’s, built the way chant run --components builds them from chant.config. A product that runs chant in process passes its own registry as capabilities to runOpWave. A step replaces the four commands, so the spec refuses it beside any of them. It also refuses hooks.apply.runBy: "apply", since no apply command exists to hand the hooks to. Shares and job groups work as with commands: each share plans its slice through the step again and applies the runs whose digest still matches the decision.

The wave-job runtime (wave-runtime.mjs) does not carry the config loader, so a spec with a step needs the full @intentius/chant install, or a product’s own bin that passes capabilities.

A waves file has no concurrency group of its own: GitHub and Forgejo get no concurrency: and GitLab’s wave jobs get no resource_group (ruling for ci-products, 2026-10-28). Two pushes to the branch run their waves side by side, and chant’s ledger keeps them apart where they meet. Forgejo has no job-level concurrency, so a group per job could not do it there.

A run through a step leases rows in _locks/rows/pr-apply.json on chant/lifecycle before it applies, by its lock grain:

GrainRowWhen another run holds it
resource (plunge, choudoufu)one row per resource the plan changes, from the lexicon’s lockRowsthe wave applies nothing and exits 5 at once. Two plunge pushes that change different resources of one stack both apply
target, stock Pulumistack <project>/<stack>, from pulumi-up’s targetLockRowthe run waits in the queue
target, Terraform, tofu, Terragruntroot <root>, from terraform-apply’s targetLockRowthe run waits in the queue
reporepo, which meets every rowthe run waits in the queue

A run whose plan changes nothing takes no row. On the target grain a lexicon with no targetLockRow (SQL is one) takes no row and keeps its engine’s own lock.

A waiting run adds itself to the file’s waiting list and reads the file again every CHANT_LOCK_POLL seconds (10 by default). It takes its rows once no live run holds one of them and no live waiter for a row that meets one of them goes before it. The older commit goes first (commitAt, the committer time of the commit the job checked out). On a tie the lower run id goes first, and after that the lower commit sha. Nothing preempts a holder, so a newer push that found the row free keeps it until it ends.

Each wave job carries timeout-minutes (GitLab: timeout), 180 by default or jobTimeoutMinutes in the pipeline options, and CHANT_LOCK_WAIT, five minutes under it in seconds. A run still waiting at that point leaves the queue and applies nothing. Its outcome is held (exit 5), and the reason starts with LockWaitTimeoutError and names the run it waited for. On GitLab the project’s own maximum timeout still caps the job.

A lease ends when the wave’s apply ends, whatever its outcome: the job lets go of its rows in a finally, so a failed apply and a lock push that was refused leave no hold behind (#4660). A job that is cancelled or killed never runs that cleanup, so a hold carries a liveness token as well. While a job holds rows, a side process (chant lock --beat) writes beat on the hold every CHANT_LOCK_BEAT seconds (60 by default). The side process ends with the job’s process, so a hold whose beat is older than CHANT_LOCK_BEAT_STALE seconds (600 by default) belongs to a job that is gone, and the next waiter takes it over. A hold with a beat is judged by the beat alone, so a long apply keeps its rows for as long as it beats, and a cancelled run that still applies keeps them too. A hold with no beat (the job could not start the side process, or an older chant wrote it) is gone when the forge says the run finished (with CHANT_FORGE_TOKEN), or when its entry is older than CHANT_LOCK_STALE seconds (7200 by default). A waiting job writes its queue entry again every CHANT_LOCK_WAITER_STALE / 3 seconds, and an entry that is CHANT_LOCK_WAITER_STALE seconds old (300 by default) is dropped, so a killed waiter does not hold up the runs behind it. Set CHANT_LOCK_BEAT=off to start no side process.

When a wait gives up, its reason names each run it waited for, when that run took its rows and when it last beat. If such a run is gone and nothing has freed its hold yet, chant unlock --run <id> frees it by hand (chant lock).

After a wait the stock engines check their own plan. pulumi-up previews again under the lease and fails when the fresh shape goes beyond the approved one, and a stale Terraform saved plan fails the run.

The sql lexicon adds two kinds (#4569). sql-migrate runs SQL Yodeler’s versioned migration engine, and sql-apply applies a declarative build with the lexicon’s own appliers.

{ "step": { "kind": "sql-migrate", "environment": "{target}", "spec": "yodel-waves.json" } }

chant runs yodel with three argv and refuses any other: yodel plan <env> --part <file>, yodel apply <env> --wave-plan <file> --spec <spec> and yodel apply <env> --wave-apply <file> --spec <spec>. Each may end with --dir, --op and --allow-out-of-order, in that order. The plan gives the member’s change-set part, one entry per object the pending migrations touch. The wave plan’s digest is the one the gate binds. Its destructive steps come back as the plan’s destructive classes, such as pg-rewrite. A wave under on-destructive waits on them. The apply hands the engine the decided plan. The engine plans again under its lock and checks the wave’s decision and the ledger’s approval itself. A plan that moved is refused and the job exits 4. The two planning commands run without YODEL_ROLE and the writer’s variables, so the writer reaches only the apply. A step without spec plans the migrations under their own digest and never applies. chant components pr-plan uses it that way.

sql-apply takes environment and build, the chant build output. It plans the build against the environment’s server as chant sql plan does. The apply goes through clickhouseApply or postgresApply by the build’s dialect. A change the applier refuses fails the plan and names the migration Op to run instead. A ClickHouse rebuild is one such change. The apply plans again and sends nothing when the digest moved.

Both kinds take the target lock grain, the environment (#4571). SQL Yodeler already keeps two applies of one environment apart with its own lock, a KeeperMap row on ClickHouse and a session advisory lock on Postgres. A member that sets ci.lockGrain: resource is refused by name, since a migration chain applies in order.

Some tools find a wave’s runs at run time. A Terragrunt repo’s waves are its units’ dependency layers from terragrunt find, and a repo can grow a layer after its pipeline was rendered. Mark those waves discover, and the last one rest:

{
"planWave": ["./bin/plan-wave", "{wave}", "{runs}", "{plans}"],
"waves": [
{ "name": "layer", "runs": [], "discover": true },
{ "name": "rest", "runs": [], "discover": true, "rest": true }
]
}

A discovering wave’s runs file has "discover": true and no runs. planWave plans the runs it finds for wave number, lists them in {plans} (an entry may name its op), and says how many waves it found in waves. A wave number past the last one it found finds no runs, so the wave applies nothing and exits 0.

A rest wave applies its own wave and then goes on to wave k+1, k+2 and so on, up to the waves its plan reports. It stops at the first wave that does not apply. Each of those waves plans in turn, waits on its own gate (gateName with its number), and is read at base under the rest wave’s name. --json lists them under rest. A rest wave cannot have shares. A discovering wave with shares hands its share jobs the runs its deciding job found. --record-plans follows the rest waves too.

With a step in place of planWave, the step’s capability finds the runs (#4842). chant calls its discoverRuns with the wave’s name and number and the step’s input, with {op} and {wave} filled and {target} left as written. It answers the wave’s targets and how many waves it found. Each target then plans through the step with {target} filled. A capability with no discoverRuns fails the wave before anything plans. The terraform lexicon’s terragrunt-apply finds a Terragrunt repo’s units with terragrunt find and cuts them into layers by their dependencies, or, given layers, cuts each listed wave again by the graph:

{
"step": { "kind": "terragrunt-apply", "unit": "{target}" },
"waves": [
{ "name": "layer", "runs": [], "discover": true, "together": true },
{ "name": "rest", "runs": [], "discover": true, "together": true, "rest": true }
]
}

Some tools plan a wave as a whole: Terragrunt runs a layer’s units with one run --all, and a composed run plans roots that read each other as one root. A wave with a step and together: true plans its runs with one call of the capability’s planGroup and applies them with one call of its runGroup, the methods a fan-out uses for a group of components. A capability without both fails the wave before anything plans.

  • Each run keeps its own member digest, its share of the plan, and its plan file. A run’s own artifact stays on its plan file, so {planJson} and a cost hold read it; the whole plan’s artifact goes back to runGroup.
  • The capability’s digest of the whole, with each run’s member and plan digest (groupDigest), is one more digest member, (wave plan). An approval of one composition does not apply another.
  • The run hooks run for each run around the one call. Each run’s env and afterInit reach its member’s context.
  • A beforeApply that stops one run stops them all, since the one call applies every run. Each run then ends as its part of the apply did: applied and no-changes apply, the rest fail. A runGroup that throws a moved plan applies nothing, lists every run under moved and exits 4.

terragrunt-apply plans the units with one run --all into its work directory and applies exactly those saved plans with one more. The units of one call need the same settings and the same env from the run hooks. terraform-apply plans and applies a together wave as one composed run (ComposedRun) when terraform.compose.enabled is set. A product can pass its own capability with the group methods it needs. A together wave cannot have parallelism over 1. OP_WAVE_STEP_WAVE_FLOOR is the first chant with discover on a step and together.

A Terragrunt unit can pin its own releases (#4849): the OpenTofu or Terraform release Terragrunt calls, and Terragrunt’s. One run --all runs one of each, so terragruntApplyCapability({ resolveUnit }) takes what each unit runs, { terragrunt?, binary? }, and a wave plans and applies as one run --all per pair, each group from its own work directory. A field the resolver leaves unset runs the step’s. Each unit keeps its member digest, and the wave keeps its (wave plan) member, whose digest names the groups only when there are two or more. terragruntUnitPinResolver({ release, carried }) reads the pins from a unit’s files (.opentofu-version or .terraform-version, an exact required_version, an exact terragrunt_version_constraint in terragrunt.hcl) and asks release(tool, version) for the path of each pinned release once. A pin that is already the step’s release, as carried names it, runs the step’s. A product with pins of its own passes its own resolver. TERRAGRUNT_UNIT_PINS_FLOOR marks it.

A run whose plan changes only outputs is a change, on terraform-apply and terragrunt-apply alike (#4849): its change-set member lists them as outputs, so it is not empty and digest.over: "changing" keeps it in the wave digest.

Hooks are commands that run before and after a wave’s plan and apply, inside the wave’s job:

{
"hooks": {
"before": { "plan": [{ "name": "lint", "command": ["./bin/lint-config"] }] },
"after": { "plan": [{ "name": "policy", "command": ["./bin/policy", "{target}", "{plan}"], "perRun": true, "onFailure": "approve" }] }
},
"waves": [
{
"name": "prod",
"runs": [{ "target": "prod" }],
"hooks": {
"before": { "apply": [{ "name": "backup", "command": ["./bin/backup", "{runs}"] }] },
"after": { "apply": [{ "name": "smoke", "command": ["./bin/smoke", "{wave}"] }] }
}
}
]
}
Hook fieldMeaning
commandArgv. {op}, {wave} and {runs} are filled in. A perRun hook also gets {target}, and {plan} once the run is planned. {planJson} is the engine’s plan document when the run’s plan names one, such as the show -json file terraform-apply writes (#4614)
nameThe hook’s name in the log and in --json. Default: its command
perRunRun the hook once per run, rather than once for the wave
onFailurefail (default) or approve
targetsRuns the hook is for: targets, or patterns where * matches within one / segment and ** across segments (#4288). A perRun hook runs for the matching runs. A hook that runs once runs when any run matches, or before a discover wave’s plan, when no run is known yet. Default: every run

The spec’s hooks run first, then the wave’s own hooks. The environment carries CHANT_OP_WAVES, CHANT_WAVE, CHANT_WAVE_NUMBER, CHANT_HOOK (such as after-plan) and CHANT_RUNS, plus CHANT_TARGET and, once the run is planned, CHANT_PLAN for a perRun hook. A planned run’s hook also gets CHANT_PLAN_DIGEST. When the plan names a plan document, CHANT_PLAN_JSON holds its path. The runs file at {runs} lists each run, with its plan once planned.

WhenRunsA failure with fail
before.observebefore anything reads live state, ahead of before.plan, in the deciding job and in each share (#4288)the wave exits 1; nothing is planned
before.planbefore the wave is plannedthe wave exits 1; nothing is planned
after.planafter the plan, before the gate decidesthe wave exits 1; nothing is applied
after.gateonce the gate decided, whatever it decided (After the gate)the wave exits 1 if it would have applied; a waiting or refused wave keeps its exit code
before.applyonce the gate lets the wave through, before the applythe wave exits 1; nothing is applied
after.applyonce every run appliedthe wave exits 1; the runs stay applied

A hook with onFailure: "approve" that fails holds the wave instead. The wave then waits for an approval of its set digest whatever its gate says, never and empty plans included. Any hooks after it still run. The pending fact names the hooks that held it, and so does the decision (heldBy). Once that digest is approved, the wave applies on its next run. A hold before the apply, or in a share job, waits only when nobody has approved the digest yet. approve cannot be used after the apply, because the runs have already applied by then, so the spec refuses it.

A wide wave’s share jobs run the hooks their deciding job read at base, around their own slice.

An after.gate hook runs once the gate has decided, whatever the outcome. It runs when the wave is approved or let through by the policy, and also when it is waiting or refused by a policy denial. It is the place for a product’s own report of a wave that does not apply, since a waiting or refused wave never calls the apply. If a hold before the apply later makes the wave wait, the hooks run again with that decision. onFailure: "approve" is refused here, because the gate has already decided.

Its environment carries the decision:

VariableHolds
CHANT_GATE_STATUSapproved, not-required, waiting or refused
CHANT_GATE_OP, CHANT_GATE, CHANT_GATE_DIGESTThe gate and digest decided: the wave’s own, or another gate a hook held it on
CHANT_GATE_APPROVEThe approve command, while waiting
CHANT_GATE_WAITING_SINCEWhen the wait began: the standing pending fact’s time
CHANT_GATE_RECORDEDtrue when this run recorded the pending fact, false when it found one standing
CHANT_DECISIONThe decision record. While waiting it holds the pending fact (pendingFact) and the newest approval of another digest (mismatch). When refused it holds refused, and each member keeps its denied

A product that keeps a report next to each pending fact writes it when CHANT_GATE_RECORDED is true.

The denial of a run the product’s policy refused is a pending fact on _gates/policy-override.jsonl. It carries the same wave: { number, name, op }, and deriveGateAudit (@intentius/chant/lifecycle/gate-audit) surfaces it as wave on the request entry (#3839).

A hook can hold the wave on a gate other than the wave’s own, with a digest of its own. For example, a state migration in the change runs before wave 1 plans, and it runs behind its own gate. The hook needs onFailure: "approve". It writes the file named by CHANT_HOLD and exits non-zero:

{ "op": "tf-migrate", "gate": "split-queues", "digest": "sha256:...", "description": "move the queues to their own root", "pending": { "members": [] } }

op defaults to the spec’s name. chant settles that gate under the wave’s approval mode, read at base. sealed counts only sealed approvals, and pr-review counts the ledger alone. If nobody has approved the digest, chant records a pending fact for it with the pending fields. The wave waits (exit 3). The pending fact carries wave: { number, name, op } (the wave and the spec’s name), so a reader can tell which wave is held even when the hook wrote its own description. The decision’s heldOn and approve then name that gate. Once someone approves it, chant runs the hook again with CHANT_HOLD_APPROVED (JSON: op, gate, digest, approvedBy, approvedAt). That run either passes, and the wave goes on, or holds the wave on a further gate the same way (#3847). Approvals of the other gate are not spent unless the hold asks chant to record it.

A hold with "record": true has chant record the gate the way it records a gated request (#4623). Before the approved re-run, chant appends an applied line to _gates/<op>/applied.jsonl, which spends the approval. If that line does not reach the remote, the hook does not run again. A digest that already has an applied line under the gate does not run again either. The re-run gets CHANT_HOLD_FINISHED, a path beside CHANT_HOLD, and writes { "result": "applied" | "failed", "detail": { ... } } there. chant then appends the finished line with that result and detail, leaving out any detail value that is an object or an array. Without the file, the exit code gives the result (0 is applied) and the line has no detail. "attachment" in the hold is text chant stores once at _gates/<op>/requests/<digest>.json before the pending fact, whose proof field is its SHA-256. CHANT_HOLD_FINISHED is set only when chant wrote the applied line, so a product that writes these lines itself on an older chant can tell which case it is in.

A change with two state migrations, where the second plans against the states the first writes, uses that: the approved run applies the first, writes CHANT_HOLD for the second’s gate and digest, and exits non-zero. chant settles that gate in turn. Approved, it runs the hook again; otherwise the wave waits on it (exit 3), and heldOn.after lists the gates approved before it. Each re-run also gets CHANT_HOLDS_APPROVED, a JSON array of every approval the call went through so far, oldest first. A re-run that holds again on a gate and digest already approved fails the wave, and so does one hook call asking for more than 10 gates in turn (OP_WAVE_MAX_CHAINED_HOLDS).

The wave job settles these holds in before.plan, after.plan and before.apply. Under hooks.apply.runBy: "apply", the apply cannot settle a gate under its own lock, so a hold on another gate there stops the apply. chant run resume --op <name> resumes only waves waiting on the spec’s own op. For another op, approve with --resume.

By default the wave job runs before.apply and after.apply hooks around the apply command. A product that takes a lock inside its apply (a database migration lock, a state lock) then checks the world before it holds the lock: two merges in quick succession run two wave jobs, the second waits minutes for the lock, and its before.apply check is stale by the time it applies. Set runBy to have the apply command run them itself, under its lock:

{ "hooks": { "apply": { "runBy": "apply" } } }

hooks.apply.runBy is chant (the default) or apply. A wave’s own setting wins over the spec’s. Like the hooks it is read at the base commit, so a change that sets it is still applied with chant running the hooks.

Every apply call, apply or applyWave, gets two environment variables:

VariableHolds
CHANT_HOOKSA JSON file: the wave, its digest, approved (an approval of the digest stands), heldBy, the runs this call applies, outcomes (every hook that already ran in this job and how it came out), and, under runBy: "apply", the before-apply and after-apply hooks read at base
CHANT_HOOKS_RESULTUnder runBy: "apply" only: where the apply’s hook outcomes go, for chant to read back

The apply runs the hooks with runOpWaveApplyHooks from @intentius/chant/op:

import { readOpWaveHooksFile, runOpWaveApplyHooks } from "@intentius/chant/op";
const hooks = readOpWaveHooksFile(); // CHANT_HOOKS, or null outside a wave job
await withLock(async () => {
if (hooks) {
const before = runOpWaveApplyHooks(hooks, "before-apply");
if (!before.proceed) process.exit(before.held.length > 0 ? 3 : 4); // apply nothing
}
await migrate();
if (hooks && !runOpWaveApplyHooks(hooks, "after-apply").proceed) process.exit(1);
});

Each call returns the outcomes (moment, name, target, exit, outcome), so the product can write them into its own history, and adds them to CHANT_HOOKS_RESULT. Pass exec to run a hook in process or keep its output. A moment the file has no hooks for runs nothing and proceeds, so the apply can make the calls whoever runs the hooks.

After the apply exits, chant reads the result back:

  • The outcomes join the wave’s result (--json, notifications) and the decision record’s outcomes.
  • A before-apply hook that held the run, with no approval standing, makes the wave settle its gate. The apply must have applied nothing. If nobody has approved the digest, the wave waits (exit 3). If someone has, chant calls the apply again with approved: true. The hooks then run again under the lock.
  • An after-apply hook that failed counts the runs as applied and fails the wave (exit 1).
  • An apply that exits 0 without running the hooks it was handed fails the wave, though its runs count as applied. When the apply changed nothing, it says so instead (below).

An apply that finds nothing to do (an empty plan, or everything already applied by the time it holds the lock) skips both moments with a reason:

runOpWaveApplyHooks(hooks, "before-apply", { skip: "nothing to apply" });
runOpWaveApplyHooks(hooks, "after-apply", { skip: "nothing to apply" });

A skip runs no hook and records the moment with outcome skipped and the reason, in the wave’s result and the decision record’s outcomes. Chant counts the moment as handled, so the wave does not fail. A skip without a reason throws.

With a per-run apply, each run’s call runs the apply-stage hooks for that run alone, so a hook that runs once for the wave runs once per run, under that run’s lock.

A product that runs the wave job in its own process can pass after-plan hooks as functions (#4614). It passes afterPlan to runOpWave, or { wave: { afterPlan, capabilities } } to runChantInProcess(["run", "wave", ...], words, ...) from @intentius/chant/ci-product. This is how a product with a step builds its wave report, its own policy rows and the plan files its later jobs read from chant’s plans, without planning anything itself.

import { runOpWave } from "@intentius/chant/op";
await runOpWave({
spec, specFile, wave: 1, capabilities,
afterPlan: {
name: "report",
run: (r) => {
const view = buildView(r.target, readFileSync(r.planJson!, "utf-8"));
writeFileSync(`plans/${r.target}.json`, view);
return { policy: myPolicy(r.target, view), files: [`plans/${r.target}.json`] };
},
},
});

Each hook is called once per planned run, in the order the wave lists its runs. The call comes after the wave’s holds and before the set digest is taken. A share or group job calls it for its own slice. The call names the run and its plan: target, planDigest, and the paths plan (the {plan} file) and planJson. It also carries the capability’s artifact and the run’s changeSet part. In policy it has the row chant’s holds.policy gave the run.

The answer is optional. Its policy rows are { source, result, rules, reason? }, with result one of passed, warned, denied or held. A denied row denies the run as a policy denial does, so an override of its rules counts. A held row holds the wave for a person. The files it names stay in the job’s directory. The rows and files go on the job’s run record under wave.plans.

A hook that throws, or answers in a shape chant cannot read, has failed. With the default onFailure: "fail" the wave exits 1 before the gate, and nothing is approved or applied. Under "approve" it holds the wave and the hooks after it still run. targets limits a hook to the runs it matches, as for a command hook. A product feature-detects this on OP_WAVE_AFTER_PLAN_FLOOR.

The spec’s command hooks at after.plan still run at the same point, after the set digest and before the gate settles. When those hooks call back into the product’s own process, pass hookExec, an exec that returns a promise, such as spawnExecAsync. The job then waits for each hook without blocking the event loop, so the product’s process can answer the call.

A hook can also have a wave function (#4842). Once run has answered for each of the hook’s runs, the job calls wave with all of them. It answers for the wave as a whole, the way a plans file does for a wave-level plan command:

afterPlan: {
name: "report",
run: (r) => ({ policy: myPolicy(r), ...(r.target === "prod/db" ? { overriders: ["github:dba-lead"] } : {}) }),
wave: (w) => ({
pending: { description: `wave ${w.wave}: ${w.runs.map((r) => r.target).join(", ")}` },
members: [{ member: "(monthly cost)", planDigest: costDigest }],
holds: unknownReads.map((r) => `${r.root} reads ${r.output}, unknown when the change was reviewed`),
overriders: ["github:platform-lead"],
overridersSource: "policy.override in my-product.yml",
report: JSON.stringify(myReport(w.runs)),
}),
},
FieldWhat chant does with it
pendingAdds fields to the wave’s pending fact, under a plans file’s rules: description is allowed, and a field chant writes itself is refused.
membersAdds digest members that are not runs, such as the wave’s cost from the product’s own estimator, so an approval at one cost does not apply at another.
holdsMakes the wave wait for a person whatever its gate says, one reason per line, as a held hook does.
overriders, overridersSourceNames who may override a denial in place of the overriders file at base, and where that list comes from for the refusal. A run’s own answer can carry overriders, which count for that run in place of the wave’s.
reportThe product’s report of these plans.
approvalsApprovals the product settled before the gate (terragucci issue 1303), each { resolvedBy, note, url?, review? }: a covered round’s approver, the approver of a stopped apply whose rest these plans are, or a review the product read. When the gate has to decide, chant records each at the wave’s gate on the spec’s op for the digest it decides, then decides. An approval already recorded for that digest by the same approver with the same note is not written again. review: { pr, head, reviewers } writes the product’s review line (via: "pr-review"), which an approvals.reviewLedger naming the spec’s op counts reviewer by reviewer. Each counts as any approval does, under the wave’s approval mode and approvals.involved. A gate that asks a decision point, or passes without an approval, records none.

While the wave waits, chant stores the report beside the pending fact at _gates/<op>/<gate>/<digest>.json (the digest’s : written as _), once per digest. When the plans moved after an approval, chant writes the current report and the one stored for the approved plans to .chant/op-waves/<name>/wave-<k>/report/current.json and approved.json, and names them on the decision as reports, for the job that explains the refusal. opWaveGateReportPath and opWaveReportDir give the paths.

A wave function that throws follows the hook’s onFailure, the same as run. OP_WAVE_AFTER_PLAN_WAVE_FLOOR is the first chant with the wave answer, and OP_WAVE_ANSWER_APPROVALS_FLOOR the first with its approvals.

A wave with a step can also take runHooks, which run in the job’s process around each run’s plan and apply (#4842). Pass them to runOpWave, or as { wave: { runHooks } } to runChantInProcess. With them a product gives each run its own credentials and checks what the engine fetched before any of it runs:

runHooks: {
name: "roots",
beforePlan: async (r) => ({
env: { ...roleEnv(r.target), ...(await secretsFor(r.target)) },
afterInit: () => checkSources(r.target),
}),
beforeApply: (r) => runChecks(r.target, r.plan),
afterApply: async (r) => (r.outcome === "applied" ? { files: [await writeStateVersion(r.target)] } : undefined),
},
HookWhenWhat its answer does
beforePlanBefore the run’s step plansenv is laid over the job’s environment for every command the capability runs for this run’s plan and apply (DeployContext.processEnv). afterInit is a check the capability calls after its engine’s init and before the plan runs the run’s code (DeployContext.afterInit). refuse stops the run before its engine starts.
beforeApplyBefore the step applies the plan the gate decidedA hook that throws fails the run, and nothing of it applies.
afterApplyOnce the apply came back, whatever its outcomeIts files go on the run record under the run’s target. A hook that throws after an apply fails the run.

When beforePlan refuses a run or its check after init throws, the job fails the way a failed plan does and nothing in the wave applies. Given several hooks, chant calls them in order and merges their env maps, the later value winning. A hook with targets sees only the runs those patterns match. There is nothing to run them around in a wave with no step. Today terraform-apply and sql-migrate read the env, and terraform-apply calls the check after init; pulumi-up does neither yet. Check OP_WAVE_RUN_HOOKS_FLOOR before relying on them.

chant run <op> on its own has no spec file, so it runs no stage hooks. A product whose own apply command also runs outside the waves (yodel apply dev from a laptop) reads the same hooks at base with opWaveHooksAtBase and runs them the same way:

import { opWaveHooksAtBase, readOpWaveHooksFile, runOpWaveApplyHooks } from "@intentius/chant/op";
const hooks = readOpWaveHooksFile() ?? opWaveHooksAtBase({ specFile: "yodel-waves.json", wave: env, base });

That file has all four moments’ hooks, and nothing is approved, so a held hook stops the apply. If the hooks at base cannot be read, the runner runs none and does not proceed.

The pull request job that records plans for pr-review (--record-plans) runs no hooks.

A product that runs its own stages, outside a wave job, runs one moment’s hooks with runStageHooks from @intentius/chant/op/stage-hooks (#4288). That module bundles without the wave loop or the gate. It reads each hook’s fields as a wave job does. A hold on another gate counts as a plain hold (packages/core/src/op/stage-hooks.ts:332). Settling that gate is the product’s job.

runStageHooks waits for each hook with spawnSync, which blocks the event loop. A product that plans several targets side by side calls runStageHooksAsync instead (#4334). It takes the same options, and its exec returns a promise. The default exec, spawnExecAsync, runs the hook with spawn (packages/core/src/op/stage-hooks.ts:76). Both forms share one hook loop, so the same exit codes give the same result in each (packages/core/src/op/stage-hooks.ts:161).

import { runStageHooksAsync } from "@intentius/chant/op/stage-hooks";
const results = await Promise.all(roots.map((root) =>
runStageHooksAsync("before-plan", hooks, {
name: "plan", op: "plan", wave: "plan",
runs: [{ target: root, op: "plan" }],
runsFile: `.out/${root}/runs.json`,
holdFile: `.out/${root}/hold.json`,
}),
));

The hooks of one call still run one after another. Calls run side by side. Give each call its own holdFile, since the runner clears that file before each hook (packages/core/src/op/stage-hooks.ts:192).

A push to chant/lifecycle starts no pipeline, so an approval alone leaves the job stopped. When the wave job runs in CI, its pending fact records where it runs: the forge, the run, and on GitLab the job. --resume uses that to start the job again after recording the approval:

Terminal window
chant approve migrations migrations-wave-3 --plan jcs1-sha256:... --resume

The approval is recorded and pushed first. If the push does not land, nothing is resumed, because the resumed job would not find the approval. A gate with a quorum is resumed only once the quorum is met.

ForgeWhat --resume asksLeast access its token needs
GitHubre-run the failed jobs of the run (POST /repos/{repo}/actions/runs/{run}/rerun-failed-jobs); the waves after it run tooactions: write: a fine-grained token with Actions read and write, or a job’s GITHUB_TOKEN granted it
GitLabretry the waiting job (POST /projects/{id}/jobs/{job}/retry); the jobs it skipped run after ita project or personal access token with the api scope, as a member with the Developer role. CI_JOB_TOKEN cannot retry jobs
Forgejodispatch the workflow again on its branch (POST /repos/{repo}/actions/workflows/{file}/dispatches), since Forgejo has no API to re-run a runa token with the write:repository scope

The token is read from CHANT_FORGE_TOKEN, else GITHUB_TOKEN or GH_TOKEN on GitHub and Forgejo, else GITLAB_TOKEN on GitLab. On GitHub and GitLab the run resumes at the commit that waited. A Forgejo dispatch runs the whole workflow at the branch’s head, so the waves before the gate run again. Their plans are empty because their runs already applied, so they wait for nothing. Their apply command still runs again and has to be safe to repeat.

Resuming approves nothing. The resumed job decides the gate again from the ledger. A run that is still going, that succeeded, or that was resumed already (a later GitHub attempt, a newer GitLab job of the same name, a Forgejo run of the workflow created after the approval) is left alone.

When the approval was recorded by something else, chant run resume --op <name> --gate <gate> resumes that gate’s job alone. Without --gate it resumes every job of the op whose approval has arrived.

A product that resumes the job itself, from one bundled file, imports the forge calls from @intentius/chant/gate-resume-run, which bundles without the workspace code (#3854). @intentius/chant/op/gate-resume exports the same functions, plus the check of whether an approval answers a pending fact.

import { resumeGateRun, resumeTokenFromEnv } from "@intentius/chant/gate-resume-run";
const loc = pending.resume!; // the gate's newest pending fact names its job
const token = resumeTokenFromEnv(loc.forge);
const outcome = await resumeGateRun(loc, { token, since: approvedAt });
// { status: "resumed", how } or { status: "skipped", reason }; a refused call throws

A gate that asks a decision point waits on a question, not an approval, and writes its resolution only when the run asks the point again. Its pending fact cites the question and, when the gate names one, its pass list. chant run resume reads the workspace’s questions (those held on chant/lifecycle included) and resumes such a job once its question is answered with an answer the gate passes on, a noul point’s yes by default. An open question, or an answer the gate does not pass on, resumes nothing (#3835).

points answer takes --resume the same way approve does.

Terminal window
chant workspace points answer <id> --answer yes --by alice --resume

It records the answer, then resumes the job waiting at the gate the question names in its subject (gate:<op>/<gate>). The answer has to reach the remote first. One held on chant/lifecycle is pushed, and one in the working tree resumes nothing until it is committed and pushed.

A product’s own resume job makes the same check with @intentius/chant/point-decision, which bundles without the workspace code:

import { chantPointQuestions, pointGateResumable } from "@intentius/chant/point-decision";
const questions = await chantPointQuestions({ command: ["npx", "chant"] });
const check = pointGateResumable(pending, questions.get(pending.answer!.id));
if (check.resumable) {
// start the job pending.resume names again
}

pending is the gate’s newest pending fact. check is { resumable: true, answer, answeredBy, answeredOn }, or { resumable: false, why, message }, where why is open, refused, unknown or not-a-point. evaluatePointGate records the job’s locator on the pending fact in CI, so pending.resume names the run to start again.

With "resume": { "schedule": "*/10 * * * *" } in the spec, the rendered pipeline gets a job that runs chant run resume --op <name> on that schedule. It resumes every waiting wave of the spec whose approval has arrived or whose decision point has a passing answer. An approval or an answer then needs no --resume and no second step.

ForgeThe resume job
GitHub<name>-resume.yml, on the cron, with permissions: { contents: read, actions: write } and the job’s own token
GitLab<name>-resume in the same file, run only in scheduled pipelines. Create a pipeline schedule with the cron, and set CHANT_FORGE_TOKEN to a project access token as in the table above
Forgejo<name>-resume.yml, on the cron, with the CHANT_FORGE_TOKEN secret

Under approvals.spend, an approval a wave already applied under is spent. chant run resume reads _gates/<op>/applied.jsonl beside the ledger and resumes nothing for a pending fact whose answering approval is spent: that apply ran, and a resumed job would only wait again. Its report says spent and names the apply (#3858).

An apply under an approval can also stop half way, when its job is killed. A wave that applies one resource at a time can record, before it applies, a line in the same file that names the approval and carries the run applying in resume (the locator a pending fact carries, from resolveGateRunLocator). When the apply ends, it writes a finished line:

{"version":1,"kind":"changes","op":"tf-apply","gate":"wave-2","planDigest":"...","approvedAt":"...","approvedBy":"alice","timestamp":"2026-10-01T02:00:01Z","resume":{"forge":"github","api":"https://api.github.com","repo":"acme/infra","run":"57","attempt":1}}
{"version":1,"kind":"finished","op":"tf-apply","gate":"wave-2","planDigest":"...","applied":"2026-10-01T02:00:01Z","result":"applied","timestamp":"2026-10-01T02:09:00Z"}

A gate whose newest applied line carries a run, with no finished line for it and no pending fact recorded since, is a stopped apply. chant run resume asks the forge about that run and starts it again once it is gone (finished without success, and not already re-run), so the wave applies the rest under the same approval. A run that still goes is left alone. chant’s own wave jobs write no run on their applied line, so this applies only to a product that writes one and resumes under the approval it applied under.

A product whose resume job applies the waves itself, rather than re-running the job that waited, takes chant’s decision without the restart. --dry-run --json starts nothing and prints one report per gate:

Terminal window
chant run resume --op tf-apply --dry-run --json
{
"dryRun": true,
"reports": [
{ "op": "tf-apply", "gate": "wave-1", "source": "pending", "status": "spent", "reason": "spent", "resumable": false,
"spent": { "appliedAt": "2026-10-01T02:00:00Z", "approvedAt": "2026-10-01T01:00:00Z" }, "message": "..." },
{ "op": "tf-apply", "gate": "wave-2", "source": "stopped", "status": "would-resume", "reason": "stopped", "resumable": true,
"planDigest": "...", "approvedBy": "alice", "run": { "forge": "github", "run": "57" },
"stopped": { "appliedAt": "2026-10-01T02:00:01Z", "approvedAt": "2026-10-01T01:00:00Z", "kind": "changes", "runGone": true }, "message": "..." }
]
}

resumable holds the decision. It is true when an approval or a passing answer stands and no wave applied under it (reason approved or answered), or when an apply stopped and its run is gone (stopped). The other reasons are not-approved and spent. source says whether the report is about a standing pending fact or a stopped apply. A dry run reads a waiting job’s run not at all, and a stopped apply’s run with a token that can read the forge’s runs (actions: read on GitHub); without one, the report says no-token and is not resumable, and the command still exits 0.

A product that bundles chant’s decision rather than running the bin calls planGateResumes from @intentius/chant/op/gate-resume-plan, which bundles without the git, gate or workspace code. It decides from the ledger alone, so a stopped apply comes back resumable and the caller checks that its run is gone:

import { parseAppliedGateFile } from "@intentius/chant/lifecycle/gate-applied";
import { planGateResumes } from "@intentius/chant/op/gate-resume-plan";
const { applied, finished } = parseAppliedGateFile(appliedText);
for (const c of planGateResumes({ op: "tf-apply", pending, resolutions, applied, finished, now: new Date().toISOString() })) {
if (c.resumable) {
// c.source is "pending" or "stopped"; c.gate, c.planDigest and c.run say what to apply and where it ran
}
}

A fact whose gate has an approval block (a quorum or a policy) needs chant’s tally: pass answering: resolutionAnswering from @intentius/chant/op/gate-resume, as chant run resume does. To ask whether a stopped apply’s run is gone without starting it, call resumeGateRun(c.run, { token, dryRun: true }) from @intentius/chant/gate-resume-run: it reads the run as a resume would and returns would-resume where the run is gone, or skipped with the reason.

A wave’s approval decides which approvals of its digest let it apply. Every mode binds the digest, so an approval of other plans never counts.

approvalCountsWhat it proves
ledger (default)any chant approve of the digest on chant/lifecyclesomeone who can push to chant/lifecycle approved these plans, in whatever name they wrote
pr-reviewthe merged pull request’s approving review of its head, by a writer other than its author, when the head planned this digest; and any chant approve of the digest, as under ledgera writer other than the author approved the change whose plans these are
sealedonly a chant approve --sign whose seal verifies against the signers file at the base commit (.chant/allowed_signers, or the file .chant/trust.json names), for the approver it namesa listed person approved these plans
pull-requestan approval of the pull request’s gate (approvals.pullRequest.gate at base, under the spec’s op) whose change set covers every member of the plans file’s changeSet; and any chant approve of the digest, as under ledgerthe reviewer approved the pull request’s plan, and the wave plans only what it showed (#4550)

The pull request’s pipeline records what its head plans. chant run wave --spec waves.json --record-plans plans every wave at the head and writes each wave’s digest to _wave-plans/<name>/<head>.json on chant/lifecycle. Each wave’s entry also holds members, one per run. A member has the run’s plan digest and a digest for each resource the run changes. The rendered pipeline runs it on each pull request (<name>-plans.yml on GitHub and Forgejo, <name>-record-plans in GitLab merge request pipelines), and the job needs to push to chant/lifecycle.

After the merge, a wave with no chant approve of its digest reads the review of the pull request that merged the commit:

The reviewThe wave
a writer other than the author approved the head, and the head planned this digestrecords the approval on chant/lifecycle (the pull request, its head and the reviewers) and applies
the same, but the head planned another digest (the plans moved after the review)waits, with the chant approve command for the new digest
only the author approved, no writer approved the head, a writer requests changes, no plans were recorded for the head, or no pull request merged the commitwaits, as under ledger
ForgeAn approving reviewA writerToken
GitHubthe reviewer’s newest review is an approval that names the head commitwrite, maintain or admin on the repositorypull-requests: read, which the rendered workflow asks for
Forgejothe same, not stale or dismissedthe review is official, which Forgejo marks for a reviewer with write accessthe job’s token
GitLaban approval of the merge request, counted only when the project removes approvals on a new push (Settings > Merge requests > Remove all approvals when commits are added), since a GitLab approval names no commitDeveloper or higherCHANT_FORGE_TOKEN with read_api

A tool that shows or checks these records reads them with @intentius/chant/lifecycle/wave-plans (#3865). parseHeadPlans(text) returns the record or null. readHeadPlans(port, name, head) reads one head, and readHeadPlanDigests(port, name) returns every recorded head with its digests by wave number. listWavePlanSpecs(port) names the specs that have records. The port is a LedgerReadPort from @intentius/chant/lifecycle/ledger-port, three methods (read, list, trees) over the branch. The module touches no git and bundles on its own. gitLedgerReadPort({ cwd, member }) from @intentius/chant/lifecycle/git is a port over a checkout, and member (or ledgerPrefix, the prefix resolveMemberLedger returns) reads a workspace member’s records under _members/<member>/_wave-plans/.

A spec with a pr-review or pull-request wave gets the record-plans job, and an approval-status job that posts <product>/approval on the pull request’s head (chant/approval for chant’s own words, plywood/approval through plywood’s bin) (#4630). It reads each wave’s approval mode and policy at the pull request’s base, and the head’s recorded plans tell it which waves the gate will hold. The status is pending while a held wave has no approval that would pass it, and success once every held wave has one or none is held.

Wave approvalWhat answers a held wave before merge
pr-reviewan approving review of the head by a writer other than its author, as the merged wave reads it
pull-requestthe pull request’s own approval: an approval at approvals.pullRequest.gate, on the pull request’s op (pr-<n>) or the spec’s op, whose change set covers the wave’s change set at the head

For a pull-request wave, --record-plans keeps the digest of the change set the wave’s plans file gives, and stores the document under _change-sets/ on chant/lifecycle. A record without one stays pending.

On GitHub and Forgejo the job runs after record-plans on each push, and alone on each review. On GitLab an approval starts no pipeline, so a pipeline schedule of the target branch that sets CHANT_APPROVAL_STATUS=1 posts the status for every open merge request (--open). An approval recorded with chant approve starts no run on any forge either. The status changes at the next push, review or scheduled run, or when someone runs chant run wave --spec <file> --approval-status --open --branch <branch> --forge <kind>.

The status advises. After the merge, the wave’s own gate decides.

Add .chant/allowed_signers in a reviewed change, one <principal> <key> line per approver, then approve with --sign:

Terminal window
chant approve migrations migrations-wave-3 --plan jcs1-sha256:... --actor github:alice --sign ~/.ssh/id_ed25519

The signers file is read at the base commit, like the policy. A pull request that adds its author’s key to it cannot use that key to approve its own waves. Without a signers file at base, no approval counts.

approvals.quorum asks for more approvers, or approvers with a role, on the waves whose targets a glob names. It is read at base. See Approval Rules.

A merged wave plans again in its own job, a while after the pull request’s plan was posted and reviewed. With the default gate, on-destructive, a change that destroys nothing needs no approval, so nothing compared the new plan with the one the reviewers saw: a record that moved in between was applied as the new plan found it.

approvals.preview: true closes that. It is read at the base commit, so a change cannot turn it off for its own merge. Each wave then compares the plans it makes now with the ones the merged pull request’s head recorded for that wave, whatever the wave’s gate policy and approval mode. The pull request is the one the forge says produced the applied commit, and the record is the _wave-plans/<name>/<head>.json that --record-plans wrote on the pull request.

The comparison is per resource. For each run, the record holds the digest of every resource the pull request’s plan changes, made from the inputs it was planned with, before and after (members[].resources, keyed by URN on Pulumi and plunge and by address on tofu and terraform). The merged wave checks each of those against the same resource in the plan it makes now.

The resourceThe wave
changed by the pull request, and planned now with other inputs or no longer changedis refused, since a record moved
changed by the pull request, and planned now as it was previewedgoes on
changed now but not by the pull requestis not compared. It belongs to another change, which was previewed and gated on its own
left alone by the pull request (same or read)is never compared, so another merge that changed its inputs does not move this plan

Two pull requests that change different resources of one stack therefore both apply when they merge one after the other, whether the first merge’s change is still in the second wave’s plan or already applied. The set digest still names the plans the wave made, and a gate or an approval binds that digest, so a destructive step another merge added waits for its approval.

The digests leave out what the engine makes up while planning, which would differ between any two plans of one change:

  • stock Pulumi and plunge: an autoname the provider drew for a create or a replacement (events-3f45941). The engine lists such an input in the step’s __defaults. Its value reads as the resource’s logical name and seven hex characters. The digest holds one fixed marker for it. A name the program wrote and an update’s name stay in, as does every other input and default.
  • tofu and terraform: a value the plan lists in after_unknown. The mark stays in, so a value that turns from known to unknown still changes the digest.

Two creates that differ in an input a reviewer saw still have two digests.

A plan command that is not a step can give the same detail: its plan file takes resources, a map of a resource’s address to its digest. A run recorded without it, such as a SQL migration, is compared whole by its plan digest, unless its plan changed nothing. A record written by chant 0.124.59 holds the wave’s set digest only and no members. The wave compares that whole digest, as 0.124.59 did, and a refusal says the record is from that release; plan the pull request again with a newer chant (push to it, or run its plans job) to record the resources.

The wave’s plansThe wave
every resource the head recorded is as it was previewed (preview.compared: "resources"), or the same set digest from a record that holds no resources ("wave")goes on as before: the gate policy and approval mode decide whether it needs an approval, and a destructive change still waits for one
a resource the pull request changed is planned with other inputs, or is no longer changed (a record moved after the preview)applies nothing and exits 4. The decision is refused with refused.reason: "moved", preview.status: "moved", preview.moved naming each resource, and the recorded and current digests in the message
nothing to compare with: no merged pull request produced the commit, no record exists for its head, or none for this waveapplies nothing and exits 4, with preview.status: "unrecorded"
either of the two above, and an approval of the digest planned now standsapplies under that approval, and the decision says preview.approvedAnyway

A refused wave names the command that approves the plans it made. Someone who has read those plans approves them (chant approve, counted under the wave’s approval mode and quorum) and starts the job again. A pr-review review never covers plans that moved: the review approves the digest the head planned. A forge or a ledger that cannot be read fails the wave (exit 1); no unreadable answer stands in for a match. A wide wave’s deciding job makes the comparison, and its share jobs end with 4 on a refused decision.

The wave applies the plans it made in its own job and compared. chant does not store a product’s plan file, which can hold secrets, so the match is by digest. The engine’s own check at apply still fires on the plan the job made: a step run whose saved plan the target moved under exits 4, and an apply command that refuses a stale plan (tofu’s stale saved plan, plunge’s exit 40) fails the run, as it did before.

The pull request’s pipeline has to record plans. A spec with approvals.preview gets the record-plans job and the approval status job, and its wave jobs ask for pull-requests: read on GitHub. A product that renders its own workflows runs chant run wave --spec <file> --record-plans on each pull request. The pull-request approval mode checks a change set instead, and a wave under it that sets preview is checked by both.

A wave whose gate should be decided by a workspace decision point, the way an Op gate with a point is, names the point on the spec, or on one wave:

{ "point": { "name": "prod-apply", "timeout": "48h" } }

point takes a point’s name, or { name, inputs?, pass?, store?, timeout? }. inputs, pass and store mean what they mean on an Op gate, and timeout is how long the pending fact stands (default 48h). When a wave sets its own point, that one is used instead of the spec’s. chant reads the point at the base commit, as it does the policy, so a change can neither add a point to its own gate nor drop one. A point at base that cannot be asked (a bad name, an unknown field) fails the wave rather than fall back to the ledger.

If the policy calls for an approval, the point is asked with gate.planDigest set to the wave’s set digest, under the subject gate:<name>/<gate>. The point has to declare that input, so each plan is its own question and a yes for one digest never passes another. The table shows what the wave does for each state of the question.

The questionThe wave
openapplies nothing and exits 3. Its pending fact cites the question and carries the plans file’s pending fields and the spec’s neverOverMcp, as an approval gate’s does. approve in the decision is the chant workspace points answer <id> --answer <answer> --by <name> line
answered with an answer pass names (default yes)records a resolution on chant/lifecycle that cites the answer, once per answer and digest, and applies (via: "point")
answered otherwiseapplies nothing and exits 8. The decision is refused with refused.reason: "point", every run, and the message naming the record. chant workspace points retract <id> takes the answer back so the point is asked again

A chant approve of the digest does not pass such a gate, and the wave’s approval mode does not apply: the point’s deciders and quorum decide. Under a neverOverMcp spec, an answer or retraction of the question over MCP or ACP is refused (answer-never-over-mcp), so a person answers it at a shell or through hud (#3863). approvals.spend does not re-ask a point either, since the same plan asks the same question. A wide wave’s deciding job asks the point, and its share jobs exit 3 or 8 with it.

Once the question is answered, chant run resume --op <name> (or the scheduled resume job) starts the waiting job again, as for any gate that asks a decision point. In a CI job the question goes to the ledger unless point.store says otherwise, so it outlives the job’s checkout.

From code, runOpWave takes points, the asker to use. The default reads the workspace in the job’s working directory; a tool that bundles chant passes chantGatePointAsker from @intentius/chant/point-decision.

By default an approval of a digest passes that digest whenever it is planned. Re-run a wave job, or revert a change and merge it again, and the wave applies the same plans under the same approval. With approvals.spend an approval is good for one apply, as terragucci’s wave gate has it:

{ "name": "migrations", "op": "migrate", "approvals": { "spend": true }, "plan": ["..."], "waves": ["..."] }

Before a wave applies under an approval, it appends one line to _gates/<name>/applied.jsonl on chant/lifecycle:

{"version":1,"kind":"applied","op":"migrations","gate":"migrations-wave-3","planDigest":"jcs1-sha256:...","approvedAt":"2026-10-10T09:00:00.000Z","approvedBy":"github:alice","timestamp":"2026-10-11T12:00:00.000Z","wave":{"number":3,"name":"prod"}}

chant fetches the remote’s chant/lifecycle first and writes the line on top of it. The push happens before anything applies. If the push does not land, the wave fails and applies nothing (#3985). The next run reads the remote, where the approval would still look unspent. A checkout with no remote is the whole ledger, so there the local line is enough. An override’s spend works the same way.

From then on every approval of that gate and digest made at or before approvedAt is spent:

The approvalWithout spendWith spend
of this digest, not yet applied underthe wave appliesthe wave applies, and records the line
of this digest, a wave already applied under itthe wave applies againthe wave waits for a new chant approve of the digest, and the log names the spent approval
of another digest, a wave already applied under itthe gate names it as the approval of other plansit counts for nothing, and the wave waits for an approval of its own digest
the merged pull request’s review, under pr-review, when a wave already applied this digest under a review of that headthe review is recorded again and the wave appliesthe review is spent too, and the wave waits

A wide wave’s deciding job writes the line once, before its share jobs apply. The line is written before the apply starts, so an apply that fails has still spent its approval and needs a new one to run again. If the line cannot be written, the wave applies nothing and exits 1.

The rule is read at the base commit with the policy, so a change that turns spend off still has its own apply judged with it on. A change that turns it on records the approval its own apply runs under, and the rule decides from the next change on. The file sits in a directory under _gates/, so chant approve and the gate ledger readers never see its lines. @intentius/chant/lifecycle/gate-audit reads them as applies. Calling appliedGateApplies(parseAppliedGateLines(text)) from @intentius/chant/gate-decision gives the applies that deriveGateAudit ties to the approval each ran under.

A product that checks plans against a policy (OPA, conftest, its own rules) can say a run’s plan is denied:

{ "runs": [{ "target": "network/vpc", "planDigest": "jcs1-sha256:...", "denied": { "rules": ["no-public-s3"], "reason": "the bucket is public" } }], "overriders": ["github:carol"] }

A per-run plan file takes denied too. A wave with a denied run applies nothing and waits for no approval: an approval of the wave’s digest does not let a denied plan through. Each denied run passes only under an override on _gates/policy-override.jsonl, decided as @intentius/chant/override-gate decides it (Ops). The override has to name this run, its plan digest and its rules. A listed overrider has to write it with a reason, and under sealed it has to carry a seal that verifies. The overriders are the plans file’s overriders, for a product that reads its own list at base. The plans file may add overridersSource, a label such as "policy.override in terragucci.yml"; refusals say not listed in <label> and the decision’s refused.overridersSource records it. Without it they say “the overriders the plans file names”. Otherwise they come from override.overriders in the spec, else .chant/overriders, read at the base commit.

The runs deniedThe wave
every one has an override that countsdecides its gate as usual. Before it applies, it spends each override with a line in _gates/policy-override/applied.jsonl
one has noneexits 7 and applies nothing. Unless a denial already stands for the run, it records one on the override ledger (the run’s plan, its rules and members) and prints chant approve policy-override <run> --rule <id> --reason "<why>"
one has an override of an earlier plan or other rulesexits 7, and refused.reason is override-moved

A plan file can also say the product’s policy holds a run for a person (#4294):

{ "runs": [{ "target": "network/iam", "planDigest": "jcs1-sha256:...", "held": { "rules": ["main.hold_iam"], "reason": "an IAM role changes" } }] }

Such a run holds its wave until a person approves the set digest. This happens under gate: "never" too, the way a hook with onFailure: "approve" holds a wave. The decision’s heldBy names it as policy on <target> (<rules>) (packages/core/src/op/op-waves-run.ts:1987). A denial on the same run still refuses the wave. @intentius/chant/gate-policy runs conftest or OPA and gives the rules a product writes here (Policy at the Gate).

holds turns on holds chant runs over a wave’s plans itself (#4545), so a product does not need its own hook for them. They are read at the base commit with the policy. A policy hold set at base or in the change holds either way, so a change can add it and cannot drop it. A cost hold at base wins over the change’s.

{ "holds": { "policy": true, "cost": { "command": ["infracost", "breakdown", "--path", "{planJson}", "--format", "json", "--log-level", "error"], "approveAbove": 100 } } }

With policy: true, the deciding job runs the workspace’s ci.policy, read from the declaration at base as the pull-request jobs read it (Policy at the Gate), over each run’s change-set part. A deny rule marks the run denied and a hold rule marks it held, exactly as a plan file’s denials and holds do. A policy that cannot run fails the wave. The decision’s ciPolicySource names the commit of ci.policy.source that judged the runs. Each run needs a change-set part, which a step always gives and a plan command gives as changeSet in its plan file.

With cost, chant runs command once for each run whose plan changes something. {target} and {plan} are filled in, and {planJson} gets the engine’s plan document when the capability’s artifact names one (terraform-apply writes show -json beside its plan file). The command prints the estimate: infracost’s JSON by default, or { "monthlyDelta": <number> } with format: "chant". chant sums the monthly change over the wave. When the sum is over approveAbove, or a run could not be priced, the wave waits for a person whatever its gate says. heldBy gives the reason. The sum is a member of the set digest, (monthly cost), so an approval at one cost does not apply at another, and --record-plans puts the same member in the head’s digest. The terraform lexicon’s preset is terraformCostHold({ approveAbove }) from @intentius/chant-lexicon-terraform/cost-hold.

A product that ran its own wave gates before moving onto chant run wave has pending facts and approvals on chant/lifecycle under its own gate names, and maybe a plan note that shows a digest over the runs that change something. Three spec fields keep those valid across the move:

{
"name": "tf-apply",
"op": "tf-apply",
"gateName": "wave-{k}",
"digest": { "over": "changing" },
"neverOverMcp": true,
"planWave": ["..."],
"waves": ["..."]
}
  • gateName names wave k’s gate. With "wave-{k}" and name tf-apply, wave 2 waits on chant approve tf-apply wave-2, as before the move. The pattern needs {k}, and fills in {gate} (the base gate name) and {k} only.
  • digest.over: "changing" takes the set digest over the runs whose plan is not empty. When every run is empty, it covers them all, and the wave does not wait anyway. An approval of a digest the product computed the same way still counts.
  • neverOverMcp puts neverOverMcp: true on each pending fact the waves record, so op-approve over MCP or ACP refuses the gate, and under a decision point points-answer there refuses its question. It is read at the base commit as well as from the change, and either one is enough.

A pending fact the product recorded before the move still stands for its digest, so the wave records no second one, and an approval newer than it lets the wave apply.

The policy, the approval mode, the decision point, the spend rule and the hooks for wave k come from the spec file as it was at the base commit, HEAD^1 by default. On a merge or a squash onto the branch, that is the branch before the change. A pull request that sets prod to never merges, and prod still waits under the policy the branch had. If the wave or the file does not exist at the base commit, the wave is always. The jobs check out the full history so the base commit is there.

The same goes for hooks. A change cannot add, edit or remove a hook that its own apply runs, and the log says so when the change’s hooks differ from the ones at base. A wave or file missing at base has no hooks. If the hooks at base are malformed, none of them run and the wave waits for an approval.

Everything else in the spec is read from the commit being applied.

A wave with hundreds of targets can be split with shares:

{ "name": "prod", "shares": 4, "runs": [{ "target": "tenant-001" }, { "target": "tenant-002" }] }

This renders wave-<k>-prod-decide and wave-<k>-prod-share-1 to -share-4. The deciding job plans every run and decides one gate over all of them. Its decision (.chant/op-waves/<name>/wave-<k>.json) is kept as an artifact. A share job plans its slice of the runs again, with the runs sorted by target and cut into contiguous slices. It applies only the runs whose plan digest matches the recorded decision. When a run’s plan has moved since then, that run is named and skipped. The rest of the slice still applies, and the job exits 4. The next wave needs every share job.

runner puts jobs on a runner. The spec’s covers every job the spec renders, the resume and record-plans jobs included, and a wave’s covers that wave’s jobs. A spec with no runner renders the jobs it always has: ubuntu-latest on GitHub, the dialect’s label on Forgejo, and no tags on GitLab.

A wave whose runs need different identities, such as an apply per environment with each environment’s own cloud role, splits its apply with jobs:

{
"name": "apply",
"runner": "plan",
"idTokens": { "PLAN_TOKEN": "plan.example.com" },
"runs": [{ "target": "live/dev/vpc" }, { "target": "live/prod/vpc" }, { "target": "live/prod/db" }],
"jobs": [
{ "name": "dev", "runs": ["live/dev/**"], "runner": "dev-apply", "environment": { "name": "dev" }, "idTokens": { "CLOUD_TOKEN": "dev.example.com" } },
{ "name": "prod", "runs": ["live/prod/**"], "shares": 2, "runner": ["self-hosted", "prod-apply"], "environment": { "name": "prod" }, "variables": { "ENV": "prod" }, "idTokens": { "CLOUD_TOKEN": "prod.example.com" } }
]
}

This renders wave-<k>-apply-decide, wave-<k>-apply-dev, and wave-<k>-apply-prod-share-1 and -share-2. The deciding job runs with the wave’s own settings (here the plan runner and the plan token), plans every run, and decides the wave’s one gate. Each group’s job runs chant run wave --wave <k> --group <name> (with --share <i> when the group has shares). It plans its own runs again with its own identity and applies those whose plan digest matches the decision, as a share job does. One approval of the wave’s digest is enough for all of them. A refused run refuses the whole wave, since the deciding job decides for every group, and the wave after it waits for every group’s job to finish.

Group fieldMeaning
nameThe group’s name, in its job’s name. Not decide or share-<i>
runsThe runs it applies: targets, or patterns where * matches within one / segment and ** across segments
sharesSplit the group’s runs across this many jobs. Default 1
runnerDefault: the wave’s, else the spec’s
environmentThe group’s forge environment. Default: the wave’s. A spec error on Forgejo
variablesAdded over the wave’s variables
setupRun after the wave’s setup steps
idTokensReplace the wave’s id tokens

Each run of the wave is in exactly one group. A run in two groups or in none is a spec error that names the run. On a discover wave the runs are known only at plan time, so the deciding job checks them and fails (exit 1) before the gate when one is in no group or in two. A group that holds none of the runs found applies nothing and exits 0. A wave with jobs cannot have its own shares or rest.

How each forge renders a job’s settings:

SettingGitHubGitLabForgejo
runnerruns-on; a runner group as { group, labels }tags; a runner group is a spec errorruns-on, through the dialect’s label map; a runner group is a spec error
environmentenvironment:environment:a group’s is a spec error; a wave’s is dropped with a header line, as before
idTokenspermissions: on the job (the workflow’s plus id-token: write) and each audience as <VARIABLE>_AUDIENCEid_tokens: { <VARIABLE>: { aud } }permissions: id-token: write and each audience as <VARIABLE>_AUDIENCE

On GitHub and Forgejo the job asks for its token at run time, with the audience it names in the request ($ACTIONS_ID_TOKEN_REQUEST_URL&audience=$CLOUD_TOKEN_AUDIENCE), so the variable is how the job’s own code finds it. GitLab mints the token into $<VARIABLE> before the job starts, with only the audiences the job declares.

A job that applies with an identity is only as separate as the forge and the cloud make it. The forge’s environment rules and protected runners decide which refs may run a group’s job, and the cloud role’s trust decides which token may assume it.

With "standDown": true on the spec, an apply steps aside when a newer commit on the branch will apply the same targets (#4581). The job then applies nothing and exits 6, superseded.

{ "name": "migrate", "op": "migrate", "standDown": true, "step": { "kind": "sql-migrate", "environment": "{target}", "spec": "yodel-waves.json" }, "waves": [...] }

The branch is GITHUB_REF_NAME on GitHub and Forgejo, CI_COMMIT_BRANCH on GitLab, else the checked-out branch. chant fetches its tip from origin. A tip that is another commit and contains this one is newer. chant then reads the spec file at that tip. The apply stands down only when that spec still runs on the branch and has a wave of this one’s name listing every target here. A discover wave counts for any target. Anything chant cannot tell goes ahead and applies. That covers a missing branch or origin and a failed fetch. So does a tip that does not contain this commit, as after a force-push, or a spec at the tip that drops a target.

The check comes after the wave’s holds are settled and its lock grain’s lease is taken, and before its approval is spent. A wave on the resource grain lets go of its rows before it exits. The job’s run record has wave.outcome stood-down, with the newer commit and its branch in wave.supersededBy, and its status is ok. No notification goes out. An apply command can still write stood-down to CHANT_APPLY_OUTCOME itself. SQL Yodeler’s YODEL_STAND_DOWN and terragucci’s newerPush do this today, and either can leave it to chant once its chant has OP_WAVE_STAND_DOWN_FLOOR.

With control on the spec, the pipeline tells a control repo how the waves ended once the last wave ran (#4617). The control repo then runs this member’s dependents, as it does after the pull request loop’s apply (The control repo).

{ "name": "stacks", "op": "pulumi-up", "control": { "repo": "github.com/acme/control", "op": "deploy", "member": "network", "tokenSecret": "CONTROL_TOKEN" }, "waves": [...] }

control takes the pull request loop’s settings: repo, op, forge, tokenSecret, readTokenSecret, ref and apiBase. member is required here, since a spec has no repository name to default it to. sentCheck and markSent are the product’s shell lines that find and set the commit’s control status.

The control-dispatch job needs the last wave’s jobs. On GitHub and Forgejo it runs after them unless the run was cancelled, so a failed run does not stop it. On GitLab a last wave whose runs failed lets it run, and a wave that waits at its gate stops it with the waves after it. The job reads every wave job’s outcome file and adds them up with chant run wave --spec <file> --waves-outcome, through the product’s bin:

OutcomeWhen
appliedA run applied, and every other run applied or had nothing to apply
partialSome runs applied, and others failed, were blocked, refused or wait
unchangedNo run had anything to apply
waitingNothing applied, and a wave waits for an approval
failedNothing applied, and a run failed, was refused or blocked, or no wave wrote an outcome

The dispatch carries that outcome with the member, the Op and the pushed commit. Only its step holds the token: the tokenSecret secret, mapped into CHANT_CONTROL_TOKEN and handed to curl on its stdin. On GitLab a CI/CD variable reaches every job, so each wave job, the resume job and the record-plans job unset the control repo’s token variables first, and the job adds up the outcome in a subshell without them.

The control repo records each dispatch that carries an outcome as a control-applied line of _control/applied.jsonl on its chant/lifecycle, and runs the dependents only after applied or partial. A pull request note reads those records to mark a stack another repository applies as stale, current or unknown (Cross-stack edges).

Each chant run wave job appends one run record to <env>/runs__<name>.jsonl on chant/lifecycle, however it ends (#4551). The record goes under the environment the spec’s labels.Env names, else local, as every Op’s does. The spec’s labels are copied onto it. The record has one phase per wave the job walked, wave-<k>, and one step per run target: ok when it applied, fail when it failed, and skipped when it moved, was blocked or waited. Its wave field names the spec, the wave, the job (wave, decide, share or group), the set digest, the exit code and the runs applied, failed, moved and blocked, so a deciding job and its share jobs join on wave.digest. chant ledger runs --where op=<name> lists them. --no-record and CHANT_NO_RECORD write none. wave.targets holds each run target whose apply the job started (#4555). An entry keeps the start time and the duration, which is also the step’s durationMs. It keeps the facts the capability gave too. A job that stood down for a newer commit names it in wave.supersededBy (branch, commit). wave.plans holds each planned run with policy rows, from holds.policy or a hook in the job’s process, and the files those hooks wrote (#4614).

A spec with a step also records each run it applied on its environment’s release ledger, as chant components promote records each component it deploys (#4615). chant components rollback <env> --component <name> then reads stacks and roots applied through op waves. The record goes under labels.Env, else the wave’s name, and names the run’s target as its component. The spec’s release changes both, and a run’s own release wins over it. Their strings take {target}, {op} and {wave}, as the step’s input does. In this spec every stack records under its wave’s name, and the prod stack records as shop.

{ "name": "pulumi-up", "op": "pulumi-up", "step": { "kind": "pulumi-up" }, "release": { "env": "{wave}", "component": "{target}" },
"waves": [{ "name": "prod", "runs": [{ "target": "shop/prod", "release": { "component": "shop" } }] }] }

When a release cut from the applied commit records the component’s templates for that environment, the record names that release and carries its templates digest. A rollback to it runs under the release, through the plan and the release gate (#4542). With no such release, the record holds the run’s plan digest with digestKind: plan, as a pull request’s apply records it. workspace status lists it, and rollback passes over it, since there are no recorded files to apply again. So cut the release before the waves run (chant release cut on the merge commit), and each wave’s apply joins it. "release": false writes no records. A record that cannot be written costs one line in the log, and the job keeps its exit code.

With OTEL_EXPORTER_OTLP_ENDPOINT (or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT) set, each chant run wave job sends one trace as OTLP/JSON over HTTP when it ends (#4555). TRACEPARENT joins it to a trace the pipeline already started. OTEL_EXPORTER_OTLP_HEADERS adds headers to the request. OTEL_TRACES_EXPORTER=none turns it off, as does OTEL_SDK_DISABLED=true. A collector that refuses the trace, or that cannot be reached, costs the job one line in its log. The exit code stays the job’s own.

SpanUnderAttributes
op <name>, the jobTRACEPARENT’s span, when setrun.id, run.kind, run.runtime, status, failure.code, vcs.ref.head.revision
wave-<k>the jobphase, status
each run targetits wavestep, status, member, kind, resources.<action> from the plan, and the capability’s facts
each timed resourceits run targetwhat the capability timed, such as plunge’s provider calls
gate:<name>, on a job that waitsits wavestatus: gated, with a gate-waiting event

Every attribute chant writes is under the CI product’s name: chant.status on chant’s own jobs, terragucci.root and plywood.stack under the products. The terraform lexicon adds root and binary. The pulumi lexicon adds stack, engine and the up.<op> counts from the update’s summary. On plunge it also reads the per-resource timings plunge prints in up --json (#4579, plunge#55). Each resource it timed becomes a span under the stack’s span, with a child span for each provider call and record write, and the same spans go under the stack’s entry in wave.targets. The stack’s span gets the totals: plunge.calls, plunge.provider_ms, plunge.record_ms and the slowest call. A stock Pulumi update prints no timings, so its stack has no resource spans.

On plunge, the stack’s step-settle event in --events-json also carries resources, one entry per timed resource (#4615). An entry names the resource by its URN with its type and name. It says ok or failed, and gives the time the resource took and how many calls it made. The job’s log prints one line for each, such as shop/dev: assets (aws:s3/bucket:Bucket) ok in 412 ms, 3 calls. The lines come once the stack’s update ends, since plunge prints its timings with each step’s outputs. A capability gives them as resources in its trace facts, and a step whose engine reports none has no resources.

With notify in the spec, a job that exits 1, 3, 4 or 7 also posts an event saying so (Notify). A delivery that fails never changes the exit code.

CodeMeaning
0The wave applied, or the deciding job decided it may apply
1A plan, an apply or a hook failed
3The wave is waiting for an approval of its set digest, because its policy or a hook holds it; nothing in it was applied
4A share job, or a job group’s job, refused a run whose plan moved since the decision. Under approvals.preview, a wave refused plans that are not the ones its pull request previewed
5The apply applied nothing: another run holds what it changes
6The apply stood down for a newer run
7The product’s policy denied a run and no override counts for it; nothing in the wave was applied
8The gate’s decision point was answered with an answer it does not pass on; nothing in the wave was applied

A tool that runs its own waves can decide a gate by these rules without running chant run wave. @intentius/chant/gate-decision exports the decision and the seal check:

ExportWhat it does
decideGateApproval({ ledger, gate, planDigest, mode, signers, review, spend })decides a plan-bound gate from its ledger lines under ledger, pr-review or sealed, and returns approved (with the resolution or the review) or waiting (with the standing pending fact, the approval of another digest, and each approval of this digest that did not count, with the reason). With spend and ledger.applied, an approval a wave applied under counts for nothing and comes back as spent
parseAppliedGateLines(text), isApprovalSpent(applied, approval)read _gates/<op>/applied.jsonl, and say whether an approval is spent by it
appliedGateApplies(records)the applied lines as gate-audit applies
baseCommit(repo)the first parent of HEAD, fetched when the checkout is shallow
gateSignersAt(repo, base)the signers file at base, at the path .chant/trust.json names there. An invalid trust.json turns attestation off, as it does in chant
gateSealRefusal(signers, approval)why a seal does not count for its approver, or null when it does
identityGatesAt(repo, base)the gates chant.workspace.json at base lists under identity.gates, each with its quorum (#4324), policy, mode and context (#4404) when the entry sets them
identityGateAdmissionAt(repo, base, gate, { packages, classes })the identity.gates rule for one gate at base, or null when the declaration names none. Its refuses(approval) is what chant’s own gateAdmission answers: the seal against the signers at base, then the class against the role grants in .chant/trust.json at base. Pass it to decideGateApproval as refuses
admitApprover(rule, approval)the same judgement over a rule you build yourself: the gate, its class, the signers, the role grants and the known classes
reviewApproval(merged, headDigest, digest)whether the merged pull request’s review approves the digest, under pr-review

identityGateAdmissionAt knows the four core classes (human, agent, runner, service) and the domain classes the declaration’s pins supply, read the way chant reads them. A path pin’s ./workspace-principals file is read at base, so a change can’t remap a class by editing its own copy of the plugin. A package pin’s file is read from the package installed under packages (the repository by default), which must be at the pinned version. A bare clone has no node_modules, so a job that reads one passes the directory its packages are installed under. The module reads that file as data and never imports a package. When a pin can’t be read, a gate naming a domain class or human refuses every approval and names the pins it could not read; a gate naming another core class, or none, is judged as usual. A gate whose class no pin supplies refuses every approval, as in chant. A caller can pass classes instead, each a { name, role }. That list stands for every domain class, and no pin is read. gateAdmission and identityGateAdmissionAt both judge with admitApprover, and gate-decision-identity.test.ts checks that they give the same answer and the same reason on the same commits, a class from a pinned package included.

Reading the ledger and the forge’s review is the caller’s job. The caller also records a pending fact, the review’s approval or the applied line. The seal is checked with node:crypto, so the job needs no ssh-keygen, and it verifies every key type a signers file accepts. Bundled with esbuild for node, the module comes to about 43 KB. gate-decision-bundle.test.ts lists every module in that bundle. It fails when TypeScript, zod or ajv joins it, and also when chant’s package loading or its git ledger code does.

A wave’s environment, or a job group’s, lands on its jobs on GitHub and GitLab, where a protected environment can hold the job for a reviewer before it starts. Forgejo Actions has no environments, so the Forgejo workflow drops the key and its header says so. The chant gate holds the wave on all three.

  • chant run: the run wave command and its flags
  • Ops: gates, and why a gate approves a plan rather than the next run
  • Pinned Module Rollout: waves of Terraform roots
  • Notify: events for a wave that waits or goes wrong

chant