Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This file records changes to what chant prints or writes for a plain project, th

## Unreleased

- [#5118](https://github.com/INTENTIUS/chant/issues/5118) `chant audit` and `chant lint` take `--preset pull-request` and `--baseline <file>`. The preset reports only its rules, each as merge-blocking or report-only, with `LEX002` and `EVL001` as tool notices, drops findings below `warning`, and fails the run on a merge-blocking finding (`chant audit` unless `--fail-on` is given). With `--baseline`, the JSON or SARIF report of the same command on the base, only findings whose identity is not in it are reported. A preset run's JSON and SARIF findings carry `gate`, and `chant lint`'s carry `identity` (SARIF `partialFingerprints`). Without `--preset` nothing changes, except that `chant lint --format json` gives a post-synth finding its `locator`.
- [#5094](https://github.com/INTENTIUS/chant/issues/5094) `chant workspace graph` stamps an Application an ApplicationSet generates with the `helmReferences` the reader gives one written by hand, so its chart joins the chart node and its values files are read by the Helm rule, under `k8s:K8s::Argo::Application:helmReferences.valuesFiles[]`, in place of the path rule. A values file it names that exists becomes a `Helm::Values` node, with a node for each object under its `extraObjects`, at `<ApplicationSet id>/values/<path>` in the ApplicationSet's member and with `generatedBy` naming the generated Application and `generator: "file"`. A catalog's generate rule takes `files`, and the pass takes a `readFile`.
- [#5094](https://github.com/INTENTIUS/chant/issues/5094) The terraform lexicon's evaluator reads `a == b` and `a != b` over two values the files determine, with Terraform's rule that values of different types are not equal, so `count = var.is_prod_cluster == "true" ? 1 : 0` gets its instance nodes: `chant graph` draws `google_container_cluster.prod_cluster[0]` where it drew the block alone, and the catalog matches the instance. A `count` or `for_each` that comes to zero plans nothing, so its block carries `evaluated: { instances: {} }` and the catalog matches none of its arguments; the test block beside a prod block of the same name is no longer an ambiguous match. A comparison with an unknown side stays unknown and names that side's reference.
- [terragucci#1461](https://github.com/INTENTIUS/terragucci/issues/1461) The product pipeline takes `commentAllow: { allow, tokenSecret? }`, which limits `/<product> plan`, `apply`, `lock`, `unlock` and `agent` to the logins and `team:<org>/<team>` entries `allow` names per command, with `default` for the ones it leaves out, on GitHub and Forgejo. Before, those comment jobs checked write access alone. The map is written into the workflow as `CHANT_COMMENT_ALLOW`, in the comment job, the product plan's re-plan decision and the agent's jobs, so it is read from the workflow on the default branch and a pull request cannot add its author. The comment job replies to a commenter the list leaves out; the re-plan and the agent stay silent. `ForgeReads.teamMember` reads a team (GitHub needs a token that can read the organization's members, Forgejo `read:organization`); `tokenSecret` names the secret that holds it, else the job's own token is used, and a team the forge cannot answer for fails closed with a message that says what to fix. A pipeline with no `commentAllow` writes the same workflow as before. Floor `COMMENT_ALLOW_FLOOR`.
Expand Down
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export default defineConfig({
collapsed: true,
items: [
{ label: 'Linting & Type-Checking', slug: 'guide/linting' },
{ label: 'Check Every Pull Request', slug: 'guide/pull-request-check' },
{ label: 'Organizational Policy', slug: 'guide/organizational-policy' },
{ label: 'Custom Rules', slug: 'lint-rules/custom-rules' },
{ label: 'Auto-Fix', slug: 'lint-rules/auto-fix' },
Expand Down
7 changes: 7 additions & 0 deletions docs/src/content/docs/cli/audit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ The **expanded** (HTML) report renders the same findings with badges, cards, and
| `--template <file>` | `html` only: a full HTML template override (see below) |
| `--theme <file>` | `html` only: a JSON file of theme knobs (`title`, `logo`, `accent`, `footer`) |
| `--max-files <n>` | Local path only: how many files the walk takes before it stops (default `1000`). See [Scan limits](#scan-limits) |
| `--preset <name>` | Report only the rules of a named preset, each as merge-blocking or report-only, and exit 1 on a merge-blocking finding unless `--fail-on` says otherwise. `pull-request` is the one preset. See [Check every pull request](/chant/guide/pull-request-check/) |
| `--baseline <file>` | With `--preset`: the JSON or SARIF report of the same audit on the pull request's base. Only findings whose `identity` is not in it are reported |
| `--agents` | Audit this machine's **agent configuration** instead of a repository (see below) |
| `--scope <list>` | `--agents` only: comma-separated `system`, `user`, `project` (default: all) |
| `--runtime <list>` | `--agents` only: comma-separated `claude`, `codex`, `gemini`, `opencode`, `cursor` (default: all) |
Expand Down Expand Up @@ -387,13 +389,18 @@ chant audit https://github.com/owner/repo -f html --theme theme.json -o report.h

# Only the PR-worthy findings, as JSON, failing CI if any exist
chant audit . --tier merge-worthy --json --fail-on merge-worthy

# Only what a pull request added, under the pull request preset
chant audit ../base --preset pull-request --json -o base.json --fail-on none
chant audit . --preset pull-request --baseline base.json
```

## Exit codes

| `--fail-on` | Exit 1 when… |
|-------------|--------------|
| `none` (default) | never (read-only) |
| not given, with `--preset` | any merge-blocking finding of the preset exists |
| `merge-worthy` | any merge-worthy finding exists |
| `warning` | any error- or warning-severity finding exists |
| `error` | any error-severity finding exists (chant #2113) |
Expand Down
4 changes: 3 additions & 1 deletion docs/src/content/docs/cli/lint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ chant lint [path] [flags]
| `-w, --watch` | `bool` | `false` | Watch for file changes and re-lint |
| `--root-only` | `bool` | `false` | At the root of a declared workspace, lint the root project alone instead of refusing. See [At a workspace root](#at-a-workspace-root) |
| `--sandbox` | `bool` | `false` | Run any project source the lint has to execute in one isolated child process rather than in the chant process. The same boundary as [`chant build --sandbox`](/chant/cli/build/#sandboxed-execution); composes with `--watch` |
| `--preset <name>` | `string` | | Report only the rules of a named preset, each as merge-blocking or report-only. `pull-request` is the one preset. See [Check every pull request](/chant/guide/pull-request-check/) |
| `--baseline <file>` | `string` | | With `--preset`: the JSON or SARIF report of the same command on the pull request's base. Only findings whose identity is not in it are reported |

## Usage

Expand Down Expand Up @@ -69,4 +71,4 @@ At the root of a [declared workspace](/chant/reference/workspace-declaration/),
| Code | Meaning |
|------|---------|
| 0 | No errors found |
| 1 | Lint errors found, including a lexicon post-synth error, a declared lexicon that could not be resolved, a lint path that does not build (`LEX002`), or `WSP000` at a workspace root |
| 1 | Lint errors found, including a lexicon post-synth error, a declared lexicon that could not be resolved, a lint path that does not build (`LEX002`), or `WSP000` at a workspace root. With `--preset`, only a merge-blocking finding exits 1, and `LEX002` is a tool notice |
80 changes: 80 additions & 0 deletions docs/src/content/docs/guide/pull-request-check.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Check Every Pull Request
description: Run chant audit and chant lint under the pull-request preset on a pull request's base and head, and report only the findings the change added
diataxis: how-to
prompt: |
Read https://intentius.io/chant/guide/pull-request-check/.
Add a pull request job that runs `chant audit` on the base with `--preset pull-request --json -o base.json --fail-on none`, then on the head with `--preset pull-request --baseline base.json --format sarif -o chant.sarif`, and uploads the SARIF.
Show me the job and one run's output before you open the 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 audit` runs every rule it has, and on a repository that chant did not write most of what it reports was there before any one pull request. The `pull-request` preset ([#5118](https://github.com/INTENTIUS/chant/issues/5118)) is a named rule set and a severity floor for a check that runs on every pull request. With a baseline from the pull request's base, it reports only the findings the change added, and it fails only on the rules that were right most of the time on a replay of real history.

## What the preset reports

The preset puts each rule in one of three sets ([source](https://github.com/INTENTIUS/chant/blob/main/packages/core/src/audit/pull-request-preset.ts)). A rule in no set is off, so a rule added to chant later stays off here until a replay shows it meets the bar.

| Set | Rules | Effect |
|---|---|---|
| Merge-blocking | `WK8501` (fields the API server prunes), `GRAF103` (a dashboard variable the dashboard does not define), `SEC001` to `SEC009` (secrets in a known format) | Reported, and the run exits 1 |
| Report-only | `WK8203`, `WK8204`, `WK8205` (container security context), `GRAF104`, `GRAF105` (duplicate and overlapping panels), `TF002` (provider pins), `WK8102`, `WK8104`, `WK8105`, `WK8201`, `WK8301`, `WK8302`, `WK8003`, `TF006`, `TF010`, `TF011`, `TF012`, `TF017`, `TF020`, `TF022`, `TF039`, `PROM217` | Reported, never fails the run |
| Tool notice | `LEX002`, `EVL001` | Printed apart from the findings: a file chant could not import or build |

The severity floor is `warning`, so an `info` finding is not reported in any set. Each off rule carries its measured reason in the preset's source. `COR001`, for example, had 116 findings on the replay and none was true, since it judges the TypeScript that `chant import` wrote. Each of the 6 `SEC010` findings was a URL or an ARN or a similar name.

## Run it on a pull request

Check out the base beside the head, audit the base, then audit the head against it:

```sh
git worktree add ../base "$BASE_SHA"
chant audit ../base --preset pull-request --json -o base.json --fail-on none
chant audit . --preset pull-request --baseline base.json
```

The second command prints the findings that are new in the head, split into merge-blocking and report-only, and ends with one line that counts the merge-blocking and report-only findings, the findings already on the base, and the ones the preset left out It exits 1 when there is a merge-blocking finding. `--fail-on none` keeps it read-only, and any other `--fail-on` value works as it does without a preset.

A finding is new when its `identity` is not in the baseline. The identity names the rule and where the finding sits in the object. It leaves out the message, so a finding that only moved lines or changed wording is not reported again ([#5106](https://github.com/INTENTIUS/chant/issues/5106)). `--baseline` reads the JSON report (`findings[].identity`) or the SARIF report (`partialFingerprints`) of the same command. A file that is neither is refused rather than read as an empty baseline.

For a SARIF upload, write the head's report with `--format sarif -o chant.sarif`. Each result carries its set in `properties.gate`.

## Run it on chant source

`chant lint` takes the same two flags:

```sh
chant lint ../base/src --preset pull-request --format json > base.json
chant lint src --preset pull-request --baseline base.json
```

Under the preset, lint exits 1 only on a merge-blocking finding, and `LEX002` (a lint path that does not build) is a tool notice. Paths in the identity are relative to the project root, so the base can be linted in another checkout. A plain `chant lint --format json` has no identities, so the base must be linted with `--preset` too.

## Render stability

On a Helm values change, run `chant helm localize <chart> --values <file>` on both sides. A render that was deterministic on the base and is unstable on the head is a merge-blocking result under the preset: the replay's one true Helm finding was a removed `existingSecret` that made the chart generate a new admin password on every render.

## How the bar was set

The rule lists were measured on a replay of merged changes to a public Kubernetes infrastructure repository, with `chant audit`, per-file `chant lint` and `chant helm localize` run on the parent and the commit of each change ([test/pr-preset-replay](https://github.com/INTENTIUS/chant/tree/main/test/pr-preset-replay)). Each merge-blocking finding was labelled by hand with its reason, and every other finding by its rule.

The bar is at least 35% precision on the merge-blocking findings, every true finding kept, and at most 10 of the 159 changes in the first window blocked. `test/pr-preset-replay/bar.test.ts` scores the labelled findings against the preset in the unit suite, so a change to the rule lists that misses the bar fails there.

| Window | Changes | Every rule on | Merge-blocking as first proposed | Merge-blocking, this preset |
|---|---|---|---|---|
| 2026-05-12 to 2026-11-12 | 159 | 17 true of 721 (2.4%) | 17 of 46 (37.0%), 7 changes blocked | 17 of 17, 3 changes blocked |
| 2025-11-12 to 2026-05-12 | 91 | 0 true of 1020 | 0 of 123, 8 changes blocked | none, no change blocked |

The first proposal on #5118 also made `GRAF104`, `GRAF105`, `WK8203`, `WK8204`, `WK8205` and `TF002` merge-blocking. It met the bar on the first window by a small margin. On the second it blocked 8 changes with nothing true, and none of the 158 findings those six rules raised across both windows was true, so they report and do not block. Most of the second window's were manifests moved to a new path in a Flux-to-Argo CD migration, which identity reads as new because it includes the file, and node DaemonSets that need root by design.

The true findings in the first window are 3 defects. One dashboard's queries used variables it did not define, which gave 14 `GRAF103` findings and was fixed by the next change the same day. An `ApplicationSet` field the API server pruned was found by both audit and lint (`WK8501`) and fixed four months later. The localize result is a values change that made a chart's admin password Secret change on every render. The second window has no true finding with every rule on, so it shows what the preset costs on a quiet half year: nothing blocked. Three defects are a small sample, so a replay of other history is worth running before the preset gates a busy repository.

## Replay another window

The replay harness takes any corpus built the same way: a git bundle with a `c/<commit>` tag for each parent and commit, a `changes.json` listing the changes and their files, and the Helm charts the localize check renders.

```sh
just replay-pr-preset <corpus dir> <work dir> --labels <labels.json> --record findings.json
```

A cold run of the first window took about an hour on a busy laptop; `<work dir>` keeps each commit's report, so a second run reads them. `--record` writes every new finding with its label, or `UNLABELLED` where the labels file has none. Label the merge-blocking ones by hand, with the reason, and run again. The harness exits 1 while a merge-blocking finding has no label, when precision is below the bar, or when a true finding is no longer found.
1 change: 1 addition & 0 deletions docs/src/content/docs/reference/level-0-exceptions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The `version` field has shipped, and `v0.80.0` is the warning release for the ot
| `chant --help` lists `query`, which was an unknown-command error. `chant query "<sql>"` is new and only reads: one SQL statement over the local `chant/lifecycle` branch, loaded into `node:sqlite` with table schema version 1. `parseRunLedger` is exported from the run ledger. A project that never runs it sees no change | [#4297](https://github.com/INTENTIUS/chant/issues/4297) | none: accepted without a warning release, as chant's breaking changes are. No golden moves |
| The otel lexicon's collector pin moves from collector-contrib v0.130.0 to v0.162.0 (`COLLECTOR_PIN`), and its built-in config types are generated from upstream `config.schema.yaml` at that release. `COLLECTOR_IMAGE`, the default image of the k8s, docker and fly collector composites, moves from `otel/opentelemetry-collector-contrib:0.130.0` to `:0.162.0`, so the image those composites write moves with it. Fields the lexicon typed change on the way: the prometheus receiver's `use_start_time_metric` and `start_time_metric_regex` are gone (removed in v0.143.0); the prometheus exporter ignores `add_metric_suffixes` by default (v0.154.0), so `spanMetricsNames()`, `serviceGraphNames()` and PROM301 read `translation_strategy` for it, and `resource_to_telemetry_conversion` is deprecated (v0.160.0) for `resource_constant_labels`; the routing connector's `request` context (v0.156.0), the `k8snode` detector (v0.154.0, alias of `k8s_api`) and the flat confighttp keepalive fields (v0.160.0) are deprecated; tail_sampling's inverted decisions lost their gate (v0.155.0); and `error_mode` defaults to `ignore` for filter, transform and routing (v0.157.0). OTEL126 and OTEL127 check against the v0.162.0 lists, which add `k8s.cronjob.uid`, `container.image.tags` and the detectors added since v0.130.0 | [#3361](https://github.com/INTENTIUS/chant/issues/3361) ([#2525](https://github.com/INTENTIUS/chant/issues/2525#issuecomment-6376504335)) | none: the maintainer accepted it without a warning release on 2026-10-23, as chant has few users. No CLI golden runs a collector composite; the composites' tests read `COLLECTOR_IMAGE` |
| One [exit-code table](/chant/reference/exit-codes/) for every command. A step that refuses a plan that moved since it was approved makes `chant run --components`, `fan-out`, `promote`, `rollback`, `redeploy` and `pr-apply` exit 4 where they exited 3, and `pr-apply` exits 4 for a digest that moved after its approval. `chant lock`, and `pr-apply` under `ci.locks`, exit 5 for a target another pull request holds, where they exited 3. A policy denial exits 7 at `pr-plan` (where it exited 1) and at `pr-apply` (where it exited 3). `chant lifecycle drift` refuses a read with 1 in place of 3. A gate, a decision point and every other wait keep 3, and `--gated-exit` still remaps only 3 | [#4553](https://github.com/INTENTIUS/chant/issues/4553) | none: accepted without a warning release, as chant's breaking changes are, by the 2026-10-27 ruling on #4553. No CLI golden runs a moved plan, a lock, a policy or a refused drift read |
| `chant lint --format json` gives a lexicon post-synth finding its `locator`, the place in the object (a container, for the `WK82*` checks) the check named, so `chant lint --preset` names the finding as `chant audit` does. A finding with no locator is unchanged, and the only golden that moved is `getting-started/lint-format-json.golden`, whose `WK8105` and `WK8203` findings gain it, and also the `entity` that [behold#919](https://github.com/INTENTIUS/behold/issues/919) added and the golden had not caught up with | [#5118](https://github.com/INTENTIUS/chant/issues/5118) | shipped without a warning release: the field is additive |

## Landing a listed change

Expand Down
Loading
Loading