Baselines
A baseline records the findings a tree already has, so a gate can fail on the ones that appeared
since without hiding the rest. It is a JSON file next to poly.toml, committed with the code; poly
never changes it except when you ask.
Write a baseline, then gate on new findings
Section titled “Write a baseline, then gate on new findings”poly baseline write -o poly.baseline.json # record everything poly finds todaypoly lint --baseline poly.baseline.json --baseline-fail-on new .poly baseline write runs the per-file lint tier with the same config, exclusions and engine
selection poly lint uses, and records every finding’s fingerprint. poly lint --baseline then
classifies each finding:
baseline: "new"— the baseline does not record it;baseline: "existing"— the baseline records it.
The document’s summary gains new, existing and fixed_since_baseline counts, and the
baseline block names the file, its scope, and whether the run was comparable. Existing findings
are still reported in full: the baseline changes the gate, not the report.
What identity means
Section titled “What identity means”A finding is identified by its rule id, its file path, the whitespace-normalised text of the offending line, and its order among identical findings in that file. That gives a stable identity across machines and unrelated edits, and the following behaviour, which is worth knowing before you commit a baseline:
| Change | Classification |
|---|---|
| Move unrelated lines above the finding, or the finding itself | still existing |
| Edit the offending line (beyond whitespace) | the finding is new; the recorded entry is fixed |
| Rename or move the file | its findings are new |
| Fix the finding | it appears under fixed_since_baseline |
Two findings of one rule on identical lines are told apart by their order. Fixing the earlier one
shifts the later one into its place: the run then reports one existing finding and one fixed
entry, not a new finding. Two findings with different text on the same line are independent.
A finding’s severity is recorded for readability but is not part of its identity, so a rule that changes severity keeps its entries and the current run still reports the new severity.
What the file holds
Section titled “What the file holds”{ "configs": [{ "hash": "…" }], "findings": [ { "fingerprint": "poly1:…", "path": "src/app.py", "rule_id": "ruff/F401", "severity": "warning", "title": "`os` imported but unused" } ], "poly_version": "0.37.0", "schema_version": 1, "scope": ["."]}- Paths are relative to the baseline file’s directory, never absolute, so the file is the same bytes on every machine and however poly was invoked. Findings and scope are sorted and keys are emitted in a fixed order: writing the same tree twice produces the same file.
scopeis the paths the baseline was written over. A run over a larger scope classifies the extra findings asnew; a run over a different scope is noted, and entries outside it are listed asoutside_scoperather than claimed as fixed.configsare the run’s configuration fingerprints. If the config changed since the baseline was written, the comparison is flagged (configs_match: falseand a stderr note) but still runs: the ruleset moved, so the result is worth a look rather than refused.schema_versionnames the shape. The committed schema isschemas/baseline.v1.schema.json; print it withpoly config schema --kind baseline.
Suppressed findings are never recorded. A suppression is an instruction in the source or the config, and the baseline does not need to repeat it.
The default file name poly.baseline.json is never treated as source: it is excluded from
discovery, reported as one excluded file rather than a skip. That keeps poly fmt from rewriting
the layout baseline write produced. A baseline you name something else is ordinary JSON to poly;
list it in [discovery] exclude if you commit it and its layout matters.
Refresh a baseline
Section titled “Refresh a baseline”poly baseline write --update -o poly.baseline.jsonwrite refuses to replace an existing baseline unless --update is passed, so a committed file is
never overwritten by accident. --update replaces the file with what the current run finds and
reports how many recorded entries it no longer matches (pruned). Pruned is not the same thing as
fixed_since_baseline: an update over part of the tree (poly baseline write --update src/) drops
every entry outside that run’s scope, so a partial-scope update can remove entries nobody
re-checked. Refresh from a full-tree run when pruning should mean “fixed”.
With --fix, a finding poly fixes is gone from the run’s results, so it moves to
fixed_since_baseline in the same run; refresh the baseline afterwards to drop it for good.
- run: poly lint --baseline poly.baseline.json --baseline-fail-on new --fail-on warning .Write the baseline on a clean checkout once, commit it, and review it like any other file: a rule that starts reporting more findings shows up as added entries, and a fixed one as removed entries.