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(mcp): clamp search_code context on both sides, add sink ceilings

Martin Vogel02bc9f2516b3
diff --git a/src/cypher/cypher.c b/src/cypher/cypher.c
index 3cc31f9d7..3be846b83 100644
--- a/src/cypher/cypher.c
+++ b/src/cypher/cypher.c
@@ -5138,7 +5138,11 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projec
/* Build initial bindings with early WHERE */
int bind_cap = scan_count > max_rows ? scan_count : (max_rows > 0 ? max_rows : SKIP_ONE);
- binding_t *bindings = malloc((bind_cap + SKIP_ONE) * sizeof(binding_t));
+ binding_t *bindings = malloc(((size_t)bind_cap + SKIP_ONE) * sizeof(binding_t));
+ if (!bindings) {
+ cbm_store_free_nodes(scanned, scan_count);
+ return CBM_NOT_FOUND; /* initial binding array refused */
+ }
int bind_count = 0;
const char *var_name = pat0->nodes[0].variable ? pat0->nodes[0].variable : CYP_ANON_HEAD_VAR;
@@ -5448,7 +5452,9 @@ int cbm_cypher_execute(cbm_store_t *store, const char *query, const char *projec
g_cypher_trail_truncated = 0;
g_cypher_truncated = false;
cypher_deadline_arm(); /* #601: start the wall-clock budget for this query */
- if (max_rows <= 0) {
+ /* max_rows sizes the initial binding array: non-positive means the
+ * ceiling, and nothing above the ceiling is ever materialized anyway. */
+ if (max_rows <= 0 || max_rows > CYPHER_RESULT_CEILING) {
max_rows = CYPHER_RESULT_CEILING;
}
diff --git a/src/cypher/cypher.h b/src/cypher/cypher.h
index 9e66b56ec..e9bd5f74c 100644
--- a/src/cypher/cypher.h
+++ b/src/cypher/cypher.h
@@ -334,7 +334,8 @@ typedef struct {
} cbm_cypher_result_t;
/* Execute a Cypher query against a store.
- * max_rows: limit on output rows (0 = use virtual ceiling of 100k).
+ * max_rows: limit on output rows; 0 or any value above the 100k ceiling uses
+ * the ceiling.
* project: project name filter (NULL = all projects).
* Returns -1 on error (check out->error for message). */
int cbm_cypher_execute(cbm_store_t *store, const char *query, const char *project, int max_rows,
diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c
index c877d5110..9f811a0ad 100644
--- a/src/mcp/mcp.c
+++ b/src/mcp/mcp.c
@@ -42,6 +42,10 @@ enum {
MCP_COMPARE_MAX_SCAN_LIMIT = 10000000,
MCP_COMPARE_SET_BYTE_BUDGET = 512 * 1024,
MCP_QUERY_MAX_VISIBLE_ROWS = 99998,
+ /* search_code `context`: lines of surrounding source per hit, the same
+ * ceiling as `source_max_lines`. Clamped at the handler and again where
+ * the window is computed, so the arithmetic never overflows. */
+ MCP_SEARCH_CONTEXT_MAX_LINES = 200,
/* max_output_tokens is model-neutral sizing guidance, not a tokenizer
* promise. The actual cross-platform contract is this deterministic UTF-8
* byte ceiling, applied only at whole semantic-unit boundaries. */
@@ -701,7 +705,7 @@ static const tool_def_t TOOLS[] = {
"\"string\"},\"file_pattern\":{\"type\":\"string\"},\"path_filter\":{\"type\":\"string\"},"
"\"mode\":{\"type\":\"string\","
"\"enum\":[\"compact\",\"full\",\"files\"],\"default\":\"compact\"},"
- "\"context\":{\"type\":\"integer\"},"
+ "\"context\":{\"type\":\"integer\",\"default\":0,\"minimum\":0,\"maximum\":200},"
"\"regex\":{\"type\":\"boolean\",\"default\":false},"
"\"debug\":{\"type\":\"boolean\",\"default\":false,"
"\"description\":\"Add scope_ms/scan_ms/enrich_ms phase timings.\"},"
@@ -13328,11 +13332,15 @@ static void attach_result_source(yyjson_mut_doc *doc, yyjson_mut_val *item, sear
}
}
} else if (context_lines > 0 && r->match_count > 0) {
- int ctx_start = r->match_lines[0] - context_lines;
- int ctx_end = r->match_lines[r->match_count - SKIP_ONE] + context_lines;
- if (ctx_start < SKIP_ONE) {
- ctx_start = SKIP_ONE;
- }
+ /* Bounded here as well as at the handler: the window must stay
+ * match ± MCP_SEARCH_CONTEXT_MAX_LINES for any caller, and the
+ * arithmetic must not overflow for any value. */
+ int ctx_lines = context_lines > MCP_SEARCH_CONTEXT_MAX_LINES ? MCP_SEARCH_CONTEXT_MAX_LINES
+ : context_lines;
+ int first_match = r->match_lines[0];
+ int last_match = r->match_lines[r->match_count - SKIP_ONE];
+ int ctx_start = first_match > ctx_lines ? first_match - ctx_lines : SKIP_ONE;
+ int ctx_end = last_match > INT_MAX - ctx_lines ? INT_MAX : last_match + ctx_lines;
char *ctx = read_file_lines(abs_path, ctx_start, ctx_end);
if (ctx) {
char *safe_context = sanitize_utf8_lossy(ctx);
@@ -14902,6 +14910,11 @@ static char *handle_search_code(cbm_mcp_server_t *srv, const char *args) {
int result_limit = cbm_mcp_get_int_arg(args, "result_limit", legacy_limit);
int result_offset = cbm_mcp_get_int_arg(args, "result_offset", 0);
int context_lines = cbm_mcp_get_int_arg(args, "context", 0);
+ if (context_lines < 0) {
+ context_lines = 0;
+ } else if (context_lines > MCP_SEARCH_CONTEXT_MAX_LINES) {
+ context_lines = MCP_SEARCH_CONTEXT_MAX_LINES;
+ }
bool use_regex = cbm_mcp_get_bool_arg(args, "regex");
uint64_t search_t0 = cbm_now_ms();
search_metrics_t metrics = {0};
diff --git a/tests/test_cypher.c b/tests/test_cypher.c
index abd334683..98c9b6a45 100644
--- a/tests/test_cypher.c
+++ b/tests/test_cypher.c
@@ -9,6 +9,7 @@
#include "../src/foundation/compat_thread.h"
#include <cypher/cypher.h>
#include <store/store.h>
+#include <limits.h>
#include <stdatomic.h>
#include <stdio.h>
#include <string.h>
@@ -4862,6 +4863,28 @@ TEST(cypher_exec_deadline_allows_normal_query_issue601) {
PASS();
}
+/* The caller-supplied output-row limit sizes the initial binding array; a
+ * value above the engine ceiling is clamped to it before that happens, and a
+ * value inside the ceiling still bounds the row count. */
+TEST(cypher_exec_max_rows_above_ceiling_is_clamped) {
+ cbm_store_t *s = setup_cypher_store();
+ cbm_cypher_result_t r = {0};
+
+ int rc = cbm_cypher_execute(s, "MATCH (f:Function)", "test", INT_MAX, &r);
+ ASSERT_EQ(rc, 0);
+ ASSERT_EQ(r.row_count, 4);
+ cbm_cypher_result_free(&r);
+
+ memset(&r, 0, sizeof(r));
+ rc = cbm_cypher_execute(s, "MATCH (f:Function)", "test", 2, &r);
+ ASSERT_EQ(rc, 0);
+ ASSERT_EQ(r.row_count, 2);
+ cbm_cypher_result_free(&r);
+
+ cbm_store_close(s);
+ PASS();
+}
+
/* ══════════════════════════════════════════════════════════════════ */
SUITE(cypher) {
@@ -5089,4 +5112,5 @@ SUITE(cypher) {
RUN_TEST(cypher_exec_prop_array_with_internal_commas);
RUN_TEST(cypher_exec_prop_string_with_escaped_quote);
RUN_TEST(cypher_single_hop_seeds_from_selective_far_node);
+ RUN_TEST(cypher_exec_max_rows_above_ceiling_is_clamped);
}
diff --git a/tests/test_mcp.c b/tests/test_mcp.c
index 22af972af..cdb873e8e 100644
--- a/tests/test_mcp.c
+++ b/tests/test_mcp.c
@@ -20983,6 +20983,346 @@ TEST(tool_result_add_notice_keeps_payload_shape_issue2144) {
PASS();
}
+/* ── Integer argument bounds ────────────────────────────────────────
+ * Sizing arguments are clamped on both sides at the handler. The fixture
+ * file is much longer than the `context` bound so the window is observable. */
+
+enum { CTX_FIXTURE_LINES = 1000, CTX_FIXTURE_NEEDLE_LINE = 500, CTX_BOUND = 200 };
+
+static bool write_context_fixture(const char *tmp, char *path, size_t path_sz) {
+ snprintf(path, path_sz, "%s/project/long.md", tmp);
+ FILE *fp = cbm_fopen(path, "wb");
+ if (!fp) {
+ return false;
+ }
+ for (int line = 1; line <= CTX_FIXTURE_LINES; line++) {
+ if (line == CTX_FIXTURE_NEEDLE_LINE) {
+ fprintf(fp, "needle-context-window\n");
+ } else {
+ fprintf(fp, "line %04d\n", line);
+ }
+ }
+ return fclose(fp) == 0;
+}
+
+static bool upsert_context_fixture_node(cbm_mcp_server_t *srv) {
+ cbm_store_t *st = cbm_mcp_server_store(srv);
+ if (!st) {
+ return false;
+ }
+ cbm_node_t node = {.project = "test-project",
+ .label = "Section",
+ .name = "long",
+ .qualified_name = "test-project.long",
+ .file_path = "long.md",
+ .start_line = 1,
+ .end_line = CTX_FIXTURE_LINES};
+ return cbm_store_upsert_node(st, &node) > 0;
+}
+
+static char *search_code_with_context(cbm_mcp_server_t *srv, const char *context_value) {
+ char req[256];
+ snprintf(req, sizeof(req),
+ "{\"project\":\"test-project\",\"pattern\":\"needle-context-window\","
+ "\"format\":\"json\",\"context\":%s,\"limit\":5}",
+ context_value);
+ char *resp = cbm_mcp_handle_tool(srv, "search_code", req);
+ if (!resp) {
+ return NULL;
+ }
+ char *inner = extract_text_content(resp);
+ free(resp);
+ return inner;
+}
+
+/* Row-0 context object of a json-format search_code answer, or NULL when the
+ * answer carries no context column. *doc_out owns the memory either way. */
+static yyjson_val *search_code_context_object(const char *inner, yyjson_doc **doc_out) {
+ *doc_out = yyjson_read(inner, strlen(inner), 0);
+ if (!*doc_out) {
+ return NULL;
+ }
+ yyjson_val *root = yyjson_doc_get_root(*doc_out);
+ yyjson_val *cols = yyjson_obj_get(root, "cols");
+ yyjson_val *rows = yyjson_obj_get(root, "rows");
+ if (!cols || !rows || yyjson_arr_size(rows) == 0) {
+ return NULL;
+ }
+ size_t col_count = yyjson_arr_size(cols);
+ for (size_t i = 0; i < col_count; i++) {
+ const char *col = yyjson_get_str(yyjson_arr_get(cols, i));
+ if (col && strcmp(col, "context") == 0) {
+ return yyjson_arr_get(yyjson_arr_get(rows, 0), i);
+ }
+ }
+ return NULL;
+}
+
+static int count_newlines(const char *s) {
+ int n = 0;
+ for (; *s; s++) {
+ n += *s == '\n';
+ }
+ return n;
+}
+
+TEST(search_code_context_window_is_bounded) {
+ char tmp[256];
+ cbm_mcp_server_t *srv = setup_snippet_server(tmp, sizeof(tmp));
+ ASSERT_NOT_NULL(srv);
+ char fixture[512];
+ ASSERT_TRUE(write_context_fixture(tmp, fixture, sizeof(fixture)));
+ ASSERT_TRUE(upsert_context_fixture_node(srv));
+
+ /* Far above the bound: the window is match ± 200, not the whole file. */
+ char *inner = search_code_with_context(srv, "100000");
+ ASSERT_NOT_NULL(inner);
+ yyjson_doc *doc = NULL;
+ yyjson_val *ctx = search_code_context_object(inner, &doc);
+ ASSERT_NOT_NULL(ctx);
+ ASSERT_EQ(yyjson_get_int(yyjson_obj_get(ctx, "context_start")),
+ CTX_FIXTURE_NEEDLE_LINE - CTX_BOUND);
+ const char *text = yyjson_get_str(yyjson_obj_get(ctx, "context"));
+ ASSERT_NOT_NULL(text);
+ ASSERT_EQ(count_newlines(text), 2 * CTX_BOUND + 1);
+ ASSERT_EQ(strncmp(text, "line 0300\n", 10), 0);
+ ASSERT_NOT_NULL(strstr(text, "\nneedle-context-window\n"));
+ ASSERT_NOT_NULL(strstr(text, "\nline 0700\n"));
+ ASSERT_NULL(strstr(text, "line 0701"));
+ yyjson_doc_free(doc);
+ free(inner);
+
+ /* Inside the bound the window is unchanged. */
+ inner = search_code_with_context(srv, "3");
+ ASSERT_NOT_NULL(inner);
+ ctx = search_code_context_object(inner, &doc);
+ ASSERT_NOT_NULL(ctx);
+ ASSERT_EQ(yyjson_get_int(yyjson_obj_get(ctx, "context_start")), CTX_FIXTURE_NEEDLE_LINE - 3);
+ text = yyjson_get_str(yyjson_obj_get(ctx, "context"));
+ ASSERT_NOT_NULL(text);
+ ASSERT_EQ(count_newlines(text), 7);
+ ASSERT_EQ(strncmp(text, "line 0497\n", 10), 0);
+ yyjson_doc_free(doc);
+ free(inner);
+
+ unlink(fixture);
+ cbm_mcp_server_free(srv);
+ cleanup_snippet_dir(tmp);
+ PASS();
+}
+
+TEST(search_code_context_extreme_values_answer_normally) {
+ char tmp[256];
+ cbm_mcp_server_t *srv = setup_snippet_server(tmp, sizeof(tmp));
+ ASSERT_NOT_NULL(srv);
+ char fixture[512];
+ ASSERT_TRUE(write_context_fixture(tmp, fixture, sizeof(fixture)));
+ ASSERT_TRUE(upsert_context_fixture_node(srv));
+
+ /* The largest value the argument can carry behaves exactly like the bound. */
+ char *inner = search_code_with_context(srv, "2147483647");
+ ASSERT_NOT_NULL(inner);
+ yyjson_doc *doc = NULL;
+ yyjson_val *ctx = search_code_context_object(inner, &doc);
+ ASSERT_NOT_NULL(ctx);
+ ASSERT_EQ(yyjson_get_int(yyjson_obj_get(ctx, "context_start")),
+ CTX_FIXTURE_NEEDLE_LINE - CTX_BOUND);
+ const char *text = yyjson_get_str(yyjson_obj_get(ctx, "context"));
+ ASSERT_NOT_NULL(text);
+ ASSERT_EQ(count_newlines(text), 2 * CTX_BOUND + 1);
+ yyjson_doc_free(doc);
+ free(inner);
+
+ /* A negative value means no context, exactly like 0: a normal answer. */
+ inner = search_code_with_context(srv, "-5");
+ ASSERT_NOT_NULL(inner);
+ ctx = search_code_context_object(inner, &doc);
+ ASSERT_NULL(ctx);
+ ASSERT_NOT_NULL(doc);
+ yyjson_val *rows = yyjson_obj_get(yyjson_doc_get_root(doc), "rows");
+ ASSERT_NOT_NULL(rows);
+ ASSERT_TRUE(yyjson_arr_size(rows) > 0);
+ yyjson_doc_free(doc);
+ free(inner);
+
+ unlink(fixture);
+ cbm_mcp_server_free(srv);
+ cleanup_snippet_dir(tmp);
+ PASS();
+}
+
+TEST(tool_query_graph_max_rows_above_ceiling_is_capped) {
+ cbm_mcp_server_t *srv = cbm_mcp_server_new(NULL);
+ ASSERT_NOT_NULL(srv);
+ cbm_store_t *store = cbm_mcp_server_store(srv);
+ ASSERT_NOT_NULL(store);
+ const char *project = "row-ceiling";
+ cbm_mcp_server_set_project(srv, project);
+ ASSERT_EQ(cbm_store_upsert_project(store, project, "/tmp/row-ceiling"), CBM_STORE_OK);
+ /* One row more than the visible ceiling (99998), so the cap is observable. */
+ enum { ROW_CEILING = 99998, ROWS = ROW_CEILING + 1 };
+ ASSERT_EQ(cbm_store_begin_bulk(store), CBM_STORE_OK);
+ ASSERT_EQ(cbm_store_begin(store), CBM_STORE_OK);
+ for (int i = 0; i < ROWS; i++) {
+ char name[32];
+ char qualified_name[64];
+ snprintf(name, sizeof(name), "row_%05d", i);
+ snprintf(qualified_name, sizeof(qualified_name), "row-ceiling.rows.%s", name);
+ cbm_node_t node = {.project = project,
+ .label = "Function",
+ .name = name,
+ .qualified_name = qualified_name,
+ .file_path = "rows.c",
+ .start_line = i + 1,
+ .end_line = i + 1};
+ ASSERT_GT(cbm_store_upsert_node(store, &node), 0);
+ }
+ ASSERT_EQ(cbm_store_commit(store), CBM_STORE_OK);
+ ASSERT_EQ(cbm_store_end_bulk(store), CBM_STORE_OK);
+
+ char *response = cbm_mcp_handle_tool(
+ srv, "query_graph",
+ "{\"project\":\"row-ceiling\",\"query\":\"MATCH (n) RETURN n.name\","
+ "\"format\":\"json\",\"max_rows\":2147483647,\"max_output_tokens\":1000000}");
+ ASSERT_NOT_NULL(response);
+ char *inner = extract_text_content(response);
+ ASSERT_NOT_NULL(inner);
+ yyjson_doc *doc = yyjson_read(inner, strlen(inner), 0);
+ ASSERT_NOT_NULL(doc);
+ yyjson_val *root = yyjson_doc_get_root(doc);
+ ASSERT_EQ(yyjson_get_int(yyjson_obj_get(root, "returned")), ROW_CEILING);
+ ASSERT_EQ(yyjson_get_int(yyjson_obj_get(root, "total")), ROWS);
+ ASSERT_TRUE(yyjson_get_bool(yyjson_obj_get(root, "has_more")));
+ yyjson_doc_free(doc);
+ free(inner);
+ free(response);
+ cbm_mcp_server_free(srv);
+ PASS();
+}
+
+TEST(tool_search_graph_limit_above_ceiling_is_capped) {
+ cbm_mcp_server_t *srv = cbm_mcp_server_new(NULL);
+ ASSERT_NOT_NULL(srv);
+ cbm_store_t *store = cbm_mcp_server_store(srv);
+ ASSERT_NOT_NULL(store);
+ const char *project = "limit-ceiling";
+ cbm_mcp_server_set_project(srv, project);
+ ASSERT_EQ(cbm_store_upsert_project(store, project, "/tmp/limit-ceiling"), CBM_STORE_OK);
+ enum { LIMIT_CEILING = 500, NODES = 600 };
+ ASSERT_EQ(cbm_store_begin(store), CBM_STORE_OK);
+ for (int i = 0; i < NODES; i++) {
+ char name[32];
+ char qualified_name[64];
+ snprintf(name, sizeof(name), "fn_%03d", i);
+ snprintf(qualified_name, sizeof(qualified_name), "limit-ceiling.m.%s", name);
+ cbm_node_t node = {.project = project,
+ .label = "Function",
+ .name = name,
+ .qualified_name = qualified_name,
+ .file_path = "m.c",
+ .start_line = i + 1,
+ .end_line = i + 1};
+ ASSERT_GT(cbm_store_upsert_node(store, &node), 0);
+ }
+ ASSERT_EQ(cbm_store_commit(store), CBM_STORE_OK);
+
+ char *response =
+ cbm_mcp_handle_tool(srv, "search_graph",
+ "{\"project\":\"limit-ceiling\",\"label\":\"Function\",\"limit\":9999,"
+ "\"format\":\"json\",\"max_output_tokens\":1000000}");
+ ASSERT_NOT_NULL(response);
+ char *inner = extract_text_content(response);
+ ASSERT_NOT_NULL(inner);
+ yyjson_doc *doc = yyjson_read(inner, strlen(inner), 0);
+ ASSERT_NOT_NULL(doc);
+ yyjson_val *root = yyjson_doc_get_root(doc);
+ ASSERT_EQ(yyjson_get_int(yyjson_obj_get(root, "returned")), LIMIT_CEILING);
+ ASSERT_EQ(yyjson_get_int(yyjson_obj_get(root, "total")), NODES);
+ ASSERT_TRUE(yyjson_get_bool(yyjson_obj_get(root, "has_more")));
+ yyjson_doc_free(doc);
+ free(inner);
+ free(response);
+ cbm_mcp_server_free(srv);
+ PASS();
+}
+
+TEST(tool_trace_cursor_truncated_after_leg_is_rejected) {
+ cbm_mcp_server_t *srv = cbm_mcp_server_new(NULL);
+ ASSERT_NOT_NULL(srv);
+ cbm_store_t *st = cbm_mcp_server_store(srv);
+ ASSERT_NOT_NULL(st);
+ const char *proj = "cursor-leg";
+ cbm_mcp_server_set_project(srv, proj);
+ ASSERT_EQ(cbm_store_upsert_project(st, proj, "/tmp/cursor-leg"), CBM_STORE_OK);
+ cbm_node_t hub = {.project = proj,
+ .label = "Function",
+ .name = "hub",
+ .qualified_name = "cursor-leg.h.hub",
+ .file_path = "h.c",
+ .start_line = 1,
+ .end_line = 9};
+ int64_t hid = cbm_store_upsert_node(st, &hub);
+ ASSERT_GT(hid, 0);
+ cbm_node_t callee = {.project = proj,
+ .label = "Function",
+ .name = "leaf",
+ .qualified_name = "cursor-leg.m.leaf",
+ .file_path = "m.c",
+ .start_line = 1,
+ .end_line = 3};
+ int64_t lid = cbm_store_upsert_node(st, &callee);
+ ASSERT_GT(lid, 0);
+ cbm_edge_t e = {.project = proj, .source_id = hid, .target_id = lid, .type = "CALLS"};
+ ASSERT_GT(cbm_store_insert_edge(st, &e), 0);
+
+ /* A token that ends right after the leg character has no generation,
+ * hash, hop or node fields to read; it is rejected like any other
+ * malformed token. */
+ static const char *const tokens[] = {"c1.o", "c1.i"};
+ for (size_t t = 0; t < sizeof(tokens) / sizeof(tokens[0]); t++) {
+ char req[256];
+ snprintf(req, sizeof(req),
+ "{\"project\":\"cursor-leg\",\"function_name\":\"hub\","
+ "\"direction\":\"outbound\",\"limit\":5,\"cursor\":\"%s\"}",
+ tokens[t]);
+ char *response = cbm_mcp_handle_tool(srv, "trace_call_path", req);
+ ASSERT_NOT_NULL(response);
+ char *inner = extract_text_content(response);
+ free(response);
+ ASSERT_NOT_NULL(inner);
+ ASSERT_NOT_NULL(strstr(inner, "invalid_cursor"));
+ free(inner);
+ }
+ cbm_mcp_server_free(srv);
+ PASS();
+}
+
+TEST(search_code_rejects_quote_in_file_pattern) {
+ char tmp[256];
+ cbm_mcp_server_t *srv = setup_snippet_server(tmp, sizeof(tmp));
+ ASSERT_NOT_NULL(srv);
+
+ /* Both quote characters are rejected before any file is scanned. */
+ static const char *const patterns[] = {"*.go\\\"", "*.go'"};
+ for (size_t p = 0; p < sizeof(patterns) / sizeof(patterns[0]); p++) {
+ char req[256];
+ snprintf(req, sizeof(req),
+ "{\"project\":\"test-project\",\"pattern\":\"HandleRequest\","
+ "\"file_pattern\":\"%s\",\"format\":\"json\"}",
+ patterns[p]);
+ char *response = cbm_mcp_handle_tool(srv, "search_code", req);
+ ASSERT_NOT_NULL(response);
+ char *inner = extract_text_content(response);
+ free(response);
+ ASSERT_NOT_NULL(inner);
+ ASSERT_NOT_NULL(strstr(inner, "path or file_pattern contains invalid characters"));
+ free(inner);
+ }
+ cbm_mcp_server_free(srv);
+ cleanup_snippet_dir(tmp);
+ PASS();
+}
+
SUITE(mcp) {
RUN_TEST(index_repository_async_and_status_refused_without_daemon_issue2144);
RUN_TEST(index_repository_schema_documents_async_polling_issue2144);
@@ -21361,6 +21701,12 @@ SUITE(mcp) {
RUN_TEST(autoindex_limit_guards_non_git_root_issue713);
RUN_TEST(autoindex_limit_admits_non_git_root_under_limit_issue713);
RUN_TEST(autoindex_limit_guards_git_root_issue713);
+ RUN_TEST(search_code_context_window_is_bounded);
+ RUN_TEST(search_code_context_extreme_values_answer_normally);
+ RUN_TEST(tool_query_graph_max_rows_above_ceiling_is_capped);
+ RUN_TEST(tool_search_graph_limit_above_ceiling_is_capped);
+ RUN_TEST(tool_trace_cursor_truncated_after_leg_is_rejected);
+ RUN_TEST(search_code_rejects_quote_in_file_pattern);
}
/* Kept separate so daemon-coordination regressions can be iterated without