mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
e6d6094e7f
When multiple `basic-memory mcp --project <name>` processes run concurrently,
each process previously spawned a file watcher over every active project instead
of just the constrained one. This caused N overlapping watchers racing on the same
files, producing cascade-delete crashes, atomic-rename collisions, and phantom
"entity not found" errors.
Changes:
- WatchService now accepts `constrained_project` and filters the per-cycle
project reload to that value when set, so N concurrent MCP processes produce
N disjoint watchers instead of N overlapping ones
- initialize_file_sync reads BASIC_MEMORY_MCP_PROJECT once and wires it to both
the one-shot background sync filter and the new WatchService kwarg
- Relation.permalink guards from_entity for None (same pattern as to_entity) to
defend against the AttributeError that surfaces when a concurrent watcher
cascade-deletes an entity while another process is resolving relation permalinks
- write_file_atomic uses a PID-unique temp suffix ({stem}.{pid}.tmp) so
concurrent processes writing the same file no longer collide on the temp name
Fixes #758
Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>