Skip to content

refactor(rag): make file watching context-owned - #4697

Merged
aheritier merged 3 commits into
mainfrom
refactor/rag-context-owned-watchers
Oct 22, 2026
Merged

aheritier merged 3 commits into
mainfrom
refactor/rag-context-owned-watchers

Conversation

@dgageot

@dgageot dgageot commented Oct 22, 2026

Copy link
Copy Markdown
Member

Replaces StartFileWatcher with context-owned WatchFiles, migrating all callers. File watching now runs in a single joined goroutine per watcher, draining events until the context is cancelled; cancellation is drained and joined before the database is closed. Debounce, overflow, and directory-contents handling are preserved.

Includes two prerequisite fixes for the same subsystem:

  • join embedding builders before returning on cancellation
  • snapshot BM25 statistics safely during queries to avoid a data race

Stop scheduling new chunk builders once the context is done, but still
wait for already-running ones before returning, so no goroutine is
left building after buildEmbeddingInputs returns.

Assisted-By: docker-agent
@dgageot
dgageot requested a review from a team as a code owner October 22, 2026 08:34
@aheritier aheritier added area/rag For work/issues that have to do with the RAG features kind/refactor PR refactors code without behavior change labels Oct 22, 2026
@aheritier
aheritier added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit dd89890 Oct 22, 2026
16 checks passed
@aheritier
aheritier deleted the refactor/rag-context-owned-watchers branch October 22, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/rag For work/issues that have to do with the RAG features kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants