From 3f116c1aae5c7588953b6d2066856ea6723884a6 Mon Sep 17 00:00:00 2001 From: Norrie Taylor Date: Sun, 27 Sep 2026 21:21:53 -0700 Subject: [PATCH 1/6] docs(agents): say the strict clippy gate is local and bounded by the directive Three agent rounds since #1724 landed rewrote lines beyond their task to satisfy `just clippy-strict`, two of them in conflict rounds whose only directive was the merge, and two coders wrote that the PR lanes would have gone red otherwise. They would not: the gate is local, no CI lane runs it. Say so where AGENTS.md names the gate, and say what a revise or conflict round does with its hits: report them in `notes`, not fix them. --- AGENTS.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 8ce0d8d388..2c8531e1ab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -204,7 +204,10 @@ PR"): it runs the same gates the PR lanes run (fmt, clippy, cargo-deny, the test suite, doctests; plus `just test-ignored` on Linux), dispatched for your OS, and then `clippy-strict`, which applies a stricter lint set to the lines your branch changed. Run `just clippy-strict` alone to see just -those. Platform notes for agents: +those. That gate is local only: no CI lane runs it, so its hits never turn +a PR red, and in a revise or conflict round the directive bounds the +change, so report its hits in `notes` rather than fix them. Platform notes +for agents: - **macOS**: the workspace does not build natively (see [Platform matrix](#platform-matrix)); `just ci` runs the darwin-capable From c239dc99f3ada8a7e55103551a7d9c032ae94d88 Mon Sep 17 00:00:00 2001 From: Norrie Taylor Date: Sun, 27 Sep 2026 21:42:04 -0700 Subject: [PATCH 2/6] chore(lint): report the strict gate in just fix, enforce it in just ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `just fix` is the innermost loop, and the gate failed there. Three agent rounds on the NET walk then rewrote lines their task never named to clear it (#1737 round 3, #1730 round 5, #1727 round 4), two of them in conflict rounds whose only directive was the merge. A command that fails in the edit loop outranks a sentence in AGENTS.md telling you to leave the hit alone, so the sentence this branch added needs the recipe to agree with it. CLIPPY_STRICT_REPORT_ONLY=1 prints the diagnostics and exits 0. `fix` sets it; `clippy-strict` and `ci` do not, so "before opening a PR" stays the round that owns the judgement. Only hits are demoted — a build or tooling failure still exits non-zero, which is what the cargo check above the filter is for. --- AGENTS.md | 10 ++++++---- justfile | 27 ++++++++++++++++++--------- scripts/clippy-strict.sh | 21 ++++++++++++++++++++- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 2c8531e1ab..d75faf0347 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -206,7 +206,9 @@ for your OS, and then `clippy-strict`, which applies a stricter lint set to the lines your branch changed. Run `just clippy-strict` alone to see just those. That gate is local only: no CI lane runs it, so its hits never turn a PR red, and in a revise or conflict round the directive bounds the -change, so report its hits in `notes` rather than fix them. Platform notes +change, so report its hits in `notes` rather than fix them. `just fix` +reports it without failing for that reason; `just ci` is where it stops +you, because that is the round that owns the judgement. Platform notes for agents: - **macOS**: the workspace does not build natively (see @@ -217,6 +219,6 @@ for agents: - **VM/daemon-path changes**: also run `just e2e` (the session proof) and/or `just test-vm` (the VM integration harnesses). - **Tight iteration loops**: `just fix` (fmt → `clippy --fix` → fmt, then the - strict clippy gate, with `--allow-dirty` so it runs mid-edit) then - `just test`. Both carry this host's scope; neither needs a hand-written - `cargo` line. + strict clippy gate reported but not enforced, with `--allow-dirty` so it + runs mid-edit) then `just test`. Both carry this host's scope; neither + needs a hand-written `cargo` line. diff --git a/justfile b/justfile index 60ea601590..326d55268d 100644 --- a/justfile +++ b/justfile @@ -271,18 +271,24 @@ fmt: # clean-worktree check — the usual case here is running mid-edit with # staged/unstaged work. # -# Autofix pass: fmt, clippy --fix, fmt again, then the strict clippy gate (runnable mid-edit). +# Autofix pass: fmt, clippy --fix, fmt again, then the strict clippy gate, reported (runnable mid-edit). fix: cargo fmt --all cargo clippy {{scope}} --all-targets --fix --allow-dirty -- -D warnings cargo fmt --all - # No autofix for the strict set, and a hit fails this recipe. `clippy --fix` - # rewrites every hit in the selected crates and cannot be scoped to changed - # lines, so autofixing it would sweep legacy sites in every crate it - # touches. Most of the set has no machine-applicable suggestion anyway (6% - # of current hits, none of the four largest lints), so these are judgement - # calls, not rewrites. - scripts/clippy-strict.sh "" {{strict-scope}} + # No autofix for the strict set. `clippy --fix` rewrites every hit in the + # selected crates and cannot be scoped to changed lines, so autofixing it + # would sweep legacy sites in every crate it touches. Most of the set has no + # machine-applicable suggestion anyway (6% of current hits, none of the four + # largest lints), so these are judgement calls, not rewrites. + # + # Reported, not enforced: this is the innermost loop, and it used to fail + # here. Three agent rounds on the NET walk then rewrote lines their task + # never named to clear it, two in conflict rounds whose only directive was + # the merge (#1737, #1730, #1727) — a failing command in the loop outranks + # any doc sentence saying to leave the hit alone. `just ci` enforces it, + # which is where "before opening a PR" owns the judgement. + CLIPPY_STRICT_REPORT_ONLY=1 scripts/clippy-strict.sh "" {{strict-scope}} # CI: ci.yml `fmt`. # @@ -301,9 +307,12 @@ clippy: # The lints below are the ones the tree is not yet clean for: CI's clippy job # runs `-D warnings`, so they live here rather than in Cargo.toml and only the # lines you changed are reported. Run it once your change is ready, fix what it -# reports in the files you touched, and promote each lint into +# reports on the lines your change introduced, and promote each lint into # [workspace.lints.clippy] as its count reaches zero. # +# This recipe and `just ci` enforce; `just fix` only reports. A hit on a line the +# round's directive did not name is a note, not a licence to edit it. +# # Strict Clippy on the lines this branch changed, scoped to the crates you touched. clippy-strict BASE="": scripts/clippy-strict.sh "{{BASE}}" {{strict-scope}} diff --git a/scripts/clippy-strict.sh b/scripts/clippy-strict.sh index c4510292b7..afd08863ca 100755 --- a/scripts/clippy-strict.sh +++ b/scripts/clippy-strict.sh @@ -19,6 +19,14 @@ # # Usage: scripts/clippy-strict.sh [BASE] [CARGO_SCOPE...] # +# CLIPPY_STRICT_REPORT_ONLY=1 prints the diagnostics and exits 0. `just fix` sets +# it, because that recipe is the mid-edit loop and a hit there is information +# rather than a stop: the round's directive bounds what the change may touch, and +# a gate that fails inside the innermost loop argues for editing past it. `just +# ci` runs without it, which is where "before opening a PR" owns the decision. +# A build or tooling failure still exits non-zero under it — only hits are +# demoted. +# # BASE defaults to the merge-base with the main branch; only diagnostics whose # primary span falls on a line added or changed since BASE are reported. Edits # that are not committed yet count, as do untracked files. Any further arguments @@ -154,7 +162,10 @@ if [ "$status" -ne 0 ]; then exit "$status" fi -python3 - "$out_file" "$diff_file" "$untracked_file" "${lints[@]}" <<'PY' +# A non-zero exit from here is hits, and nothing else: the cargo failure above +# already left. So report-only can demote this without hiding a broken build. +hits_status=0 +python3 - "$out_file" "$diff_file" "$untracked_file" "${lints[@]}" <<'PY' || hits_status=$? import json import sys @@ -255,3 +266,11 @@ if hits: print("clippy-strict: clean") PY + +if [ "$hits_status" -ne 0 ] && [ -n "${CLIPPY_STRICT_REPORT_ONLY:-}" ]; then + echo "clippy-strict: reported, not enforced here." \ + "\`just ci\` is the gate; in a revise or conflict round the directive" \ + "bounds the change, so these belong in \`notes\`." >&2 + exit 0 +fi +exit "$hits_status" From 357657d42a5bdb8423922031696089d626fdded1 Mon Sep 17 00:00:00 2001 From: Norrie Taylor Date: Sun, 27 Sep 2026 21:51:00 -0700 Subject: [PATCH 3/6] fix(lint): demote only the filter's hits, and never inherit report-only Two false-success paths in the report-only mode added a commit ago, both of them the thing this gate exists to avoid: exiting 0 without having checked. The filter's exit was read as "hits" whatever it was, so no python3 on PATH or a crash inside it made `just fix` pass having reported nothing. It now exits a distinct 2 for hits and only that is demoted; 1 from an unhandled exception, 127 from a missing interpreter, and the cargo failure above the filter all still leave non-zero. CLIPPY_STRICT_REPORT_ONLY was read from the ambient environment, so one export in a shell profile would have turned the gate off in `just clippy-strict` and therefore in `just ci`, silently. The enforcing recipe clears it. --- justfile | 5 ++++- scripts/clippy-strict.sh | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/justfile b/justfile index 326d55268d..1ec49bf7b5 100644 --- a/justfile +++ b/justfile @@ -315,7 +315,10 @@ clippy: # # Strict Clippy on the lines this branch changed, scoped to the crates you touched. clippy-strict BASE="": - scripts/clippy-strict.sh "{{BASE}}" {{strict-scope}} + # Cleared, not inherited: an exported CLIPPY_STRICT_REPORT_ONLY would make + # this recipe report and exit 0, and `just ci` depends on it, so one stray + # export in a shell profile would turn the gate off without saying so. + CLIPPY_STRICT_REPORT_ONLY= scripts/clippy-strict.sh "{{BASE}}" {{strict-scope}} # A local advisories failure may just mean newer RUSTSEC data than CI's last run. # CI: ci.yml `cargo-deny` (advisories/bans/licenses/sources). diff --git a/scripts/clippy-strict.sh b/scripts/clippy-strict.sh index afd08863ca..b058a76af7 100755 --- a/scripts/clippy-strict.sh +++ b/scripts/clippy-strict.sh @@ -162,15 +162,19 @@ if [ "$status" -ne 0 ]; then exit "$status" fi -# A non-zero exit from here is hits, and nothing else: the cargo failure above -# already left. So report-only can demote this without hiding a broken build. +# HITS_EXIT, and only HITS_EXIT, is the filter saying it found something. Any +# other non-zero is the filter itself failing — no python3 on PATH, a crash in +# it — and report-only must not demote that: a gate that exits 0 because it +# could not run is worse than no gate. +HITS_EXIT=2 hits_status=0 -python3 - "$out_file" "$diff_file" "$untracked_file" "${lints[@]}" <<'PY' || hits_status=$? +python3 - "$HITS_EXIT" "$out_file" "$diff_file" "$untracked_file" "${lints[@]}" <<'PY' || hits_status=$? import json import sys -out_path, diff_path, untracked_path = sys.argv[1], sys.argv[2], sys.argv[3] -strict = set(sys.argv[4:]) +hits_exit = int(sys.argv[1]) +out_path, diff_path, untracked_path = sys.argv[2], sys.argv[3], sys.argv[4] +strict = set(sys.argv[5:]) # path -> [(start, end)] of lines added or changed in the new revision. changed = {} @@ -262,12 +266,14 @@ if hits: f'with #[expect(, reason = "...")]. Re-run: just clippy-strict', file=sys.stderr, ) - sys.exit(1) + # Distinct from the 1 an unhandled exception here would exit with, so the + # caller can demote hits without demoting a broken filter. + sys.exit(hits_exit) print("clippy-strict: clean") PY -if [ "$hits_status" -ne 0 ] && [ -n "${CLIPPY_STRICT_REPORT_ONLY:-}" ]; then +if [ "$hits_status" -eq "$HITS_EXIT" ] && [ -n "${CLIPPY_STRICT_REPORT_ONLY:-}" ]; then echo "clippy-strict: reported, not enforced here." \ "\`just ci\` is the gate; in a revise or conflict round the directive" \ "bounds the change, so these belong in \`notes\`." >&2 From ddce6790fb0a8e21c81ced7142b03469eed96680 Mon Sep 17 00:00:00 2001 From: Norrie Taylor Date: Sun, 27 Sep 2026 21:56:16 -0700 Subject: [PATCH 4/6] fix(lint): take the strict gate's base from origin/main, not the local ref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The base was `git merge-base main HEAD`, and a branch that merges `origin/main` leaves the local ref where it was — agent sandboxes and worktrees never check main out at all. The merge-base against a ref that stale predates the main commits the branch merged in, so every line of those commits reads as a line this branch changed, and the gate reports diagnostics on other people's code under a heading saying they are yours. Three agent rounds fixing lines their task never named is what that looks like from the outside (#1737, #1730, #1727). Measured on this branch: a local `main` ten commits behind turned a change touching no Rust at all into 14 changed Rust files across `minimald`, `sessions` and `switch`. With `origin/main` it is nought, and the gate says "no Rust changes" as it should. The remote ref is the safe one by construction: it cannot be behind anything the branch merged, because merging it required fetching it, and a fetch only moves it forward. Stale means the base is older than the newest main, never older than this branch's first commit. The local ref stays as the fallback for a clone without a remote. --- scripts/clippy-strict.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/clippy-strict.sh b/scripts/clippy-strict.sh index b058a76af7..94f1e57712 100755 --- a/scripts/clippy-strict.sh +++ b/scripts/clippy-strict.sh @@ -27,7 +27,7 @@ # A build or tooling failure still exits non-zero under it — only hits are # demoted. # -# BASE defaults to the merge-base with the main branch; only diagnostics whose +# BASE defaults to the merge-base with `origin/main`; only diagnostics whose # primary span falls on a line added or changed since BASE are reported. Edits # that are not committed yet count, as do untracked files. Any further arguments # are passed to `cargo clippy` as the crate scope, overriding the derived one @@ -66,7 +66,24 @@ if [ "$#" -gt 0 ]; then shift fi if [ -z "$base" ]; then - base="$(git merge-base main HEAD 2>/dev/null || git merge-base origin/main HEAD)" + # `origin/main`, not the local `main`. A branch that merges `origin/main` + # leaves the local ref where it was — agent sandboxes and worktrees never + # check main out at all — and the merge-base against a ref that stale + # predates the main commits the branch merged in, so every line of those + # commits reads as a line this branch changed. The gate then reports + # diagnostics on other people's code, under a heading saying they are + # yours. That is what it looked like: on the branch adding this comment, + # a local `main` ten commits behind turned a change touching no Rust at + # all into 14 changed Rust files across `minimald`, `sessions` and + # `switch`. + # + # The remote ref is the safe one by construction: `origin/main` cannot be + # behind anything the branch merged, because merging it required fetching + # it first, and a fetch only moves it forward. Stale means the base is + # merely older than the newest main, never older than this branch's own + # first commit. The local ref is kept as a fallback for a clone with no + # remote. + base="$(git merge-base origin/main HEAD 2>/dev/null || git merge-base main HEAD)" fi explicit_scope=("$@") From 3999bf75fce155d9b58c0148a0ebc983eb441547 Mon Sep 17 00:00:00 2001 From: Norrie Taylor Date: Sun, 27 Sep 2026 22:10:10 -0700 Subject: [PATCH 5/6] fix(lint): report-only never fails, whatever stopped the gate `just fix` is the autofix loop: safe to run any number of times and never stopping on the strict gate. Report-only demoted hits but still exited 101 on a build failure and 127 with no python3, so the loop failed on the gate it was told only to report. Under report-only every failure is now printed with its exit code and demoted; enforcing (`just ci`) keeps every one fatal, so a gate that did not run still cannot pass there. Driven through cargo and python3 shims: hit 2/0, cargo 101/0, no python3 127/0 (enforcing/report-only), and report-only twice gives the same output. --- scripts/clippy-strict.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/scripts/clippy-strict.sh b/scripts/clippy-strict.sh index 94f1e57712..14289987a7 100755 --- a/scripts/clippy-strict.sh +++ b/scripts/clippy-strict.sh @@ -24,8 +24,11 @@ # rather than a stop: the round's directive bounds what the change may touch, and # a gate that fails inside the innermost loop argues for editing past it. `just # ci` runs without it, which is where "before opening a PR" owns the decision. -# A build or tooling failure still exits non-zero under it — only hits are -# demoted. +# Under it the script never exits non-zero: a build or tooling failure is +# printed with its exit code and demoted too, because `just fix` is an autofix +# loop that must be safe to run any number of times and must never stop on the +# gate. Without it every failure is fatal, so `just ci` still cannot pass on a +# gate that did not run. # # BASE defaults to the merge-base with `origin/main`; only diagnostics whose # primary span falls on a line added or changed since BASE are reported. Edits @@ -34,6 +37,17 @@ # (the justfile pins it on macOS, where the Linux-only crates do not build). set -euo pipefail +# A failure to run the gate at all. Enforcing, it is fatal with its own exit +# code; report-only, it is said and demoted, so `just fix` never stops here. +report_only_exit() { + if [ -n "${CLIPPY_STRICT_REPORT_ONLY:-}" ]; then + echo "clippy-strict: did not run to completion (exit $1); nothing enforced" \ + "here, \`just ci\` is the gate" >&2 + exit 0 + fi + exit "$1" +} + lints=( clippy::string_slice clippy::indexing_slicing @@ -176,13 +190,13 @@ cargo clippy "${cargo_scope[@]}" --all-targets --locked --message-format=json -- if [ "$status" -ne 0 ]; then echo "clippy-strict: cargo clippy failed (exit ${status})" >&2 cat "$err_file" >&2 - exit "$status" + report_only_exit "$status" fi # HITS_EXIT, and only HITS_EXIT, is the filter saying it found something. Any # other non-zero is the filter itself failing — no python3 on PATH, a crash in -# it — and report-only must not demote that: a gate that exits 0 because it -# could not run is worse than no gate. +# it — and is said as such rather than read as clean: enforcing, it is fatal; +# report-only, it is printed and demoted like everything else. HITS_EXIT=2 hits_status=0 python3 - "$HITS_EXIT" "$out_file" "$diff_file" "$untracked_file" "${lints[@]}" <<'PY' || hits_status=$? @@ -296,4 +310,9 @@ if [ "$hits_status" -eq "$HITS_EXIT" ] && [ -n "${CLIPPY_STRICT_REPORT_ONLY:-}" "bounds the change, so these belong in \`notes\`." >&2 exit 0 fi +if [ "$hits_status" -ne 0 ] && [ "$hits_status" -ne "$HITS_EXIT" ]; then + echo "clippy-strict: the diagnostic filter failed (exit ${hits_status});" \ + "nothing was checked" >&2 + report_only_exit "$hits_status" +fi exit "$hits_status" From 12acc879686bfeabc00a0d5c4c6a3e26f77baff2 Mon Sep 17 00:00:00 2001 From: Norrie Taylor Date: Sun, 27 Sep 2026 22:20:27 -0700 Subject: [PATCH 6/6] chore(lint): take the strict gate out of just fix `just fix` is the edit loop, and everything it prints is something to fix, so a strict hit printed beside fmt and clippy --fix reads as work whatever a doc sentence says. Report-only kept the hits in that loop and only removed the failure. Remove the gate from the recipe instead: it runs in `just clippy-strict` and `just ci`, the round that owns the judgement, and nowhere else. With no caller, the report-only mode and the recipe that cleared it go too; the script's exit codes are 0 clean, 2 hits, anything else a failure to run, none read as clean. AGENTS.md's tight-loop bullet says the loop prints only what to fix. --- AGENTS.md | 11 +++++------ justfile | 35 ++++++++++++++------------------- scripts/clippy-strict.sh | 42 +++++++++++----------------------------- 3 files changed, 31 insertions(+), 57 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d75faf0347..1d30644dcd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -207,8 +207,7 @@ the lines your branch changed. Run `just clippy-strict` alone to see just those. That gate is local only: no CI lane runs it, so its hits never turn a PR red, and in a revise or conflict round the directive bounds the change, so report its hits in `notes` rather than fix them. `just fix` -reports it without failing for that reason; `just ci` is where it stops -you, because that is the round that owns the judgement. Platform notes +does not run it, so nothing in the edit loop asks you to. Platform notes for agents: - **macOS**: the workspace does not build natively (see @@ -218,7 +217,7 @@ for agents: is unverified until `just test-cross` has run. - **VM/daemon-path changes**: also run `just e2e` (the session proof) and/or `just test-vm` (the VM integration harnesses). -- **Tight iteration loops**: `just fix` (fmt → `clippy --fix` → fmt, then the - strict clippy gate reported but not enforced, with `--allow-dirty` so it - runs mid-edit) then `just test`. Both carry this host's scope; neither - needs a hand-written `cargo` line. +- **Tight iteration loops**: `just fix` (fmt → `clippy --fix` → fmt, with + `--allow-dirty` so it runs mid-edit) then `just test`. Both carry this + host's scope; neither needs a hand-written `cargo` line. Everything that + loop prints is something to fix; the strict gate is not in it. diff --git a/justfile b/justfile index 1ec49bf7b5..4610374079 100644 --- a/justfile +++ b/justfile @@ -271,24 +271,21 @@ fmt: # clean-worktree check — the usual case here is running mid-edit with # staged/unstaged work. # -# Autofix pass: fmt, clippy --fix, fmt again, then the strict clippy gate, reported (runnable mid-edit). +# The strict clippy gate is not part of this loop. It ran here once, and +# three agent rounds on the NET walk then rewrote lines their task never +# named to clear it, two in conflict rounds whose only directive was the +# merge (#1737, #1730, #1727): everything else this recipe prints is +# something to fix, so a strict hit printed beside it reads the same way, +# whatever a doc says. There is no autofix for that set either — `clippy +# --fix` cannot be scoped to changed lines and would sweep legacy sites — so +# the gate lives in `just clippy-strict` and `just ci`, which is the round +# that owns the judgement. +# +# Autofix pass: fmt, clippy --fix, fmt again (runnable mid-edit). fix: cargo fmt --all cargo clippy {{scope}} --all-targets --fix --allow-dirty -- -D warnings cargo fmt --all - # No autofix for the strict set. `clippy --fix` rewrites every hit in the - # selected crates and cannot be scoped to changed lines, so autofixing it - # would sweep legacy sites in every crate it touches. Most of the set has no - # machine-applicable suggestion anyway (6% of current hits, none of the four - # largest lints), so these are judgement calls, not rewrites. - # - # Reported, not enforced: this is the innermost loop, and it used to fail - # here. Three agent rounds on the NET walk then rewrote lines their task - # never named to clear it, two in conflict rounds whose only directive was - # the merge (#1737, #1730, #1727) — a failing command in the loop outranks - # any doc sentence saying to leave the hit alone. `just ci` enforces it, - # which is where "before opening a PR" owns the judgement. - CLIPPY_STRICT_REPORT_ONLY=1 scripts/clippy-strict.sh "" {{strict-scope}} # CI: ci.yml `fmt`. # @@ -310,15 +307,13 @@ clippy: # reports on the lines your change introduced, and promote each lint into # [workspace.lints.clippy] as its count reaches zero. # -# This recipe and `just ci` enforce; `just fix` only reports. A hit on a line the -# round's directive did not name is a note, not a licence to edit it. +# This recipe and `just ci` are the only callers; `just fix` does not run it. A +# hit on a line the round's directive did not name is a note, not a licence to +# edit it. # # Strict Clippy on the lines this branch changed, scoped to the crates you touched. clippy-strict BASE="": - # Cleared, not inherited: an exported CLIPPY_STRICT_REPORT_ONLY would make - # this recipe report and exit 0, and `just ci` depends on it, so one stray - # export in a shell profile would turn the gate off without saying so. - CLIPPY_STRICT_REPORT_ONLY= scripts/clippy-strict.sh "{{BASE}}" {{strict-scope}} + scripts/clippy-strict.sh "{{BASE}}" {{strict-scope}} # A local advisories failure may just mean newer RUSTSEC data than CI's last run. # CI: ci.yml `cargo-deny` (advisories/bans/licenses/sources). diff --git a/scripts/clippy-strict.sh b/scripts/clippy-strict.sh index 14289987a7..7f38b335a4 100755 --- a/scripts/clippy-strict.sh +++ b/scripts/clippy-strict.sh @@ -19,16 +19,15 @@ # # Usage: scripts/clippy-strict.sh [BASE] [CARGO_SCOPE...] # -# CLIPPY_STRICT_REPORT_ONLY=1 prints the diagnostics and exits 0. `just fix` sets -# it, because that recipe is the mid-edit loop and a hit there is information -# rather than a stop: the round's directive bounds what the change may touch, and -# a gate that fails inside the innermost loop argues for editing past it. `just -# ci` runs without it, which is where "before opening a PR" owns the decision. -# Under it the script never exits non-zero: a build or tooling failure is -# printed with its exit code and demoted too, because `just fix` is an autofix -# loop that must be safe to run any number of times and must never stop on the -# gate. Without it every failure is fatal, so `just ci` still cannot pass on a -# gate that did not run. +# Callers: `just clippy-strict` and, through it, `just ci`. Not `just fix`: that +# is the mid-edit loop, and everything it prints is something to fix, so a hit +# printed there reads as work whatever a doc says — the round's directive bounds +# what a change may touch, and a hit outside it belongs in the round's notes. +# +# Exit codes: 0 clean, 2 hits on changed lines, anything else a failure to run +# (cargo's own status, 127 with no python3, 1 for a crash in the filter). A gate +# that exits 0 because it could not run is worse than no gate, so none of those +# is ever read as clean. # # BASE defaults to the merge-base with `origin/main`; only diagnostics whose # primary span falls on a line added or changed since BASE are reported. Edits @@ -37,17 +36,6 @@ # (the justfile pins it on macOS, where the Linux-only crates do not build). set -euo pipefail -# A failure to run the gate at all. Enforcing, it is fatal with its own exit -# code; report-only, it is said and demoted, so `just fix` never stops here. -report_only_exit() { - if [ -n "${CLIPPY_STRICT_REPORT_ONLY:-}" ]; then - echo "clippy-strict: did not run to completion (exit $1); nothing enforced" \ - "here, \`just ci\` is the gate" >&2 - exit 0 - fi - exit "$1" -} - lints=( clippy::string_slice clippy::indexing_slicing @@ -190,13 +178,12 @@ cargo clippy "${cargo_scope[@]}" --all-targets --locked --message-format=json -- if [ "$status" -ne 0 ]; then echo "clippy-strict: cargo clippy failed (exit ${status})" >&2 cat "$err_file" >&2 - report_only_exit "$status" + exit "$status" fi # HITS_EXIT, and only HITS_EXIT, is the filter saying it found something. Any # other non-zero is the filter itself failing — no python3 on PATH, a crash in -# it — and is said as such rather than read as clean: enforcing, it is fatal; -# report-only, it is printed and demoted like everything else. +# it — and is said as such rather than read as clean. HITS_EXIT=2 hits_status=0 python3 - "$HITS_EXIT" "$out_file" "$diff_file" "$untracked_file" "${lints[@]}" <<'PY' || hits_status=$? @@ -304,15 +291,8 @@ if hits: print("clippy-strict: clean") PY -if [ "$hits_status" -eq "$HITS_EXIT" ] && [ -n "${CLIPPY_STRICT_REPORT_ONLY:-}" ]; then - echo "clippy-strict: reported, not enforced here." \ - "\`just ci\` is the gate; in a revise or conflict round the directive" \ - "bounds the change, so these belong in \`notes\`." >&2 - exit 0 -fi if [ "$hits_status" -ne 0 ] && [ "$hits_status" -ne "$HITS_EXIT" ]; then echo "clippy-strict: the diagnostic filter failed (exit ${hits_status});" \ "nothing was checked" >&2 - report_only_exit "$hits_status" fi exit "$hits_status"