Skip to content

Deliver Through Stages

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/pipeline/.
In the member's directory, run `npx chant pipeline spec` and show me the folded spec, then `npx chant pipeline spec --stage <stage>` for the stage I name.
If the file does not fold, show me the finding and the line it names.
Never deploy to a real cloud account or shared environment, approve (`chant approve`), merge, or cut a release (`chant release cut --yes`).

A stage is an environment in promotion order: dev, then staging, then prod. A member’s pipeline declares every stage in one file, .chant/pipeline.ts, with the waves each stage applies, the gate each stage passes, its hooks, and its holds. The file is written inside the TypeScript-as-data subset, so chant folds it to a JSON spec without running it, and a reviewer and the gates read the same spec before anything executes. The fields are in the pipeline reference.

  1. A pull request plans as before. When it changes the pipeline, its plan note shows the folded spec’s diff.
  2. The merge applies the first stage’s waves, each behind the stage’s gate, read from the pipeline at the base commit.
  3. Once the first stage’s last wave applied, the merge cuts a release from the applied commit with chant release cut auto --first 0.1.0 --yes --wait-checks, which follows the member’s release.green setting. Under forge-checks the cut waits for the other push workflows still running on the merge commit, and counts the jobs of its own run that its wave depended on (the product’s firstWaveNeeds jobs, such as its check, and the earlier waves’ jobs) through --own-run-jobs, so a merge commit that only this run checks still gets its release. A follow-on run of a later wave, or a run that is started again for the commit, has none of those jobs, so the cut there names none and waits for a check from another workflow. The member’s first merge cuts its first release at 0.1.0, or at the version release.first names, and each later merge bumps the previous release.
  4. Each later stage takes that release through chant components promote --to <stage> --release <label>, behind that stage’s gate. A person runs it, or starts the generated promote job.

The control repo’s <product>-applied dispatch goes out after the first stage, the one a merge applies.

A product built on chant writes .chant/pipeline.ts from its own config, as it writes its workflows. A member with no product writes it by hand:

import { pipeline } from "@intentius/chant/pipeline";
const step = { kind: "pulumi-up", stack: "{target}" };
export default pipeline({
name: "shop",
defaults: { op: "shop", step },
stages: [
{ name: "dev", waves: [{ name: "dev", runs: [{ target: "dev" }] }], gate: { policy: "never" } },
{ name: "staging", waves: [{ name: "staging", runs: [{ target: "staging" }] }], gate: { policy: "on-destructive" } },
{
name: "prod",
waves: [{ name: "prod", runs: [{ target: "prod-eu" }, { target: "prod-us" }] }],
gate: { approval: "sealed", quorum: [{ count: 2, roles: ["sre"], notAuthor: true }] },
freeze: [{ from: "2026-12-20T00:00:00Z", until: "2027-01-04T00:00:00Z", reason: "year end" }],
},
],
});

The file holds imports from @intentius/chant/pipeline, consts of literals, and one export default pipeline({ ... }). Fold it:

Terminal window
chant build
chant pipeline spec
chant pipeline spec --stage prod

chant build writes the spec to .chant/pipeline.json. chant pipeline spec --stage prod prints the op-waves spec the stage runs, under the name shop-prod, so each stage’s wave gates are its own.

A file outside the subset stops the build with the evaluability rule it breaks, and chant lint and the editor show the same finding at the same line:

.chant/pipeline.ts:3:14 [EVL001] ambient "process" read is not foldable
Terminal window
chant pipeline generate github

This writes two workflows. The first runs the first stage’s waves on a push to the default branch. Each wave job runs chant run wave --render-spec, and its spec comes from chant pipeline spec --stage dev at the commit the job hands it, so the gate is the one the pipeline declared at the base commit. The second, shop-promote.yml, is started by hand with a stage and a release, and runs chant components promote for that stage. gitlab and forgejo write the same two files for their forge.

Terminal window
chant components promote --to staging --release v1.4.0

