#12: memoize and batch the baseline git queries - #35
Merged
Conversation
createSnoozeIndex caches the git queries the snooze check needs for one run: a single whole-tree `git status --porcelain -z` for the dirty set, and memoized last-commit hashes. Replaces the per-file, per-rule `git log` + `git status` spawns. Unused until wired in. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nq6xHU6JtSNpYWhMYjXB15
builds one index per run and threads it through, so the ~O(rules x baseline-files) git spawns collapse to O(1) status + O(files) memoized log calls. Behaviour is unchanged (covered by the four-quadrant filter tests, now driving the index). Collapse allowedFilesBySmell to one expression to stay under the line cap. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nq6xHU6JtSNpYWhMYjXB15
…ines After rebasing onto main the file grew to 203 lines due to the configWarnings addition from #21. Inlining the single-use helper allowedFilesBySmell into filterViolations removes the 3 surplus lines with no behaviour change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
devill
force-pushed
the
issue-12-batch-git
branch
from
June 17, 2026 14:45
376f1b9 to
50c9e4b
Compare
devill
marked this pull request as ready for review
June 17, 2026 14:45
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 #12.
The baseline snooze check ran
git log+git statusper file, per rule, with no caching — ~1,700 synchronous git spawns and ~117s wall-clock on a 110-entry baseline × 9 rules, where the actual tools take ~5.5s.Fix (locked decision — memoize AND batch)
A per-run
SnoozeIndex(src/baseline/snooze-index.ts), built once inbuildContextand threaded throughpartitionBySnooze:git status --porcelain -zbuilds the dirty set (replacing per-filegit status -- path).lastCommitHashis cached per relative path across rules.This collapses the spawns to O(1) status + O(baseline-files) log per run.
Parity
Behaviour (which files are snoozed) is unchanged — the existing four-quadrant
partitionBySnoozetests now drive the real-git path through the index. Git-failure → all dirty (matches oldisWorkingTreeCleanForreturning false). The-zparser covers both sides of a rename/copy.Atomic commits
#12: add a memoized, batched snooze index— the index + unit tests (incl. a spawn-count assertion: 9 rules × 2 files → exactly 1 status + 2 log).#12: drive the snooze check through the per-run index—partitionBySnooze(files, baseline, index), runner threading, updated filter tests. (Also collapsesallowedFilesBySmellto stay under the line cap.)Gates
pnpm build,pnpm lint— clean (runner.ts at the 200 cap)pnpm test— 389 passed (+4)🤖 Generated with Claude Code
Generated by Claude Code