The #1222 capacity probe guards reads only: search and check_duplicate fall
back to BM25 when the flushed HNSW segment lags sqlite. Writes went straight
to chromadb — and an upsert into that index does not fail, it blocks inside
chromadb's Rust upsert with no timeout of its own, for the life of the
process, while this server holds the dispatch lock, the palace mine lock and
the writer lease. Peer sessions drop to read-only behind a server whose
handshake still answers, and nothing on the server side says why: the only
trace of a 25-minute outage was the client's own "tool still running" ticks,
and mempalace_status could not answer because the stuck call held the
dispatch lock. This is the #1845 / #1908 symptom.
Measured on a 3.7.0 palace whose flushed segment held 803 of 820 embeddings
(py-spy: MainThread parked in chromadb/api/rust.py:_upsert, 64 idle
tokio-rt-workers, no fcntl lock on chroma.sqlite3 — an internal wait, not
lock contention): on copies of that palace, three of five freshly generated
vectors blocked forever, the other two committed in 0.03s, and each vector
reproduced its own verdict on retry. A write's fate depended on where its
embedding landed in the damaged graph. After
`mempalace repair rebuild-index`, all five committed in ~0.2s.
Two guardrails, both Tier 1 of #1963:
- _mcp_diverged_index_refusal: dispatch refuses the vector-write tools while
the probe reports divergence, and puts the rebuild command in the error
payload. Narrower than _MUTATING_TOOLS on purpose — the knowledge-graph
and tunnel/hallway tools keep their own state and never reach the segment,
so they must not even pay for the probe. Refusing is also the honest answer
for the write that does *not* hang: chromadb acknowledges it into sqlite
and the metadata segment, then leaves it out of HNSW, so the drawer reports
success while being invisible to vector search. In the same incident 16
such drawers came out of one checkpoint that returned "completed
successfully in 2s". The probe is pure sqlite + pickle, so the gate costs
no chromadb interaction on the path it protects, and it re-runs per call so
a repair in another process un-gates this server without a restart.
- a write-stall watchdog: MEMPALACE_MCP_WRITE_STALL_WARN_SECS (default 60,
0 disables) warns on stderr — where the MCP host records it — from a
thread the stuck call is not blocking. MEMPALACE_MCP_WRITE_STALL_EXIT_SECS
(default 0, opt-in) lets an operator turn the wedge into a restartable
failure: a server stuck inside chromadb never recovers, and exiting is what
releases the palace locks its peers are queued behind. Exit code 75
(EX_TEMPFAIL) so it does not read as an orderly shutdown.
Refs #1845, #1908, #1963
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>