Repository navigation
Description
The gap
kit hooks add writes the git-hook enforcement floor into the directory git will actually run hooks from — resolveHooksDir() honors core.hooksPath, and that is correct: installing into .git/hooks while git reads somewhere else would be a silent no-op, which is the defect the comment at src/hooks.ts:8-18 exists to prevent.
What is missing is everything around it. When core.hooksPath is absolute and points outside the repo, kit will:
- write the hook outside the repo root — creating the directory tree if it does not exist — and report
✓ installed; - never mention that the floor for this repo lives in another directory;
- leave no surface (
kit check,kit status,kit doctor,kit hooks) that reports the floor is external, or that it now dangles.
So the gate can disappear because of a change to a directory that has nothing to do with the repo, and every kit report stays green.
This also contradicts a declared scope claim in src/fix.ts:205-212:
// Git-hook installs resolve their target via `core.hooksPath` at runtime;
// they land inside the repo, which the repo-rooted [scope].fs covers.
They do not always land inside the repo. Measured below: the write target's realpath is not under the repo root, so a repo-rooted [scope].fs does not cover it.
Reproduction (6.6.5, macOS, non-root)
The starting state is ordinary: a second checkout made by copying the first, so .git/config carries the first one's absolute core.hooksPath. Nothing exotic sets it.
$ git init -q clone-b && cd clone-b
$ printf '[tools]\nnode = "22"\n' > .kit.toml && git add -A && git commit -qm init
$ git config core.hooksPath "$PWD/.git/hooks" # absolute, as husky/kit setups often leave it
$ cd .. && cp -R clone-b clone-a # the copy inherits the absolute path
$ git -C clone-a config core.hooksPath
/tmp/repro/clone-b/.git/hooks # clone-a's hooks live in clone-b
1. The install lands outside the repo and says nothing about it
$ cd clone-a && kit hooks add secret-scan --non-interactive
✓ pre-commit installed 1 command(s)
$ ls clone-a/.git/hooks | grep -v sample # empty
$ ls clone-b/.git/hooks | grep -v sample
post-commit
pre-commit
2. The gate does fire — so nothing looks wrong
$ printf 'const k = "sk_test_AAAAAAAAAAAAAAAAAAAA";\n' > leak.ts && git add leak.ts
$ git commit -qm "blocked?"
✗ kit secret-scan blocked the commit
Found 1 potential secret(s) in 1 staged file(s):
$ git rev-list --count HEAD
1
3. Delete the OTHER directory. Touch nothing in this repo.
$ rm -rf ../clone-b
$ git commit -qm "still blocked?" # same staged fake credential
$ git rev-list --count HEAD
2 # committed. exit 0. no warning.
4. No kit surface reports the dangling floor
$ git config core.hooksPath
/tmp/repro/clone-b/.git/hooks
$ ls "$(git config core.hooksPath)"
ls: .../clone-b/.git/hooks: No such file or directory
$ kit status | grep -i hook
○ memory hooks not installed → run `kit memory install`
$ kit doctor | grep -i hook
✓ hook wrapper ~/.kit/bin/kit
✓ memory hooks 5 wired
$ kit check --category security | grep -i hook
✓ memory hooks liveness pass 5 capture hook(s) wired
Git-hook state is not reported at all here, so a hooks path that resolves to nothing reads exactly like a repo that never wired hooks — and kit status's next-step line (kit hooks install) is the same in both cases.
5. Re-installing recreates a tree outside the repo
$ kit hooks add secret-scan --non-interactive
✓ pre-commit installed 1 command(s)
$ ls ../clone-b/.git/hooks # kit re-created the deleted directory
post-commit pre-commit
$ ls .git/hooks | grep -v sample # still empty
repo: /tmp/repro/clone-a
hooks: /tmp/repro/clone-b/.git/hooks
inside repo: False
kit created a directory hierarchy in an unrelated location and reported success.
Why this is the same family as #470 and #488
- Audit: nothing reads the anchor record, so N working trees give N green verdicts and no union view #470: the audit anchor was correct, complete,
0600— and read by nothing, so N green verdicts hid the union. - 43 command modules still accept unknown flags silently — sweep the flag-validation advisory to zero #488: a flag that silently does nothing is indistinguishable from a working one.
- Here: an enforcement floor that resolves outside the repo is indistinguishable from one inside it, until an unrelated
rm -rfremoves it and every report still says nothing. README calls git hooks "the agent-agnostic enforcement floor"; a floor whose location is unreported can be moved out from under the claim.
Proposed
- Report the location. A
kit check/kit doctorrow for the git-hook floor: which directory it resolves to, and whether that is inside the repo.kit hooks addshould print the resolved path when it is external, rather than a bare✓ installed. - A dangling hooks path is a finding, not silence.
core.hooksPathpointing at a non-existent directory means every hook is off; that is a fail-closed condition for a repo that has hooks configured, and today it is unreported. - Do not create directories outside the repo without saying so. Re-creating a deleted external tree on
kit hooks addis surprising; at minimum name the path, or require an explicit opt-in. - Correct the
fix.tsscope comment, and consider declaring the resolved hooks dir inscopeNeeds.fsWriteswhen it is external, so[scope].fsdescribes the write that actually happens.
Not proposed
Stopping kit from honoring core.hooksPath — that behavior is right, and src/hooks.ts explains why. The gap is the reporting and the scope claim, not the resolution.
Provenance
Found on a machine holding two checkouts of the same repository, one copied from the other, where the copy's inherited absolute core.hooksPath put its hooks in the original's tree. Reproduced from scratch above with throwaway repos; measured against 6.6.5.
🤖 Generated with Claude Code
Activity
feat(hooks): report where the git-hook floor is and whether it can fa…
chore(release): 6.7.0 (#499)
chore(release): 6.8.0 (#516)