Repository navigation
Description
Bug Description
The local watcher restarts its awatch cycle every watch_project_reload_interval seconds.
_schedule_restart() sets the cycle's stop_event (index/watch_service.py:122-125). run() then
leaves _watch_projects_cycle(), selects projects again, and opens a new awatch
(watch_service.py:205-232). File events that are pending in the old watcher at the stop, or that
arrive before the new one is up, are never indexed, and nothing rescans afterwards. The note stays on
disk with no entity until something else touches it.
The loss depends on the reload interval, at most about one file per reload while files are being
written. With the default (300 s) we saw no loss in our runs. With a short interval it is easy to hit.
Steps To Reproduce
Throwaway home (BASIC_MEMORY_CONFIG_DIR pointing at an empty directory) with one project, config
"watch_project_reload_interval": 2, "index_delay": 1000:
- Start
bm mcp --transport streamable-http --host 127.0.0.1 --port <port>and wait for
Event-index watch service startedin the log. - Write 120 small notes into the project directory, one every 0.25 s.
- Wait 15 s, then
SELECT count(*) FROM entity WHERE file_path LIKE 'n%.md'.
Expected Behavior
120 entities.
Actual Behavior
On 0.24.1: 118 of 120, with n2 and n3 missing. In earlier runs on 0.23.2 (same code path),
2–4 of 120 were lost at 2 s, about one per cycle at 30 s (3 of 400), and none at 300 s (0 of 120,
also 0 of 120 on 0.24.1).
Environment
- OS: macOS 27.0.1 (FSEvents)
- Python version: 3.13.17
- Basic Memory version: 0.24.1
- Installation method: Homebrew
- Claude Desktop version (if applicable): n/a
Additional Context
Related but distinct: #1817 is about a project that joins the watch set at a reload. This bug
affects a project that is watched the whole time. The reload exists so config changes are picked
up, so the gap is paid on every cycle, even when nothing changed.
We mitigate with the default 300 s interval. That narrows the window but does not close it.
Possible Solution
Either of these:
- Keep one watcher (
RustNotify) across cycles and only swap the project set when it changed. - Restart only when the project set changed, and after any restart run an incremental scan of the
watched projects (the checksum-based change planning already makes that cheap).
Activity
fix(sync): keep file events across watcher reloads (#1951)