Skip to content

index supervisor spawns worker with raw-JSON + flag argv the new CLI parser rejects - all default-path indexing fails on main #838

Description

@Sowiedu

Summary

On current main (9871e7e0), every cli index_repository run fails with {"status":"error","outcome":"exit_nonzero","hint":"Indexing worker crashed on a file..."} — on any repo, immediately (~0.2 s). The worker didn't crash on a file: the index supervisor (#827) spawns the worker with an argument layout the new CLI parser (#680) rejects.

Root cause

cbm_index_spawn_worker() (src/mcp/index_supervisor.c) builds:

<self> cli --index-worker index_repository <raw-json-args> --response-out <path>

i.e. a raw-JSON positional mixed with a --response-out flag. Since the #680 CLI overhaul, the presence of a --flag puts the parser in flag mode; the raw JSON positional is ignored (only the deprecation warning fires) and parsing fails with repo_path is required. The worker exits 1, the supervisor reports exit_nonzero, and the misleading "crashed on a file" hint is returned.

Repro (no supervisor involved — the spawned command itself)

codebase-memory-mcp.exe cli --index-worker index_repository '{"repo_path": "C:/some/repo", "mode": "fast"}' --response-out $env:TEMP\resp.json
# -> warning: passing raw JSON ... is deprecated ...
# -> repo_path is required
# -> exit code 1, resp.json = {"content":[{"type":"text","text":"repo_path is required"}],"isError":true}

The same JSON without --response-out parses fine (with the deprecation warning). Verified on Windows 11; the arg-parsing interaction is platform-independent, so POSIX default-path indexing should be equally affected unless something masks it.

Workaround

CBM_INDEX_SUPERVISOR=0 (in-process indexing) works perfectly — same repo indexes in ~3 s.

Suggested fix

Have the supervisor pass worker args in a form the new parser accepts unambiguously — e.g. --args-file <tmp.json> (already supported by #680) or stdin piping, instead of the deprecated raw-JSON positional. Alternatively, teach the parser to accept a raw-JSON positional alongside flags, but the --args-file route avoids the deprecated path entirely and sidesteps Windows cmdline quoting concerns for embedded JSON.

Found while upgrading past #792/#793 (thanks for the fast merge!).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions