Files
codebase-memory-mcp/tests
Martin Vogel e79f61db49 fix(resolver): keep JSON strict when source text is not UTF-8
yyjson's strict writer refuses a whole document over one undecodable byte. Source
files can be in any encoding, and the strict resolver puts source text in JSON on
its way to publication, treating a NULL write as fatal:

  record_properties    call arguments and callee    -> aborted_previous_preserved
  fact_json            proof lookup keys and scopes -> persist_failed
  pass_pkgmap          import paths and names       -> aborted_previous_preserved
  lsp_surface          definitions and imports      -> every file's surface row dropped

Neovim and redis took the first route: a latin-1 string argument in a test file
stopped the whole index. Main writes these same bytes into edge properties raw, so it
published, with invalid UTF-8 inside that JSON.

Add cbm_json_write_text: valid documents are written unchanged at no extra cost,
and only a document the writer refused has its strings repaired, replacing undecodable
bytes with U+FFFD. That covers every field of a document, rather than each field that
happens to carry source text today. The exact-bytes columns (resolver_occurrences
spelling, resolver_lookups key) keep the original bytes; the MCP layer normalizes
those at its own encoding boundary.

The pending unresolved-call key is compared against text read back from that JSON,
so it applies the same replacement to both sides.

The UTF-8 sequence check moves from mcp.c to foundation/str_util so there is one copy.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-31 23:57:23 +01:00
..
…
…