Repository navigation
feat(repo): A commit with unformatted Rust is refused before it leaves the machine - #38
Merged
Merged
Conversation
…s the machine A tracked pre-commit hook in .githooks/ checks the staged copy of each Rust file with rustfmt and each staged JavaScript file with ESLint. It runs no build, no test and no network call; CI keeps those. A Claude session installs it at start by setting core.hooksPath, which covers every worktree of the clone. docs/develop.md says how to install it without Claude. Refs #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…des no existing hook ESLint in the hook now takes the paths the packages' lint scripts give it, so a commit touching tracked JavaScript that pnpm lint never checks is not refused for lint debt CI accepts. The installer leaves core.hooksPath unset when the clone's hooks folder holds hooks of its own, which the setting would stop running. The hook finds the pinned rustfmt once, and names the toolchain to install when it is missing. Refs #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ks folder running Hook managers often install a hook in .git/hooks as a symlink. The installer's check looked only for regular files, so it set core.hooksPath and stopped such a hook running. Refs #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is a symlink find does not follow a symlink given as its starting point, so a symlinked .git/hooks was itself reported as a hook and the installer refused. A trailing slash makes find list the folder's contents. Refs #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sodre
marked this pull request as ready for review
November 20, 2026 07:59
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.
Closes #31
Summary
A commit whose staged Rust is not formatted, or whose staged package JavaScript fails ESLint, is now refused before it leaves the machine, with the command that fixes it. A Claude session installs the hook when it starts, and
scripts/install-git-hooks.shinstalls it without Claude. Nothing changes for anyone using the product.Choices the ticket left open:
core.hooksPath=.githooks, a relative path in the clone's shared config. One run covers every worktree, and each worktree runs its own tracked copy of the hook.cargo fmt: ESLint on the paths the packages' lint scripts give it. It takes 0.2–0.4 s. Other tracked JavaScript has 28 ESLint errors today thatpnpm lintnever checks, so the hook leaves those files alone too. No Markdown check exists to run.core.hooksPathalone, and it leaves hooks already in.git/hooksalone, symlinks included, because the setting would silently stop them running.node_modules(a fresh worktree) the hook skips ESLint and says so, since CI runspnpm lint. A missing pinned Rust toolchain refuses the commit and namesrustup show.Not asked for and here: a CI step runs the hook's tests on Linux, so they do not rot.
Evidence
cargo fmt --check, and says how to fix itgit commit.claude/settings.jsoninstalls the hook, and is a no-op when already installeddocs/develop.mdsays what the hook checks, how to install it without Claude, and that CI runs the slow checksgrepofdocs/develop.mdbelowAssertionError: 0 == 0; SessionStart command replaced bytrue:0 == 00 == 00 == 0pnpm lintlintsdistribution/npm/launch.cjs,scripts/tool.mjs,crates/x/tests/addon.cjsnode_modulesthe hook skips ESLint and says so'ESLint skipped' not foundrustup showsleep 5in the hook:5.038 not less than 5.0'again\n' != '''.githooks' != '/elsewhere'pre-pushhook; with-type f, the symlink subtest failedhookscargo --version:cargo --versionlogged; hook opens/dev/tcp/127.0.0.1/9:connect(3, {sa_family=AF_INET ...python3 -m unittest discover -s scripts -p test_git_hooks.pyon d57cbef: 12 tests, 12 passed, 0 skipped, 0 failed. Each test copies the hook's files into a throwaway repository and a freshgit worktreeof it.Live session start: a
git clone --no-localof this branch into a scratch folder, thengit worktree add --detach fresh.core.hooksPathbefore: empty.claude -p "Reply with the single word OK."infreshprintedOK.core.hooksPathafter:.githooks. Infresh, an unformattedcrates/countersign-protocol/src/zz.rswas refused with exit 1:The formatted
zz.rsplusREADME.mdcommitted with exit 0 inreal 0m0.037s.Timing of the hook alone (
/usr/bin/time .githooks/pre-commit, stagedcrates/countersign-gateway/src/worker_sandbox.rs, 363 lines, anddocs/develop.md): 0.03 s, 0.03 s, 0.03 s. Withpackages/widget/src/widget.jsadded, which runs ESLint: 0.44 s. With 61 Rust files: 0.93 s.grepofdocs/develop.md: line 30 "It refuses a commit when a staged Rust file is not formatted ascargo fmtwould format it, and when a staged JavaScript file thatpnpm lintcovers fails ESLint"; line 32 "Without Claude, install it once per clone from the checkout root:" followed byscripts/install-git-hooks.sh; line 30 "Clippy, the test suites and the Gateway's runtime test run in the [CI workflow]".Not run: the hook on macOS and Windows (its tests run on Linux only; it is written for macOS's bash 3.2 but nothing runs it there); the new CI step, which runs on this pull request; a review round on d57cbef, the fix to round 3's finding (the owner chose to open the pull request after three rounds).
Merge Danger
Door: two-way. A revert removes the hook and the SessionStart entry. A clone where a session already set
core.hooksPath=.githooksthen points at a folder that no longer exists, so git runs no hooks there.git config --unset core.hooksPathrestores.git/hooks.Blast Radius: tooling only.
No image, infrastructure or flag. After the merge, every Claude session in a clone of this repository sets
core.hooksPaththe first time it starts, unless the clone already has one or holds hooks in.git/hooks. Worktrees on branches without.githooks/then run no pre-commit hook until they rebase.Reviews
Correctness, Standards, Spec and Security, three rounds: 18 findings, each with its outcome
Correctness, round 1
pnpm lintcovers only the packages and the demo Integrator, and the rest has 28 errors today. Fixed: the hook lints only those paths.node_modules, so ESLint is skipped there. Pushed back:eslint.config.mjsimports@eslint/jsfrom the worktree, so another checkout's ESLint cannot load it. CI runspnpm lint, and the hook says ESLint was skipped.core.hooksPathsilently stops hooks in.git/hooks. Fixed: the installer changes nothing and names them../.githooksor an absolute path is reported as another hooks path. Pushed back: the message is true (the value differs from the one the script writes) and harmless, and the hook still runs.rustup show.--diff-filter=ACMRskips a path whose type changed. Pushed back: no tracked file is a symlink, and CI'scargo fmt --all -- --checkstill catches it.stagehelper and a command prefix.Standards, round 1
whole,partialandlintwere vague names. Fixed:js_whole,js_partial,eslint_failed.Spec, round 1
Correctness, round 2
.git/hooksthat is a symlink. Fixed: it counts anything that is not a folder.Spec, round 3
.git/hooksis itself a symlink. Fixed:findlists the folder's contents through a trailing slash (d57cbef, which no round has read).Tracking
Epic: none
Spec: none
Ticket: #31 A fast pre-commit hook installs itself when a Claude session starts
Flag: none
🤖 Generated with Claude Code