Files
codebase-memory-mcp/tests
Andrew Hundt 4834ea90b7 mcp: auto-index on first use + auto-context injection + use-after-free fix
Auto-index on first use (REQUIRE_STORE + search_graph):
  When store is NULL and session_root is a valid directory:
  1. If autoindex_active: join background thread, re-resolve store
  2. If still NULL: run cbm_pipeline_run() synchronously, then
     cbm_dep_auto_index() + cbm_pagerank_compute_with_config()
  Handles all 3 paths: CWD (detect_session), explicit path (Rule 0),
  MCP roots (future). access(session_root, F_OK) guard prevents
  triggering on non-existent paths in tests.

inject_context_once(): auto-provide architecture/schema on first response.
  First tool response gets _context header with: status, nodes, edges,
  node_labels, edge_types, ranked_nodes, pagerank_computed_at,
  detected_ecosystem. Subsequent responses only get session_project.

Fix: use-after-free in inject_context_once (ASAN crash at mcp.c:937).
  cbm_store_schema_free() freed label/type strings while yyjson still
  held borrowed pointers. Fix: yyjson_mut_obj_add_strcpy() copies strings
  into yyjson's allocator before schema is freed.

Fix: _hidden_tools count corrected from "12" to "14" (14 tools hidden).

Tests: 2 new (first_response_has_context_header, context_has_schema_info).
Total: 2141 tests passing.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-03-22 05:33:25 -04:00
..