Hook writes call loadAll() of the full observation corpus
Description
memorix hook / handleHookEvent called initObservations() which loadAll()'d the entire observation corpus (~44k rows) before writing a single hook capture. On a large store that made file.edited / command.executed / tool.execute.after too slow, so operators disabled OpenCode per-tool events (skipHookEvents) or set [memory] formation = "shadow".
Those are workarounds. The native path must write a hook observation without loading the corpus.
Steps to Reproduce
- Large SQLite store (~40k+ observations).
printf '%s' '{"hook_event_name":"PostToolUse","cwd":"<git-project>","tool_name":"Write",...}' | memorix hook- Time the process. On 1.6.0 this was ~8–11s in a full E2E (isolated ~0.9s after a write-only init).
Expected Behavior
Hook capture is write-only: persist the observation, exit in ~1s. Control plane picks the row up via ensureFresh. No Orama insert and no loadAll() on the hook process.
Actual Behavior
Hook init loaded the full corpus. OpenCode skipped per-tool events. formation=shadow was left as a short-circuit on some hosts.
Environment
- Memorix 1.6.0
- macOS + Linux
- OpenCode plugin
~/.config/opencode/plugins/memorix.js - Cursor / Claude hooks via
quiet-memorix-hook.sh
Additional Context
#205 (closed) covered hook processes that never exit. This issue is the remaining work on the happy path: loadAll() before a write. #214 adds initObservations(..., { skipCorpusLoad: true }) for hooks.
Related: #205, #125, #214.
Fix is in PR https://github.com/AVIDS2/memorix/pull/214 — not on main yet, so leaving this issue open until that PR merges.
Relevant work:
35358a1a4c— persist hook captures withoutloadAll()viaskipCorpusLoadonhookObservationRuntimeOptions- Files:
src/hooks/lifecycle.ts,src/memory/observations.ts,tests/memory/hook-write-without-corpus-load.test.ts
Fixed by #214 and released in v1.6.2. Hook writes no longer load the full observation corpus on the foreground path. Closing as shipped.