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(registry): keep workspace-sibling imports out of the external-import guard
Yyunozor797a11a15eff
diff --git a/src/pipeline/pass_calls.c b/src/pipeline/pass_calls.cindex 734e9b956..7fc6bc423 100644--- a/src/pipeline/pass_calls.c+++ b/src/pipeline/pass_calls.c@@ -675,7 +675,7 @@ static int resolve_single_call(cbm_pipeline_ctx_t *ctx, CBMCall *call,* #725 guard, after the service-pattern bypasses above, so no HTTP/route* edge can be lost to it. */if (cbm_suppress_external_import_shadow(call->callee_name, res.strategy, file_imports, imp_keys,- imp_count)) {+ imp_count, cbm_pipeline_get_pkgmap())) {return 0;}emit_classified_edge(ctx, call, source_node, target_node, &res, module_qn, imp_keys, imp_vals,diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.cindex 76ed4e9a4..a57d594cf 100644--- a/src/pipeline/pass_parallel.c+++ b/src/pipeline/pass_parallel.c@@ -2571,7 +2571,7 @@ static void resolve_file_calls(resolve_ctx_t *rc, resolve_worker_state_t *ws, CB}if (target_node && source_node->id != target_node->id &&cbm_suppress_external_import_shadow(call->callee_name, res.strategy, &result->imports,- imp_keys, imp_count)) {+ imp_keys, imp_count, cbm_pipeline_get_pkgmap())) {/* #1355: same guard as pass_calls.c — a bare call bound by an* external package import must not become a CALLS edge to an* unrelated project symbol of the same name. */diff --git a/src/pipeline/pipeline.h b/src/pipeline/pipeline.hindex f24cc3045..45ef74f84 100644--- a/src/pipeline/pipeline.h+++ b/src/pipeline/pipeline.h@@ -19,8 +19,9 @@#include <stdint.h>#include <stdatomic.h>-#include "discover/discover.h" /* cbm_ignored_file_t (#963) */-#include "foundation/constants.h" /* CBM_SZ_512 */+#include "discover/discover.h" /* cbm_ignored_file_t (#963) */+#include "foundation/constants.h" /* CBM_SZ_512 */+#include "foundation/hash_table.h" /* CBMHashTable (#1355 pkgmap lookup) *//* Forward declarations */typedef struct cbm_store cbm_store_t;@@ -297,10 +298,14 @@ bool cbm_suppress_weak_local_binding_call(bool enabled, bool callee_is_locally_b* `import { eq } from "drizzle-orm"` must not make `eq(...)` a CALLS edge to an* unrelated project `eq`. A name the import map does bind, a relative* specifier, a member/qualified callee, and every import-/receiver-aware- * strategy are all kept. Pure; unit-tested in test_registry.c. */+ * strategy are all kept. `indexed_packages` is the pipeline package map: a+ * specifier naming a package the tree itself declares (a workspace sibling)+ * counts as in-tree and is kept too; NULL disables that check.+ * Pure; unit-tested in test_registry.c. */bool cbm_suppress_external_import_shadow(const char *callee_name, const char *strategy,const CBMImportArray *file_imports,- const char **import_map_keys, int import_map_count);+ const char **import_map_keys, int import_map_count,+ const CBMHashTable *indexed_packages);/* #725: drop a suffix_match CALLS edge when the caller language and the* target file's language disagree. unique_name (candidates == 1) is #1572diff --git a/src/pipeline/registry.c b/src/pipeline/registry.cindex 6c0cdb42a..adbe2c713 100644--- a/src/pipeline/registry.c+++ b/src/pipeline/registry.c@@ -528,6 +528,43 @@ static bool specifier_is_relative(const char *module_path) {return false;}+/* True when the specifier names a package that the indexed tree DECLARES —+ * a workspace sibling, not a third-party dependency. `indexed_packages` is the+ * pipeline's package map, keyed by the `name` of every manifest found in the+ * tree (package.json, go.mod, Cargo.toml, ...), so a pnpm/npm/cargo workspace+ * registers each of its own packages here.+ *+ * The key is the bare package name, so a subpath specifier is walked back one+ * slash at a time: "drizzle-orm/pg-core" -> "drizzle-orm". Scoped names keep+ * their leading segment ("@scope/pkg/sub" -> "@scope/pkg" -> "@scope").+ *+ * Deliberately a NAME test, not a resolution test. A workspace package usually+ * points `main`/`module` at a build artifact ("./index.cjs") that is not+ * checked in, so asking whether the entry file exists in the graph answers+ * "no" for exactly the monorepos this has to protect. Whether the tree claims+ * the name is decidable from the manifest alone. */+static bool specifier_names_indexed_package(const CBMHashTable *indexed_packages,+ const char *module_path) {+ if (!indexed_packages || !module_path || !module_path[0]) {+ return false;+ }+ if (cbm_ht_has(indexed_packages, module_path)) {+ return true;+ }+ char buf[CBM_SZ_512];+ if (strlen(module_path) >= sizeof(buf)) {+ return false;+ }+ snprintf(buf, sizeof(buf), "%s", module_path);+ for (char *slash = strrchr(buf, '/'); slash != NULL; slash = strrchr(buf, '/')) {+ *slash = '\0';+ if (cbm_ht_has(indexed_packages, buf)) {+ return true;+ }+ }+ return false;+}+static bool import_map_binds(const char **import_map_keys, int import_map_count,const char *local_name) {if (!import_map_keys || import_map_count <= 0) {@@ -569,10 +606,17 @@ static bool import_map_binds(const char **import_map_keys, int import_map_count,* relative and a package specifier keeps the edge — the relative binding wins* the tie explicitly, so the outcome does not depend on import order.*+ * `indexed_packages` extends that same reasoning to workspace monorepos, where+ * a BARE specifier also names in-tree code: `import { eq } from "drizzle-orm"`+ * inside the drizzle-orm repository is a sibling package, not a dependency. A+ * specifier the tree's own manifests claim is treated exactly like a relative+ * one. NULL disables the check and restores the specifier-shape-only contract.+ ** Pure + side-effect-free so the contract is unit-testable without a pipeline. */bool cbm_suppress_external_import_shadow(const char *callee_name, const char *strategy,const CBMImportArray *file_imports,- const char **import_map_keys, int import_map_count) {+ const char **import_map_keys, int import_map_count,+ const CBMHashTable *indexed_packages) {if (!callee_name || !callee_name[0] || !strategy || !strategy[0]) {return false;}@@ -595,7 +639,8 @@ bool cbm_suppress_external_import_shadow(const char *callee_name, const char *stif (!imp->local_name || !imp->module_path || strcmp(imp->local_name, callee_name) != 0) {continue;}- if (specifier_is_relative(imp->module_path)) {+ if (specifier_is_relative(imp->module_path) ||+ specifier_names_indexed_package(indexed_packages, imp->module_path)) {return false; /* an in-tree binding for this name — never suppress */}external_binding = true;diff --git a/tests/test_pipeline.c b/tests/test_pipeline.cindex 863254fda..f772acc69 100644--- a/tests/test_pipeline.c+++ b/tests/test_pipeline.c@@ -5112,6 +5112,116 @@ TEST(pipeline_external_import_shadow_not_bound_to_local_homonym_issue1355) {PASS();}+/* #1355 / #1732: the same tree, but the bare specifier now names a WORKSPACE+ * package that the repository itself ships. `main` deliberately points at a+ * build artifact that is not checked in — the shape every real monorepo has,+ * and the reason an entry-file lookup cannot answer this question. */+static void write_workspace_shadow_fixture(const char *dir, int pad_files) {+ /* One directory level only: write_temp_file's mkdir is documented as+ * "simple version, one level", and a deeper path fails silently — which+ * makes the fixture look healthy while the file never lands. */+ write_temp_file(dir, "lib/package.json",+ "{\n \"name\": \"@fixture/lib\",\n \"main\": \"./dist/index.js\"\n}\n");+ write_temp_file(dir, "lib/index.ts",+ "export function wsEq(a: string, b: string): boolean {\n"+ " return a === b;\n"+ "}\n");+ write_temp_file(dir, "app/package.json", "{\n \"name\": \"@fixture/app\"\n}\n");+ /* The lone project symbol named wsSpec — an ordinary local helper that a+ * project-wide guess would happily bind an external `wsSpec` to. */+ write_temp_file(dir, "app/spec-helpers.ts",+ "export function wsSpec(label: string): string {\n"+ " return label;\n"+ "}\n");+ write_temp_file(dir, "app/query.ts",+ "import { wsEq } from '@fixture/lib';\n"+ "import { wsSpec } from 'vitest';\n"+ "export function wsBuild(id: string): unknown {\n"+ " return [wsEq(id, id), wsSpec('case')];\n"+ "}\n");+ for (int i = 0; i < pad_files; i++) {+ char name[64];+ char body[128];+ snprintf(name, sizeof(name), "app/pad_%02d.ts", i);+ snprintf(body, sizeof(body), "export function wsPad%02d(): number { return %d; }\n", i, i);+ write_temp_file(dir, name, body);+ }+}++static int assert_workspace_shadow_contract(const char *dir, const char *db_name) {+ char db_path[512];+ snprintf(db_path, sizeof(db_path), "%s/%s", dir, db_name);+ cbm_pipeline_t *p = cbm_pipeline_new(dir, db_path, CBM_MODE_FULL);+ if (!p) {+ return 1;+ }+ if (cbm_pipeline_run(p) != 0) {+ cbm_pipeline_free(p);+ return 2;+ }+ const char *project = cbm_pipeline_project_name(p);+ cbm_store_t *s = cbm_store_open_path(db_path);+ if (!s) {+ cbm_pipeline_free(p);+ return 3;+ }+ int rc = 0;+ /* (1) the workspace sibling: the tree declares @fixture/lib, so the bare+ * specifier is in-project and the fallback keeps its chance. RED without+ * the package-map check — this is the 1377-edge class measured on+ * drizzle-team/drizzle-orm. */+ if (!cross_file_call_exists(s, project, "wsBuild", "wsEq")) {+ rc = 4;+ }+ /* (2) a genuine third-party package in the very same file is still cut:+ * the check must not disarm the guard wholesale. */+ if (rc == 0 && cross_file_call_exists(s, project, "wsBuild", "wsSpec")) {+ rc = 5;+ }+ cbm_store_close(s);+ cbm_pipeline_free(p);+ return rc;+}++TEST(pipeline_external_import_shadow_keeps_workspace_sibling_issue1355) {+ char tmp[256];+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_ws_import_shadow_XXXXXX");+ if (!cbm_mkdtemp(tmp)) {+ FAIL("tmpdir");+ }+ write_workspace_shadow_fixture(tmp, EXTERNAL_IMPORT_SHADOW_PARALLEL_PAD);++ const char *old_workers = getenv("CBM_WORKERS");+ char *saved_workers = old_workers ? strdup(old_workers) : NULL;+ 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);+ int sequential = assert_workspace_shadow_contract(tmp, "ws-sequential.db");++ cbm_unsetenv("CBM_INDEX_SINGLE_THREAD");+ cbm_setenv("CBM_WORKERS", "4", 1);+ int parallel = assert_workspace_shadow_contract(tmp, "ws-parallel.db");++ if (saved_workers) {+ cbm_setenv("CBM_WORKERS", saved_workers, 1);+ free(saved_workers);+ } else {+ cbm_unsetenv("CBM_WORKERS");+ }+ if (saved_single) {+ cbm_setenv("CBM_INDEX_SINGLE_THREAD", saved_single, 1);+ free(saved_single);+ } else {+ cbm_unsetenv("CBM_INDEX_SINGLE_THREAD");+ }+ th_rmtree(tmp);++ ASSERT_EQ(sequential, 0);+ ASSERT_EQ(parallel, 0);+ PASS();+}+TEST(pipeline_tsjs_receiver_parallel_keeps_service_edges) {char tmp[256];snprintf(tmp, sizeof(tmp), "/tmp/cbm_tsjs_par_XXXXXX");@@ -13461,6 +13571,7 @@ SUITE(pipeline) {RUN_TEST(pipeline_python_bare_local_binding_suppresses_weak_edge);RUN_TEST(pipeline_python_bare_local_binding_parallel_suppresses_weak_edge);RUN_TEST(pipeline_external_import_shadow_not_bound_to_local_homonym_issue1355);+ RUN_TEST(pipeline_external_import_shadow_keeps_workspace_sibling_issue1355);RUN_TEST(pipeline_parallel_python_cross_only_dunder_gets_synthetic_carrier);RUN_TEST(pipeline_parallel_rust_cross_only_macro_hidden_gets_synthetic_carrier);RUN_TEST(pipeline_arg_url_rejects_non_http_slash_arguments);diff --git a/tests/test_registry.c b/tests/test_registry.cindex d4d7545aa..d8494ce82 100644--- a/tests/test_registry.c+++ b/tests/test_registry.c@@ -970,6 +970,9 @@ TEST(weak_call_guards_share_one_drop_list) {}ASSERT_EQ(member, binding);}+ PASS();+}+TEST(external_import_shadow_drops_package_bound_bare_call) {/* #1355: `import { eq, sql } from "drizzle-orm"` binds both names to a* package outside the indexed tree, so no import-map key exists for them and@@ -983,14 +986,14 @@ TEST(external_import_shadow_drops_package_bound_bare_call) {/* Only the relative import materialized an IMPORTS edge. */const char *keys[] = {"users"};- ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, keys, 1));- ASSERT_TRUE(cbm_suppress_external_import_shadow("sql", "unique_name", &arr, keys, 1));- ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "suffix_match", &arr, keys, 1));- ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "field_type_hint", &arr, keys, 1));- ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "fuzzy", &arr, keys, 1));+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, keys, 1, NULL));+ ASSERT_TRUE(cbm_suppress_external_import_shadow("sql", "unique_name", &arr, keys, 1, NULL));+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "suffix_match", &arr, keys, 1, NULL));+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "field_type_hint", &arr, keys, 1, NULL));+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "fuzzy", &arr, keys, 1, NULL));/* A file whose imports all failed to materialize is still covered: the* evidence is the import statement, not the map. */- ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, NULL, 0));+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, NULL, 0, NULL));PASS();}@@ -1008,34 +1011,42 @@ TEST(external_import_shadow_keeps_everything_else) {const int nkeys = 2;/* Import-/receiver-/module-aware strategies are never this guard's business. */- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "import_map", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "import_map_suffix", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "same_module", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "qualified_suffix", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "lsp_ts_import", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "lsp_ts_method", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "service_pattern", &arr, keys, nkeys));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "import_map", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("eq", "import_map_suffix", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "same_module", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("eq", "qualified_suffix", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("eq", "lsp_ts_import", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("eq", "lsp_ts_method", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("eq", "service_pattern", &arr, keys, nkeys, NULL));/* A relative specifier names a path inside the tree — a missing IMPORTS edge* there is an in-project gap, not an external binding. */ASSERT_FALSE(- cbm_suppress_external_import_shadow("normalize", "unique_name", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("normalize", "unique_name", &arr, NULL, 0));- /* A package the import map DOES bind resolved in-graph (workspace package). */+ cbm_suppress_external_import_shadow("normalize", "unique_name", &arr, keys, nkeys, NULL));ASSERT_FALSE(- cbm_suppress_external_import_shadow("getRootContainer", "unique_name", &arr, keys, nkeys));+ cbm_suppress_external_import_shadow("normalize", "unique_name", &arr, NULL, 0, NULL));+ /* A package the import map DOES bind resolved in-graph (workspace package). */+ ASSERT_FALSE(cbm_suppress_external_import_shadow("getRootContainer", "unique_name", &arr, keys,+ nkeys, NULL));/* A name the file never imports (called with no import at all). */- ASSERT_FALSE(cbm_suppress_external_import_shadow("helper", "unique_name", &arr, keys, nkeys));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("helper", "unique_name", &arr, keys, nkeys, NULL));/* Member and package/namespace-qualified callees belong to the* receiver-aware guards, not to this one. */- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq.apply", "unique_name", &arr, keys, nkeys));ASSERT_FALSE(- cbm_suppress_external_import_shadow("eq::apply", "unique_name", &arr, keys, nkeys));+ cbm_suppress_external_import_shadow("eq.apply", "unique_name", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("eq::apply", "unique_name", &arr, keys, nkeys, NULL));/* Empty / absent inputs. */- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", NULL, &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow(NULL, "unique_name", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("", "unique_name", &arr, keys, nkeys));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", NULL, keys, nkeys));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", NULL, &arr, keys, nkeys, NULL));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(cbm_suppress_external_import_shadow(NULL, "unique_name", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("", "unique_name", &arr, keys, nkeys, NULL));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", NULL, keys, nkeys, NULL));PASS();}@@ -1054,8 +1065,8 @@ TEST(external_import_shadow_relative_binding_wins_the_tie) {};CBMImportArray a = {.items = pkg_first, .count = 2, .cap = 2};CBMImportArray b = {.items = rel_first, .count = 2, .cap = 2};- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", &a, NULL, 0));- ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", &b, NULL, 0));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", &a, NULL, 0, NULL));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", &b, NULL, 0, NULL));PASS();}@@ -1078,9 +1089,10 @@ TEST(external_import_shadow_windows_relative_specifier_kept) {* 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));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, NULL, 0, NULL));+ ASSERT_FALSE(cbm_suppress_external_import_shadow("sql", "unique_name", &arr, NULL, 0, NULL));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("normalize", "unique_name", &arr, NULL, 0, NULL));/* 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". */@@ -1088,7 +1100,57 @@ TEST(external_import_shadow_windows_relative_specifier_kept) {{.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));+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &parr, NULL, 0, NULL));+ PASS();+}++TEST(external_import_shadow_workspace_sibling_kept) {+ /* #1355 / #1732: inside a workspace monorepo a BARE specifier can still name+ * in-tree code — `import { eq } from "drizzle-orm"` written inside the+ * drizzle-orm repository is a sibling package, not a dependency. Measured on+ * drizzle-team/drizzle-orm at b7862528: without this check the guard removed+ * 2609 CALLS edges, 1377 of which pointed at exactly the file the specifier+ * names. The package map is keyed by each in-tree manifest's `name`, so the+ * tree's own claim decides. */+ CBMImport imports[] = {+ {.local_name = "eq", .module_path = "drizzle-orm"},+ {.local_name = "pgTable", .module_path = "drizzle-orm/pg-core"},+ {.local_name = "hoisted", .module_path = "@scope/kit/sub"},+ {.local_name = "test", .module_path = "vitest"},+ };+ CBMImportArray arr = {.items = imports, .count = 4, .cap = 4};++ CBMHashTable *pkgs = cbm_ht_create(8);+ ASSERT_NOT_NULL(pkgs);+ cbm_ht_set(pkgs, "drizzle-orm", (void *)"qn");+ cbm_ht_set(pkgs, "@scope/kit", (void *)"qn");++ /* Exact name, subpath, and scoped subpath all resolve to an in-tree+ * package — the same-name fallback keeps its chance. */+ ASSERT_FALSE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, NULL, 0, pkgs));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("pgTable", "suffix_match", &arr, NULL, 0, pkgs));+ ASSERT_FALSE(+ cbm_suppress_external_import_shadow("hoisted", "unique_name", &arr, NULL, 0, pkgs));+ /* A genuine third-party dependency is untouched by the new check: the tree+ * declares no package called "vitest", so the #1355 removal still happens. */+ ASSERT_TRUE(cbm_suppress_external_import_shadow("test", "suffix_match", &arr, NULL, 0, pkgs));++ /* A tree with no manifests at all (pkgmap NULL) keeps the pre-existing+ * specifier-shape-only contract — every one of these is external again. */+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, NULL, 0, NULL));+ ASSERT_TRUE(+ cbm_suppress_external_import_shadow("pgTable", "suffix_match", &arr, NULL, 0, NULL));++ /* An unrelated package map must not accidentally match by prefix: "drizzle"+ * is not "drizzle-orm", and the walk is by path segment, not by substring. */+ CBMHashTable *other = cbm_ht_create(8);+ ASSERT_NOT_NULL(other);+ cbm_ht_set(other, "drizzle", (void *)"qn");+ ASSERT_TRUE(cbm_suppress_external_import_shadow("eq", "unique_name", &arr, NULL, 0, other));++ cbm_ht_free(other);+ cbm_ht_free(pkgs);PASS();}@@ -1195,4 +1257,5 @@ SUITE(registry) {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);+ RUN_TEST(external_import_shadow_workspace_sibling_kept);}