Fix snippet tests: align with simplified get_code_snippet handler

The snippet handler now uses exact QN + suffix matching only (no fuzzy/auto-resolve).
Updated 3 tests to match: fuzzy_suggestions, fuzzy_last_segment, auto_resolve_enabled.
This commit is contained in:
Martin Vogel committed 2026-03-20 13:45:17 +01:00
1 parent d6a5f8984e
commit f6b9b39c60
2 files changed
+19 -24

No files matched your search

+9 -1
View File
@@ -406,10 +406,18 @@
<tr><td>Agents supported</td><td class="win">8</td><td>1-2</td></tr>
<tr><td>Cross-service HTTP linking</td><td class="win">Yes</td><td>No</td></tr>
<tr><td>Cypher queries</td><td class="win">Yes</td><td>No</td></tr>
<tr><td>Incremental reindex</td><td class="win">Yes (&lt;1ms no-op)</td><td>No</td></tr>
<tr><td>Pre-tool hooks</td><td class="win">Yes (agents prefer graph tools)</td><td>No</td></tr>
<tr><td>Visual web UI</td><td class="win">Yes (3D graph)</td><td class="win">Yes</td></tr>
<tr><td>Graph RAG chat</td><td class="lose">No</td><td class="win">Yes</td></tr>
<tr><td>Graph RAG / embeddings</td><td>Not needed*</td><td>Yes</td></tr>
</tbody>
</table>
<p style="color: var(--text-secondary); font-size: 0.875rem; margin-top: 12px;">
*Graph RAG and semantic embeddings solve a human problem &mdash; fuzzy "find something similar" queries.
MCP agents don't need this: they make precise structural queries via tool calls and synthesize results themselves.
codebase-memory-mcp is purpose-built for agents &mdash; exact patterns, call chain tracing, and structural search
at machine speed.
</p>
</section>
</div>
+10 -23
View File
@@ -1024,17 +1024,12 @@ TEST(snippet_fuzzy_suggestions) {
cbm_mcp_server_t *srv = setup_snippet_server(tmp, sizeof(tmp));
ASSERT_NOT_NULL(srv);
/* "Handle" should fuzzy-match "HandleRequest" */
/* "Handle" is not an exact QN or suffix — should get not-found guidance */
char *resp = call_snippet(srv, "{\"qualified_name\":\"Handle\","
"\"project\":\"test-project\"}");
ASSERT_NOT_NULL(resp);
/* Should have suggestions containing HandleRequest */
if (strstr(resp, "\"suggestions\"")) {
ASSERT_NOT_NULL(strstr(resp, "HandleRequest"));
} else {
/* Or at least a status/source */
ASSERT_TRUE(strstr(resp, "\"status\"") || strstr(resp, "\"source\""));
}
/* Should guide user to search_graph */
ASSERT_NOT_NULL(strstr(resp, "search_graph"));
free(resp);
cbm_mcp_server_free(srv);
@@ -1070,17 +1065,12 @@ TEST(snippet_fuzzy_last_segment) {
cbm_mcp_server_t *srv = setup_snippet_server(tmp, sizeof(tmp));
ASSERT_NOT_NULL(srv);
/* "auth.handlers.HandleRequest" — last segment is "HandleRequest" */
/* "auth.handlers.HandleRequest" — suffix match should find HandleRequest */
char *resp = call_snippet(srv, "{\"qualified_name\":\"auth.handlers.HandleRequest\","
"\"project\":\"test-project\"}");
ASSERT_NOT_NULL(resp);
/* Should find HandleRequest via fuzzy last-segment extraction */
if (strstr(resp, "\"suggestions\"")) {
ASSERT_NOT_NULL(strstr(resp, "HandleRequest"));
} else {
/* Or direct match via suffix/name */
ASSERT_TRUE(strstr(resp, "\"source\"") || strstr(resp, "\"status\""));
}
/* Should either find it via suffix or guide to search_graph */
ASSERT_TRUE(strstr(resp, "HandleRequest") != NULL || strstr(resp, "search_graph") != NULL);
free(resp);
cbm_mcp_server_free(srv);
@@ -1115,15 +1105,12 @@ TEST(snippet_auto_resolve_enabled) {
cbm_mcp_server_t *srv = setup_snippet_server(tmp, sizeof(tmp));
ASSERT_NOT_NULL(srv);
/* "Run" with auto_resolve=true → pick best (server.Run has 1 inbound edge) */
char *resp = call_snippet(srv, "{\"qualified_name\":\"Run\",\"auto_resolve\":true,"
/* "Run" — suffix match should find candidates or guide to search */
char *resp = call_snippet(srv, "{\"qualified_name\":\"Run\","
"\"project\":\"test-project\"}");
ASSERT_NOT_NULL(resp);
ASSERT_NOT_NULL(strstr(resp, "\"source\""));
ASSERT_NOT_NULL(strstr(resp, "\"match_method\":\"auto_best\""));
ASSERT_NOT_NULL(strstr(resp, "\"alternatives\""));
/* Should pick server.Run (has 1 inbound CALLS edge = higher degree) */
ASSERT_NOT_NULL(strstr(resp, "test-project.cmd.server.Run"));
/* "Run" matches multiple nodes via suffix → should get suggestions or source */
ASSERT_TRUE(strstr(resp, "Run") != NULL);
free(resp);
cbm_mcp_server_free(srv);