Repository navigation
fix(sync): embed a caught-up project in the background, not in the watcher loop - #2046
Merged
Merged
Conversation
…tcher loop The watcher catches a newly attached project up inside its batch consumer. The catch-up embedded vectors inline, so while the model loaded or a large project embedded, no watch batch was handled for any project. A live edit in the first seconds after attach waited behind it; the removed lifecycle test timed out on exactly that (#1979). File indexing stays in the catch-up, serialized with watch batches. The watcher's runtime factory now hands batch vector syncs to background work, like the per-write vector scheduler, and retires cached searches when the vectors land. Closes #1979 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CMYVL4TcbWdXhdvAzxfqjo Signed-off-by: phernandez <paul@basicmachines.co>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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 #1979.
What was wrong
The watcher catches a newly attached project up inside its batch consumer (
_watch_projects_cycle). That catch-up ranrun_local_project_index_for_projectwith embeddings inline. Until it returned, no watch batch was handled for any project.The removed lifecycle test showed it. I restored it locally and ran 25 copies, 8 at a time. In 8 runs the catch-up was still fetching the FastEmbed model ("Fetching 5 files", stuck at 1/5) when the 45 s deadline passed. The
narwhaledit was never dropped. It was waiting behind the embedding.In production, adding a large project, or a first model load, delayed live edits in every project until embedding finished.
Fix
BackgroundEmbeddingRuntimeFactory(inindex/local_schedulers.py) wraps the watcher's project-index runtime. ItsBackgroundBatchVectorSynchands each batch vector sync to background work, like the per-write vector scheduler, and retires cached searches when the vectors land.initialize_file_indexinggives the watcher the wrapped factory. The startup scans already run as separate tasks and keep inline embedding.Tests
tests/index/test_watch_catch_up_embeddings.py:live.md, and requires it to be indexed while embedding is still held.tests/services/test_initialization.pynow asserts the watcher gets the wrapped factory.Not restored
I did not bring back
test-int/mcp/test_new_project_watch_lifecycle.py. Under 8× load it passed and then hung at event-loop close: a leftover task didn't finish when cancelled. That happened 2 times in 56 runs, once on unmodifiedmaincode. It is a separate shutdown issue and would keep the test flaky. The new watcher test covers the #1979 behavior deterministically.Checks
just fast-checktests/index,tests/services,test-int/mcpon SQLite (-n 4)🤖 Generated with Claude Code
https://claude.ai/code/session_01CMYVL4TcbWdXhdvAzxfqjo