Summary
- Serializes MCP write tools through an explicit queue to prevent concurrent SQLite write contention.
- Fixes a
mem_savetimeout path exposed by v1.14.6 by closing candidate-search rows before follow-up writes. - Keeps MCP read tools direct so searches/current-project lookups do not wait behind writes.
Details
- Queued MCP write tools:
mem_save,mem_update,mem_delete,mem_save_prompt,mem_session_summary,mem_session_start,mem_session_end,mem_capture_passive,mem_merge_projects, andmem_judge. - Read tools such as
mem_search,mem_context,mem_current_project, andmem_get_observationremain direct. - Queue cancellation is worker-owned so callers do not receive a false cancellation for a write that already started.
- Panics in a write handler are isolated so the queue worker stays alive for later writes.
- Queue backpressure returns a clear retryable error instead of hanging.
Validation
- Double adversarial review returned clean after fixing the cancellation race.
go test -count=1 ./internal/mcp ./internal/store ./cmd/engram ./internal/setupgo test -race ./internal/mcp -run 'Test(WriteQueue|ReadHandlerDoesNotWaitBehindBlockedQueuedWrite)' -count=1git diff --check