Skip to content

refactor(hooks): pin the remaining unfiltered local hooks to pre-commit - #1494

Merged
c-vigo merged 2 commits into
devfrom
chore/1491-pin-remaining-hook-stages
Aug 13, 2026
Merged

c-vigo merged 2 commits into
devfrom
chore/1491-pin-remaining-hook-stages

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Closes #1491

Summary

sync-manifest and check-agent-identity carried neither stages: nor a file
filter, 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 — only typos
received a filename, so the other two were pure waste rather than a second bug.

Both are now pinned to pre-commit in the yaml fragment of nix/hooks.nix,
which renders both committed configs.

The check-agent-identity decision

The 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-commit only (git-hooks.nix defaults it there) while the yaml fragment ran
at all three — the runner and the flake-generated surfaces disagreed about when
it fires. Probed against real git rather than assumed:

Path pre-commit message stages GIT_AUTHOR_NAME / EMAIL seen
git commit fires fire identical at all three stages
git commit --author="Claude <…>" fires fire Claude at all three stages
git merge — fire empty → falls back to git config user.*
git rebase replay — — (no commit-msg per pick) —

So the message stages saw nothing pre-commit did not, including under the
--author= override this hook exists to catch. The only real coverage delta is a
merge commit, where git exports no author and the hook merely re-read
git config user.* — the persistent identity that fails the committer's very
next ordinary commit at pre-commit. That is the trade recorded in the code
comment 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 on
    both portable renders before the fix, with the consumer surface already
    passing (the disagreement being reconciled). Full module green after: 68 passed
  • Drift gate green — nix/hooks.nix and both committed configs stay in step
  • Live-proven on this branch's own commits: before, one commit ran the two hooks
    9 times across the three rounds and both surfaces; after, they appear only in
    the pre-commit round — 3 invocations
  • just precommit (prek run --all-files) green, exit 0, with both hooks still
    running — 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 passed

Consumer impact

check-agent-identity is scaffolded, so scaffolded repos adopt the alignment
with this release; direnv consumers were already at pre-commit and see no
change. sync-manifest is runner-only.

c-vigo added 2 commits August 13, 2026 11:37
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
@c-vigo
c-vigo merged commit e214b3a into dev Aug 13, 2026
14 checks passed
@c-vigo
c-vigo deleted the chore/1491-pin-remaining-hook-stages branch August 13, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant