Skip to content

chant ci

llms.txt lists every page for an agent
chant ci last-green [--json] [--lane <name>] [--from <rev>] [--branch <branch>]
chant ci base [--json] [--phase <name> | --lane <name>] [--from <rev>] [--branch <branch>]
chant ci verdict [--commit <sha>] [--wait [--retries <n>] [--timeout-minutes <n>]] [--branch <branch>]
chant ci list [--json] [--branch <branch>] [--limit <n>] [--since <rev>] [--forge github] [--source checks|runs]
chant ci tick [--dry-run] [--forge github] [--source checks|runs] [--key <runner key.pem>]
chant ci quarantine check
chant ci quarantine filter --phase <name> --runner nextest|playwright|list [--only] [--json]
chant ci quarantine report --phase <name> --junit <file>... [--commit <sha>] [--dry-run] [--json]
chant ci run plan|record|apply|env-up|env-post|env-down|env-sweep --env <env> --base <sha> [--pr <n>] [--commit <sha>] [--head <sha>] [--result <r>] [--forge github|gitlab|forgejo]
[--gate <name>] [--wave-gate <name>] [--wave <k>] [--branch <name>] [--events-json] [--report-url <url>] [--run-index-limit <n>]
[--image <image>]
[--before-script <line>]... [--pr-build] [--pr-build-command <line>] [--require-review] [--apply-before-merge]
[--no-status] [--status-url <url template>]
[--chant <command>] [--pass-env <NAME>]... [--secrets <file>]
[--key <runner key.pem>] [-o <dir>] [--in-place | --local] [--no-push] [--require-runner-start] [--verbose]
chant ci runner-start sign --key <runner key.pem> --principal <name> --job <json|@file> [-o <file>]
chant ci runner-start verify [--base <rev>] [--commit <sha>] [--json]
chant ci run --at <sha>
chant ci runs [--report-url <url>] [--json]
chant ci serve --forge forgejo|github|git --repo <owner/repo> --env <env> [--interval <s>] [--max-jobs <n>]
[--state <dir>] [--author <login>]... [--once] [--rerun-failed] [--unsigned] [--apply-on-merge]
[--build-command <line> [--land]] [ci run's job flags]
chant ci serve --setup-key [--trust [--principal <name>]] [--state <dir>] [--branch <name>]
chant ci run --setup-key [--trust [--principal <name>]] [--state <dir>] [--branch <name>]
chant ci init --workflow trunk-curated|trunk-curated+apply-on-merge|apply-before-merge [--forge github|gitlab|forgejo] [--security <group>]... [--yes]
chant ci check --base <rev> [<target>...] [--output <dir>] [--json]
chant ci forge-check [--env <env>] [--member <name>] [--forge github|gitlab|forgejo] [--repo <owner/name>] [--branch <default>] [--require-clouds] [--json]
chant ci workflow [--workflow <name>]... [--output <file>] [--chant <command>] [--install <command>]
[--token-secret <NAME> | --app-id-var <VAR> --app-key-secret <NAME>]
[--runner-key-secret <NAME>]

chant ci records which commits of a branch passed CI as git tags, from the ci.green block of the workspace declaration (#3573, ws-103). A commit that passes every required phase gets ci/green/<sha>. A green commit that later fails one gets ci/revoked/<sha>. Anyone with a clone can then find the newest commit that passed, for example to freeze it and release from it.

Prints the full id of the newest first-parent commit of the branch that has a green tag and no revoked tag. The walk follows refs/remotes/origin/<branch> when the checkout has it, else the local branch. Only local tags are read, so fetch them first:

Terminal window
git fetch origin --tags
git checkout "$(chant ci last-green)"

When no commit qualifies, a message goes to stderr and the exit code is 1. With a list in ci.green.branch, --branch <branch> reads one of the listed branches instead of the first, and a branch not in the list is ci-branch-unknown. --from <rev> walks the first-parent commits of rev instead of the branch, so chant ci last-green --from <sha> prints <sha> exactly when that commit counts as green. --lane <name> reads a lane’s tags, ci/green-<lane>/ and ci/revoked-<lane>/, and a lane ci.green doesn’t declare is declaration-invalid. With signed tags, each tag the walk ignores is printed on stderr as a warning.

--json prints a read contract document, ci-last-green.schema.json, whose commit is { sha, tag, tagged, committed } or null, and exits 0 in both cases. ignored lists the tags the walk passed over for want of a valid statement, newest first, each with tag, status and reason. newer (#4169) lists up to 50 commits above the one found. Each has the commit’s record, or null when it has none. A failure has an error and exits 1. Its code is ci-green-undeclared for a declaration with no ci.green, ci-branch-unknown when the branch has no ref in this checkout, or the code of a declaration that can’t be read.

Prints the commit a path filter should diff against when its phase declares build: "newest" (#4643). It walks the first-parent ancestors of --from (HEAD by default), leaving that commit out, and stops at the newest one whose record shows the phase built and passed on that very commit. A commit a newer build covered was never built, and a commit where the phase failed would let a change on top of the failure skip the job, so both are passed over. Without --phase, every required phase must have passed there. A commit with no record, from before the tick’s window, counts when it has a green tag and no revoked tag, as ci last-green reads them.

Terminal window
git fetch origin --tags +refs/heads/chant/lifecycle:refs/remotes/origin/chant/lifecycle
base=$(chant ci base --phase test) || base="" # no base: run everything

The records are read from the local chant/lifecycle, or from origin/chant/lifecycle when the checkout has no local branch, which is the usual case in a CI job. When no commit qualifies, a message goes to stderr and the exit code is 1, and the caller should run the job. --phase must name a phase in ci.green. --lane <name> checks a lane’s phases instead, and its tags for a commit with no record; give --phase or --lane, not both. --branch picks the green branch as for ci last-green.

--json prints ci last-green’s document with two additions: phase, the phase asked about or null, and commit.via, record or tag. commit.tag is null for a commit whose record passed the phase but which has no green tag. The document exits 0 whether or not it found a commit.

Judges one commit by the phases ci.green requires, from its check runs, as ci tick judges a commit (#4644), and prints the result. The commit is --commit <sha>, else GITHUB_SHA, else HEAD, and the check runs come from GitHub as the tick reads them (GITHUB_REPOSITORY and a token). Its own check run, chant-verdict, doesn’t count. It exits 0 when every required phase passed, 1 when one failed or wasn’t built, and 3 while one is pending. With --wait it reads again every 30 seconds until none is pending.

While it waits, GitHub answering 5xx or 429 is not a failure, and neither is a request that gets no answer (#4729). It looks again after 15 seconds and doubles the wait each time up to two minutes. After 8 such errors in a row it fails and names the last one. Any other error, such as a 404 or a missing token, fails at once. --timeout-minutes <n> bounds the wait: once that time is up it exits 1 with a message saying what it was still waiting for, so a job can end before Actions kills it at its own timeout-minutes.

--retries <n> gives a failed job more attempts before the commit fails, as the tick gives a commit on the branch one retry. It overrides ci.green.mergeQueue.retries, and both default to 0, which fails at the first failed job. Above 0, on a failed job of a required phase, the verdict waits for the job’s workflow run to finish (GitHub re-runs a run only then), and while the run’s attempt is no more than <n> it re-runs the run’s failed jobs (POST /repos/{repo}/actions/runs/{run}/rerun-failed-jobs) and keeps waiting. A run that fails on attempt <n> + 1 fails the commit with a message naming the phase and the job in its workflow run. A failed check run that is no Actions job has nothing to re-run and fails at once. The token needs actions: write.

With "mergeQueue": true in ci.green, ci workflow adds merge_group (checks_requested) to the triggers of each workflow holding a phase that sets build, and writes .github/workflows/chant-merge-queue.yml beside the tick. Its one job, chant-verdict, runs chant ci verdict --wait on the group’s commit. Require chant-verdict in the branch’s ruleset, and the queue merges a group only when every required phase passed on it. With "mergeQueue": { "retries": 1 } the verdict re-runs a failed job’s workflow run once before it fails the group, and the job gets actions: write and runs chant ci verdict --wait --timeout-minutes 115, five minutes inside its two hours (#4729). true is { "retries": 0 }, and writes the file as before. A workflow holding a phase without build gets no trigger, so add merge_group to it by hand, or its phase stays pending and the verdict waits out its job’s two hours.

The queue lands the commit its group tested, so the group’s check runs are already on the branch’s commit, and the tick counts them. The push run on that commit reports the same jobs again. A skipped or cancelled attempt never replaces a decided one, so a job a path filter skips on the push, or a push run a newer one cancels, leaves the group’s result standing, and the commit’s record lists the group’s run.

A lane is a named subset of the phases with tags of its own (#4662), for a repository that ships several things from one branch: a server release can wait on the server’s phases alone while ci/green/<sha> still needs every one.

"green": {
"branch": "main",
"phases": { "lint": ["lint"], "test": ["test"], "windows": ["windows"] },
"require": ["lint", "test", "windows"],
"lanes": { "server": { "require": ["lint", "test"] } }
}

The tick judges each lane after the branch, from the check runs it already read, so a lane runs nothing and asks for no build or retry of its own; the bisect and the retry stay per phase. A commit that passes a lane’s phases gets ci/green-<lane>/<sha>, and a lane-green commit that later fails one gets ci/revoked-<lane>/<sha>. Each annotation’s record carries lane. Under signedSince the statement signs it, so a lane’s tag never counts as ci/green or as another lane’s, and a ci/green statement never counts for a lane. ci last-green --lane and ci base --lane read a lane, and the tick’s report has a line for each lane tag it makes. The _ci/<sha>.json records keep each phase’s verdict, from which any lane’s state follows.

A test that fails on both tries on unrelated commits turns the branch red for everyone, and the tick can’t tell that red from a real one. Until someone fixes it, the test can go in ci.green.quarantine (#4677): the phase’s runner leaves it out, so the phase’s check runs and the verdict don’t depend on it, and a scheduled run of the quarantined tests alone says whether it still fails.

"green": {
"branch": "main",
"phases": { "test": ["test (*)"], "e2e": ["e2e"] },
"require": ["test", "e2e"],
"quarantine": {
"maxDays": 14,
"phases": {
"test": [
{ "test": "arugulad::integration ssh::ssh_installs_runs", "issue": "1234", "until": "2026-11-10", "why": "Fails on both tries on unrelated commits (2ac1e89ba, c2b452072)." }
],
"e2e": [
{ "file": "chat-control.spec.ts", "test": "polish: edits the last message and Esc cancels", "issue": "https://github.com/acme/app/issues/1235", "until": "2026-11-10", "why": "Races the composer's focus." }
]
}
}
}

Each entry names the test as its runner does, the issue that tracks the fix (a number or a URL), the last day it stays out (until, UTC) and why. For nextest, test is the binary id, a space and the test’s name, as nextest prints them in its log, or the name alone to match it in any binary. For Playwright, test is the test’s title and file the spec’s path from the project’s testDir, as Playwright prints it. Any other runner can take the entries as a list.

chant ci quarantine filter --phase <name> --runner <runner> prints what the phase’s runner takes:

--runnerPrintsPass it as
nextestA filterset over the phase’s entries without a file: not ((binary_id(=arugulad::integration) & test(=ssh::ssh_installs_runs))), or all() when there are none.cargo nextest run -E "$(chant ci quarantine filter --phase test --runner nextest)"
playwrightA pattern over the phase’s entries with a file, matching each test’s title path: (?:^| )chat-control\.spec\.ts (?:.* )?polish: edits the last message and Esc cancels(?: @\S+)*$, joined with |, or (?!), which matches nothing, when there are none. Regex characters in the file and title are escaped.npx playwright test --grep-invert "$(chant ci quarantine filter --phase e2e --runner playwright)", or grepInvert: new RegExp(...) in the config
listEvery entry of the phase, a line each: the test, or the file, a tab and the test. Nothing when there are none.Whatever the runner takes

Playwright’s CLI compiles --grep-invert case-insensitively, so a title that differs from a quarantined one only in case is left out too. --json prints the filter with the entries it covers.

The filter fails with declaration-invalid, at the entry’s line in the declaration, when an entry of the phase is past its until or the until is more than maxDays (14 by default) from today. The phase’s job then fails, as the test did, until someone fixes the test and deletes the entry, or deletes the test. chant ci quarantine check makes the same check over every phase without printing a filter; run it where the declaration is linted. The declaration’s reader checks only what holds on any day: each phase is declared, each until is a real day and no test is listed twice, so an expired entry never stops the tick or any other command. quarantine needs minReader 0.124.63 or newer.

--only prints the opposite selection for a run of the quarantined tests alone: nextest’s filterset without the not (none() when there are none), the same Playwright pattern for --grep, and the same list. It doesn’t fail on an expired entry, so the scheduled run still says whether that test passes. Run it under a job whose check run no phase’s patterns match, so the verdict never reads it.

The quarantined tests still run, alone, on a schedule. chant ci workflow doesn’t write this job, because chant doesn’t know what a phase’s job sets up before its tests (a toolchain, a database, browsers); copy the phase’s own setup into a workflow like this one:

name: quarantine
on:
schedule:
- cron: "47 7 * * *"
workflow_dispatch: {}
permissions:
contents: read
jobs:
quarantined:
# No pattern in ci.green.phases matches this check run, so the verdict never reads it.
name: quarantined tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# The setup the test phase's own job does.
- name: Anything quarantined?
id: any
run: |
if [ -n "$(npx chant ci quarantine filter --phase test --runner list)" ]; then echo "run=true" >> "$GITHUB_OUTPUT"; fi
- name: The quarantined tests
if: steps.any.outputs.run == 'true'
run: cargo nextest run --profile ci --ignore-default-filter -E "$(npx chant ci quarantine filter --phase test --runner nextest --only)"
- name: What became of each, and who is told
if: always() && steps.any.outputs.run == 'true'
env:
CHANT_WEBHOOK: ${{ secrets.CHANT_WEBHOOK }}
CHANT_WEBHOOK_KEY: ${{ secrets.CHANT_WEBHOOK_KEY }}
run: npx chant ci quarantine report --phase test --junit target/nextest/ci/junit.xml

The job is red while a quarantined test still fails, and nothing requires it. Give its check run a name no phase’s patterns match: a broad pattern such as * would make the verdict wait on it.

chant ci quarantine report reads the run’s JUnit XML: nextest writes it with [profile.ci.junit] in its config (target/nextest/ci/junit.xml for path = "junit.xml"), and Playwright with --reporter=junit and PLAYWRIGHT_JUNIT_OUTPUT_NAME. For Playwright, run npx playwright test --grep "$(npx chant ci quarantine filter --phase e2e --runner playwright --only)". The report prints each quarantined test of the phase as passed, flaky, failed, skipped or not run. A nextest test that passed only on a retry is flaky, not passed, and a Playwright test passes when its case passed in every project. For each test that passed, it sends ci.quarantine-passed through ci.green.notify, naming the test, its issue and until, so someone can check the issue and take the entry out. It sends again on each scheduled run the test passes in, until the entry goes, with an id made from the test and the commit. It exits 0 whatever the tests did, and 1 only when it can’t read the declaration or a JUnit file. --dry-run sends nothing and says what it would send; --json prints the outcomes. The commit is --commit, else GITHUB_SHA, else HEAD.

Prints what happened to the branch’s recent history: the first-parent commits inside ci.green.window, newest first. Each has a state and the result of every required phase (#4021). It follows the same ref as ci last-green and reads local tags only, so fetch them first with git fetch origin --tags.

StateMeaning
greenThe commit has ci/green/<sha> and no revoked tag.
revokedThe commit has ci/revoked/<sha>.
undecidedThe commit has neither tag.

A phase’s result comes from the tags. A green tag’s annotation records the runs of each phase that passed, so a green commit lists every required phase as pass with its runs. A revoked one keeps those and shows the phase its revoked tag names as fail, with the failed run. An undecided commit has no tag to read, so its phases are unrecorded and have no runs. Add --forge github to read the check runs of undecided commits from the forge, as ci tick does, and each phase becomes pass, fail or pending. The forge is asked about nothing else, and without --forge the command reaches no network. When the source is chant runs, an undecided commit’s phases are judged from the signed Op runs on the local chant/lifecycle instead, still with no network, and --forge is refused. Each run then has an opRun object naming the run, and each commit has ignoredRuns, listing the runs that do not count.

A line for an unlinked or wrong commit ends with ; why unknown: and the reason. Link commits to work items says how a commit names one.

With signed tags, the state counts only the tags that carry a valid statement. A tag that does not is listed on its own line under the commit, as ignored <tag> (<status>): <reason>, and in --json under the commit’s ignored. The green and revoked objects name the runner that signed the tag in signer, which is null for a tag that counts unsigned.

--limit <n> keeps the newest n. --since <rev> lists what came after rev and replaces the window, so a reader holding the last sha it saw can ask for what is new.

--json prints a read contract document, ci-list.schema.json, with window, since, require and a commits array. Each entry has sha, committed, state, phases, and a green and a revoked object holding the tag and the time it was made, plus the failed phase and run for a revoked tag. Either object is null when the tag is absent. Each entry also has work (#4029), { state, ids, problems }, where state says whether the commit names its work item. The judgement is the one workspace check --changes makes, against the work records at the listed ref. work is null when the workspace declares no work kind. chant 0.124.28 added it within contract 1, and a reader ignores fields it does not know. A failure uses the codes of ci last-green, and revision-unknown when --since names no commit, with exit code 1.

Each entry also has record, what the commit’s record on the local chant/lifecycle says, or null when it has none (#4169): its state (green, red, unbuilt or pending), and the first reason, coveredBy and culprit its required phases carry. An undecided commit with a record gets a second line, recorded <state>, <reason>, covered by <sha>, culprit <sha>, with the parts it has. A phase read from the forge whose runs were cancelled is unbuilt.

One pass over the branch. With a list in ci.green.branch, it makes the pass for each listed branch in turn, and prints a section for each (#4325). It fetches the branch and the ci/* tags from origin, and the fetch prunes a ci/* tag deleted there by hand. It reads the check runs of each first-parent commit within window, then makes the tags that are due and pushes them, never forced:

A commit withthat nowgets
no green tagpasses every required phaseci/green/<sha>
a green tag and no revoked tagfails a required phaseci/revoked/<sha>
a revoked taganythingnothing, and its check runs are not read

A revoked tag also revokes every release cut from its commit, and the tick writes nothing more for that: the readers join each release’s commit to the tags (#4033). The tick never cuts a release.

Running it again over the same check runs changes nothing. --dry-run prints what it would tag and makes no tag. With signed tags, the tick signs each tag it makes and judges the tags already there as every other reader does, so a hand-pushed tag doesn’t count. Since chant never moves or deletes a tag, a hand-pushed tag that holds the name of a tag the tick would make stops it, and the tick says which tag to delete. A commit that names no work item, or a wrong one, has ; why unknown: and the reason at the end of its line, as in ci list.

The tick also fetches every chant/compose/<name> branch on origin (#4168, mode b). It judges each branch’s first-parent commits within window that trunk does not have, by the same phases, and makes their tags. A tag’s record names the compose branch, and with signed tags its statement does too, so readers check it against that branch. Its output lists each branch and its composed commits after trunk’s. Builds, retries and _ci records are trunk’s only. When the tick revokes a trunk commit that a composed commit carries in its Chant-Composed-From trailer, it warns and names the composed commit, whose own tags decide its releases. release compose makes the branches.

A run that was cancelled leaves its commit unbuilt, not red (#4169). A commit with no tag whose failed run has one attempt is held pending while the tick runs the failed job again, once: through the forge’s re-run on GitHub, which needs actions: write, or with a build request for chant runs. On GitHub the re-run covers every failed job of the job’s workflow run (#4219), so a job that only collects other jobs’ results, such as chant’s suites over its e2e shards, runs again with the shards that failed rather than against their old results. A retry that has not started within an hour counts as the failure it was. A green commit’s failure is never retried, since it is already a second run.

A phase declared build: "every" that has no run on a commit half an hour after the commit landed, because the forge never started its push run, gets one build request, missing, for those phases (#4216). The tick starts the workflows holding them at the ci/build/<sha> tag as it does for a bisect step, and the commit’s record keeps missing, so it is asked for once. A phase that sets no build is never asked for.

A phase declared build: "newest" runs only on the newest commit when a runner frees. A commit below a newer one that ran the phase is unbuilt, covered by it. When the newest commit the phase ran on is red, the tick bisects the unbuilt commits back to the last one the phase passed on, asking for one build per tick: the commit halfway when more than four are left, else the one just below the red. It asks with an annotated tag, ci/build/<sha>, whose record names the phases and the reason, and on GitHub it starts each workflow holding the phases at that tag with workflow_dispatch. Under chant runs, ci serve --build-command serves the tag. A phase a request waits on is pending, a request no runner served within six hours leaves it unbuilt, and once its phases are decided the tick deletes the tag. The first red commit is the culprit, named on it and every commit after it. --dry-run reports the requests and retries it would make, and makes none.

A job that skips itself by the paths a push changed needs care under newest. The push’s previous commit (github.event.before) may have been superseded and never built, so a tip that changes only docs would skip a job whose code a commit below it changed, and with skipped: "pass" the tip would go green with that change untested. Diff against chant ci base --phase <name> instead, and run the job whenever it finds no base.

The tick keeps a record of each commit it judges in _ci/<sha>.json on chant/lifecycle. It writes only the records whose content changed, all in one commit, and pushes it. The fields are in the declaration reference. A record left pending when its commit leaves the window is rewritten unbuilt, for the reason aged-out. If the tick can’t write or push the records, it warns and carries on. A request or a retry it can’t make is a warning too. The green and revoked tags are pushed before any of these. With recording off (CHANT_NO_RECORD) it writes no record.

With ci.green.notify, the tick tells people when the branch is red after its retry, when a bisect names a culprit, and when the branch is green again, once each, marking what it told in the records (notify, #4645). With notify.staleAfter it also sends ci.stale when the branch has had no green commit for that many hours, once per red stretch, marked in _ci/branch/<branch>.json (#4678).

By default the check runs come from the forge. GitHub is the only forge with a check-run reader: the tick reads GITHUB_REPOSITORY, a token from CHANT_FORGE_TOKEN, GITHUB_TOKEN or GH_TOKEN with checks: read, and GITHUB_API_URL for GitHub Enterprise Server. --forge gitlab and --forge forgejo are refused. GitLab and Forgejo get no status reader, and are covered through the results of chant’s own runs instead (#4044). Mapping pipeline jobs and commit statuses to check runs would need rules for retries and skips per forge, since GitLab reports jobs per pipeline and Forgejo reports statuses per context. An Op run’s result is the same on every forge. Pushing the tags needs contents: write on the remote.

A project whose pipelines run as chant Ops can take its phase results from those runs in place of a forge’s check runs (#4044). This is how a project on GitLab or Forgejo gets green and revoked tags. Set source to runs in ci.green, or pass --source runs to ci tick and ci list, which overrides the declaration either way. checks is the default.

"ci": {
"green": {
"branch": "main",
"phases": { "lint": ["lint"], "test": ["test", "e2e-*"] },
"require": ["lint", "test"],
"source": "runs"
}
}

With runs, a phase’s patterns match Op names, with * standing for any run of characters, as they match check-run names otherwise. Each Op run’s record on chant/lifecycle (<env>/runs__<op>.jsonl, see chant run) names the commit it built from as gitSha, and counts for that commit. For each Op on a commit, the latest record by end time decides, so a re-run replaces the run before it. Status ok passes, fail fails, and a stop at a gate or a decision point leaves the phase undecided. Records from every environment count alike.

Signing is optional (#4156). An unsigned run counts, and ci list shows it with signer: null. To verify who ran a job, add a runner key: the run signs its record as it settles when chant run <op> is given one, with --key <file> or the PEM in CHANT_RUNNER_KEY, and ci list then names the signer. The key and its principal follow the rules for the tick’s own key: .chant/trust.json at the checkout’s HEAD must list it under runners, and the principal must hold the runner role. chant run --key refuses any other key before the run starts, and a key that is not an Ed25519 PEM is an error from either source. A key from CHANT_RUNNER_KEY that trust.json does not list leaves the run unsigned, with a line under --verbose.

Anyone who can write to chant/lifecycle can write an unsigned passing run. To require signatures, set ci.green.signedSince. It covers runs as it covers tags: an unsigned run on a strict first-parent ancestor of that commit counts, and one on any other commit, that one included, is ignored. With it set, ci run and chant run warn when they leave a run unsigned, and ci serve refuses to start without a trusted key.

The envelope format matches the tag’s, with its own predicate type, https://intentius.io/chant/op-run/v1, over the run’s commit. The predicate names the signer and the run, with the run’s status and the SHA-256 of its record without the statement. Stored on the record as statement, it makes the record and its signature one ledger line. Every run is checked against .chant/trust.json at the branch’s tip, and one whose statement fails is ignored with the statuses a tag uses, with or without signedSince. Such a run neither greens nor revokes its commit, and appears under the commit as ignored run <id> of <op> in <env> (<status>): <reason>.

StatusWhen
unsignedThe record carries no statement, and ci.green.signedSince asks for one on its commit.
invalidThe envelope or its payload is not an op-run statement, or it names another signer than the key’s.
untrustedNo key that .chant/trust.json lists under runners signed it, or its principal holds no runner role.
mismatchIt signs another run, Op, env, status or commit, or the record changed after it was signed.

A tick from runs fetches chant/lifecycle before it reads, without forcing it, and stops when the local branch and the remote’s have diverged. It needs no forge token. Given a runner key it signs the tags it makes. Without one its tags are unsigned, which signedSince refuses. A tag made from runs has source: "runs" in its record. Each run in it has id: null and an opRun object holding the Op run’s id, env, the runner that signed it (null for an unsigned run) and the run’s statement when it has one.

A pipeline on GitLab or Forgejo runs its Ops with the key and then the tick. chant run appends each run’s record to the local chant/lifecycle and does not push it, so push the branch for later ticks and other checkouts to see the runs:

Terminal window
chant run lint --key "$RUNNER_KEY_FILE"
chant run test --key "$RUNNER_KEY_FILE"
git push origin chant/lifecycle
chant ci tick --source runs --key "$RUNNER_KEY_FILE"

ci workflow writes only a GitHub Actions file, so on another forge the tick goes in the pipeline by hand, or in a scheduled job that runs it every few minutes.

The tags are plain git tags, so anyone who may push a tag could make ci/green/<sha> by hand and go around CI (#4031). Setting ci.green.signedSince in the declaration closes that. It names the full sha of the first commit on the branch whose tags must be signed, and a tag on that commit or any later one counts only when its annotation carries a statement signed by a runner key. Without signedSince, every tag counts, as before.

"ci": {
"green": {
"branch": "main",
"phases": { "test": ["test"] },
"require": ["test"],
"signedSince": "8b045980cf9cd1351dd4f60c9c46ee69d45ec0d7"
}
}

The statement is the one runner evidence and agent-run statements use: an in-toto statement in a DSSE envelope, signed with an Ed25519 key. Its subject is the tagged commit, and its predicate (https://intentius.io/chant/ci-tag/v1) holds the signer and the tag’s JSON record. The envelope sits in that record as statement, so a reader that doesn’t know it reads the record as before.

A reader counts such a tag when all of these hold, and otherwise ignores it with one of four statuses:

StatusWhen
unsignedThe annotation carries no statement, as with a lightweight tag or one made by hand.
invalidThe envelope or its payload is not a ci-tag statement, or it names another signer than the key’s.
untrustedNo key that .chant/trust.json lists under runners signed it, or its principal holds no runner role there. Both are read where the branch is, at refs/remotes/origin/<branch> or the local branch.
mismatchIt signs another commit, another kind of tag or another branch, the annotation’s record is not the one signed, or the tag points at another commit than its name gives.

A tag on a strict first-parent ancestor of signedSince counts without a statement, so the tags a workspace already has keep working. Position in history decides, never a date: whoever makes a commit or a tag sets its time, so a backdated commit or tag outside that ancestry gains nothing. A signedSince that names no commit in the clone is refused with declaration-invalid, so fetch the branch before reading the tags. Every reader judges the tags the same way: ci tick, ci list, ci last-green, release cut and chant’s own scripts/release-preflight.sh.

The tick signs with an Ed25519 private key in PEM, from --key <file> or from the CHANT_RUNNER_KEY environment variable. .chant/trust.json lists its public half under runners, and the principal it names holds the runner role:

{
"schema": 1,
"runners": [{ "principal": "ci:acme/app", "class": "runner", "key": "ssh-ed25519 AAAA..." }],
"roles": { "runner": ["ci:acme/app"] }
}

The tick refuses a key the file doesn’t list, a principal without the role and a key the signers file lists, before it makes any tag. A person’s key never signs a tag. With signedSince set, the tick refuses to run without a key, apart from --dry-run. Both files are read at the branch’s tip, and changing either is a protected write, as for runner evidence. Make the key as for runner evidence:

Terminal window
openssl genpkey -algorithm ed25519 -out runner.pem

A tick given a key the file doesn’t list yet refuses it and prints the key’s ssh-ed25519 line to add under runners. Keep runner.pem out of the repository. chant workspace trust runner add writes both the entry and the role, from the PEM file or the ssh-ed25519 line, and leaves the commit to you:

Terminal window
chant workspace trust runner add ci:acme/app --key runner.pem --by github:alex
git commit -S -m "trust the ci:acme/app runner" .chant/trust.json

On GitHub the key lives in a repository secret, and chant ci workflow --runner-key-secret <NAME> hands it to the tick as CHANT_RUNNER_KEY. Turn signing on in this order: add the key to runners and the principal to roles.runner, store the secret and regenerate the workflow, then set signedSince to the sha of the branch’s current tip. A commit can’t name its own sha, so the commit that sets signedSince comes after it, and its tags and every later commit’s must be signed. A chant older than 0.124.28 refuses a declaration with signedSince, so set minReader to 0.124.28 with it.

Runs one job of the pull-request pipeline as a pipeline Op on this machine, with no forge runner (#4094). Each job runs its command: plan runs chant components pr-plan, and record runs chant components pr-record (#4168). apply runs chant components pr-apply. Each gets the flags and variables the job in a generated workflow has: chant builds the job from the same typed value the github, gitlab and forgejo generators use, and reads no YAML. Pass the flags you generated the pipeline with (--env, --gate, --branch, --events-json, --report-url, --image, --before-script, --pr-build, --pr-build-command, --wave-gate) so the two run the same command. With --wave-gate <name> the apply runs pr-apply --wave-gate <name> with no --wave, so it applies the waves in order and stops at the first whose moved plan waits on its own gate (#4003).

The job runs in a fresh checkout of --commit, HEAD by default: a detached git worktree in a new temporary directory outside the repository, removed when the job ends. The worktree shares the repository’s refs, so what pr-apply records on chant/lifecycle and the remote it pushes to are the repository’s own. ci run copies the job’s report directory to -o <dir>, by default .chant/pr in the directory it was run from. A forge keeps the same directory as an artifact. Inside a workspace member the job runs in the member’s directory and passes --member, as the member’s generated pipeline does.

The Op has a setup phase with the setup lines of the default image, a build phase with the --before-script lines and then, with --pr-build or --pr-build-command, the job’s build and lint lines (#4088), and a phase named plan or apply with the command. Each line is a step that runs with a clean environment, which holds only these variables:

VariablesFrom
PATH, HOME, USER, LOGNAME, SHELL, LANG, LC_ALL, LC_CTYPE, TMPDIR, TZthis process, when set
CHANT_FORGE_TOKEN, GITHUB_TOKEN, GH_TOKEN, GITHUB_REPOSITORY, GITHUB_SERVER_URL, GITHUB_API_URL, GITLAB_TOKEN, CI_API_V4_URL, CI_PROJECT_ID, CI_SERVER_HOST, CI_SERVER_URLthis process, when set: the forge and token the commands post with
each --pass-env <NAME>this process, such as the cloud credentials a deploy needs
the secrets the job getsthe secrets file given with --secrets, which replace a variable of the same name above
CHANT_ENV--env, as the generated workflow sets it
GITHUB_SHA, or CI_COMMIT_SHA on GitLabthe commit the job runs at
BASE_SHA--base, in place of the push’s or the pull request’s base commit
PR_NUMBER--pr, which the plan needs
CHANT_RUN_EVENTS_DIRthe job, with --events-json

A step of the plan job gets no forge token (#4295), since the plan runs the pull request’s code. Every name in FORGE_TOKEN_VARS (packages/core/src/ci-handover.ts) is left out of its environment, wherever it came from (ciRun in packages/core/src/workspace/ci-run.ts). The plan’s pr-plan runs with --no-status. Once the steps settle, ci run posts the note and the chant/plan status from the report itself, with its own token, as pr-post does. A report for another pull request or head fails the status and posts no note, and so does one for another environment or member. The record and apply jobs run the target branch’s code and keep their token.

CHANT_RUNNER_KEY is never passed to a step: --pass-env CHANT_RUNNER_KEY and a secrets file that sets it are refused. A secret doesn’t replace the variables from CHANT_ENV down, which the runner sets for the job. --chant <command> runs chant in the job’s command and in its build and lint lines with another command, such as npx chant, and --before-script 'npm ci' installs what that command needs in the fresh checkout. The forge comes from --forge, or from the environment inside a forge’s own job.

The run is recorded as the job’s Op (pr-<job>) in <env>/runs__<op>.jsonl on chant/lifecycle, with gitSha the commit and runOrigin { "forge": "chant" }, and ci run then pushes chant/lifecycle to the remote, unless --no-push. A tick from runs counts it. With --key <file>, or the PEM in CHANT_RUNNER_KEY, the record also carries a statement signed by the runner key. The key follows the rules for chant run --key, checked against .chant/trust.json at the commit the job runs. A phase pattern such as "plan": ["pr-plan"] matches the job. The run’s events are kept on this host for chant run events, with kind: "pipeline" and runtime: "ci". With --events-json they are printed on stdout as well. Each line the job prints goes to stderr as it arrives, and the summary follows it there. It exits 0 when the job passed. When the command failed with an exit code, ci run exits with that code, such as 3 for a moved plan or a wave that waits on its gate, as the command did in a forge job. Any other failure exits 1.

ci run also runs the jobs of a pull request’s environment: env-up, env-post, env-down and env-sweep (#4330). Their --env defaults to pr-<n>, and to local for the sweep. env-up runs with no forge token in its steps, and the runner then runs env-post at --base with the token and the report env-up wrote, unless the run is --local or --in-place. env-post on its own runs at --base and takes --head <sha> and, on GitHub and Forgejo, --result <r>. Their reports land under .chant/pr-env, and the run index lists only the pull-request jobs.

A generated job runs chant ci run plan|record|apply --in-place (#4156), so a forge job writes the same record as a job on this host. --in-place runs the job in the checkout it is started in, at its HEAD, with no worktree, no setup phase and no commit status of its own, since the forge shows the job. The steps get the job’s whole environment except CHANT_RUNNER_KEY, since the forge job is already the boundary. The report stays where the command wrote it, and a record that can’t be written is a warning. The record’s runOrigin names the forge’s run: forge (github for GitHub and Forgejo, gitlab), repo, url, jobId (GITHUB_JOB, or CI_JOB_ID on GitLab) and attempt (GITHUB_RUN_ATTEMPT).

The plan job passes --no-push, so the pull request’s code writes nothing to the remote chant/lifecycle. Since #4295 a generated plan holds no forge token, and its plan-note job posts. In place, ci run plan still leaves every token out of the steps. A token in its own environment means the pipeline predates #4295. Then ci run posts after the steps and warns to regenerate, since the pull request’s code ran beside the token. An apply job of a pipeline generated with a gate per wave passes --wave <k>, which ci run hands to pr-apply. --require-review passes --require-review to pr-apply, for a pipeline generated with requireReview: true, chant build --pr-loop --require-review, or in a workspace that opts into the review-rules security group. Review is off without one of those (#4168). --apply-before-merge makes ci run apply the apply before merge of a pipeline generated with --apply-before-merge: pr-apply --before-merge with --base and --pr, run at the pull request’s head (#4301, apply before merge). --no-require-review, which pipelines generated before that pass, is still accepted and is the default. Who ran a job shows how to give the jobs a runner key. --require-runner-start refuses the job before its first step unless a runner-start statement names it. A failed job’s record says why in failure, as does its run-settle event. failure holds code and a one-line reason, with phase and exitCode when known. When the command failed and its report (pr-plan.json or pr-apply.json) exists, code is the report’s refusal (not-approved, plan-changed, not-a-reviewer, author-approved, no-pull-request, locked) or else its status (plan-failed, failed, refused), and reason is the report’s message or else the members that failed. A command that failed with no such report gives command-failed, and a failed setup or build line gives setup-failed or build-failed with the line as the reason. A revoke that a failed run caused names the code in the tag’s subject line.

Terminal window
chant ci run plan --env prod --forge forgejo --base "$(git merge-base origin/main HEAD)" --pr 42 --key runner.pem
chant ci run record --env prod --forge forgejo --base "$(git rev-parse HEAD^)" --key runner.pem
chant ci tick --source runs --key runner.pem

--local (#4161) runs the job the same way, in a fresh worktree of --commit, and writes nothing outside this machine. It implies --no-push and --no-status. It writes nothing under a report URL and nothing to the run index, even when --report-url is given. The job’s command gets no --report-url and gets --no-status, so pr-plan and pr-apply post no status and no note on the pull request. --events-json still streams, and the exit code is the same as without --local. A runner key still signs the record when one is given, and with none the record is unsigned and nothing warns.

The record is still written to chant/lifecycle in this repository, as pr-plan or pr-apply, so a reader on this machine can show it next to CI’s run for the same commit. Its runOrigin is { "forge": "local" } and its events say runtime: "local", where a CI job’s say ci. ci tick --source runs and ci list never count a record with runOrigin.forge local, signed or not. A pr-apply still pushes its own release records and gate facts, since a local apply changes the same infrastructure a CI one does. --local and --in-place are refused together.

Terminal window
chant ci run plan --local --events-json --env prod --forge github --base "$(git merge-base origin/main HEAD)" --pr 42

--secrets <file> names a file on this host that holds the values jobs get, such as cloud credentials and the endpoint a deploy uses (#4096). It stands in for a forge’s repository secrets. Without the flag, ci run and ci serve read the file CHANT_CI_SECRETS names, and with neither a job gets no secrets.

It must belong to the user running chant and give its group and other users no permission at all, as ssh asks of a private key. Any other mode is refused before a job runs, with the chmod 600 that fixes it. Windows is not checked.

Write it as dotenv or as a JSON object. In dotenv, each line is NAME=value, and a line may start with export or be a # comment. A value in single quotes is taken as written. A value in double quotes may span lines and takes the escapes \n, \t, \" and \\:

Terminal window
# /etc/chant/ci.env, chmod 600
AWS_ACCESS_KEY_ID=AKIAEXAMPLE
AWS_SECRET_ACCESS_KEY='wJalrXUtnFEMI/K7MDENG'
AWS_ENDPOINT_URL=http://floci.localhost:4566

A JSON file is either a map of name to value, or a secrets map with a jobs allowlist that names, for plan or apply, the secrets that job gets:

{
"secrets": {
"AWS_ACCESS_KEY_ID": "AKIAEXAMPLE",
"AWS_SECRET_ACCESS_KEY": "wJalrXUtnFEMI/K7MDENG",
"READ_ONLY_TOKEN": "ro-0000"
},
"jobs": { "plan": ["READ_ONLY_TOKEN"] }
}

A job the allowlist doesn’t name gets every secret, so with no jobs both jobs get them all. The allowlist lives in the file on the host and not in the repository, so a pull request can’t change what its own plan gets. Only the JSON form takes an allowlist.

chant redacts every value in the file from what the run writes, whether the job got it or not. It also redacts the value of each variable in the job’s environment whose name looks secret, which is a name with TOKEN, SECRET, KEY or PASSWORD in it. GITHUB_TOKEN is one, and so is a --pass-env AWS_SECRET_ACCESS_KEY. Each one then reads *** in these places:

WhereWhat is redacted
Run eventsEach line on stdout with --events-json, and the copy kept on this host.
The run record on chant/lifecycleThe whole record, step errors and failure.reason included. It is redacted before it is signed, so the statement covers the redacted record and verifies.
The report ci run copies outEvery text file in it, the change set and the component events too. A JSON file stays JSON.
The consoleEach line a step prints, and what ci run and ci serve print after.

A value shorter than 4 characters is not redacted, since it would match too much ordinary text. A value that spans lines is also redacted line by line, as step output arrives a line at a time. What the job itself uploads with --report-url is the job’s own copy and is not redacted, and neither is the resume record ci serve keeps.

ci run runs one job when you run it, and a re-run of a failed apply plans every member again, since ci run keeps no resume record between runs. ci serve watches the forge and keeps one.

When the environment has a forge token (CHANT_FORGE_TOKEN, GITHUB_TOKEN or GH_TOKEN), ci run sets a commit status on the forge at the job’s commit, so the pull request shows the job as Actions would (#4097). The status is pending when the job starts and success or failure when it settles. It is set through the GitHub and Forgejo clients’ setCommitStatus, which posts to /repos/{owner}/{repo}/statuses/{sha}. GitLab jobs set none.

JobContext
planchant/pr-plan
applychant/pr-apply, or chant/<gate> when --gate renamed the gate

These differ from the chant/plan and chant/apply statuses and the pull request note that pr-plan and pr-apply post themselves, which are unchanged. The description of a passed job is pr-plan passed in 12s. A failed job’s is the run record’s failure.code and reason, such as not-approved: no reviewer approved this plan, cut to the 140 characters the forge keeps. A job that stops on an error of its own gets an error status.

The status links to the job’s report. With an https:// --report-url the link is <url>/<pr>/<commit>[/<member>]/, the key --report-url uploads under, with unknown in place of the pull request when --pr is not given. For an s3:// URL, which a browser can’t open, --status-url <template> maps it: --status-url 'https://host/reports/{key}' fills {key} with the same key. --status-url also overrides an https --report-url. Without either, the status has no link.

A status the forge refuses is a warning, and the job’s result and exit code stand. --no-status sets none. ci serve takes both flags and passes them to every job.

With --report-url, ci run also adds the job to <report-url>/runs/index.json when it settles (#4098). Without the flag, ci run, ci serve and ci runs use the workspace’s ci.reportUrl when it declares one, and ci serve says so when it starts (#4160). The flag wins over the field. A declaration that can’t be read stops the command with its reason code, such as declaration-invalid, before any job runs. Outside a workspace nothing is read. A failed job is added too. ci serve passes its job flags on, so it keeps the same index. Entries are newest first. The index keeps the newest 200, or as many as --run-index-limit says.

Entry fieldHolds
job, commit, runIdplan or apply, the full commit, and the Op run id
prthe pull request, or null when the job found none
status, failure.codeok or fail, and the run record’s failure code for a failed job
started, endedthe run’s instants
keythe folder of the job’s report below the report URL: <pr>/<commit>, unknown for no pull request, and /<member> after for a member
runOrigin{ "forge": "chant" }, or the forge’s run for a forge job
signerthe runner that signed the record, or null for an unsigned run. Chant 0.124.32 and newer write it
exitCodethe code ci run exited with: 0 for a pass, the command’s own code such as 3 for a moved plan or a waiting wave, and 1 otherwise (#4165). Chant 0.124.32 and newer write it, and older entries lack it

The update uses the upload path --report-url already has: aws s3 cp for s3://, and a temporary file and a rename for file://. Two runners writing one index can lose an entry, so keep one host per report URL. A problem with the index is a warning, and the job keeps its own result. The format is the ci-run-index contract.

A runner-start statement is a provisioner’s signed word that it started a runner for one CI job (#4147). A persistent self-hosted runner keeps files and processes between jobs, so a plan job that ran a pull request’s code can leave something behind for the next apply. An apply job that requires the statement refuses to run on a runner no trusted provisioner says it started for this job, before the job’s first step and so before it trades for any credentials. Nothing requires it by default, and a job that doesn’t ask never reads it.

The statement differs from the signed run record in three ways. The provisioner signs it before the job runs, where a runner signs a run record when the run settles. The provisioner holds the key, so a job on the runner can’t sign one for itself. And it names the job, so a statement made for one job doesn’t verify in another.

The envelope and key type are the ones the ci tag statement uses. The subject is the commit the job runs, and the predicate https://intentius.io/chant/runner-start/v1 holds:

FieldWhat it says
signerthe principal .chant/trust.json lists the provisioner’s key for
ci.systemgithub, gitlab or forgejo
ci.repoowner/name, or the GitLab project path
ci.run, ci.attempt, ci.jobthe run, its attempt and the job, as the forge’s variables below name them
runner.namethe runner’s name, required on GitHub and Forgejo
runner.singleJobalways true: the runner was started for this one job
issuedAtwhen the provisioner signed it

The provisioner is whatever starts the runner for a job, such as a webhook handler that registers a just-in-time GitHub runner, a Forgejo runner started per job, or a GitLab autoscaler hook. It knows the job’s ids when it starts the runner, and it signs them with a runner key listed under runners in .chant/trust.json, whose principal holds the runner role, as for the tick’s key. Keep that key on the provisioner. The runner and the job never get it.

Terminal window
cat > job.json <<'JSON'
{ "system": "github", "repo": "acme/infra", "run": "4242", "attempt": "1", "job": "apply",
"commit": "8b045980cf9cd1351dd4f60c9c46ee69d45ec0d7", "runner": "jit-apply-4242-1" }
JSON
chant ci runner-start sign --key provisioner.pem --principal ci:acme/provisioner --job @job.json -o runner-start.json

--job takes the JSON or @<file>, and refuses a field chant doesn’t know. attempt defaults to 1. A GitHub or Forgejo job needs runner, since GITHUB_JOB is the job’s key in the workflow and repeats across a matrix’s jobs, while the runner’s name tells them apart. On GitLab job is CI_JOB_ID, which a retry changes, so runner is not needed there. A provisioner written in JavaScript can call signRunnerStart(job, signer) from @intentius/chant/runner-start instead.

The provisioner puts the envelope where the job looks for it, through the runner’s environment or its image:

ForgeThe statementThe job’s ids come from
GitHubCHANT_RUNNER_START (the envelope’s JSON) or a file at CHANT_RUNNER_START_FILE, else /run/chant/runner-start.jsonGITHUB_REPOSITORY, GITHUB_RUN_ID, GITHUB_RUN_ATTEMPT, GITHUB_JOB, GITHUB_SHA, RUNNER_NAME
Forgejothe samethe same GITHUB_* names, with FORGEJO_ACTIONS or GITEA_ACTIONS set. When the runner doesn’t set RUNNER_NAME, set it in the runner’s envs
GitLabthe sameCI_PROJECT_PATH, CI_PIPELINE_ID, CI_JOB_ID, CI_COMMIT_SHA

The commit is the one the forge gives the job, so sign the commit the job checks out. A push’s job and the forge’s job event name the same commit, while a GitHub pull_request job checks out a merge commit the job event doesn’t name, so sign for push-triggered jobs such as an apply.

chant ci runner-start verify takes the job’s ids from the forge’s variables and checks the statement against .chant/trust.json at --base. Without --base it reads the remote’s default branch (origin/HEAD), or HEAD when there is no remote. It exits 0 when the statement verifies and 1 otherwise, printing the status and the reason. --commit checks against another commit than the forge’s variable, and --json prints the verdict as JSON.

In chant ci run the flag runs this check with the job’s own commit, reading .chant/trust.json at the run’s --base. For an apply that is the commit before the change. A key that the change itself adds to trust.json doesn’t count for it. The run’s notes name the provisioner that signed. A --local run has no forge job to check, so it refuses the flag.

StatusWhen
verifiedA key listed under runners, whose principal holds the runner role, signed a statement for this system, repository, run, attempt, job, commit and, on GitHub and Forgejo, runner.
missingThe job has no statement, or the environment names no forge job.
invalidThe envelope or its payload is not a runner-start statement, has a field chant doesn’t know, or names another signer than the key’s.
untrustedNo key listed under runners signed it, or its principal holds no runner role.
mismatchIt names another job, attempt, run, repository, commit or runner.

A stage bundled without chant’s CLI can import verifyRunnerStartForJob from @intentius/chant/runner-start, which needs only node:crypto and node:fs, and pass the runners and roles from .chant/trust.json. The CLI also drops a runner entry the signers file lists, and a stage that passes the lists itself skips that check.

The statement proves that a provisioner holding a listed key said it started this runner for this job. It doesn’t prove what the runner image holds, or that the provisioner tore the runner down afterwards. Those are the provisioner’s to keep.

chant ci run --at <sha> asks for every required phase to be built at a first-parent commit of the green branch, so you can make that commit releasable (#4169). It fetches the branch and the build requests, pushes ci/build/<sha>, and prints the tag. On GitHub, with GITHUB_REPOSITORY and a token in the environment, it starts each workflow holding a required phase at the tag at once and names them. Otherwise the next tick starts them, or ci serve --build-command serves the tag for chant runs. A commit that already has a request is left as it is. A workflow holding a phase without a workflow_dispatch trigger can’t be started at a tag, and is named in a warning. Once the phases pass there, the tick tags the commit green.

chant ci runs --report-url <url> lists the index, one line per run, newest first. Without --report-url it reads the workspace’s ci.reportUrl. With --json it prints the index document unchanged. The command exits 1 when the URL has no index or the index can’t be read.

Watches a forge and runs the pull-request jobs on this host with ci run (#4095). Each poll reads the open pull requests into the target branch (--branch, default main) and the branch’s head through the forge’s API. It runs the plan for each pull request head it has not planned, with --base the pull request’s base commit and --pr its number. It runs the record for each new commit on the target branch (#4168), with --base the head the previous job on that branch was measured to, which is the push’s before on a forge. The record applies nothing. With --apply-on-merge it also runs the apply at the newest green commit of the branch, once per commit, as pr-apply --green (#4168 step 9), and --wave-gate needs that flag. The pull request whose merge commit a recorded commit is comes from the same pullRequestFor call pr-record uses, and the job gets it as --pr, so its commit status link and run index use the <pr>/<commit> key. When the forge finds none, or the lookup fails, the job runs without --pr as before. The first poll only notes the head: a commit the branch held before the runner watched it is not run.

After each job settles, ci serve runs ci tick from the runs its jobs recorded (--source runs), signed with the same runner key, so a merged commit can go green with no other workflow. A workspace with no ci.green gets no tick. A tick that fails is an error on stderr and does not fail the job. --forge is forgejo or github. The token and, on Forgejo, GITHUB_SERVER_URL and GITHUB_API_URL come from the environment as for pr-plan, and --repo sets GITHUB_REPOSITORY for the poll and for every job. Each job it starts gets the job flags ci serve was given, which are ci run’s, such as --gate, --chant, --secrets and --key. It reads the secrets file once when it starts, so a loose or broken file stops it before the first poll, and a changed file is read on the next start.

Where ci serve runs decides the branches it polls (#4325). In a member that ci.branches routes, it polls the route alone and gives the member’s record and apply jobs --branch <route>. In any other member it polls --branch, main by default. At the workspace root it polls main and each routed branch. The state file keeps a head for each branch it polls. --branch naming a branch other than a routed member’s route is refused.

It runs in host mode. Each job runs in a fresh worktree on this host as the user running ci serve, with the clean environment ci run gives it, and the plan runs the pull request’s code. A pull request from a fork is never planned. --author <login> (repeatable) plans only the pull requests those people opened. Run it only for a repository whose authors you trust with the host’s credentials; a container per job is #4015.

The state lives in --state <dir>, by default chant/ci-serve in the repository’s common git directory:

PathHolds
<group>.jsonEvery job started, keyed by job and commit (plan:<pr>:<sha>, record:<sha>, apply:<sha>), with its status, attempts and report, and the target head the last job on the branch was measured to. A job already there is not started again.
resume/<key>.jsonEach apply’s resume record, named by the forge cache key with the commit (chant-apply-<env>-<commit>, chant-apply.<member>.<env>-<commit> in a member). ci serve copies it into the job’s checkout at .chant/pr-resume/pr-apply.json before pr-apply --resume reads it, and back after, so a re-run at the same commit skips the members that applied.
reports/<group>/<op>-<sha>Each job’s report directory, as ci run -o copies it.

<group> is the apply’s concurrency group, chant-apply-<env>, or chant-apply.<member>.<env> in a workspace member. Before an apply runs, ci serve takes a lease on refs/chant/lease/<group>, the git-ref lease chant operator uses. It renews the lease while the apply runs and releases it after. It pushes the lease to the remote, so two hosts serving one repository run one apply per group between them. An apply that finds the lease held waits for a later poll. At most --max-jobs jobs run at once, 1 by default, and a job over the limit waits for a later poll too.

ci serve runs a job for a new head on the target branch only when it descends from the head it saw before (#4122). Any other move leaves the new head recorded as seen and not run, and ci serve says so on stderr. A force push back to an older commit is such a move. The next commit pushed on top of that head runs as usual. As on Actions, a head whose commit message contains [skip ci] or [ci skip] is recorded as seen and not run, and a pull request whose head commit says so is not planned.

Before each job, ci serve makes its clone’s chant/lifecycle follow the forge’s (#4121). The clone’s branch is deleted if the forge has none, and reset to the forge’s if neither contains the other, as after a rewrite. Either way ci serve warns on stderr and never pushes the old ledger back. A clone’s branch ahead of the forge’s keeps its facts for the next apply to push.

--build-command <line> serves build requests (#4169). Each poll fetches the ci/build/* tags and runs <line> once for each tag it has not served, oldest first, in a fresh detached worktree of the tag’s commit, with CHANT_BUILD_COMMIT, CHANT_BUILD_PHASES (comma-separated) and CHANT_BUILD_REASON (bisect, retry, requested or missing) set. The line runs the phases’ Ops, such as npm ci && npx chant build && npx chant run suites, and their run records are what the tick reads. A build counts against --max-jobs, and the state file keeps it under build:<sha> with how it ended. A failed build is not run again. Without the flag, the tags are left alone.

--land lets a change reach the target branch without a pull request (#4168 4.4). It needs --build-command and a ci.green.preMerge list in the workspace declaration, and ci serve refuses to start without either. Each poll lists the chant/land/<name> branches on origin and takes each head it has not seen:

  1. A head that does not descend from the target’s head is refused and left on the remote. Rebase it and push again.
  2. <line> runs in a fresh worktree of the head, as for a build request. CHANT_BUILD_PHASES holds the preMerge phases and CHANT_BUILD_REASON is land.
  3. The phases are judged from the Op run records on the head, as ci tick --source runs judges them, with the trust config read at the target’s head. An unsigned run counts unless ci.green.signedSince is set, so a land needs no runner key.
  4. When <line> exits 0 and every phase passes, ci serve pushes the head to the target branch. The push is a plain one, so the remote refuses it if the target moved meanwhile. Then it deletes the land branch.

A land that exits non-zero, fails a phase, or records no finished run for one is refused, and the target and the land branch stay as they were. The state file keeps each head under land:<name>:<sha>, so the same head is never tried twice and a new push to the branch is. The next poll sees the target’s new head and runs the record job, whose merge record names the work items the head’s Chant-Record trailers name, or a direct push. A land counts against --max-jobs.

Terminal window
chant ci serve --forge github --repo acme/app --env prod --land \
--build-command 'npm ci && npx chant run check'

--forge git serves a repository on a git server with no forge API, such as plain sshd, Soft Serve or a bare repository (#4016 gap 6). The target’s head comes from git ls-remote origin. There are no pull requests to plan, so the target moves only through land branches and direct pushes. No commit status is set, and ci serve says so once on stderr. The jobs run without --forge. --repo is optional and only names the state file’s repository, by default origin’s URL. The remote should protect the ci/* and release/* tags itself, with a pre-receive hook where it has no rule for them.

Terminal window
chant ci serve --forge git --env prod --land --build-command 'npm ci && npx chant run check'

A failed job stays failed. --rerun-failed runs again the failed record at the target’s head, the failed apply at the newest green commit, and the failed plan of each open pull request head, as a forge’s re-run button does: after you approve a plan the apply refused, run chant ci serve --once --rerun-failed. With --wave-gate, the same re-run carries on from a wave that waited on its own gate, once that wave’s plan is approved, since the resume record keeps the waves that applied. --interval sets the time between polls, in seconds or as a duration such as 2m, 30 seconds by default. --once runs one poll, waits for the jobs it started and exits 1 when one failed. Without it ci serve polls until it is stopped and waits for its running jobs on SIGINT or SIGTERM.

Terminal window
GITHUB_SERVER_URL=http://forgejo.localhost GITHUB_API_URL=http://forgejo.localhost/api/v1 CHANT_FORGE_TOKEN=... \
chant ci serve --forge forgejo --repo demo/estate --env local --author demo-driver \
--chant 'npx chant' --before-script 'npm ci' --secrets /etc/chant/ci.env --key runner.pem

ci serve signs each run when it has a trusted runner key (#4099). Without one it serves unsigned and says nothing about it, apart from one line under --verbose (#4156). It takes the key from --key, then CHANT_RUNNER_KEY, then the host’s own key, runner-key.pem in the state directory. Before its first poll it fetches the target branch and reads .chant/trust.json at its head. When that file doesn’t list the key under runners for a principal holding the runner role, ci serve prints one warning with the command that lists it, and serves unsigned. A key that is not an Ed25519 PEM stops it. With ci.green.signedSince set, it refuses to start without a trusted key. --unsigned is still accepted. It skips the key, and has no effect under signedSince.

--setup-key sets the host’s key up, on ci serve or ci run. When the state directory (--state, by default chant/ci-serve in the common git directory) holds no key, it makes an Ed25519 key in PEM there, with mode 0600 in a directory of mode 0700. It prints the public key, an ssh-ed25519 line, on stdout. On stderr it says whether .chant/trust.json at the target’s head lists the key, and if not, the exact chant workspace trust runner add command that would. A key file that other users can read is refused.

With --trust it makes that change itself, on a branch for review. In a temporary worktree at the target’s head it runs trust runner add for --principal, by default chant-runner:<host>, and commits the result on chant/trust-runner/<principal>. It then pushes that branch to origin and never writes the target branch. Open a pull request from it. Changing the trust config is a protected write, so when the policy has signers, an admin signs the commit before it merges. The commit is made with the host’s git identity and signing settings. Once it has merged, ci serve starts signed.

Terminal window
chant ci serve --setup-key --trust --principal chant-runner:demo-host
# open a pull request from chant/trust-runner/chant-runner-demo-host, and merge it
chant ci serve --forge forgejo --repo demo/estate --env local

ci run uses the host’s key too when it is given no --key and no CHANT_RUNNER_KEY. As with the variable, a host key the commit’s trust config doesn’t list leaves the run unsigned, with a warning only under signedSince.

ci serve takes no webhook yet. It polls, so the host needs no inbound port, and a webhook checked with an HMAC secret is a follow-up.

chant ci check --base <rev> [<target>...] runs the ci.hooks.check hooks the workspace declaration at --base names (#4556). A product’s check job runs it before any plan. Each target is a root, stack or component the change touches, and a perRun hook runs once per target. The hooks run with no forge token or cloud credentials in their environment. When they pass, each lexicon the project lists runs its own check steps for its members (#4633): the pulumi lexicon runs pulumi install, a stack config check and pulumi about --json for each pulumi member (The pulumi member), in the same environment. check-hooks.json under --output (default .chant/check) lists each hook’s and step’s result, and --json prints it. The command exits 1 when a hook or step failed, and 0 when every one passed or there were none. Hooks on Pull-Request Jobs has the shape.

chant ci forge-check reads the forge, each cloud identity’s trust and Pulumi Cloud’s OIDC policies, and compares them with the pull-request pipelines ci.identity.cloud gives the workspace (#4608). Each pipeline has three jobs: the plan job on the pull request, and the record and apply jobs on the default branch. --env picks the environment (default production), and --member one member; without it every member is read. Each identity should trust its own jobs and no other subject. The check prints one row per setting:

WhereRow
GitHubeach protected branch has branch protection or a ruleset, the default branch requires the plan status, each apply environment deploys from the default branch only, each apply runner group is limited to selected workflows
GitLabeach protected branch is protected, merge requests need a passing pipeline, each apply environment is protected, the apply runners take protected refs only
Forgejoeach protected branch has a rule, and the default branch’s rule checks the plan status
AWSeach role’s trust policy admits its jobs’ subjects and audience, and nothing wider (iam:GetRole)
GCPthe workload identity provider’s attribute condition is its jobs’ condition, or a narrower one
Azureeach app’s federated credentials are its jobs’, and no other
Pulumi Cloudthe forge is a registered OIDC issuer of the organization, and the issuer’s policies grant each token to its own jobs alone

The plan status is the product’s, such as chant/plan or plywood/preview. Each required status also gets a row for whether it has been posted on the default branch’s head. One not posted yet reads unknown, since the pipeline may not have run.

A row reads match or mismatch. It reads unknown when the setting could not be read, such as a scope the token lacks or a GitLab edition without protected environments, and not-checked when no credentials for that cloud are set. Credentials come from the environment:

ForVariables
The forgeGH_TOKEN, GITLAB_TOKEN or FORGEJO_TOKEN
AWSAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, or a profile with static keys
GCPGOOGLE_OAUTH_ACCESS_TOKEN
AzureAZURE_GRAPH_TOKEN, a Microsoft Graph token
Pulumi CloudPULUMI_ACCESS_TOKEN, an organization admin’s

On a laptop pass --forge and --repo; in a forge job both come from the job. --branch sets the default branch when the repository read cannot.

The command only reads. Every request is a GET, or the one POST of IAM’s GetRole, and anything else is refused before it is sent. It exits 1 on a mismatch, and with --require-clouds also when a cloud went unchecked; otherwise 0. --json prints the rows. terragucci’s terragucci forge check and plywood’s plywood forge check run the same check from @intentius/chant/forge-check.

Sets the workspace up for a prescribed delivery workflow (#4168): trunk-curated, where a merge records the plan and deploys nothing, trunk-curated+apply-on-merge, or apply-before-merge (#4301). The workflows and what each requires are on CI Workflows, and Set Up Trunk with Curated Releases walks through it.

Terminal window
chant ci init --workflow trunk-curated
chant ci init --workflow trunk-curated --yes

It runs WSP151 over the workspace as it would be with ci.workflow set, and proposes what answers each finding:

FindingWhat it proposes
no ci.workflowci.workflow in the declaration
ci-workflow-green-undeclareda ci.green block: on GitHub, one phase per workflow file with its jobs as the check runs, those a pull request runs as preMerge; elsewhere, one check phase to edit
ci-workflow-no-pre-mergepreMerge, from the phases a pull request runs
ci-workflow-no-environmentsenvironments: ["staging", "prod"] after export default {, when the default export is a plain object
ci-workflow-no-components<member>.component.ts, a stub with a gate and a TODO(chant ci init) line, which WSP151 reports until it is filled in
ci-workflow-pipeline-missing, -pipeline-differsruns chant build --components --generate <forge> --pr-loop in each member, with --env set to the first environment, --apply-on-merge under that workflow and --apply-before-merge under apply before merge, then chant ci workflow on GitHub
ci-workflow-publish-missingruns chant release workflow

The proposal is printed first: each file as a diff, then each generator. Nothing is written without --yes or a yes at the prompt. A key the declaration lacks is added as text, so the rest of the file keeps its layout. A component someone wrote is never edited, and one with no gate gets a note instead. A JSONC declaration is refused, since its comments would be lost. A rerun proposes only what is still missing.

FlagDescription
--workflow <name>trunk-curated, trunk-curated+apply-on-merge or apply-before-merge. Required.
--forge <forge>github, gitlab or forgejo. Inferred from .github/workflows, .forgejo/workflows or .gitlab-ci.yml.
--security <group>Add a security group to the top-level security, repeatable. Without it no group is turned on.
--yesWrite and run without asking.

Writes .github/workflows/chant-ci-green.yml (or --output), the root CI file that runs the tick. A tick starts when a workflow holding a required check run completes on the branch, so a result or a re-run is acted on within seconds. A cron every 15 minutes covers an event that was dropped or late, and is what sends ci.stale when nothing else runs the tick (#4678). All ticks share one concurrency group that never cancels, so they run one at a time.

It finds the workflows to listen to by reading the other files in .github/workflows/. A job reports its name or its id as its check run, followed by (<matrix values>) for a matrix job, and a workflow is kept when one of its jobs can report a check run that a required phase’s pattern matches. It warns about each required pattern no job matches. --workflow <name> adds a workflow the scan can’t see, such as one whose job names are built from expressions, and it is repeatable.

The tick runs in the workspace root as npx --yes @intentius/chant@<version> ci tick, at the version that wrote the file. --chant <command> runs chant with another command instead, and ci tick is put after it. --install <command> adds a step before the tick that installs what that command needs, in the same directory. When the workspace root has a package-lock.json, the install step also gets setup-node’s npm cache. Both flags go into the regenerate command in the header. The file’s first line is the generated-file header naming the command. When the command runs in a member’s directory, that member records the file as one it generates (ws-042). Regenerate it after changing ci.green or the workflows it listens to.

For each phase that sets build (#4169), ci workflow also writes the top-level blocks of the workflows holding it. Each block sits under a comment naming ci workflow, and the rest of the file stays as it is:

buildon:concurrency:
newestpushes to the branch and workflow_dispatch, with any schedule removed and other triggers keptchant-build-<phases>-${{ github.ref }}, never cancelling a run in progress, so GitHub keeps the newest push waiting and drops the ones between, and each ci/build/<sha> tag runs on its own. When a phase it holds sets skipped: "pass", a comment in the block names ci base for its path filters (#4643)
everykept, with workflow_dispatch added so the tick can start a run the forge never started (#4216)the commit itself on the branch, so no push cancels or replaces another’s run, and the ref elsewhere, where a new push cancels the run it supersedes

A workflow holding a phase of each value is refused, since no one group serves both. The tick’s workflow then also has actions: write, to re-run a failed job and start a workflow at a tag, and its workflow_run trigger listens on ci/build/** as well as the branch. With no phase setting build, every file comes out as before.

When the workspace declares a ci.workflow, at the top level or on a member, composed releases live on chant/compose/<name> branches (#4220). Under newest, pushes to chant/compose/** start a run too. For every, the filter joins a push that lists branches (a push that lists none already runs on all of them), and the concurrency group keys a compose branch’s runs by commit, as the branch’s. The tick’s workflow_run lists chant/compose/** too. Without a ci.workflow the files come out as before.

For chant runs, a push Op’s trigger takes build too, in chant run --generate (#4169). On GitHub and Forgejo, newest runs on pushes to the branch, on ci/build/** tags and by hand, in a concurrency group per ref; every gets a group per commit. On GitLab, newest adds a rule for ci/build/ tags, and the file’s header says to keep the project’s auto-cancel of redundant pipelines on for newest and off for every, since a waiting pipeline is dropped only by that setting.

Pushing tags to commits that change workflows

Section titled “Pushing tags to commits that change workflows”

By default the tick pushes its tags with the Actions token, GITHUB_TOKEN, which actions/checkout leaves in the clone. GitHub treats a new ref to a commit whose files under .github/workflows/ differ from the default branch’s as an update to those workflows. That needs the workflows permission, and the Actions token can never have it. So on a branch where a commit changes a workflow file, every push of that commit’s tag fails with refusing to allow a GitHub App to create or update workflow ... without workflows permission, and chant ci tick says so in its error.

Give the push a token that may update workflows, kept in a repository secret, and regenerate the workflow with it:

Terminal window
chant ci workflow --token-secret CI_GREEN_TOKEN

The checkout then uses ${{ secrets.CI_GREEN_TOKEN || github.token }}, so the push does too. Where the secret is unset, as in a fork or a fresh repository, the checkout falls back to the Actions token: the tick still runs, and only the tags for commits that change .github/workflows/ fail to push, which ci tick reports. A fine-grained personal access token for the repository needs Contents read and write and Workflows read and write. The tick still reads check runs with the Actions token and the job’s checks: read, because a fine-grained token can’t call the Checks API.

A GitHub App with Contents and Workflows write works too. Put its id in an Actions variable and its private key in a secret, and the workflow mints an installation token with actions/create-github-app-token before the checkout:

Terminal window
chant ci workflow --app-id-var CI_GREEN_APP_ID --app-key-secret CI_GREEN_APP_KEY

--runner-key-secret <NAME> passes the repository secret NAME to the tick step as CHANT_RUNNER_KEY, so the tick signs its tags. The secret holds the runner key as PEM, and the key’s principal needs the runner role in .chant/trust.json. When the declaration sets ci.green.signedSince and the flag is missing, ci workflow warns, since every tick would fail.

Regenerating keeps the token flags you passed, since the header records them. Leave them out and the file comes out byte for byte as 0.108.0 wrote it.

chant declares ci.green for its own main in its chant.workspace.json. The phases are check, test, validate and suites. The first three are the checks branch protection requires, each one check run of the same name from the chant workflow, where test is the job that passes only when the unit shards passed. That workflow holds the fast checks, and it is all that runs on a push or a pull request. Those checks are the unit tests and typechecks, plus lint and some small guards. suites is the job of the same name in release-suites.yml. That project is every *.e2e.test.ts, which covers the CLI goldens and the corpus differentials as well as the reference workspace. The first three phases declare build: "every" and suites declares build: "newest" (#4169), so ci workflow writes the triggers of both files: the chant workflow runs on every push to main, none is cancelled, and the tick starts it at a ci/build/<sha> tag on a commit GitHub never ran it on, and release-suites.yml runs on the newest push when its last run ends, and at each ci/build/<sha> tag the tick bisects with. A commit is green only when all four passed, so a release never tags a commit the long suites have not passed. A commit release-suites.yml never ran on is unbuilt, and its record names the commit that covers it. The other large suites live in large-suites.yml and helm-survey.yml, which run only when a person dispatches them; no phase and no release waits on those. Other workflows can run on main’s commits too, so none of their jobs is named check, test, validate or suites, which keeps their runs out of those phases.

Its tick runs the source at the commit it checks out, so a change to chant ci is tested on main before it ships:

Terminal window
chant ci workflow --chant 'npx tsx packages/core/src/cli/main.ts' --install 'npm install --ignore-scripts'

The install skips the lexicon builds, and the tick needs none of them. just release-when-green starts the phases a commit lacks and the tick, waits for the green tag, then runs just release (scripts/release-when-green.sh, #4218). just release picks the commit it tags from these tags: scripts/release-preflight.sh reads them whenever the declaration on origin/main sets ci.green for main. When no commit has a green tag, it refuses to release. It doesn’t fall back to asking GitHub, and CHANT_RELEASE_SKIP_PREFLIGHT=1 skips the check. chant does not set signedSince yet, so its tags are unsigned and the script checks that they exist. Once the declaration on origin/main sets it, the script asks chant instead, running ci last-green --from <commit> through $CHANT_CLI, which defaults to this checkout’s source through tsx. Each tag chant ignored is printed as it goes. The publish workflow has a second gate, release-gate, that waits for a green chant run, which is core’s typecheck and the unit tests, on the released commit. It runs on every tag push and every dispatch, and it is the only gate before the publish. The repository variable CHANT_RELEASE_SKIP_CI_GATE that used to skip it is no longer read.

chant