mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-10-27 06:53:11 +08:00
The 300ms in-process SIGALRM budget in hook-augment self-terminated with a silent _exit(0) on real cold starts (SQLite/mmap open under load), so PreToolUse augmentation never appeared in real sessions (reporter: 0/24 observed) while warm manual invocations worked - and a fired deadline was indistinguishable from a legitimate no-match run. Default budget is now 2000ms (the settings.json hook timeout stays the outer backstop), overridable via CBM_HOOK_DEADLINE_MS (clamped 50..10000). When the deadline fires, the handler write()s a pre-formatted breadcrumb (deadline, pid, the env knob to raise) to ~/.cache/codebase-memory-mcp/logs/hook-augment-timeouts.log before exiting - fd and message are prepared at arm time so the handler stays async-signal-safe; CBM_HOOK_TIMEOUT_LOG overrides the path for tests. Windows keeps relying on the settings.json timeout (unchanged no-op). Deterministic reproduction: stdin is a pipe whose writer never sends, so the read blocks past a 60ms deadline - the timer must fire, exit 0 (fail-open), and leave the breadcrumb. RED before (no breadcrumb), GREEN after. Closes #858 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>