Skip to content

Commit c02d3c9

Browse files
committed
Incremental indexing + MCP tool integration tests (155 tests)
Comprehensive test suite using real repo (FastAPI 0.99.1, ~1100 files): - Full index baseline with perf metrics (nodes, edges, RSS, timing) - Incremental: modify/add/delete/rename files, noop, formatter run - Adversarial: empty file, syntax errors, 5000-line function, binary - Stress: rapid reindex, batch 20 files, delete-all + re-add - Accuracy: incremental vs full within ±2 nodes/edges - MCP tools: all 14 tools, every parameter, content validation - Error handling: bad project, missing params for each tool - Performance: 5s timeout on every tool call Fix use-after-free in detect_changes and manage_adr: yyjson_mut_arr_add_str stored pointer to stack buffer without copy. Changed to yyjson_mut_arr_add_strcpy / yyjson_mut_obj_add_strcpy.
1 parent b00e1f7 commit c02d3c9

4 files changed

Lines changed: 2937 additions & 6 deletions

File tree

Makefile.cbm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ TEST_GO_LSP_SRCS = tests/test_go_lsp.c
283283

284284
TEST_C_LSP_SRCS = tests/test_c_lsp.c
285285

286-
TEST_INTEGRATION_SRCS = tests/test_integration.c
286+
TEST_INTEGRATION_SRCS = tests/test_integration.c tests/test_incremental.c
287287

288288
TEST_TRACES_SRCS = tests/test_traces.c
289289

src/mcp/mcp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,7 @@ static char *handle_detect_changes(cbm_mcp_server_t *srv, const char *args) {
25022502
continue;
25032503
}
25042504

2505-
yyjson_mut_arr_add_str(doc, changed, line);
2505+
yyjson_mut_arr_add_strcpy(doc, changed, line);
25062506
file_count++;
25072507

25082508
/* Find symbols defined in this file */
@@ -2514,9 +2514,9 @@ static char *handle_detect_changes(cbm_mcp_server_t *srv, const char *args) {
25142514
if (nodes[i].label && strcmp(nodes[i].label, "File") != 0 &&
25152515
strcmp(nodes[i].label, "Folder") != 0 && strcmp(nodes[i].label, "Project") != 0) {
25162516
yyjson_mut_val *item = yyjson_mut_obj(doc);
2517-
yyjson_mut_obj_add_str(doc, item, "name", nodes[i].name ? nodes[i].name : "");
2518-
yyjson_mut_obj_add_str(doc, item, "label", nodes[i].label);
2519-
yyjson_mut_obj_add_str(doc, item, "file", line);
2517+
yyjson_mut_obj_add_strcpy(doc, item, "name", nodes[i].name ? nodes[i].name : "");
2518+
yyjson_mut_obj_add_strcpy(doc, item, "label", nodes[i].label);
2519+
yyjson_mut_obj_add_strcpy(doc, item, "file", line);
25202520
yyjson_mut_arr_add_val(impacted, item);
25212521
}
25222522
}
@@ -2592,7 +2592,7 @@ static char *handle_manage_adr(cbm_mcp_server_t *srv, const char *args) {
25922592
while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r')) {
25932593
line[--len] = '\0';
25942594
}
2595-
yyjson_mut_arr_add_str(doc, sections, line);
2595+
yyjson_mut_arr_add_strcpy(doc, sections, line);
25962596
}
25972597
}
25982598
(void)fclose(fp);

0 commit comments

Comments
 (0)