command_idempotent
Run a user-declared formatter/checker in its --check
(idempotence) mode once: exit 0 ⇒ the tree is
formatter-clean (silent); non-zero ⇒ violation(s). The sibling
of generated_file_fresh — that rule diffs a generator's
captured stdout against a committed file; this trusts a
checker's own --check exit code. alint never runs a
mutating formatter and never writes the tree. With
files_from (stdout/stderr) the tool's own offender list is
parsed into one violation per file (optional files_pattern
regex, capture group 1 = path, for tools that wrap the path in a
message like cargo fmt's Diff in <path> at line N); without
it, one violation for the whole invocation. A non-zero exit is
never swallowed into a pass. Single-shot, opt-in. Trust-gated
like command (see below): declarable only in your own
top-level config.
A completed non-zero checker exit is the configured policy verdict and remains a violation. A spawn or wait failure, or a timeout before the checker exits, produces a non-baselinable evaluation analysis failure instead.
As with generated_file_fresh, the optional workdir (the child's working directory, relative to the lint root) must stay inside the repository: an absolute path or a .. that climbs out is rejected when the config loads, and a workdir that resolves outside the repository through a symlink is refused at run time (reported as a spawn failure) instead of running the command there.
Options
Section titled "Options"| Option | Type | Required | Default | Description |
|---|---|---|---|---|
command | list of string | yes | Checker argv (no shell), run in its --check / idempotence mode; exit 0 = clean. | |
files_from | one of none | stdout | stderr | none | On failure, parse this stream into per-file violations (default: none = one violation for the whole invocation). | |
files_pattern | string | null | Regex whose capture group 1 is a file path, applied per output line (requires files_from; omit for bare-path listers). | |
timeout | integer (>= 1) | null | Checker timeout in seconds (default 120). On timeout the child is killed and one non-baselinable evaluation analysis failure is emitted. | |
workdir | string | null | Checker cwd, relative to the lint root (default: lint root). |
Plus the common level, id, and when fields. This rule analyses the whole repository, so it takes no paths or expect_matches. This table is generated from the JSON Schema; option types and defaults are authoritative.
Example
Section titled "Example"A checker that flags an offending file
Section titled "A checker that flags an offending file"The rule fires on this repository:
- src/
- src/main.rs
✗ error fmt-clean
src/main.rs: not formatter-clean
fn main() {}With this .alint.yml:
version: 1rules: - id: fmt-clean kind: command_idempotent command: ["sh", "-c", "printf 'src/main.rs \\n'; exit 1"] files_from: stdout level: erroralint check reports:
--- src/main.rs ---------------------------------------------------------------- x error fmt-clean src/main.rs: not formatter-clean
Summary (1 violation): x 1 error 0 passing * 1 failingA checker that exits clean
Section titled "A checker that exits clean"This repository is compliant:
- src/
- src/main.rs✓
fn main() {}With this .alint.yml:
version: 1rules: - id: fmt-clean kind: command_idempotent command: ["sh", "-c", "exit 0"] level: erroralint check reports:
v All 1 rule(s) passed.