Repository navigation
refactor(hooks): pin the remaining unfiltered local hooks to pre-commit - #1494
Merged
Merged
Conversation
sync-manifest and check-agent-identity carry neither stages nor a file filter, so both run at every hook stage — three invocations of a uv run entry point per commit where one is meant. Record the decision for check-agent-identity in the test: git exports the same GIT_AUTHOR_NAME/EMAIL to all three stages of an ordinary commit, including under --author=, so the message stages see nothing the pre-commit stage does not. The only path where they alone fire is git merge, and there git exports no author, so the hook re-reads git config user.* — the identity the next ordinary commit fails on. RED on both portable renders; the consumer surface already passes, which is the disagreement being reconciled. Refs: #1491
sync-manifest and check-agent-identity carried neither stages nor a file filter, so both ran at every hook stage: three uv run invocations per commit for one useful result. Neither was broken by it — typos (#1489) was the only one of the group that received a filename — so this is the waste that trap left behind, not a second bug. For check-agent-identity the pin also settles a disagreement between surfaces. The consumer fragment has always run at pre-commit only, since git-hooks.nix defaults it there, while the yaml fragment behind both committed configs ran at all three. The message stages are the ones to drop: git exports the same GIT_AUTHOR_NAME/GIT_AUTHOR_EMAIL to every stage of an ordinary commit, including under --author=, the case this hook exists to catch, so the commit-msg round only re-read what pre-commit had already rejected on. The lone path where the message stages fire and pre-commit does not is git merge, and git exports no author there at all — the hook fell back to git config user.*, the persistent identity that fails the committer's next ordinary commit. A merge is therefore the one commit this no longer guards locally. Scaffolded consumers pick the alignment up by adopting this release. No coverage is lost elsewhere: prek run --all-files and the CI lint lane both run the pre-commit stage. Refs: #1491
4 tasks
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 #1491
Summary
sync-manifestandcheck-agent-identitycarried neitherstages:nor a filefilter, so both ran at every hook stage. Split out of #1489, which fixed the
one hook of this group (
typos) that actually broke a commit — onlytyposreceived a filename, so the other two were pure waste rather than a second bug.
Both are now pinned to
pre-commitin theyamlfragment ofnix/hooks.nix,which renders both committed configs.
The
check-agent-identitydecisionThe issue asked for a deliberate decision here rather than a reflex pin, because
this hook guards the author/committer and its consumer fragment already ran at
pre-commitonly (git-hooks.nix defaults it there) while theyamlfragment ranat all three — the runner and the flake-generated surfaces disagreed about when
it fires. Probed against real git rather than assumed:
pre-commitGIT_AUTHOR_NAME/EMAILseengit commitgit commit --author="Claude <…>"Claudeat all three stagesgit mergegit config user.*git rebasereplaycommit-msgper pick)So the message stages saw nothing
pre-commitdid not, including under the--author=override this hook exists to catch. The only real coverage delta is amerge commit, where git exports no author and the hook merely re-read
git config user.*— the persistent identity that fails the committer's verynext ordinary commit at
pre-commit. That is the trade recorded in the codecomment and the changelog: one locally-unguarded merge, in exchange for dropping
two of three invocations per commit.
Verification
tests/test_flake_hooks.py::TestUnfilteredLocalHooksPinTheirStage— RED onboth portable renders before the fix, with the consumer surface already
passing (the disagreement being reconciled). Full module green after: 68 passed
nix/hooks.nixand both committed configs stay in step9 times across the three rounds and both surfaces; after, they appear only in
the
pre-commitround — 3 invocationsjust precommit(prek run --all-files) green, exit 0, with both hooks stillrunning — no lint coverage lost, which was the acceptance criterion
pytest tests/test_flake_hooks.py tests/test_transforms.py tests/test_workflow_model.py tests/test_workflow_prepare_extension.py— 159 passedConsumer impact
check-agent-identityis scaffolded, so scaffolded repos adopt the alignmentwith this release; direnv consumers were already at
pre-commitand see nochange.
sync-manifestis runner-only.