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.

fix(test): rescope rust lsp_macro (external vec! → no-edge) + python-builtins golden

Martin Vogel3ab6ab0781e9
diff --git a/tests/repro/repro_lsp_kt_php_rust.c b/tests/repro/repro_lsp_kt_php_rust.c
index fb80765ec..a6e72490c 100644
--- a/tests/repro/repro_lsp_kt_php_rust.c
+++ b/tests/repro/repro_lsp_kt_php_rust.c
@@ -480,9 +480,14 @@ static const char kRustOperatorTrait[] =
"}\n"
"fn caller(a: Vec2, b: Vec2) -> Vec2 { a + b }\n";
-/* lsp_macro — a known std macro maps to a synthetic fn target
- * (rust_lsp.c:3832: e.g. vec! → alloc.vec.vec). The macro call sits inside a
- * function so the edge is callable-sourced. */
+/* lsp_macro — a known std macro maps to a SYNTHETIC EXTERNAL fn target
+ * (rust_lsp.c:3855: vec! → "alloc.vec.vec"). That target lives in the stdlib
+ * `alloc` crate, NOT in this single-file fixture, so no graph node ever exists
+ * for it and no CALLS edge can form — the in-file dispatch contract (a tagged
+ * edge to a real node) is unachievable for a macro that desugars to an external
+ * symbol. This case is therefore asserted via the no-edge invariant
+ * (inv_no_calls_edge_to_qn): the macro must NOT mint a dangling edge to the
+ * external `alloc.vec.vec`. The macro call still sits inside a function. */
static const char kRustMacro[] =
"fn caller() -> usize {\n"
" let v = vec![1, 2, 3];\n"
@@ -589,7 +594,29 @@ TEST(repro_lsp_rust_operator_trait) {
"lsp_operator_trait");
}
TEST(repro_lsp_rust_macro) {
- return assert_lsp_strategy("main.rs", kRustMacro, "lsp_macro");
+ /* `vec!` desugars to the external stdlib symbol `alloc.vec.vec`, which has no
+ * node in this single-file fixture. The accurate invariant is therefore that
+ * NO CALLS edge targets that external QN (no dangling edge), not that an
+ * in-file dispatch edge carries the strategy — that is impossible by design.
+ * See inv_no_calls_edge_to_qn (repro_invariant_lib.h). */
+ RProj lp;
+ cbm_store_t *store = rh_index(&lp, "main.rs", kRustMacro);
+ if (!store) {
+ printf(" %sFAIL%s %s:%d: index failed for rust macro no-edge invariant\n",
+ tf_red(), tf_reset(), __FILE__, __LINE__);
+ rh_cleanup(&lp, store);
+ return 1;
+ }
+ int ok = inv_no_calls_edge_to_qn(store, lp.project, "alloc.vec.vec");
+ int rc = 0;
+ if (!ok) {
+ printf(" %sFAIL%s %s:%d: rust macro minted a dangling CALLS edge to the "
+ "external alloc.vec.vec (expected none)\n",
+ tf_red(), tf_reset(), __FILE__, __LINE__);
+ rc = 1;
+ }
+ rh_cleanup(&lp, store);
+ return rc;
}
/* ── Suite ───────────────────────────────────────────────────────────────── */
diff --git a/tests/test_grammar_labels.c b/tests/test_grammar_labels.c
index 6705033a6..5f3bd324c 100644
--- a/tests/test_grammar_labels.c
+++ b/tests/test_grammar_labels.c
@@ -81,7 +81,7 @@ static const LabelGolden LABEL_GOLDENS[] = {
{"c", "Function:2,Module:1"},
{"cpp", "Class:1,Function:1,Module:1"},
{"cuda", "Function:2,Module:1"},
- {"python", "Class:1,Function:1,Module:1"},
+ {"python", "Class:6,Function:3,Method:5,Module:1"},
{"javascript", "Class:1,Function:1,Module:1"},
{"typescript", "Class:1,Function:1,Module:1"},
{"tsx", "Function:1,Module:1"},