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
chore(lint): keep the #1827 selector encoding within the memory-core ratchet
Martin Vogel6b7628bb6bbf
diff --git a/src/mcp/mcp.c b/src/mcp/mcp.cindex 7540b9a4d..4df0a4ffe 100644--- a/src/mcp/mcp.c+++ b/src/mcp/mcp.c@@ -1498,34 +1498,28 @@ static bool has_non_ascii_byte(const char *s) {* identity. Stored names never change; ASCII selectors keep their existing* validation; a selector that collapses to the "root" fallback is left alone* so it never selects the root project. */-static char *encode_bare_project_arg(char *project) {- if (!has_non_ascii_byte(project)) {- return project;- }- char *encoded = cbm_project_name_sanitize(project);- if (!encoded || strcmp(encoded, "root") == 0 || !cbm_validate_project_name(encoded)) {- free(encoded);- return project;- }- free(project);- return encoded;+static bool bare_project_encoding_usable(const char *encoded) {+ return strcmp(encoded, "root") != 0 && cbm_validate_project_name(encoded);}static char *normalize_project_arg(char *project) {if (!project) {return project;}- if (!strchr(project, '/') && !strchr(project, '\\')) {- return encode_bare_project_arg(project);- }-- project = canonicalize_repo_path_if_exists(project);- char *normalized = cbm_project_name_from_path(project);- if (normalized) {- free(project);- return normalized;+ char *normalized = NULL;+ bool bare = !strchr(project, '/') && !strchr(project, '\\');+ if (bare) {+ if (has_non_ascii_byte(project)) {+ normalized = cbm_project_name_sanitize(project);+ }+ } else {+ project = canonicalize_repo_path_if_exists(project);+ normalized = cbm_project_name_from_path(project);}- return project;+ /* Keep exactly one of the two strings and release the other. */+ bool use_normalized = normalized && (!bare || bare_project_encoding_usable(normalized));+ free(use_normalized ? project : normalized);+ return use_normalized ? normalized : project;}/* Forward decls — defined below alongside store resolution. */diff --git a/src/pipeline/fqn.c b/src/pipeline/fqn.cindex 2ee8c6bc5..96e959a0b 100644--- a/src/pipeline/fqn.c+++ b/src/pipeline/fqn.c@@ -432,12 +432,9 @@ char *cbm_project_name_from_path(const char *abs_path) {}char *cbm_project_name_sanitize(const char *name_path) {- if (!name_path || !name_path[0]) {- return strdup("root");- }-- /* Work on mutable copy */- char *path = strdup(name_path);+ /* Work on mutable copy. NULL and "" map to "" and fall through to the+ * empty-after-trim "root" return below. */+ char *path = strdup(name_path ? name_path : "");if (!path) {return NULL;}