With a pipeline, components promote reads it at the default branch’s tip:

  • --from defaults to the stage before --to, or to the first stage its after names.
  • A held stage, or one inside a freeze window, refuses with exit 3 and names the time it opens.
  • The stage’s gate waits for an approval of the release’s digest, unless its policy is never. The promote exits 3 and prints the chant approve shop staging --env staging --plan <digest> line; run the promote again once it is approved.
  • A promote that skips a stage is refused. With --allow-skip it passes only through each skipped stage’s gate, <stage>-skip, and the skip is recorded on _gates/shop/applied.jsonl.
  • A release someone rejected at the stage’s gate does not enter the stage, and is not skipped past it. The promote exits 8 and names who rejected it and why.
  • Under a gate whose approval is sealed, only an approval sealed by a signer at the tip counts, as it does for a wave.

A component run into a stage, chant run --components all --env staging, waits at the same gate: under --release it binds the release’s digest, so the approval a promote waited on lets the run through too. A stage whose policy is never goes straight to its components’ own gates. A redeploy, a rollback and a fan-out into the stage wait at the gate too. See A run into a pipeline stage.

A member whose defaults.step applies each stage, such as a SQL project’s sql-migrate, and whose work is its op waves rather than *.component.ts files, promotes by the stage’s own op waves. Once the stage’s gate passes for the release, the promote writes the stage’s spec to .chant/op-waves/shop-staging.spec.json, with a step input named spec pointing at that file, and runs each wave in order as chant run wave runs it. Each wave plans, decides its gate on its plan digest under the op shop-staging, and applies the plan it decided. A wave that waits exits 3 with its chant approve line, and the same promote carries on from there once it is approved. The gates of the waves are read from the pipeline at the tip, through pipelineStageShow, which an engine that checks chant’s decision again passes to readOpWavePolicy.

Such a promote takes --release, and the checkout must hold the commit the release was cut from. The release records it writes name the release. When a stage’s run targets name its environments (dev, staging), every stage records under the pipeline’s name as the component, or under defaults.release.component.

A reviewer who does not want a release in a stage turns it down at the stage’s gate:

Terminal window
chant reject shop staging --reason "the migration locks the orders table"

chant reject <pipeline> <stage> records the rejection on _gates/shop/rejected.jsonl on chant/lifecycle, bound to the release’s digest. It takes the digest, the environment and the release off the gate’s pending fact, as chant approve does; with no pending fact yet, pass --plan <digest>. The promote into staging then exits 8 with release <digest> was rejected at shop staging ... rejected by github:alice at <time>: the migration locks the orders table.

A rejection counts by the rules an approval of the same gate counts by. A gate whose approval is sealed, or that the workspace’s identity.gates names, counts only a signed rejection: --sign [<key file>], or --statement and then --signature <file> --at <time> for a signature made with a passkey or elsewhere. A gate whose rules count only proven approvers, or approvers with a role, counts only a rejection from someone they would count. An agent’s rejection counts for nothing, as an agent’s approval does. A rejection that does not count is printed with the reason, and the gate is decided as if it were not there.

A product whose words map a comment command onto reject takes the same from a pull request comment, /<product> reject <reason>, recorded under the author’s forge identity where the stage’s mode takes it. A sealed stage, or one whose rules need a proven approver, answers with the chant reject ... --sign line instead (product config).

Approvals never clear a rejection, and nothing withdraws it. The way on is a new release with the change the reason asks for, which has a new digest and goes through the gate again.

chant workspace train promote reads the same holds for each member before any member deploys.

A stage publishes named values for the release it applied, and a later stage reads them from that same release:

{ name: "dev", waves: [...], publish: { endpoint: { member: "cluster", output: "endpoint" } } },
{ name: "staging", waves: [...], reads: { TF_VAR_dev_endpoint: { stage: "dev", artifact: "endpoint" } } },

