Skip to content

#12: memoize and batch the baseline git queries - #35

Merged
devill merged 3 commits into
mainfrom
issue-12-batch-git
Jun 17, 2026
Merged

#12: memoize and batch the baseline git queries#35
devill merged 3 commits into
mainfrom
issue-12-batch-git

Conversation

@devill

@devill devill commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #12.

The baseline snooze check ran git log + git status per 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 in buildContext and threaded through partitionBySnooze:

  • Batch: one whole-tree git status --porcelain -z builds the dirty set (replacing per-file git status -- path).
  • Memoize: lastCommitHash is 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 partitionBySnooze tests now drive the real-git path through the index. Git-failure → all dirty (matches old isWorkingTreeCleanFor returning false). The -z parser covers both sides of a rename/copy.

Atomic commits

  1. #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).
  2. #12: drive the snooze check through the per-run indexpartitionBySnooze(files, baseline, index), runner threading, updated filter tests. (Also collapses allowedFilesBySmell to 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

claude and others added 3 commits June 17, 2026 16:43
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
devill force-pushed the issue-12-batch-git branch from 376f1b9 to 50c9e4b Compare June 17, 2026 14:45
@devill
devill marked this pull request as ready for review June 17, 2026 14:45
@devill
devill merged commit 26a3651 into main Jun 17, 2026
2 checks passed
@devill
devill deleted the issue-12-batch-git branch June 19, 2026 12:21
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.

Baseline snooze check spawns ~1700 synchronous git processes per run (O(rules × baseline files)) — 117s where checks take 5s

2 participants