Harden Mimir subprocess lifecycle (deadlock, restart, timeout, key collisions)#6
Merged
Merged
Conversation
- stderr=DEVNULL (was PIPE, never drained): prevents pipe-buffer deadlock that silently hung the plugin on long sessions - reader thread + queue with deadline: _mcp_send now times out (RECALL_MCP_TIMEOUT, default 30s) instead of blocking forever - lazy single restart when mimir died; clean "Memory backend unavailable" JSON-RPC error instead of leaked AttributeError - content-hash suffix on auto-generated keys: distinct facts with a shared 50-char prefix no longer silently overwrite each other - guarded shutdown wait (TimeoutExpired -> kill) - tests: 15 unit tests over the protocol seam + lifecycle machinery - CI: GitHub Actions pytest workflow Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 12, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the four subprocess lifecycle failure modes from the 2026-06-12 deep-dive review (A-1 through A-5).
Fixes
stderr=PIPEthat nothing drained; once the OS pipe buffer filled, Mimir blocked on its next stderr write and the plugin hung forever. Nowstderr=DEVNULL._mimir_proc = Noneand every invoke leakedAttributeError: 'NoneType' object has no attribute 'stdin'; a mid-session death raised forever with no restart. Now_mcp_sendlazily restarts Mimir once, and if that fails the agent gets a clean JSON-RPC error:Memory backend unavailable — …._mcp_sendblocked indefinitely onreadline(). A reader thread now feeds a queue, and reads enforce a deadline (RECALL_MCP_TIMEOUT, default 30s) — a stuck call raises instead of freezing every memory tool.handle()), key generation, timeout/restart machinery, and the reader thread — no Mimir binary required. GitHub Actions workflow added.Verification
🤖 Generated with Claude Code