Skip to content

Avoid partial word index rebuilds#330

Merged
justrach merged 1 commit intorelease/0.2.579from
fix/word-index-partial
Apr 26, 2026
Merged

Avoid partial word index rebuilds#330
justrach merged 1 commit intorelease/0.2.579from
fix/word-index-partial

Conversation

@justrach
Copy link
Copy Markdown
Owner

What changed

  • Prevent fast snapshot restores with capped content caches from rebuilding a silently partial word index.
  • Rebuild the word index by streaming files from the project root when the cache is incomplete and a root is available.
  • Fail closed with WordIndexIncomplete when only a partial snapshot cache exists and no source root is available.
  • Extend the large snapshot regression test to cover both paths.

Validation

  • zig build test
  • zig build

Fixes the review finding on #329 where a fresh machine with only codedb.snapshot and no readable word.index could miss codedb_word hits after the 1000-file content cache cap.

@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 542476 536460 -1.11% -6016 OK
codedb_changes 60594 57090 -5.78% -3504 OK
codedb_deps 9910 10030 +1.21% +120 OK
codedb_edit 6371 6428 +0.89% +57 OK
codedb_find 67520 68634 +1.65% +1114 OK
codedb_hot 106009 105689 -0.30% -320 OK
codedb_outline 286486 293146 +2.32% +6660 OK
codedb_read 93323 100728 +7.93% +7405 OK
codedb_search 215383 178500 -17.12% -36883 OK
codedb_snapshot 264775 284967 +7.63% +20192 OK
codedb_status 108569 113733 +4.76% +5164 OK
codedb_symbol 65125 63467 -2.55% -1658 OK
codedb_tree 46190 50676 +9.71% +4486 OK
codedb_word 112711 76628 -32.01% -36083 OK

@justrach justrach merged commit fb2b772 into release/0.2.579 Apr 26, 2026
1 check passed
@justrach justrach deleted the fix/word-index-partial branch April 26, 2026 06:56
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc6dff64fc

ℹ️ 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".

Comment thread src/explore.zig
Comment on lines +1062 to +1065
self.mu.lock();
defer self.mu.unlock();
self.word_index.deinit();
self.word_index = rebuilt;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Rebuild word index under writer lock to avoid lost updates

rebuildWordIndex now does most of its work without holding the write lock, then swaps self.word_index at the end. In MCP/serve mode, queries can run concurrently with watcher.incrementalLoop updates (commitParsedFileOwnedOutline/removeFile), so updates applied while rebuild is in progress can be overwritten by this final assignment, leaving word_index_complete = true but missing recent file changes until another mutation happens. The previous implementation rebuilt while holding the writer lock, so this is a correctness regression under concurrent query + file-change workloads.

Useful? React with 👍 / 👎.

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.

1 participant