Follow-up to #328.
Add a persistent VCS history cache keyed by HEAD SHA and repo identity, so re-running bca vcs on an unchanged tree reuses prior work.
Why
The v1 implementation walks the full history on every invocation. For large repos (Linux kernel: ~1.2M commits, ~80k files) this is non-trivial. CI integration in particular benefits from caching: the only deltas between consecutive runs are commits added since the last cache entry.
Scope
- Cache location:
~/.cache/big-code-analysis/vcs/<repo-hash>/<head-sha>.json (or --cache-dir).
- Cache key:
(repo_canonical_path, head_sha, options_hash).
- Cache content: serialized
HistoryIndex.
- Incremental update: if HEAD has moved forward by
N commits and the prior cache entry is still present, walk only the new commits and merge.
- Invalidation: if
vcs_schema_version or risk_score_version differs, ignore the cache and recompute.
- Flag:
--no-cache to disable; --clear-cache to wipe.
Edge cases
- Force-pushed history: detect via parent SHA mismatch; invalidate.
- Different
--long-window / --recent-window: counted as part of options_hash, so window changes force a fresh walk.
- Concurrent runs: cache writes are atomic via tempfile + rename.
Acceptance criteria
Follow-up to #328.
Add a persistent VCS history cache keyed by HEAD SHA and repo identity, so re-running
bca vcson an unchanged tree reuses prior work.Why
The v1 implementation walks the full history on every invocation. For large repos (Linux kernel: ~1.2M commits, ~80k files) this is non-trivial. CI integration in particular benefits from caching: the only deltas between consecutive runs are commits added since the last cache entry.
Scope
~/.cache/big-code-analysis/vcs/<repo-hash>/<head-sha>.json(or--cache-dir).(repo_canonical_path, head_sha, options_hash).HistoryIndex.Ncommits and the prior cache entry is still present, walk only the new commits and merge.vcs_schema_versionorrisk_score_versiondiffers, ignore the cache and recompute.--no-cacheto disable;--clear-cacheto wipe.Edge cases
--long-window/--recent-window: counted as part ofoptions_hash, so window changes force a fresh walk.Acceptance criteria