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: address review feedback on external-import-shadow guard
Yyunozora8293c498ca6
diff --git a/src/pipeline/registry.c b/src/pipeline/registry.cindex ff78c4354..6c0cdb42a 100644--- a/src/pipeline/registry.c+++ b/src/pipeline/registry.c@@ -31,6 +31,7 @@ enum { REG_MAX_CANDIDATES = 256 };#include "foundation/dyn_array.h"#include "foundation/platform.h"+#include <ctype.h>#include <math.h>#include <stdio.h>#include <stdlib.h>@@ -502,10 +503,29 @@ bool cbm_suppress_weak_local_binding_call(bool enabled, bool callee_is_locally_b}/* A module specifier that names a path inside the indexed tree ("./x", "../x",- * "/abs/x") rather than an external package. Package specifiers are everything- * else — "drizzle-orm", "rxjs/operators", "@scope/pkg". */+ * "/abs/x", and on Windows "C:\x", "C:/x", "\\server\share\x") rather than an+ * external package. Package specifiers are everything else — "drizzle-orm",+ * "rxjs/operators", "@scope/pkg". Windows paths must count as in-tree here:+ * pr-smoke runs this pipeline on Windows, and misclassifying a drive-letter or+ * UNC specifier as "external" is exactly the false-external edge this guard+ * exists to prevent (#1355). */static bool specifier_is_relative(const char *module_path) {- return module_path && (module_path[0] == '.' || module_path[0] == '/');+ if (!module_path || !module_path[0]) {+ return false;+ }+ if (module_path[0] == '.' || module_path[0] == '/') {+ return true;+ }+ /* UNC share: \\server\share\... */+ if (module_path[0] == '\\' && module_path[1] == '\\') {+ return true;+ }+ /* Drive-letter absolute path: C:\repo\... or C:/repo/... */+ if (isalpha((unsigned char)module_path[0]) && module_path[1] == ':' &&+ (module_path[2] == '\\' || module_path[2] == '/')) {+ return true;+ }+ return false;}static bool import_map_binds(const char **import_map_keys, int import_map_count,diff --git a/tests/test_pipeline.c b/tests/test_pipeline.cindex fd6d51855..863254fda 100644--- a/tests/test_pipeline.c+++ b/tests/test_pipeline.c@@ -4976,6 +4976,17 @@ static int count_nodes_named(cbm_store_t *s, const char *project, const char *na* (axios.get, api.patch on a renamed-axios instance, supertest request(app).get).* The regex false edge must stay suppressed in parallel too. CBM_WORKERS forces* >1 worker so the parallel path is taken regardless of the host core count. */+/* #1355: padding count for write_external_import_shadow_fixture, deliberately+ * well past MIN_FILES_FOR_PARALLEL (=50, a private #define in+ * src/pipeline/pipeline.c — not exposed to tests, so this cannot be a+ * static_assert against it) rather than sitting right at the threshold. The+ * margin, not the exact value, is what the test depends on: a modest bump to+ * the real threshold must not silently drop this fixture back onto the+ * sequential-only path and leave the parallel resolver unexercised. Same+ * pattern as ET_PARALLEL_PAD / CP_PARALLEL_PAD in test_edge_types_probe.c /+ * test_convergence_probe.c. */+enum { EXTERNAL_IMPORT_SHADOW_PARALLEL_PAD = 64 };+/* #1355: write the shared external-import-shadow fixture into `dir`.* `pad_files` filler modules push the run over MIN_FILES_FOR_PARALLEL so the* same tree can be indexed by both resolvers. */@@ -5066,11 +5077,13 @@ TEST(pipeline_external_import_shadow_not_bound_to_local_homonym_issue1355) {/* Enough files that CBM_WORKERS can take the fused-parallel path; the same* tree is then indexed by each resolver in turn, because the guard lives at* two independent emit sites (pass_calls.c and pass_parallel.c). */- write_external_import_shadow_fixture(tmp, 50);+ write_external_import_shadow_fixture(tmp, EXTERNAL_IMPORT_SHADOW_PARALLEL_PAD);- char *old_workers = getenv("CBM_WORKERS");+ /* getenv() returns a pointer into the process environment that must be+ * treated as read-only; strdup() below only ever reads through it. */+ const char *old_workers = getenv("CBM_WORKERS");char *saved_workers = old_workers ? strdup(old_workers) : NULL;- char *old_single = getenv("CBM_INDEX_SINGLE_THREAD");+ const char *old_single = getenv("CBM_INDEX_SINGLE_THREAD");char *saved_single = old_single ? strdup(old_single) : NULL;cbm_setenv("CBM_INDEX_SINGLE_THREAD", "1", 1);diff --git a/tests/test_registry.c b/tests/test_registry.cindex eb47679f3..d4d7545aa 100644--- a/tests/test_registry.c+++ b/tests/test_registry.c@@ -1059,6 +1059,39 @@ TEST(external_import_shadow_relative_binding_wins_the_tie) {PASS();}+TEST(external_import_shadow_windows_relative_specifier_kept) {+ /* #1355 follow-up: a Windows-style specifier —+ * drive-letter absolute (`C:\...` / `C:/...`) or UNC share (`\\server\...`)+ * — names a path inside the indexed tree exactly like a POSIX "./x" or+ * "/x". pr-smoke runs this pipeline on Windows; before this fix these+ * specifiers fell through to "external package" and the same-name guess+ * they'd otherwise validate got suppressed on that platform only. */+ CBMImport imports[] = {+ {.local_name = "eq", .module_path = "C:\\repo\\src\\text-utils.ts"},+ {.local_name = "sql", .module_path = "C:/repo/src/text-utils.ts"},+ {.local_name = "normalize", .module_path = "\\\\server\\share\\text-utils.ts"},+ };+ CBMImportArray arr = {.items = imports, .count = 3, .cap = 3};++ /* None of these materialized an import-map key (as if resolution missed+ * them, mirroring the reported scenario) — the specifier alone must still+ * keep the edge because it is in-tree, not external. RED before the fix+ * (specifier_is_relative saw '.' / '/' only, so all three were classified+ * external and suppressed); GREEN after. */+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, NULL, 0));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("sql", "unique_name", &arr, NULL, 0));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("normalize", "unique_name", &arr, NULL, 0));+ /* A bare package specifier without any drive letter or leading separator+ * (e.g. "drizzle-orm") must still be external — this predicate must not+ * become "anything with a colon or backslash". */+ CBMImport pkg_only[] = {+ {.local_name = "eq", .module_path = "drizzle-orm"},+ };+ CBMImportArray parr = {.items = pkg_only, .count = 1, .cap = 1};+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &parr, NULL, 0));+ PASS();+}+/* ── Suite ─────────────────────────────────────────────────────── *//* Method call THROUGH an imported symbol that is itself an indexed node@@ -1161,4 +1194,5 @@ SUITE(registry) {RUN_TEST(external_import_shadow_drops_package_bound_bare_call);RUN_TEST(external_import_shadow_keeps_everything_else);RUN_TEST(external_import_shadow_relative_binding_wins_the_tie);+ RUN_TEST(external_import_shadow_windows_relative_specifier_kept);}