fix(win): deliver non-ASCII CLI paths end-to-end (wide argv + CreateProcessW)#891
Conversation
|
One housekeeping ask before we merge, @Flipper1994: could you drop The fix itself looks great: clean wide-argv |
4a09d4a to
ead2ec6
Compare
…rocessW) Closes DeusData#423, DeusData#20. A non-ASCII repo path passed to `codebase-memory-mcp cli index_repository "<json>"` was mangled on Windows, so the command failed with "repo_path is required" instead of indexing the real directory. POSIX is unaffected (argv is already UTF-8). Two boundaries had to be fixed: 1. argv read: main() took only the narrow `int main(int argc, char **argv)`, so the CRT handed it argv in the active ANSI code page. On Windows main() now rebuilds argv from the wide command line (GetCommandLineW + CommandLineToArgvW) and converts each element to UTF-8 (cbm_wide_to_utf8). 2. worker spawn: the index supervisor (and the UI index thread) spawned the worker via CreateProcessA, which re-interpreted the UTF-8 command line through the ANSI code page -- re-mangling the path at the parent->worker boundary even after (1). Both spawns now build a wide command line (cbm_utf8_to_wide) and use CreateProcessW. Without (2) the default (supervisor-enabled) path stayed broken while only the in-process path worked, so this is the complete end-to-end fix, not just argv. Promotes tests/windows/test_cli_non_ascii_arg.py from an opt-in known-red to a green Windows guard (scripts/test-windows.ps1 + the test-windows-guards CI job). The guard now exercises the DEFAULT supervised path (it drops the suite's CBM_INDEX_SUPERVISOR=0 so it actually crosses the worker-spawn boundary). Verified on native Windows: RED before the fix, GREEN after (a non-ASCII repo indexes, nodes>0). Also adds -lshell32 explicitly (main.c now uses CommandLineToArgvW) and refreshes RED_TEST_ANALYSIS.md. Signed-off-by: Flipper <jacobphilipp@ymail.com>
ead2ec6 to
14142b3
Compare
|
Done -- |
|
Merged ( |
Summary
Closes #423, #20 -- the still-open Windows narrow-argv bug flagged in the #639 review as "genuinely still present". A non-ASCII repo path passed to
codebase-memory-mcp cli index_repository "<json>"was mangled on Windows and the command failed with "repo_path is required" instead of indexing the real directory. POSIX is unaffected (argv is already UTF-8).The bug has TWO boundaries (both fixed)
A self-review caught that fixing only argv is insufficient — the default runtime re-mangles the path a second time:
main()took only the narrowint main(int argc, char **argv), so the CRT handed it argv in the active ANSI code page. On Windowsmain()now rebuilds argv from the wide command line (GetCommandLineW+CommandLineToArgvW) and converts each element to UTF-8 (cbm_wide_to_utf8).CreateProcessA, which re-interprets the UTF-8 command line through the ANSI code page — re-mangling the path at the parent→worker boundary even after (1). Both spawn sites (subprocess.ccbm_run_winand the UIhttp_server.cindex spawn) now build a wide command line (cbm_utf8_to_wide) and useCreateProcessW.Without (2) the default path stays broken while only
CBM_INDEX_SUPERVISOR=0(in-process) works — so this is the complete end-to-end fix.Test — reproduce-first, promoted guard, exercises the DEFAULT path
tests/windows/test_cli_non_ascii_arg.py(the opt-in known-red from #639) is promoted to a green guard ($knownReds→$guards, gated bytest-windows-guards). Critically it now drops the suite'sCBM_INDEX_SUPERVISOR=0, so it crosses the real supervisor→worker spawn boundary — otherwise a green guard would mask the spawn half of the bug.Verified on native Windows (Win11, CLANG64):
café_日本語_repoindexes,nodes>0) on the supervised path.-GuardsOnlysuite green.Also:
-lshell32added explicitly (main.cnow depends onCommandLineToArgvW), andRED_TEST_ANALYSIS.mdrefreshed from known-red to green-guard.Closes #423, #20.