Skip to content

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.

Merge branch 'main' into fix/go-weak-selector-calls

Martin Vogelb74cecc53cea
diff --cc src/pipeline/pass_calls.c
index 2d96d440d,84958954c..7d8e68196
--- a/src/pipeline/pass_calls.c
+++ b/src/pipeline/pass_calls.c
@@@ -623,28 -623,34 +623,42 @@@ static int resolve_single_call(cbm_pipe
* language gated on only one resolver produces an edge on the sequential
* path and not the parallel one (or vice versa), breaking MT determinism.
* ArkTS belongs to the JS/TS family here (#1842); dropping it would
- * reintroduce the #592/#606 false-edge class for .ets files. */
+ * reintroduce the #592/#606 false-edge class for .ets files.
+ *
+ * Go (#1906) rides the same deferred-drop plumbing through its OWN
+ * predicate: its drop-list differs (field_type_hint is receiver-aware for
+ * Go, and unique_name drops only when import-unreachability-penalized), so
+ * it composes via cbm_go_suppress_weak_method_match instead of widening
+ * the shared gate. Same lockstep rule: mirror pass_parallel.c. */
bool suppress_weak_member = lang == CBM_LANG_PYTHON || lang == CBM_LANG_JAVASCRIPT ||
lang == CBM_LANG_TYPESCRIPT || lang == CBM_LANG_TSX ||
- lang == CBM_LANG_ARKTS;
+ lang == CBM_LANG_ARKTS ||
+ /* Files whose calls are embedded JS/TS (<script>
+ * bodies): the calls carry the JS receiver flag
+ * but the FILE language gated them out, so
+ * generated Dokka pages bound localStorage.getItem
+ * to a docs bundle (2026-09-16 probe: 4,207 junk
+ * edges on JetBrains/Exposed). */
+ lang == CBM_LANG_HTML || lang == CBM_LANG_VUE ||
+ lang == CBM_LANG_SVELTE || lang == CBM_LANG_ASTRO;
/* Bare-call local-binding suppression. A member call has a receiver the
* guard above can reason about; a bare `run()` has none, so that guard
* cannot see this class at all. Python-only today because the extraction
* flag is set only for Python — this gate MUST match pass_parallel.c's
* exactly, for the same divergence reason noted above. */
bool suppress_weak_local_binding = lang == CBM_LANG_PYTHON;
+ /* The member guard's one exemption (Python, self/cls-rooted receiver,
+ * unique_name, not a builtin type's method) — see
+ * cbm_weak_member_unique_name_exempt. MUST match pass_parallel.c exactly. */
bool drop_plain_call =
- cbm_suppress_weak_member_match(suppress_weak_member, call->is_method, res.strategy) ||
+ (cbm_suppress_weak_member_match(suppress_weak_member, call->is_method, res.strategy) &&
+ !cbm_weak_member_unique_name_exempt(lang == CBM_LANG_PYTHON,
+ call->receiver_is_self_attribute, call->callee_name,
+ res.strategy)) ||
cbm_suppress_weak_local_binding_call(suppress_weak_local_binding,
- call->callee_is_locally_bound, res.strategy);
+ call->callee_is_locally_bound, res.strategy) ||
+ cbm_go_suppress_weak_method_match(lang == CBM_LANG_GO, call->is_method, res.strategy,
+ res.confidence);
/* Service-pattern HTTP/ASYNC calls to an EXTERNAL client library (e.g.
* `requests.get("/api/orders/{id}")`) resolve to a QN containing the library
diff --cc src/pipeline/pass_parallel.c
index 3e896c1f4,e85ad015f..41c15b099
--- a/src/pipeline/pass_parallel.c
+++ b/src/pipeline/pass_parallel.c
@@@ -2834,21 -2940,24 +2940,28 @@@ static void resolve_file_calls(resolve_
* #606 direction.
*
* This language set MUST match the one in pass_calls.c exactly — see the
- * note there. ArkTS belongs to the JS/TS family (#1842). */
+ * note there. ArkTS belongs to the JS/TS family (#1842). Go (#1906)
+ * composes via its own predicate (different drop-list — see
+ * cbm_go_suppress_weak_method_match), mirrored in pass_calls.c. */
bool suppress_weak_member = lang == CBM_LANG_PYTHON || lang == CBM_LANG_JAVASCRIPT ||
lang == CBM_LANG_TYPESCRIPT || lang == CBM_LANG_TSX ||
- lang == CBM_LANG_ARKTS;
+ lang == CBM_LANG_ARKTS ||
+ /* embedded-script hosts — see pass_calls.c */
+ lang == CBM_LANG_HTML || lang == CBM_LANG_VUE ||
+ lang == CBM_LANG_SVELTE || lang == CBM_LANG_ASTRO;
/* Bare-call local-binding suppression — see the note in pass_calls.c.
* This gate MUST stay identical to the one there. */
bool suppress_weak_local_binding = lang == CBM_LANG_PYTHON;
+ /* The member guard's one exemption — MUST match pass_calls.c exactly. */
bool drop_plain_call =
- cbm_suppress_weak_member_match(suppress_weak_member, call->is_method, res.strategy) ||
+ (cbm_suppress_weak_member_match(suppress_weak_member, call->is_method, res.strategy) &&
+ !cbm_weak_member_unique_name_exempt(lang == CBM_LANG_PYTHON,
+ call->receiver_is_self_attribute,
+ call->callee_name, res.strategy)) ||
cbm_suppress_weak_local_binding_call(suppress_weak_local_binding,
- call->callee_is_locally_bound, res.strategy);
+ call->callee_is_locally_bound, res.strategy) ||
+ cbm_go_suppress_weak_method_match(lang == CBM_LANG_GO, call->is_method, res.strategy,
+ res.confidence);
/* Service-pattern HTTP/ASYNC client call (`requests.get(url)`): the
* service signal lives in the callee_name. The registry can mis-resolve
diff --cc tests/test_pipeline.c
index dfa5fea20,690fb9664..b2ab5fd04
--- a/tests/test_pipeline.c
+++ b/tests/test_pipeline.c
@@@ -5467,99 -5741,123 +5741,216 @@@ TEST(pipeline_python_receiver_suppresse
PASS();
}
+ /* The member guard's one exemption (2026-09-16, v0.10.8 → v0.11.0 A/B on
+ * django/django): a member call whose receiver is an attribute chain rooted at
+ * self/cls, whose callee has exactly ONE definition in the project and is not a
+ * builtin type's own method keeps its unique_name edge —
+ * `self.compiler.apply_converters()` names the only apply_converters there is.
+ * A bare parameter receiver and the builtin-member class the guard was built
+ * for (`parts.extend()` -> a project ListMixin.extend) stay suppressed.
+ * Fewer than 50 files exercises pass_calls.c. */
+ TEST(pipeline_python_receiver_keeps_specific_unique_name_member_call) {
+ char tmp[256];
+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_python_uniq_XXXXXX");
+ if (!cbm_mkdtemp(tmp)) {
+ FAIL("tmpdir");
+ }
+
+ write_temp_file(tmp, "compiler.py",
+ "class SQLCompiler:\n"
+ " def apply_converters(self, rows):\n"
+ " return rows\n");
+ write_temp_file(tmp, "mixin.py",
+ "class ListMixin:\n"
+ " def extend(self, other):\n"
+ " return other\n");
+ write_temp_file(tmp, "caller.py",
+ "class RawIterable:\n"
+ " def __init__(self, compiler):\n"
+ " self.compiler = compiler\n"
+ "\n"
+ " def iterate(self):\n"
+ " return self.compiler.apply_converters([])\n"
+ "\n"
+ "\n"
+ "def collect(parts):\n"
+ " parts.extend([1])\n"
+ " return parts\n"
+ "\n"
+ "\n"
+ "def handed_in(compiler):\n"
+ " return compiler.apply_converters([])\n");
+
+ char db_path[512];
+ snprintf(db_path, sizeof(db_path), "%s/python_uniq.db", tmp);
+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
+ ASSERT_NOT_NULL(p);
+ ASSERT_EQ(cbm_pipeline_run(p), 0);
+ const char *project = cbm_pipeline_project_name(p);
+
+ cbm_store_t *s = cbm_store_open_path(db_path);
+ ASSERT_NOT_NULL(s);
+
+ /* POSITIVE: the only apply_converters in the project binds through
+ * self.compiler, an object the class owns. */
+ ASSERT_TRUE(cross_file_call_exists(s, project, "iterate", "apply_converters"));
+ /* NEGATIVE: the same unique name through a bare parameter carries no
+ * ownership evidence and stays suppressed (#1276's own shape). */
+ ASSERT_FALSE(cross_file_call_exists(s, project, "handed_in", "apply_converters"));
+ /* NEGATIVE: list.extend on a parameter must not bind ListMixin.extend. */
+ ASSERT_FALSE(cross_file_call_exists(s, project, "collect", "extend"));
+ /* Tripwire against a vacuous run. */
+ ASSERT_GTE(cbm_store_count_edges_by_type(s, project, "CALLS"), 1);
+
+ cbm_store_close(s);
+ cbm_pipeline_free(p);
+ th_rmtree(tmp);
+ PASS();
+ }
+
+ /* Embedded-script hosts (2026-09-16 probe on JetBrains/Exposed): a member call
+ * inside an HTML <script> body is extracted as JavaScript and carries the JS
+ * receiver flag, but the weak-member guard was gated on the FILE language, so
+ * 4,207 generated Dokka pages bound `localStorage.getItem` to a docs bundle
+ * function through unique_name. HTML (and Vue/Svelte/Astro) join the gate.
+ * POSITIVE tripwire: a bare project call in a plain .js file still resolves. */
+ TEST(pipeline_html_embedded_member_call_stays_unbound) {
+ char tmp[256];
+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_html_member_XXXXXX");
+ if (!cbm_mkdtemp(tmp)) {
+ FAIL("tmpdir");
+ }
+
+ /* One directory level each: write_temp_file creates a single parent. */
+ write_temp_file(tmp, "scripts/storage.js",
+ "function getItem(key) {\n"
+ " return key;\n"
+ "}\n");
+ write_temp_file(tmp, "scripts/theme.js",
+ "import { getItem } from './storage.js';\n"
+ "\n"
+ "function loadTheme() {\n"
+ " return getItem('theme');\n"
+ "}\n");
+ write_temp_file(tmp, "docs/index.html",
+ "<html><head><script>\n"
+ "var mode = localStorage.getItem('dokka-dark-mode');\n"
+ "</script></head><body></body></html>\n");
+
+ char db_path[512];
+ snprintf(db_path, sizeof(db_path), "%s/html_member.db", tmp);
+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
+ ASSERT_NOT_NULL(p);
+ ASSERT_EQ(cbm_pipeline_run(p), 0);
+ const char *project = cbm_pipeline_project_name(p);
+
+ cbm_store_t *s = cbm_store_open_path(db_path);
+ ASSERT_NOT_NULL(s);
+
+ /* NEGATIVE: localStorage's own method must not bind the docs bundle. */
+ ASSERT_FALSE(cross_file_call_exists(s, project, "index", "getItem"));
+ /* POSITIVE: the bare project call in storage.js resolves as before. */
+ ASSERT_TRUE(cross_file_call_exists(s, project, "loadTheme", "getItem"));
+
+ cbm_store_close(s);
+ cbm_pipeline_free(p);
+ th_rmtree(tmp);
+ PASS();
+ }
+
+TEST(pipeline_go_receiver_suppresses_weak_method_edge) {
+ char tmp[256];
+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_go_recv_XXXXXX");
+ if (!cbm_mkdtemp(tmp)) {
+ FAIL("tmpdir");
+ }
+
+ /* go.mod makes project imports resolvable — real Go repos always have one,
+ * and import reachability (the unique_name penalty) depends on it. */
+ write_temp_file(tmp, "go.mod", "module example.com/myapp\n\ngo 1.22\n");
+ /* The lone project symbol named "Close" — a real method. */
+ write_temp_file(tmp, "storage/storage.go",
+ "package storage\n"
+ "\n"
+ "type Storage struct{ open bool }\n"
+ "\n"
+ "func NewStorage() *Storage { return &Storage{open: true} }\n"
+ "\n"
+ "func (s *Storage) Close() {\n"
+ "\ts.open = false\n"
+ "}\n"
+ "\n"
+ "func Boot() {\n"
+ "\ts := NewStorage()\n"
+ "\ts.Close()\n"
+ "}\n");
+ /* Cross-package control target: imported by hash.go, so the caller file
+ * has a non-empty import map (like any real Go file) and unreachable
+ * unique_name candidates get the import penalty. */
+ write_temp_file(tmp, "util/util.go",
+ "package util\n"
+ "\n"
+ "func Tag() string { return \"t\" }\n");
+ /* Stdlib receiver: `f.Close()` closes an *os.File, NOT the project method.
+ * The Go LSP cannot bind it to a project symbol → the registry would guess
+ * Close by short name (weak). This is the false edge to suppress —
+ * the exact shape that attached every file/rows/gzip Close in a real Go
+ * repo to one unrelated project method. */
+ write_temp_file(tmp, "hash/hash.go",
+ "package hash\n"
+ "\n"
+ "import (\n"
+ "\t\"os\"\n"
+ "\n"
+ "\t\"example.com/myapp/util\"\n"
+ ")\n"
+ "\n"
+ "func FileLen(path string) int64 {\n"
+ "\tf, err := os.Open(path)\n"
+ "\tif err != nil {\n"
+ "\t\treturn 0\n"
+ "\t}\n"
+ "\tdefer f.Close()\n"
+ "\tst, err := f.Stat()\n"
+ "\tif err != nil {\n"
+ "\t\treturn 0\n"
+ "\t}\n"
+ "\treturn st.Size()\n"
+ "}\n"
+ "\n"
+ "func localHelper() int { return 1 }\n"
+ "\n"
+ "func CallsLocal() int { return localHelper() }\n"
+ "\n"
+ "func UsesUtil() string { return util.Tag() }\n");
+
+ char db_path[512];
+ snprintf(db_path, sizeof(db_path), "%s/go_recv.db", tmp);
+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
+ ASSERT_NOT_NULL(p);
+ ASSERT_EQ(cbm_pipeline_run(p), 0);
+ const char *project = cbm_pipeline_project_name(p);
+
+ cbm_store_t *s = cbm_store_open_path(db_path);
+ ASSERT_NOT_NULL(s);
+
+ /* (1) The false edge is suppressed (reproduce-first: RED before the fix). */
+ ASSERT_FALSE(cross_file_call_exists(s, project, "FileLen", "Close"));
+ /* (2) The same-package typed-receiver call survives (LSP / same_module —
+ * both outside the weak drop-list). */
+ ASSERT_TRUE(cross_file_call_exists(s, project, "Boot", "Close"));
+ /* (3) The bare local call survives (is_method stays false for bare calls). */
+ ASSERT_TRUE(cross_file_call_exists(s, project, "CallsLocal", "localHelper"));
+ /* (4) The import-qualified cross-package call survives (import-aware
+ * strategies are outside the drop-list). */
+ ASSERT_TRUE(cross_file_call_exists(s, project, "UsesUtil", "Tag"));
+
+ cbm_store_close(s);
+ cbm_pipeline_free(p);
+ th_rmtree(tmp);
+ PASS();
+}
+
/* Fixture for the #1928 cross-language reference-guard probes (sequential and
* parallel twins). pad_files > 0 adds filler files to push the index over the
* parallel-pipeline threshold, since USAGE/WRITES/READS have one resolver per
@@@ -14687,7 -15341,8 +15434,9 @@@ SUITE(pipeline)
#endif
RUN_TEST(pipeline_tsjs_receiver_suppresses_weak_method_edge);
RUN_TEST(pipeline_python_receiver_suppresses_weak_method_edge);
+ RUN_TEST(pipeline_python_receiver_keeps_specific_unique_name_member_call);
+ RUN_TEST(pipeline_html_embedded_member_call_stays_unbound);
+ RUN_TEST(pipeline_go_receiver_suppresses_weak_method_edge);
RUN_TEST(pipeline_go_rw_usage_never_cross_into_c);
RUN_TEST(pipeline_go_rw_usage_never_cross_into_c_parallel);
RUN_TEST(pipeline_go_bare_ref_never_binds_field);