Repository navigation
Description
The gap
kit audit verify answers for one working tree. On a machine running several, that produces several independent green verdicts and no way to ask the question a reviewer actually asks — what did the agents do to this repo today?
This is not a bug in the cwd work; it is a consequence of that work being correct. logAuditEvent resolves resolve(cwd ?? process.cwd(), logFile), and a git worktree is a distinct working tree, so it correctly gets its own chain.
Measured with two real worktrees of this repo on the same commit:
$ cd wt-a && kit audit verify
✓ audit chain intact 1 entries
✓ HMAC anchor verified (1 sealed entries). exit 0
$ cd wt-b && kit audit verify
✓ audit chain intact 1 entries
✓ HMAC anchor verified (1 sealed entries). exit 0
Two greens, neither of which is the whole story. A checker whose oracle is one working tree cannot see its siblings, which is the same failure class self-audit rule 14 exists to catch.
What does survive the model, also measured, so this issue is scoped to the part that doesn't:
- Worktrees share the
.gitcommon dir, so installedpre-commit/pre-push/post-commithooks fire in every one of them without reinstalling — an agent cannot create itself an ungated worktree. .kit.tomlis tracked, so policy cannot drift by construction, and the narrowing-only semantic means a session editing its own copy cannot self-approve.
The data to fix it already exists
~/.kit/audit-anchor.json stores the HMAC tip per log path and lives in the home dir, shared across every working tree on the machine. After appends in two worktrees it held both absolute paths. It is, in effect, an index of every audit log kit has ever sealed here.
Nothing reads it that way. kit audit anchor seals the audit log — the one in cwd — and the only reader outside audit-anchor.ts looks up a single path:
$ grep -rn "readAnchorRecord\|Object.keys(record" src/*.ts | grep -v audit-anchor
src/hints.ts:96: return (await readAnchorRecord(logPath)) === null;
On the machine where this was measured that record already keys 15 log paths across 15 directories, none of which any command has ever enumerated. Most are short-lived temp dirs from test runs — which is exactly why a fix has to distinguish gone from stalled rather than alarming on both.
Proposed
kit audit verify --all(oraudit anchor --list): iterate the anchor record, verify every chain it knows about, and report paths that are missing or stalled as distinct outcomes with a meaningful exit code. The iteration is the whole feature; the data is already on disk and already 0600.- Thread
cwdat one call site.elevation.tscallsappendAuditEventDirectwithoutcwd, so it lands inprocess.cwd()'s log. That is the same threading thecwdarc did everywhere else, and this call site was missed.
Why (2) matters more than its size suggests: KIT_ELEVATED=1 is documented as the CI escape hatch that "gets audit-logged loudly so a leaked CI env doesn't silently bypass". The warning does go to stderr and the record does get written — but it is written into one of N logs that no command reads together. "Loudly" is a claim about a reader, and the reader is the weak link.
Not proposed
A new gate or policy. The floor is fine; what is missing is a way to read what it already wrote.
Provenance
Found while researching agent session managers that give every session its own git worktree — a workflow that turns "N working trees on one machine" from an edge case into the normal case. The measurements above were taken against 6.6.3.
🤖 Generated with Claude Code
Activity
docs(roadmap): the worktree audit gap, moved to where work is planned (…
fix: kit failed the hook it just wrote on any /root machine — plus 6.…
feat(audit): kit audit verify --all — the union view over every seale…
chore(release): 6.7.0 (#499)