Stop hook silently fails to find CLI for non-standard venv paths (cli-not-found), plus orphan maintenance snapshots
Summary
Two related housekeeping issues found via iai-mcp doctor on a fresh 3.2.3 install (project-local venv, not one of the hardcoded discovery paths).
1. Stop hook CLI resolution fails silently for non-standard venv locations
Install: pip install iai-pme into a project-local venv at a custom path (e.g. /Users/<me>/projects/<project>/.venv), not ~/.pyenv/shims, ~/.local/bin, a pipx venv, Homebrew, or the hardcoded ~/IAI-MCP/.venv/bin.
iai-mcp-session-capture.sh (the Stop hook) resolves the CLI in this order:
$IAI_MCP_SESSION_CAPTURE_CLIenv var- cached path at
~/.iai-mcp/.cli-path command -v iai-mcp(requires it on$PATH)- a hardcoded candidate list (pyenv shims,
~/.local/bin, pipx, Homebrew,~/IAI-MCP/.venv/bin,/usr/local/bin)
None of these match a project-local venv, and — critically — the cache file is never seeded on a successful capture-hooks install, so there is no path that ever succeeds for this kind of install. Every Stop hook invocation exits 0 after writing {"rc":"cli-not-found", ...} to ~/.iai-mcp/.capture-state/.stop-hook-failures.jsonl. It's silent — no console output, only visible via iai-mcp doctor check (kk).
Observed impact: 216 cli-not-found failures logged across 17 distinct sessions within ~36 hours. First failure timestamp lines up with a pip install --upgrade iai-pme (3.0.8 → 3.2.3) followed by re-running iai-mcp capture-hooks install to refresh hook templates — the newly-installed hook template appears to have lost whatever resolved the CLI correctly before the refresh (possibly an install-time-embedded absolute path that the current template no longer writes).
Since per-turn capture (iai-mcp-turn-capture.sh) is pure file IO and doesn't need the CLI, most content still gets captured on the next turn. But the Stop hook's capture-turn-deferred catch-up — which is specifically for turns after the last per-turn hook fire, e.g. a session's final assistant response with no following user prompt — silently never runs, so that tail content is dropped, not merely delayed.
Workaround: manually seed the cache once, with the venv active:
which iai-mcp > ~/.iai-mcp/.cli-path
This immediately fixed all further Stop-hook invocations (cache is checked before command -v/candidates).
Suggested fix: iai-mcp capture-hooks install already knows the resolved CLI path at install time (it's running from that same venv) — it should write it to ~/.iai-mcp/.cli-path (or embed it directly into the generated hook script) at install/refresh time, rather than relying purely on runtime $PATH/candidate-list guessing that has no knowledge of project-local or otherwise non-standard venvs.
2. Orphan snapshot directories from maintenance commands aren't cleaned up
iai-mcp blob-quarantine --apply (and presumably idem-dedup --apply / schema-cleanup --apply) snapshot the store dir first as a safety net — good — but never remove the snapshot afterward, even on clean success. Found one sitting at:
~/.iai-mcp/hippo-pre-blob-quarantine-<timestamp>/ 204 MB
almost a third of the total ~/.iai-mcp footprint (701 MB → 497 MB after manually removing it). Over repeated maintenance runs this would accumulate indefinitely with no automatic cleanup and no CLI to list/prune old ones.
Suggested fix: either auto-remove the pre-op snapshot after a verified-successful --apply, or add a small iai-mcp maintenance list-snapshots / prune-snapshots [--older-than] command so these don't have to be found and removed by hand.
Environment
- macOS (Apple Silicon),
iai-pme3.2.3, installed viapip install iai-pmeinto a project-local venv iai-mcp doctoroutput showing the failure: check(kk)—9 stop-hook failure(s) in the last 60miai-mcp doctoralso separately flagged(gg) store format— legacy sqlite format with a documented WAL-sidecar-orphaning defect under concurrent read-only opens — not the same bug as above but same theme (orphaned artifacts), flagging in case it's useful context:iai-mcp migrate-to-lilliis the documented fix path for that one.
Happy to share the full .stop-hook-failures.jsonl or doctor output if useful.