Query chant/lifecycle with SQL
Show the whole prompt
Read https://intentius.io/chant/guide/query-lifecycle/.
Answer the question I ask with `npx chant query "<sql>"` and show me the statement you ran with its rows.
Change no file and open no pull request.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.Optional: hand this page to your coding agent
Read https://intentius.io/chant/guide/query-lifecycle/.Answer the question I ask with `npx chant query "<sql>"` and show me the statement you ran with its rows.Change no file and open no pull request.Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.chant keeps its records on the chant/lifecycle branch. chant query loads them into SQLite in memory and runs one statement. Nothing is written, and the database is gone when the command exits.
Get the records
Section titled “Get the records”The command reads the local branch. To query what CI recorded, fetch it first:
git fetch origin chant/lifecycle:chant/lifecycleList what is deployed
Section titled “List what is deployed”The resources table has one row per resource in each environment’s snapshot, from the lexicon that observed it:
chant query "SELECT env, lexicon, type, count(*) AS n FROM resources GROUP BY env, lexicon, type ORDER BY n DESC"An attribute a lexicon read is in the attributes JSON:
chant query "SELECT name, json_extract(attributes, '$.Arn') AS arn FROM resources WHERE env = 'prod' AND lexicon = 'aws'"snapshots says when each environment was last observed, and at which commit:
chant query "SELECT env, lexicon, observed_at, git_sha FROM snapshots ORDER BY observed_at"Find failed runs
Section titled “Find failed runs”chant query "SELECT op, env, started, failure_code, failure_reason FROM runs WHERE status = 'fail' ORDER BY started DESC LIMIT 10"See who approved a deploy
Section titled “See who approved a deploy”A deploy record names its release, and a gate resolution names the release it approved. Join them:
chant query "SELECT d.env, d.component, d.timestamp, g.resolved_by FROM deploys d LEFT JOIN gates g ON g.kind = 'resolution' AND g.release_digest = d.release_digest AND g.environment = d.env ORDER BY d.timestamp DESC"Gates still waiting:
chant query "SELECT op, gate, timestamp, expires_at FROM gates WHERE kind = 'pending' AND expires_at > strftime('%Y-%m-%dT%H:%M:%SZ', 'now')"Label deploys with their release
Section titled “Label deploys with their release”chant query "SELECT d.env, d.component, c.label, d.timestamp FROM deploys d JOIN cuts c ON c.release_digest = d.release_digest ORDER BY d.timestamp DESC"Query a workspace
Section titled “Query a workspace”In a workspace every row has the member it came from. --member reads only the members it names:
chant query "SELECT member, count(*) FROM deploys GROUP BY member"chant query "SELECT * FROM runs" --member apiUse the rows in a script
Section titled “Use the rows in a script”--json prints the columns, the rows and the schema version. A script that depends on the columns can check the version first:
chant query "SELECT DISTINCT version FROM chant_schema" --jsonThe reference lists every table and column.