The local gate's sweep cache is never written from a worktree, so every push re-sweeps 33-36 #258

Closed
opened 2026-09-06 22:15:35 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-09-06 22:15:35 +00:00 (Migrated from github.com)

The local gate's sweep cache is never written from a git worktree, so every commit and
every push re-runs the full API 33-36 sweep even when app/src has not changed since the last
green one.

What happens

tools/git-hooks/pre-commit files the sweep under .git/lmc-verify/<app/src tree hash>:

CACHE_DIR=".git/lmc-verify"
...
mkdir -p "$CACHE_DIR" && [ -n "$tree" ] && : > "$CACHE_DIR/$tree"

REPO_ROOT is git rev-parse --show-toplevel, which in a worktree is the worktree root — and
there .git is a file, not a directory. It points at
<main repo>/.git/worktrees/<name>. So mkdir -p .git/lmc-verify fails with

mkdir: cannot create directory ‘.git’: Not a directory

Measured 2026-09-06 while landing #252 from .claude/worktrees/agent-…: the commit's sweep went
green on 33, 34, 35 and 36 in about 35 minutes, printed that mkdir line, and wrote nothing —
so pre-push found no cache entry and swept all four levels again for a byte-identical
app/src.

Why it is worth fixing rather than living with

The cache is the thing that makes the gate affordable, and its own header says so: keying it on
the whole repo tree "was wrong in a way that would have trained people to hate this hook". A
worktree gets the hate without the cache. It also fails silently in the sense that matters —
mkdir writes to stderr, the && short-circuits, the hook prints "green on API 33, 34, 35, 36"
and exits 0, so nothing says the evidence was thrown away. Agents working in
.claude/worktrees/ hit this on every push.

The fix

git rev-parse --git-dir (or --git-common-dir) resolves to the real gitdir in a worktree and
to .git in a normal checkout, so CACHE_DIR="$(git rev-parse --git-dir)/lmc-verify" is a
one-line change. --git-common-dir shares one cache across every worktree of the repo, which is
the behaviour worth having here: the cache is keyed on the app/src tree hash, and that hash
means the same thing in every worktree.

Whichever is chosen, the write should also stop being silent — a failed mkdir or touch
should say that the sweep was not recorded, since the next run paying for it again is the only
symptom today.

The local gate's sweep cache is never written from a git worktree, so every commit **and** every push re-runs the full API 33-36 sweep even when `app/src` has not changed since the last green one. ## What happens `tools/git-hooks/pre-commit` files the sweep under `.git/lmc-verify/<app/src tree hash>`: ```bash CACHE_DIR=".git/lmc-verify" ... mkdir -p "$CACHE_DIR" && [ -n "$tree" ] && : > "$CACHE_DIR/$tree" ``` `REPO_ROOT` is `git rev-parse --show-toplevel`, which in a worktree is the worktree root — and **there `.git` is a file, not a directory**. It points at `<main repo>/.git/worktrees/<name>`. So `mkdir -p .git/lmc-verify` fails with ``` mkdir: cannot create directory ‘.git’: Not a directory ``` Measured 2026-09-06 while landing #252 from `.claude/worktrees/agent-…`: the commit's sweep went green on 33, 34, 35 and 36 in about 35 minutes, printed that `mkdir` line, and wrote nothing — so `pre-push` found no cache entry and swept all four levels again for a byte-identical `app/src`. ## Why it is worth fixing rather than living with The cache is the thing that makes the gate affordable, and its own header says so: keying it on the whole repo tree "was wrong in a way that would have trained people to hate this hook". A worktree gets the hate without the cache. It also fails *silently* in the sense that matters — `mkdir` writes to stderr, the `&&` short-circuits, the hook prints "green on API 33, 34, 35, 36" and exits 0, so nothing says the evidence was thrown away. Agents working in `.claude/worktrees/` hit this on every push. ## The fix `git rev-parse --git-dir` (or `--git-common-dir`) resolves to the real gitdir in a worktree and to `.git` in a normal checkout, so `CACHE_DIR="$(git rev-parse --git-dir)/lmc-verify"` is a one-line change. `--git-common-dir` shares one cache across every worktree of the repo, which is the behaviour worth having here: the cache is keyed on the `app/src` tree hash, and that hash means the same thing in every worktree. Whichever is chosen, the write should also stop being silent — a failed `mkdir` or `touch` should say that the sweep was not recorded, since the next run paying for it again is the only symptom today.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMediaConverter#258