mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-10-26 06:43:15 +08:00
The index supervisor gate (cbm_index_supervisor_should_wrap) wrapped ANY embedder of cbm_mcp_handle_tool: it resolved the CURRENT executable and re-invoked it as '<self> cli --index-worker index_repository ...'. In a test binary 'self' is the test runner, which ignores those args and re-runs its suites instead, producing recursive spawn chains (observed 11-minute hangs, and multiplied kernel VM-map/memory load during the 2026-07-04 host panics). The gate is now opt-in: only a process that called cbm_index_supervisor_mark_host() — the real binary's main(), before any subcommand dispatch — may spawn workers. Embedders index in-process by default; the test mains additionally pin CBM_INDEX_SUPERVISOR=0 as belt-and-suspenders. Guarded by index_supervisor_gate_requires_marked_host_issue845 (fork+alarm harness, new spawn-count test hook; red on the old gate, green without the env kill switch on the new one). A supervised worker whose supervisor died also kept indexing as an orphan: the parent-death watchdog only ran in MCP-server mode. run_cli now starts the same watchdog (detached; on ppid change it only writes to stderr and _exit(0)s, so it is safe outside server mode) when it detects --index-worker. Guarded by tests/test_worker_watchdog.sh (scripts/test.sh Step 5b): a CBM_TEST_HANG_ON busy-spin pins the worker mid-index, the wrapper parent is killed, and the worker must self-exit within 15s — red without the wiring, green with it. Fixes #845. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>