Drift
Optional: hand this page to your coding agentThe steps work by hand too.Show the whole prompt
The drift watch reported drift in the environment I name. Following https://intentius.io/sql-yodeler/drift/, run `npx yodel drift <env>` with the reader's credentials and tell me what changed out of band.
Then ask me whether to put the live object back by hand or keep the change. To keep it, declare it in src/, run `npx yodel new <name>` and `npx yodel lint`, and open a pull request.
Never run `yodel apply` against a shared environment, never run `chant approve`, `yodel approve` or `yodel override`, never edit the `chant/lifecycle` branch or `.chant/allowed_signers`, never merge; approvals and applies belong to people.Drift is a declared object changed out of band (by hand, by another tool) or gone. yodel drift <env> compares the declared objects with the live ones, through chant (chant lifecycle diff <env> --live). An object the project does not declare is never reported. A column added by hand to a declared table is: it reads column <name>: declared (none), live <type>.
What the server is compared with (--against):
history, the default when the project has migrations: the schema recorded by the newest migration the environment’s history records as applied (migration.json’sschema). A migration merged but not applied yet, waiting at its gate or refused, is not drift; a change made by hand is. With no migration applied yet there is no recorded schema, and nothing is reported.src, the default without migrations: the declared schema insrc/.
Objects on the server of a kind yodel cannot declare (an operator, a foreign table, a publication, and the others Adopting a database names) are reported apart, under “Unmanaged”, and in --json as unmanaged. They never count as drift.
Exit codes: 0 no drift, 2 drift, 1 the drift could not be read, or a declared object could not be read (its state is then unknown, not clean). --json prints the report as JSON, with what it was compared with (against) and a fingerprint of the drift: a hash of the environment and what drifted, the same for the same drift, which the tracking issue uses to tell an unchanged drift from a new one.
In the ClickHouse example, someone changes a column default by hand:
ALTER TABLE shop.events MODIFY COLUMN source LowCardinality(String) DEFAULT 'app'$ npx yodel drift devDrift in dev (clickhouse 26.8.15.10 at 127.0.0.1:8123)
Compared with the schema 20261010T1723-add-source records, the newest migration the history records as applied.
Changed out of band: events (ClickHouse::Table) column source default.expr: declared 'web', live 'app'[exit 2]Put back, there is none:
$ npx yodel drift devDrift in dev (clickhouse 26.8.15.10 at 127.0.0.1:8123)
Compared with the schema 20261010T1723-add-source records, the newest migration the history records as applied.
No drift: every declared object matches the server.The output quoted here is from the examples’ runs.
On a schedule: the WatchOp
Section titled “On a schedule: the WatchOp”ops/watch-<env>.op.ts declares the same check as a chant WatchOp with a cron schedule. The watch only reads. With the resume job, it is all yodel runs on a schedule.
import { WatchOp } from "@intentius/chant/op";
// Every hour at :17, read dev and report drift: a declared object changed out// of band, or gone. Objects src/ does not declare are never reported.// `chant run watch-dev` runs it once, by hand.export const { op: watchDev } = WatchOp({ name: "watch-dev", env: "dev", schedule: "17 * * * *" });The watch job in the template’s pipelines runs it on its schedule (chant run watch-dev, underneath). A run takes a snapshot, diffs declared against live, and reports:
$ npx chant run watch-devSnapshot saved to chant/lifecycle (sql(2))
sql — environment: dev0 missing, 0 orphan, 0 disappeared, 0 newly observed, 0 drifted, 2 unchanged--------------------------------------------------------------------------------
sql (properties)1 property drift across 1 resource(s), 0 accepted, 1 unchanged--------------------------------------------------------------------------------
PROPERTY DRIFT (declared vs live; baseline shown where one exists): - events (ClickHouse::Table) columns[4].default.expr: 'web' → 'app' [from: authored][phase] Snapshot ✓ lifecycleSnapshot(env=dev) 923ms[phase] Diff ✓ lifecycleDiff(env=dev, live=true) 781ms [outcome] Drift=trueOp "watch-dev" completed in 1.8schant run exits 0 when the watch completes, drift or not. The drift is the run’s Drift outcome, in its run record on the local chant/lifecycle branch. The WatchOp compares with src/, so in the starter templates’ watch job it is followed by yodel drift <env> --issue, which compares with the history, fails the job on drift, and keeps the tracking issue below.
The starter templates render a scheduled pipeline per watch for each forge (npm run ci writes them from ops/): a GitHub Actions or Forgejo Actions workflow on the watch’s cron, and a GitLab CI job run by a pipeline schedule you create with the cron the file notes (GitLab keeps no cron in the file). The job reads with the reader’s credentials and never pushes: its snapshot and run record stay in the job. Its token writes only issues: GitHub’s job token gets issues: write, Forgejo’s can write already, and GitLab uses GITLAB_TOKEN, the project access token the plan comment uses.
When the watch stops running
Section titled “When the watch stops running”A scheduled job can stop with no error anywhere. GitHub turns a scheduled workflow off after 60 days with no activity in the repository, and on GitLab the job runs only from a pipeline schedule someone created. yodel plan <env> --comment asks the forge when the environment’s watch job last ran, and when the watch’s cron has fired at least twice since, the comment carries a warning (chant#4289), and the job log the same line:
Warning: Op `watch-dev` is overdue: its schedule `17 * * * *` has fired at least twice and its last run was on 2026-10-18. GitHub turns a scheduled workflow off after 60 days with no activity in the repository. Turn the workflow on again under Actions, or run it by hand.The watch is the WatchOp whose env is the environment, and the job is the file npm run ci rendered for it: .github/workflows/watch-<env>.yml, .forgejo/workflows/watch-<env>.yml, or the job in .gitlab/yodel-watch.gitlab-ci.yml whose rules select it (src/pr/overdue.ts). A watch with no rendered file is not checked. With no run on record, the count starts at the commit that added the file. chant gives the verdict (overdueVerdict, op/schedule-overdue.ts:107 in chant 0.124.46), so one late or dropped run is not a warning.
The warning never fails the plan. A forge that does not answer is a line in the job log and no warning. On GitHub the plan job reads the workflow’s runs with actions: read, which the rendered yodel-pr.yml asks for; run npm run ci to add it to pipelines rendered before.
The tracking issue
Section titled “The tracking issue”yodel drift <env> --issue keeps one issue for the project and environment on the forge, found again by a marker in its body (<!-- yodel:drift project=<dir> env=<env> -->, where <dir> is the project’s directory in its repository, . at the root):
- drift found and no issue open: it opens one, titled with the environment and the objects (
Drift in dev: events, daily), its body the report as markdown, what it was compared with, the CI run that found it and the fingerprint; - drift found and the issue open: it updates the issue when the fingerprint changed, and leaves it when it did not;
- no drift: it comments that the drift is gone and closes the issue. Drift found again later opens a new one;
- the drift could not be read, or a declared object could not be (exit 1): it leaves the issue as it is, and says so.
The forge, repository and token come from the CI job’s environment, as for yodel plan --comment (Approval): GITHUB_TOKEN on GitHub Actions, GITLAB_TOKEN on GitLab CI, FORGEJO_TOKEN or GITHUB_TOKEN on Forgejo Actions, each after its CHANT_<FORGE>_TOKEN (and GH_TOKEN on GitHub and Forgejo). The issue counts as current while its title is the same and its body still carries the drift’s fingerprint, so a scheduled run that finds the same drift leaves it alone. --forge, --repo, --api-url and --token-env set them outside CI. yodel drift prints what it did to the issue on stderr, and --json adds it as issue (opened, updated, unchanged, closed, none or left, with the number and link). An issue the forge refuses fails the run with exit 1 unless it found drift (exit 2).
The Postgres example’s drift and watch are in its section 8.
Proven by
Section titled “Proven by”The scenario claims below run what this page describes against a real server, once plain (it passes) and once with the behaviour broken (the claim catches it). Claims status lists every claim.
| Claim | What it says | Plain, broken | Last run |
|---|---|---|---|
declarative |
the declarative path: yodel plan shows the change against the live server and yodel apply makes it behind the plan-bound gate, for src/ declarations (on Postgres, functions, procedures and triggers, and access control: a role, a policy and grants, with a grant made by hand revoked; on ClickHouse, a dictionary, a function, and access control: a role, a user, a row policy and grants, with a grant made by hand revoked) and for an ORM’s exported DDL; a pull request on that path gets lint over the planned changes and the plan comment with them, and a policy rule at the base commit that denies the plan refuses yodel apply before the gate; yodel drift reports a declared object changed out of band, naming the property, a column added to it by hand, and one dropped; on the versioned path it compares with the newest applied migration’s recorded schema, so a pending migration is not drift; yodel init –from adopts a live database without touching it, and yodel plan then shows no change; on Postgres its policies, row-level security and grants too, on ClickHouse its dictionaries, functions, roles, users, row policies and grants; it refuses a database holding an object of a kind it cannot declare, naming it; yodel init –baseline records the baseline, behind the gate, in a second environment that holds the same schema, and refuses one that differs | ClickHouse: pass, caught; Postgres: pass, caught | 821d93b, 2026-11-03 |
