Bring the workspace back to rustfmt, and keep it there - #44
Merged
Conversation
`cargo fmt --all` had drifted far enough that running it touched 116 files, which meant every feature branch either carried a pile of unrelated reformatting or had to be de-noised by hand before review. This is that reformat, on its own, so the next one does not have to be. Pure `cargo fmt --all` output, with one class of exception. Where a standalone comment block directly follows a line that already ends in a trailing comment, rustfmt aligns the block to that comment's column — pushing text out to column 50-90 and, in a few cases, past the 120 the config asks for. That is worse than the drift it replaces, so 20 blank lines were inserted by hand to break the association and let the comments sit at their natural indent. Two of those artifacts predate this commit; they are fixed here too. One comment changed wording rather than position: the `// 400 absent entirely` note in `archaic::tests` documented a panel site deliberately missing from the genotype list, and rustfmt could only render it at a bad indent inside the `vec![]`. It is now a sentence above the binding, which is where it belonged. `cargo fmt --all --check` is clean and idempotent; clippy `--all-targets` clean; `cargo test --workspace` green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`cargo fmt` clean was already a per-commit gate for this repo, but nothing enforced it, and the drift that accumulated once reached 116 files — at which point every feature branch either carried a pile of unrelated reformatting into review or had to be de-noised by hand before it was readable. The preceding commit clears the drift; this stops it coming back. Local rather than CI, deliberately: the useful moment to catch this is before it is committed, not after a build fails. `cargo fmt --all --check` costs ~0.6s and compiles nothing, so it is cheap enough that nobody has a reason to disable it. The hook only ever *checks*. A hook that reformats your files mid-commit produces a commit whose contents you did not read, which is a worse failure than the one it prevents. It reports the offending files and the command to fix them. It stays out of the way where it has no business: no cargo on PATH (docs-only checkout) exits 0, and so does a commit with no staged `.rs` files — which also covers merges and reverts, where the tree is whatever the other side wrote and blocking helps nobody. `--no-verify` remains the escape hatch. Hooks live in per-clone git config, so this is not automatic on checkout; CLAUDE.md documents the one-time `git config core.hooksPath .githooks`. Verified by exercising both paths: a clean tree passes, staged drift is rejected with the file list, and the rejected commit is genuinely not created. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cargo fmt --allhad drifted far enough that running it touches 116 files. That made it a tax on every feature branch: either carry a pile of unrelated reformatting into review, or de-noise the diff by hand before opening the PR (which is what #43 had to do). Two commits — clear the drift, then stop it coming back.mainis genuinely drifted, not misconfigured — stable rustfmt disagrees withmaintoo, so this isn't a nightly-toolchain artifact.1.
7c4fbf6— the reformatAlmost all mechanical
cargo fmt --alloutput, skimmable. There are two places I did not simply take what the tool produced, and those are the only spots worth a real look:20 hand-inserted blank lines, across 13 files. Where a standalone comment block directly follows a line that already ends in a trailing comment, rustfmt aligns the block to that comment's column — pushing text out to column 50–90 and, in a few cases, past the 120 the config asks for:
That is worse than the drift it replaces, so a blank line breaks the association and the comments sit at their natural indent. Two of these artifacts already existed on
main(ui/mod.rs,domain/src/consensus.rs) — fixed here too.One comment rewritten —
navigator-analysis/src/archaic.rs. The// 400 absent entirelynote documented a panel site deliberately missing from the genotype list, and rustfmt could only render it at a bad indent inside thevec![]. It is now a sentence above the binding. This is the only content change in the branch.2.
2534c37— the hook.githooks/pre-commitrunscargo fmt --all --checkand rejects a commit that would reintroduce drift. Local, not CI — the useful moment to catch this is before it is committed, not after a build fails. ~0.6s, compiles nothing, so there is no incentive to disable it.It only ever checks; it never reformats your tree mid-commit, because a commit whose contents you did not read is a worse failure than the one being prevented. It reports the offending files and the fix.
Stays out of the way where it has no business: no
cargoon PATH exits 0, and so does a commit with no staged.rsfiles — which also covers merges and reverts.--no-verifyis the escape hatch.Enable once per clone (hooks are per-clone git config, so this is not automatic on checkout — CLAUDE.md documents it):
Testing
cargo fmt --all --checkclean and idempotent ·cargo clippy --all-targetsclean ·cargo test --workspacegreen, 0 failures.Hook exercised on both paths: clean tree passes, staged drift is rejected with the file list, and the rejected commit is genuinely not created. The no-staged-
.rspath is exercised by2534c37itself, which the hook correctly let through.🤖 Generated with Claude Code