Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(test): cancel-probe tools updated to the real ingest_traces contract

Martin Vogel7f2c56321064
diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c
index d948d757b..e2fc55049 100644
--- a/src/mcp/mcp.c
+++ b/src/mcp/mcp.c
@@ -11148,7 +11148,7 @@ static char *adr_read_legacy_file(const char *root_path) {
* that reader before opening a dedicated writer because atomic publication uses
* a self-contained DELETE-mode database that switches back to WAL on write. */
static cbm_store_t *open_store_for_write(cbm_mcp_server_t *srv, cbm_store_t *resolved,
- cbm_store_t **owned_rw) {
+ cbm_store_t **owned_rw) {
if (!srv || !resolved || !owned_rw) {
return NULL;
}
diff --git a/tests/test_mcp.c b/tests/test_mcp.c
index 6b3318d0f..1940f48de 100644
--- a/tests/test_mcp.c
+++ b/tests/test_mcp.c
@@ -5758,8 +5758,17 @@ TEST(tool_outer_request_scope_preserves_predispatch_cancel) {
strstr(cancelled_response, "\"isError\":true");
cbm_mcp_server_request_scope_end(srv);
- char *next_response = srv ? cbm_mcp_handle_tool(srv, "ingest_traces", "{\"traces\":[]}") : NULL;
- bool next_response_clean = next_response && strstr(next_response, "accepted") &&
+ /* Clean-token probe: a valid ingest (unresolved names store nothing)
+ * must succeed normally — the cancel must not leak into it. The old
+ * probe sent traces:[] and expected the stub's "accepted"; empty
+ * traces are a tool error under the real contract. */
+ char *next_response =
+ srv ? cbm_mcp_handle_tool(
+ srv, "ingest_traces",
+ "{\"project\":\"outer-scope-cancel-adr\",\"traces\":"
+ "[{\"caller\":\"never-indexed-a\",\"callee\":\"never-indexed-b\"}]}")
+ : NULL;
+ bool next_response_clean = next_response && strstr(next_response, "\"status\":\"stored\"") &&
!strstr(next_response, "cancelled") &&
!strstr(next_response, "\"isError\":true");
@@ -5819,9 +5828,12 @@ TEST(tool_index_repository_early_raw_cancel_survives_index_entry) {
snprintf(db_path, sizeof(db_path), "%s/%s.db", cache, project ? project : "missing-project");
bool no_project_published = !cbm_file_exists(db_path);
- char *next_response = srv ? cbm_mcp_handle_tool(srv, "ingest_traces", "{\"traces\":[]}") : NULL;
- bool next_response_clean = next_response && strstr(next_response, "accepted") &&
- !strstr(next_response, "cancelled") &&
+ /* Clean-token probe: no project exists here by design (the index was
+ * cancelled), so probe with the project-free list_projects — the next
+ * request must simply run clean, unpoisoned by the cancel. The old
+ * probe leaned on the ingest_traces stub, which accepted anything. */
+ char *next_response = srv ? cbm_mcp_handle_tool(srv, "list_projects", "{}") : NULL;
+ bool next_response_clean = next_response && !strstr(next_response, "cancelled") &&
!strstr(next_response, "\"isError\":true");
free(cancelled_response);