fix(explore): wire .codedbrc max_cached into ContentCache capacity#460
Conversation
PR #208 added a CLOCK eviction cache but hardcoded its capacity to 16384, leaving .codedbrc's max_cached parsed-and-forgotten. Thread the configured value through Explorer.init and the MCP ProjectCache so the knob actually controls cache size. Default bumped from 1000 to 16384 to preserve pre-fix behavior for users without a .codedbrc. Issue-102 tests rewritten to assert the wiring end-to-end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4433aecc53
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| var explorer = Explorer.init(allocator); | ||
| explorer.content_cache_limit = cfg.max_cached; | ||
| var explorer = Explorer.init(allocator, cfg.max_cached); |
There was a problem hiding this comment.
Avoid building trigram indexes from a capped cache
When a user sets .codedbrc max_cached below the repo's file count, this line now bounds explorer.contents, but the cold non-search path still builds/persists trigrams only from that cache (main.zig:351-361) and Explorer.rebuildTrigrams also iterates only self.contents. That means the persisted/rebuilt trigram index can cover only the cached subset rather than every scanned outline, degrading later searches to slow skip/full scans and potentially omitting matches once earlier cached candidates fill max_results; build trigrams from disk or avoid the cache-only path when contents.count() != outlines.count().
Useful? React with 👍 / 👎.
Summary
16384, leaving.codedbrc'smax_cachedparsed-and-forgotten.cfg.max_cachedthroughExplorer.init(and the MCPProjectCache) so the knob actually controls cache size.1000→16384so users without a.codedbrcsee no behavior change vs. the (accidentally) shipped16384.issue-102tests insrc/tests.zigpreviously documented the deadness in comments; they're rewritten to assert the wiring end-to-end — they would have caught the original bug.Files
src/explore.zig— newpub const DEFAULT_CONTENT_CACHE_CAPACITY = 16384;Explorer.initnow takes a capacity param; deadcontent_cache_limitfield removed.src/hot_cache.zig—std.debug.assert(capacity >= 1)guard (capacity 0 used to silently panic onh % 0).src/config.zig—Config.max_cacheddefault1000→16384.src/main.zig— passcfg.max_cachedtoExplorer.initand through tomcp.run.src/mcp.zig—ProjectCachecarries the capacity;mcp.runandBenchContext.initsignatures updated to thread it through.src/wasm.zig,src/bench.zig,src/benchmark.zig— passDEFAULT_CONTENT_CACHE_CAPACITYat boundaries with no config in scope.src/tests.zig,src/adversarial_tests.zig— bulk-updated ~260 call sites; rewrote issue-102 tests to assert real wiring.Test plan
zig build test→ exit 0 (all 536 tests pass on4433aec)issue-102: Explorer.init capacity flows to ContentCache— constructs with capacity 8, assertsexplorer.contents.capacity == 8issue-101+102: .codedbrc max_cached threads through to ContentCache capacity— parsesmax_cached = 32, assertsexplorer.contents.capacity == 32.codedbrcwithmax_cached = 64in a project, run codedb, confirm cache stats show capacity 64Notes
release/v0.2.5814per the standing rule (collect fixes on release branch, never merge straight tomain).build.zig.zon+src/release_info.zig) intentionally not included — that belongs in the release commit when you're ready to cut v0.2.5814.Closes #102footer.🤖 Generated with Claude Code