The merge publishes dev’s artifacts right after it cuts the release. promote --to staging --release v1.4.0 reads endpoint from dev’s record of v1.4.0 into TF_VAR_dev_endpoint before it deploys, and refuses when dev has not published it for that release. chant build refuses a read of a stage that is not upstream of the reading stage, or that does not publish the artifact. Upstream means an ancestor through after, or an earlier stage when no stage names after, so a stage cannot read from a sibling that fans out from the same stage. A secret is published as where it is kept ({ secret: { awsSecretsManager: "..." } }), and an output the engine marks sensitive is refused. Another repository reads them with chant pipeline artifacts read --stage dev --from <dir>. The reference has the rules.

A later stage can run agent steps: a model reads what earlier stages published for the release and answers in a shape you declare, such as the services to watch during the soak.

{
name: "prod",
waves: [...],
gate: { holds: { policy: true } },
agentSteps: {
watch: {
prompt: "List the services to watch during the soak.",
reads: { endpoint: { stage: "staging", artifact: "endpoint" } },
schema: { type: "object", required: ["services"], properties: { services: { type: "array", items: { type: "string" } } } },
},
},
}

The generated promote workflow runs the steps in a job of their own that holds a read token only, then records their answers with the release before it promotes:

Terminal window
chant pipeline agent run --stage prod --release v1.4.0
chant pipeline agent record --stage prod --release v1.4.0
chant components promote --to prod --release v1.4.0

An answer that does not match the schema fails its step, and the promote holds with exit 3 naming the step and the schema’s complaint. With holds.policy, the gate’s policy reads the answers as input.agent.watch, and the gate still waits for a person’s approval. chant pipeline agent answer --stage prod --release v1.4.0 --name watch prints an answer for any later step. The reference has the rules.

Fan out to regions and join before production

Section titled “Fan out to regions and join before production”

A stage follows the stage before it in stages unless it names its own with after. Name one stage in several after lists and a release fans out to each; name several stages in one after and the stage waits for the same release in each of them:

stages: [
{ name: "dev", waves: [{ name: "dev", runs: [{ target: "dev" }] }], gate: { policy: "never" } },
{ name: "us", waves: [{ name: "us", runs: [{ target: "us" }] }], after: ["dev"] },
{ name: "eu", waves: [{ name: "eu", runs: [{ target: "eu" }] }], after: ["dev"] },
{ name: "prod", waves: [{ name: "prod", runs: [{ target: "prod" }] }], after: ["us", "eu"], queue: "replace" },
],

chant components promote --to prod --release v1.4.0 opens prod only once v1.4.0 applied in us and in eu, and then through prod’s gate. Until then it exits 3 and names the stages missing. A stage that names after is promoted with --release, since the join reads the same release in each stage. A cycle, such as two stages that name each other, fails chant build with the stages named.

queue: "replace" lets one release into the stage at a time. When v1.5.0 reaches prod while v1.4.0 still waits for its approval there, v1.5.0 replaces it: the stage log records the replacement, and a later promote of v1.4.0 into prod is refused. A release already in the stage finishes; one that arrives meanwhile exits 3 and goes in on its next promote once that deploy has ended. chant workspace status prod shows what is deploying in prod now, what waits for it, and which releases were replaced there.

Let a wave of many targets go on past a few failures

Section titled “Let a wave of many targets go on past a few failures”

A wave that applies to many tenant databases can tolerate a few failed runs. Set failureTolerance on the stage, or on one wave:

{ name: "prod", waves: [{ name: "tenants", runs: tenants }], failureTolerance: "5%" }

Within the tolerance the failed runs stay failed and block the runs that depend on them, and the wave counts as applied. The tolerance is read at the base commit with the gate.

Set hold: true on a stage, or hold: { reason, until, description }, and merge the change. A promote into the stage then refuses with exit 3 until the hold lifts.

description is what the person who lifts the hold reads first, such as what to check before the stage goes on:

{ name: "prod", waves, hold: { reason: "billing cut-over", description: "confirm the invoice run finished in the billing dashboard" } }

The promote the hold refuses prints it, chant workspace status prints it under the member, and the plan note of the pull request that lifts the hold shows it above the pipeline’s diff.

chant