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.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(search): treat wildcard-free file_pattern as a path substring (#200)
Martin Vogel53be053d3fd8
diff --git a/src/store/store.c b/src/store/store.cindex 34d624928..16b28e8ef 100644--- a/src/store/store.c+++ b/src/store/store.c@@ -2359,6 +2359,22 @@ static int search_where_basic(const cbm_search_params_t *params, char *where, in}if (params->file_pattern) {char *lp = cbm_glob_to_like(params->file_pattern);+ /* A file_pattern with no glob wildcards is treated as a path-substring+ * match (issue #200): file_pattern="offer-server" should match+ * "src/offer-server/x.js", not only a path equal to "offer-server".+ * Patterns that DO contain * / ? keep their explicit glob semantics. */+ if (lp && !strchr(params->file_pattern, '*') && !strchr(params->file_pattern, '?')) {+ size_t lplen = strlen(lp);+ char *contains = malloc(lplen + 3);+ if (contains) {+ contains[0] = '%';+ memcpy(contains + 1, lp, lplen);+ contains[lplen + 1] = '%';+ contains[lplen + 2] = '\0';+ free(lp);+ lp = contains;+ }+ }int pool_was_full = (pool->count >= ST_LIKE_POOL_MAX);like_pool_add(pool, lp);if (!pool_was_full && lp) {diff --git a/tests/test_store_search.c b/tests/test_store_search.cindex 6675409eb..ded121a27 100644--- a/tests/test_store_search.c+++ b/tests/test_store_search.c@@ -104,6 +104,32 @@ TEST(store_search_by_file_pattern) {PASS();}+/* Issue #200: a wildcard-free file_pattern must match as a path substring,+ * not require the path to equal it. "offer-server" should match+ * "src/offer-server/decision.js". */+TEST(store_search_file_pattern_substring_issue200) {+ cbm_store_t *s = cbm_store_open_memory();+ cbm_store_upsert_project(s, "test", "/tmp/test");+ cbm_node_t n = {.project = "test",+ .label = "Function",+ .name = "evaluate",+ .qualified_name = "test.offer.evaluate",+ .file_path = "src/offer-server/decision.js"};+ cbm_store_upsert_node(s, &n);++ cbm_search_params_t params = {+ .project = "test", .file_pattern = "offer-server", .min_degree = -1, .max_degree = -1};+ cbm_search_output_t out = {0};+ int rc = cbm_store_search(s, ¶ms, &out);+ ASSERT_EQ(rc, CBM_STORE_OK);+ ASSERT_EQ(out.count, 1);+ ASSERT_STR_EQ(out.results[0].node.name, "evaluate");+ cbm_store_search_free(&out);++ cbm_store_close(s);+ PASS();+}+/* ── Search pagination ──────────────────────────────────────────── */TEST(store_search_pagination) {@@ -1209,6 +1235,7 @@ SUITE(store_search) {RUN_TEST(store_search_by_label);RUN_TEST(store_search_by_name_pattern);RUN_TEST(store_search_by_file_pattern);+ RUN_TEST(store_search_file_pattern_substring_issue200);RUN_TEST(store_search_pagination);RUN_TEST(store_search_degree_filter);RUN_TEST(store_search_all);