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.

Add probe reproduction suites: LSP-pass resolution, node creation, edge-type creation

Martin Vogel0798748abf61
diff --git a/Makefile.cbm b/Makefile.cbm
index 6e10fc079..e4bcadd31 100644
--- a/Makefile.cbm
+++ b/Makefile.cbm
@@ -342,7 +342,7 @@ TEST_JAVA_LSP_SRCS = tests/test_java_lsp.c tests/test_java_lsp_coverage.c
TEST_KOTLIN_LSP_SRCS = tests/test_kotlin_lsp.c
TEST_RUST_LSP_SRCS = tests/test_rust_lsp.c
-TEST_INTEGRATION_SRCS = tests/test_integration.c tests/test_incremental.c tests/test_lang_contract.c tests/test_edge_imports.c tests/test_edge_structural.c
+TEST_INTEGRATION_SRCS = tests/test_integration.c tests/test_incremental.c tests/test_lang_contract.c tests/test_edge_imports.c tests/test_edge_structural.c tests/test_lsp_resolution_probe.c tests/test_node_creation_probe.c tests/test_edge_types_probe.c
TEST_TRACES_SRCS = tests/test_traces.c
diff --git a/tests/test_edge_types_probe.c b/tests/test_edge_types_probe.c
new file mode 100644
index 000000000..3c4c47a0e
--- /dev/null
+++ b/tests/test_edge_types_probe.c
@@ -0,0 +1,1324 @@
+/*
+ * test_edge_types_probe.c — Reproduce-first probe of LESS-COMMON edge types.
+ *
+ * GREEN = works; kept as regression guard.
+ * RED = found bug (edge not produced); kept as reproduction until fixed.
+ *
+ * Probed edge types (broadened from P6 in test_lang_contract.c):
+ * HANDLES — route→handler across web frameworks (Express/Fastify TS, FastAPI/Django,
+ * Go net/http + Gin, Spring Java, ASP.NET C#, Laravel PHP, Rails Ruby,
+ * Actix/Axum Rust).
+ * HTTP_CALLS — outbound HTTP client call (fetch JS, axios TS, requests Python,
+ * net/http Go, HttpClient Java, RestSharp C#, HTTParty Ruby, Guzzle PHP,
+ * reqwest Rust).
+ * ASYNC_CALLS— queue/pubsub dispatch (Celery Python, Sidekiq Ruby, kafkajs TS,
+ * amazon-sqs-go Go, BullMQ JS).
+ * THROWS — function throws/raises a checked exception (Java, Kotlin, Python,
+ * TypeScript, PHP, C#, Scala). Checked = no "Error"/"Panic" in name.
+ * RAISES — function raises a runtime error/panic (Python, Kotlin, TypeScript,
+ * C#, PHP). Unchecked = name contains "Error"/"Panic".
+ * WRITES — variable assignment resolved across function boundary (Python, Go, Rust,
+ * Java, C#, Kotlin). WRITES/READS are parallel-path only (>50 files).
+ * DEFINES_METHOD — class→method across languages (Go, Rust, Java, C#, PHP, Ruby,
+ * Kotlin, TypeScript, Scala).
+ * OVERRIDE — Go interface satisfaction (method overrides interface method).
+ * Parallel-path only (>50 files).
+ *
+ * Edge types that do NOT exist in the schema and are explicitly not probed:
+ * RETURNS / RETURNS_TYPE — no such edge type in the production schema (confirmed
+ * by searching ALL_EDGE_TYPES in test_lang_contract.c and the cli.c edge list).
+ * DATA_FLOWS — already guarded in test_lang_contract.c (contract_edge_data_flows).
+ *
+ * Path notes:
+ * SEQUENTIAL path (< 50 files): HANDLES, HTTP_CALLS, ASYNC_CALLS, DEFINES_METHOD,
+ * THROWS, RAISES are produced in pass_calls.c / pass_usages.c.
+ * PARALLEL path (≥ 50 files via index_parallel_fixture): WRITES, OVERRIDE and the
+ * parallel variants of THROWS/RAISES/USAGE are exercised here.
+ *
+ * Registration: NOT registered in test_main.c (per task specification).
+ * Run standalone: link the suite and call suite_edge_types_probe() from a main().
+ */
+
+#include "../src/foundation/compat.h"
+#include "test_framework.h"
+#include "test_helpers.h"
+#include "cbm.h"
+#include <mcp/mcp.h>
+#include <store/store.h>
+#include <pipeline/pipeline.h>
+#include <foundation/log.h>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+/* ── Fixture harness (mirrors test_lang_contract.c) ──────────────────────── */
+
+typedef struct {
+ char tmpdir[256];
+ char dbpath[512];
+ char *project;
+ cbm_mcp_server_t *srv;
+} EtProj;
+
+typedef struct {
+ const char *name;
+ const char *content;
+} EtFile;
+
+static void et_to_fwd_slashes(char *p) {
+ for (; *p; p++) {
+ if (*p == '\\') *p = '/';
+ }
+}
+
+/* Write files, then run index_repository and open the graph DB. */
+static cbm_store_t *et_index_files(EtProj *lp, const EtFile *files, int nfiles) {
+ memset(lp, 0, sizeof(*lp));
+ snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_et_XXXXXX");
+ if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
+ et_to_fwd_slashes(lp->tmpdir);
+
+ for (int i = 0; i < nfiles; i++) {
+ char path[700];
+ snprintf(path, sizeof(path), "%s/%s", lp->tmpdir, files[i].name);
+ char *slash = strrchr(path, '/');
+ if (slash && slash > path + strlen(lp->tmpdir)) {
+ *slash = '\0';
+ cbm_mkdir_p(path, 0755);
+ *slash = '/';
+ }
+ FILE *f = fopen(path, "wb");
+ if (!f) return NULL;
+ fputs(files[i].content, f);
+ fclose(f);
+ }
+
+ lp->project = cbm_project_name_from_path(lp->tmpdir);
+ if (!lp->project) return NULL;
+
+ const char *home = getenv("HOME");
+ if (!home) home = "/tmp";
+ char cache_dir[512];
+ snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/codebase-memory-mcp", home);
+ cbm_mkdir(cache_dir);
+ snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", cache_dir, lp->project);
+ unlink(lp->dbpath);
+
+ lp->srv = cbm_mcp_server_new(NULL);
+ if (!lp->srv) return NULL;
+
+ char args[700];
+ snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir);
+ char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args);
+ if (resp) free(resp);
+
+ return cbm_store_open_path(lp->dbpath);
+}
+
+static void et_cleanup(EtProj *lp, cbm_store_t *store) {
+ if (store) cbm_store_close(store);
+ if (lp->srv) { cbm_mcp_server_free(lp->srv); lp->srv = NULL; }
+ free(lp->project); lp->project = NULL;
+ th_rmtree(lp->tmpdir);
+ unlink(lp->dbpath);
+ char wal[600], shm[600];
+ snprintf(wal, sizeof(wal), "%s-wal", lp->dbpath);
+ snprintf(shm, sizeof(shm), "%s-shm", lp->dbpath);
+ unlink(wal); unlink(shm);
+}
+
+/* Assert edge_type count >= floor; dump diagnostic on failure. */
+static int et_edge_present(const EtFile *files, int nfiles, const char *edge, int floor) {
+ EtProj lp;
+ cbm_store_t *store = et_index_files(&lp, files, nfiles);
+ int got = store ? cbm_store_count_edges_by_type(store, lp.project, edge) : -1;
+ if (got < floor) {
+ fprintf(stderr, " [ET-EDGE] FAIL %-20s count=%d expected>=%d\n", edge, got, floor);
+ }
+ et_cleanup(&lp, store);
+ return got >= floor;
+}
+
+/* Index meaningful[] plus PARALLEL_PAD_FILES trivial pad files to force the
+ * parallel pipeline path (MIN_FILES_FOR_PARALLEL = 50). */
+enum { ET_PARALLEL_PAD = 52, ET_PAD_MAX = 68 /* 52 pad + 16 meaningful */ };
+
+static cbm_store_t *et_index_parallel(EtProj *lp, const EtFile *meaningful, int n_mean) {
+ static char pad_name[ET_PARALLEL_PAD][48];
+ static char pad_body[ET_PARALLEL_PAD][64];
+ EtFile files[ET_PAD_MAX] = {0};
+ int n = 0;
+ for (int i = 0; i < n_mean; i++) files[n++] = meaningful[i];
+ for (int i = 0; i < ET_PARALLEL_PAD; i++) {
+ snprintf(pad_name[i], sizeof(pad_name[i]), "pad/pad_%02d.py", i);
+ snprintf(pad_body[i], sizeof(pad_body[i]), "def pad_%02d():\n return %d\n", i, i);
+ files[n].name = pad_name[i];
+ files[n].content = pad_body[i];
+ n++;
+ }
+ return et_index_files(lp, files, n);
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * HANDLES — route→handler across web frameworks
+ *
+ * Strategy: the route_path is extracted from decorators (Python Flask/FastAPI/
+ * Django, Java Spring) or from the resolved QN matching a framework library id
+ * (Express, Fastify, Gin, ASP.NET MapGet/MapPost, Laravel). Each fixture uses a
+ * LOCAL wrapper whose QN carries the framework substring so the sequential-path
+ * resolver (pass_calls.c → cbm_service_pattern_match → CBM_SVC_ROUTE_REG) fires.
+ * Decorator-based frameworks (Flask, FastAPI, Django, Spring @RequestMapping) are
+ * handled via extract_route_from_decorators which sets def.route_path in the
+ * extraction result and creates Route+HANDLES during pass_definitions.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Flask (Python) — already covered in test_lang_contract.c:contract_edge_handles.
+ * Included here as baseline sanity guard for this file. */
+TEST(handles_flask_python) {
+ static const EtFile f[] = {
+ {"app.py",
+ "from flask import Flask\n\napp = Flask(__name__)\n\n\n"
+ "@app.route(\"/items\")\ndef list_items():\n return {\"items\": []}\n\n\n"
+ "@app.route(\"/items/<int:item_id>\")\ndef get_item(item_id):\n return {\"id\": item_id}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "HANDLES", 1));
+ PASS();
+}
+
+/* FastAPI (Python) — @app.get / @app.post decorators */
+TEST(handles_fastapi_python) {
+ static const EtFile f[] = {
+ {"api.py",
+ "from fastapi import FastAPI\n\napp = FastAPI()\n\n\n"
+ "@app.get(\"/users\")\ndef read_users():\n return [{\"id\": 1}]\n\n\n"
+ "@app.post(\"/users\")\ndef create_user(name: str):\n return {\"name\": name}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "HANDLES", 1));
+ PASS();
+}
+
+/* Express (JS/TS) — local express wrapper whose QN contains "express";
+ * route registration call: router.get("/path", handler) */
+TEST(handles_express_ts) {
+ static const EtFile f[] = {
+ {"router.ts",
+ "export function expressRouter() {\n"
+ " return { get: (p: string, h: any) => h, post: (p: string, h: any) => h };\n}\n"},
+ {"users.ts",
+ "import { expressRouter } from './router';\n\n"
+ "const router = expressRouter();\n\n"
+ "function listUsers(req: any, res: any) {\n res.json([]);\n}\n\n"
+ "function createUser(req: any, res: any) {\n res.json({});\n}\n\n"
+ "router.get('/users', listUsers);\n"
+ "router.post('/users', createUser);\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HANDLES", 1));
+ PASS();
+}
+
+/* Fastify (JS) — local fastify() wrapper */
+TEST(handles_fastify_js) {
+ static const EtFile f[] = {
+ {"server.js",
+ "function fastify() {\n"
+ " return { get: (p, h) => h, post: (p, h) => h };\n}\n\n"
+ "const app = fastify();\n\n"
+ "function getHealth(req, reply) { reply.send({ ok: true }); }\n\n"
+ "function postOrder(req, reply) { reply.send({ created: true }); }\n\n"
+ "app.get('/health', getHealth);\n"
+ "app.post('/orders', postOrder);\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "HANDLES", 1));
+ PASS();
+}
+
+/* Go net/http + gin — local gin.Engine wrapper whose QN contains "gin." */
+TEST(handles_gin_go) {
+ static const EtFile f[] = {
+ {"gin/engine.go",
+ "package gin\n\n"
+ "type Engine struct{}\n\n"
+ "func Default() *Engine {\n return &Engine{}\n}\n\n"
+ "func (e *Engine) GET(path string, handler interface{}) {}\n"
+ "func (e *Engine) POST(path string, handler interface{}) {}\n"},
+ {"main.go",
+ "package main\n\n"
+ "import \"gin\"\n\n"
+ "func listOrders(w interface{}, r interface{}) {}\n\n"
+ "func createOrder(w interface{}, r interface{}) {}\n\n"
+ "func main() {\n"
+ " r := gin.Default()\n"
+ " r.GET(\"/orders\", listOrders)\n"
+ " r.POST(\"/orders\", createOrder)\n"
+ "}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HANDLES", 1));
+ PASS();
+}
+
+/* Spring (Java) — @RequestMapping decorator sets route_path in extraction */
+TEST(handles_spring_java) {
+ static const EtFile f[] = {
+ {"OrderController.java",
+ "package com.example;\n\n"
+ "import org.springframework.web.bind.annotation.RequestMapping;\n"
+ "import org.springframework.web.bind.annotation.GetMapping;\n\n"
+ "@RequestMapping(\"/api\")\npublic class OrderController {\n"
+ " @GetMapping(\"/orders\")\n"
+ " public String listOrders() {\n"
+ " return \"orders\";\n }\n\n"
+ " @GetMapping(\"/orders/{id}\")\n"
+ " public String getOrder(int id) {\n"
+ " return \"order:\" + id;\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "HANDLES", 1));
+ PASS();
+}
+
+/* ASP.NET Minimal API (C#) — MapGet/MapPost in resolved QN */
+TEST(handles_aspnet_csharp) {
+ static const EtFile f[] = {
+ {"App.cs",
+ "namespace App {\n"
+ " class WebApp {\n"
+ " static string MapGet(string path, Func<string> handler) { return handler(); }\n"
+ " static string MapPost(string path, Func<string> handler) { return handler(); }\n"
+ " }\n\n"
+ " class Program {\n"
+ " static void Main() {\n"
+ " WebApp.MapGet(\"/products\", GetProducts);\n"
+ " WebApp.MapPost(\"/products\", CreateProduct);\n }\n"
+ " static string GetProducts() { return \"[]\"; }\n"
+ " static string CreateProduct() { return \"{}\" ; }\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "HANDLES", 1));
+ PASS();
+}
+
+/* Laravel (PHP) — Route facade whose QN contains "Laravel" */
+TEST(handles_laravel_php) {
+ static const EtFile f[] = {
+ {"Laravel/Route.php",
+ "<?php\nnamespace Laravel;\n\n"
+ "class Route {\n"
+ " public static function get($path, $handler) { return $handler; }\n"
+ " public static function post($path, $handler) { return $handler; }\n}\n"},
+ {"routes/web.php",
+ "<?php\nuse Laravel\\Route;\n\n"
+ "function showUsers() { return ['users' => []]; }\n"
+ "function storeUser() { return ['stored' => true]; }\n\n"
+ "Route::get('/users', 'showUsers');\n"
+ "Route::post('/users', 'storeUser');\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HANDLES", 1));
+ PASS();
+}
+
+/* Rails (Ruby) — ActionDispatch router: routes.draw + get/post */
+TEST(handles_rails_ruby) {
+ static const EtFile f[] = {
+ {"ActionDispatch/Routing.rb",
+ "module ActionDispatch\n module Routing\n"
+ " class Mapper\n"
+ " def get(path, opts = {}); end\n"
+ " def post(path, opts = {}); end\n"
+ " end\n end\nend\n"},
+ {"config/routes.rb",
+ "require_relative '../ActionDispatch/Routing'\n\n"
+ "mapper = ActionDispatch::Routing::Mapper.new\n\n"
+ "def list_items; end\ndef create_item; end\n\n"
+ "mapper.get '/items', to: 'list_items'\n"
+ "mapper.post '/items', to: 'create_item'\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HANDLES", 1));
+ PASS();
+}
+
+/* Actix-web (Rust) — local actix_web::get macro-like function
+ * whose QN contains "actix_web" */
+TEST(handles_actix_rust) {
+ static const EtFile f[] = {
+ {"actix_web/mod.rs",
+ "pub fn get(path: &str, handler: fn()) -> String {\n"
+ " format!(\"{}\", path)\n}\n\n"
+ "pub fn post(path: &str, handler: fn()) -> String {\n"
+ " format!(\"{}\", path)\n}\n"},
+ {"main.rs",
+ "mod actix_web;\n\n"
+ "fn list_widgets() {}\nfn create_widget() {}\n\n"
+ "fn main() {\n"
+ " actix_web::get(\"/widgets\", list_widgets);\n"
+ " actix_web::post(\"/widgets\", create_widget);\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HANDLES", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * HTTP_CALLS — outbound HTTP client calls
+ *
+ * Strategy: use a local wrapper whose QN carries the library substring
+ * (e.g., "requests_get" contains "requests") — same approach as
+ * test_lang_contract.c:contract_edge_http_calls.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* fetch (JavaScript) — "fetch" itself is not in the library list; a local
+ * wrapper named node_fetch or similar triggers "node-fetch".
+ * NOTE: bare `fetch` does not match any library id substring — this is a
+ * known gap. The test uses a wrapper with "node_fetch" in the name. */
+TEST(http_calls_fetch_js) {
+ static const EtFile f[] = {
+ {"http.js",
+ "function node_fetch(url, opts) { return Promise.resolve({ json: () => ({}) }); }\n\n"
+ "async function fetchUser(id) {\n"
+ " return node_fetch('/api/users/' + id);\n}\n\n"
+ "async function createUser(data) {\n"
+ " return node_fetch('/api/users', { method: 'POST', body: data });\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* axios (TypeScript) — "axios" substring in QN */
+TEST(http_calls_axios_ts) {
+ static const EtFile f[] = {
+ {"axios.ts",
+ "export function axiosGet(url: string): Promise<any> {\n"
+ " return Promise.resolve({ data: {} });\n}\n\n"
+ "export function axiosPost(url: string, data: any): Promise<any> {\n"
+ " return Promise.resolve({ data });\n}\n"},
+ {"client.ts",
+ "import { axiosGet, axiosPost } from './axios';\n\n"
+ "export async function getOrders(): Promise<any> {\n"
+ " return axiosGet('/api/orders');\n}\n\n"
+ "export async function submitOrder(payload: any): Promise<any> {\n"
+ " return axiosPost('/api/orders', payload);\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* requests (Python) — already in test_lang_contract.c but uses different fixture;
+ * this variant tests cross-file import resolution */
+TEST(http_calls_requests_python) {
+ static const EtFile f[] = {
+ {"http/requests_client.py",
+ "def requests_get(url, params=None):\n return {'url': url, 'params': params}\n\n"
+ "def requests_post(url, json=None):\n return {'url': url, 'json': json}\n"},
+ {"services/order_service.py",
+ "from http.requests_client import requests_get, requests_post\n\n\n"
+ "def fetch_order(order_id):\n"
+ " return requests_get('/api/orders', params={'id': order_id})\n\n\n"
+ "def place_order(payload):\n"
+ " return requests_post('/api/orders', json=payload)\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* net/http (Go) — "net/http" substring in resolved QN; same-file wrapper */
+TEST(http_calls_nethttp_go) {
+ static const EtFile f[] = {
+ {"nethttp/client.go",
+ "package nethttp\n\n"
+ "func Get(url string) (interface{}, error) { return nil, nil }\n"
+ "func Post(url string, body interface{}) (interface{}, error) { return nil, nil }\n"},
+ {"catalog/service.go",
+ "package catalog\n\n"
+ "import \"nethttp\"\n\n"
+ "func ListProducts() (interface{}, error) {\n"
+ " return nethttp.Get(\"/api/products\")\n}\n\n"
+ "func CreateProduct(body interface{}) (interface{}, error) {\n"
+ " return nethttp.Post(\"/api/products\", body)\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* RestTemplate (Java) — "RestTemplate" substring in resolved QN */
+TEST(http_calls_resttemplate_java) {
+ static const EtFile f[] = {
+ {"RestTemplate.java",
+ "package http;\n\n"
+ "public class RestTemplate {\n"
+ " public Object getForObject(String url, Class<?> responseType) { return null; }\n"
+ " public Object postForObject(String url, Object req, Class<?> responseType) { return null; }\n"
+ "}\n"},
+ {"OrderClient.java",
+ "package client;\n\n"
+ "import http.RestTemplate;\n\n"
+ "public class OrderClient {\n"
+ " private RestTemplate rest = new RestTemplate();\n\n"
+ " public Object fetchOrders() {\n"
+ " return rest.getForObject(\"/api/orders\", Object.class);\n }\n\n"
+ " public Object placeOrder(Object req) {\n"
+ " return rest.postForObject(\"/api/orders\", req, Object.class);\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* RestSharp (C#) — "RestSharp" substring in resolved QN */
+TEST(http_calls_restsharp_csharp) {
+ static const EtFile f[] = {
+ {"RestSharp/Client.cs",
+ "namespace RestSharp {\n"
+ " public class RestClient {\n"
+ " public string Get(string url) { return \"\"; }\n"
+ " public string Post(string url, object body) { return \"\"; }\n }\n}\n"},
+ {"Services/ProductService.cs",
+ "using RestSharp;\n\n"
+ "namespace Services {\n"
+ " class ProductService {\n"
+ " RestClient client = new RestClient();\n"
+ " public string GetProducts() { return client.Get(\"/products\"); }\n"
+ " public string AddProduct(object p) { return client.Post(\"/products\", p); }\n"
+ " }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* HTTParty (Ruby) — "HTTParty" substring in resolved QN */
+TEST(http_calls_httparty_ruby) {
+ static const EtFile f[] = {
+ {"HTTParty.rb",
+ "module HTTParty\n"
+ " def self.get(url, opts = {}); end\n"
+ " def self.post(url, opts = {}); end\nend\n"},
+ {"user_client.rb",
+ "require_relative 'HTTParty'\n\n"
+ "def fetch_users\n HTTParty.get('/api/users')\nend\n\n"
+ "def create_user(body)\n HTTParty.post('/api/users', body: body)\nend\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* Guzzle (PHP) — "Guzzle" substring in resolved QN */
+TEST(http_calls_guzzle_php) {
+ static const EtFile f[] = {
+ {"GuzzleHttp/Client.php",
+ "<?php\nnamespace GuzzleHttp;\n\n"
+ "class Client {\n"
+ " public function get(string $uri): string { return ''; }\n"
+ " public function post(string $uri, array $opts = []): string { return ''; }\n}\n"},
+ {"Services/OrderService.php",
+ "<?php\nuse GuzzleHttp\\Client;\n\n"
+ "class OrderService {\n"
+ " private Client $client;\n\n"
+ " public function __construct() { $this->client = new Client(); }\n\n"
+ " public function getOrders(): string { return $this->client->get('/orders'); }\n"
+ " public function createOrder(array $data): string {\n"
+ " return $this->client->post('/orders', ['json' => $data]);\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* reqwest (Rust) — "reqwest" substring in resolved QN */
+TEST(http_calls_reqwest_rust) {
+ static const EtFile f[] = {
+ {"reqwest/mod.rs",
+ "pub fn get(url: &str) -> String {\n url.to_string()\n}\n\n"
+ "pub fn post(url: &str, body: &str) -> String {\n format!(\"{}{}\", url, body)\n}\n"},
+ {"api/client.rs",
+ "mod reqwest;\n\n"
+ "pub fn fetch_items() -> String {\n reqwest::get(\"/api/items\")\n}\n\n"
+ "pub fn push_item(body: &str) -> String {\n reqwest::post(\"/api/items\", body)\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "HTTP_CALLS", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * ASYNC_CALLS — message/queue/pubsub dispatch
+ *
+ * Strategy: local wrappers whose QN carries the broker substring
+ * (celery, Sidekiq, kafkajs, sqs, bullmq).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Celery (Python) — "celery" substring in resolved QN */
+TEST(async_calls_celery_python) {
+ static const EtFile f[] = {
+ {"celery/app.py",
+ "class Celery:\n"
+ " def task(self):\n def decorator(fn): return fn\n return decorator\n\n"
+ " def send_task(self, name, args=None): return (name, args)\n\n"
+ "app = Celery()\n"},
+ {"tasks/order_tasks.py",
+ "from celery.app import app\n\n\n"
+ "def dispatch_order_created(order_id):\n"
+ " return app.send_task('order_created', args=[order_id])\n\n\n"
+ "def dispatch_order_shipped(order_id):\n"
+ " return app.send_task('order_shipped', args=[order_id])\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "ASYNC_CALLS", 1));
+ PASS();
+}
+
+/* Sidekiq (Ruby) — "Sidekiq" substring in resolved QN */
+TEST(async_calls_sidekiq_ruby) {
+ static const EtFile f[] = {
+ {"Sidekiq/Worker.rb",
+ "module Sidekiq\n module Worker\n"
+ " def self.perform_async(*args); end\n end\nend\n"},
+ {"workers/notification_worker.rb",
+ "require_relative '../Sidekiq/Worker'\n\n"
+ "class NotificationWorker\n"
+ " include Sidekiq::Worker\n\n"
+ " def self.enqueue_welcome(user_id)\n"
+ " Sidekiq::Worker.perform_async('welcome', user_id)\n end\n\n"
+ " def self.enqueue_alert(user_id)\n"
+ " Sidekiq::Worker.perform_async('alert', user_id)\n end\nend\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "ASYNC_CALLS", 1));
+ PASS();
+}
+
+/* KafkaJS (TypeScript) — "kafkajs" substring in resolved QN */
+TEST(async_calls_kafkajs_ts) {
+ static const EtFile f[] = {
+ {"kafkajs/producer.ts",
+ "export function kafkajsProduce(topic: string, message: any): void {}\n"},
+ {"events/order_events.ts",
+ "import { kafkajsProduce } from '../kafkajs/producer';\n\n"
+ "export function emitOrderCreated(orderId: string): void {\n"
+ " kafkajsProduce('order-created', { orderId });\n}\n\n"
+ "export function emitOrderCancelled(orderId: string): void {\n"
+ " kafkajsProduce('order-cancelled', { orderId });\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "ASYNC_CALLS", 1));
+ PASS();
+}
+
+/* AWS SQS (Go) — "aws-sdk-go/service/sqs" substring in resolved QN */
+TEST(async_calls_sqs_go) {
+ static const EtFile f[] = {
+ {"aws-sdk-go/service/sqs/api.go",
+ "package sqs\n\n"
+ "type SendMessageInput struct{ QueueUrl string; MessageBody string }\n"
+ "type SQS struct{}\n\n"
+ "func New() *SQS { return &SQS{} }\n\n"
+ "func (s *SQS) SendMessage(input *SendMessageInput) error { return nil }\n"},
+ {"queue/dispatcher.go",
+ "package queue\n\n"
+ "import \"aws-sdk-go/service/sqs\"\n\n"
+ "func DispatchOrderEvent(queueUrl, body string) error {\n"
+ " client := sqs.New()\n"
+ " return client.SendMessage(&sqs.SendMessageInput{\n"
+ " QueueUrl: queueUrl,\n"
+ " MessageBody: body,\n })\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "ASYNC_CALLS", 1));
+ PASS();
+}
+
+/* BullMQ (JavaScript) — "bullmq" substring in resolved QN */
+TEST(async_calls_bullmq_js) {
+ static const EtFile f[] = {
+ {"bullmq/queue.js",
+ "class bullmqQueue {\n"
+ " add(jobName, data) { return { jobName, data }; }\n}\n\n"
+ "module.exports = { bullmqQueue };\n"},
+ {"jobs/mailer.js",
+ "const { bullmqQueue } = require('./bullmq/queue');\n\n"
+ "const mailQueue = new bullmqQueue();\n\n"
+ "function scheduleWelcomeEmail(userId) {\n"
+ " return mailQueue.add('welcome-email', { userId });\n}\n\n"
+ "function schedulePasswordReset(userId) {\n"
+ " return mailQueue.add('password-reset', { userId });\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 2, "ASYNC_CALLS", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * THROWS — checked exceptions (no "Error"/"Panic" in name)
+ *
+ * Parallel-path only (> 50 files). THROWS/RAISES require:
+ * 1. The exception CLASS is defined as a node in the registry.
+ * 2. The throw is extracted (throw_node_types or throws_clause_field).
+ * 3. pass_parallel resolves the enclosing_func_qn + exception_name.
+ *
+ * All three conditions must hold for the edge to appear. The fixtures
+ * define the exception class in the same file so same-module resolution
+ * succeeds.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Java — explicit `throw new NotFoundException()` + class in same file.
+ * is_checked_exception("NotFoundException") = true (no "Error"/"Panic"). */
+TEST(throws_java) {
+ static const EtFile meaningful[] = {
+ {"Service.java",
+ "package app;\n\n"
+ "class NotFoundException extends Exception {\n"
+ " public NotFoundException(String msg) { super(msg); }\n}\n\n"
+ "class OrderService {\n"
+ " public String findOrder(int id) throws NotFoundException {\n"
+ " if (id < 0) {\n"
+ " throw new NotFoundException(\"Order not found: \" + id);\n }\n"
+ " return \"order:\" + id;\n }\n\n"
+ " public String getUser(int id) throws NotFoundException {\n"
+ " if (id == 0) throw new NotFoundException(\"No user zero\");\n"
+ " return \"user:\" + id;\n }\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int throws = store ? cbm_store_count_edges_by_type(store, lp.project, "THROWS") : -1;
+ if (throws < 1) {
+ fprintf(stderr, " [ET-THROWS] Java: THROWS=%d\n", throws);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(throws >= 1);
+ PASS();
+}
+
+/* Kotlin — `throw NotFoundException(...)` inside a function */
+TEST(throws_kotlin) {
+ static const EtFile meaningful[] = {
+ {"Service.kt",
+ "class NotFoundException(msg: String) : Exception(msg)\n\n"
+ "fun findItem(id: Int): String {\n"
+ " if (id < 0) throw NotFoundException(\"item not found: $id\")\n"
+ " return \"item:$id\"\n}\n\n"
+ "fun getCategory(name: String): String {\n"
+ " if (name.isEmpty()) throw NotFoundException(\"category missing\")\n"
+ " return name\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int throws = store ? cbm_store_count_edges_by_type(store, lp.project, "THROWS") : -1;
+ if (throws < 1) {
+ fprintf(stderr, " [ET-THROWS] Kotlin: THROWS=%d\n", throws);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(throws >= 1);
+ PASS();
+}
+
+/* Python — `raise ValidationException(...)` — checked (no Error/Panic) */
+TEST(throws_python) {
+ static const EtFile meaningful[] = {
+ {"validate.py",
+ "class ValidationException(Exception):\n"
+ " pass\n\n\n"
+ "def validate_email(email):\n"
+ " if '@' not in email:\n"
+ " raise ValidationException('invalid email: ' + email)\n"
+ " return email\n\n\n"
+ "def validate_age(age):\n"
+ " if age < 0:\n"
+ " raise ValidationException('age must be non-negative')\n"
+ " return age\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int throws = store ? cbm_store_count_edges_by_type(store, lp.project, "THROWS") : -1;
+ if (throws < 1) {
+ fprintf(stderr, " [ET-THROWS] Python: THROWS=%d\n", throws);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(throws >= 1);
+ PASS();
+}
+
+/* TypeScript — `throw new HttpException(...)` — checked (no Error/Panic) */
+TEST(throws_typescript) {
+ static const EtFile meaningful[] = {
+ {"exceptions.ts",
+ "export class HttpException {\n"
+ " constructor(public status: number, public message: string) {}\n}\n"},
+ {"controller.ts",
+ "import { HttpException } from './exceptions';\n\n"
+ "export function getUser(id: number): string {\n"
+ " if (id <= 0) throw new HttpException(404, 'User not found');\n"
+ " return `user:${id}`;\n}\n\n"
+ "export function updateUser(id: number, name: string): string {\n"
+ " if (!name) throw new HttpException(400, 'Name required');\n"
+ " return `updated:${id}`;\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int throws = store ? cbm_store_count_edges_by_type(store, lp.project, "THROWS") : -1;
+ if (throws < 1) {
+ fprintf(stderr, " [ET-THROWS] TypeScript: THROWS=%d\n", throws);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(throws >= 1);
+ PASS();
+}
+
+/* C# — `throw new NotFoundException(...)` — checked (no Error/Panic) */
+TEST(throws_csharp) {
+ static const EtFile meaningful[] = {
+ {"Services.cs",
+ "using System;\n\n"
+ "namespace App {\n"
+ " class NotFoundException : Exception {\n"
+ " public NotFoundException(string msg) : base(msg) {}\n }\n\n"
+ " class UserService {\n"
+ " public string GetUser(int id) {\n"
+ " if (id <= 0) throw new NotFoundException($\"User {id} not found\");\n"
+ " return $\"user:{id}\";\n }\n\n"
+ " public string DeleteUser(int id) {\n"
+ " if (id <= 0) throw new NotFoundException($\"Cannot delete {id}\");\n"
+ " return \"deleted\";\n }\n }\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int throws = store ? cbm_store_count_edges_by_type(store, lp.project, "THROWS") : -1;
+ if (throws < 1) {
+ fprintf(stderr, " [ET-THROWS] C#: THROWS=%d\n", throws);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(throws >= 1);
+ PASS();
+}
+
+/* PHP — `throw new NotFoundException(...)` — checked */
+TEST(throws_php) {
+ static const EtFile meaningful[] = {
+ {"Repository.php",
+ "<?php\n\n"
+ "class NotFoundException extends \\Exception {\n"
+ " public function __construct(string $msg) { parent::__construct($msg); }\n}\n\n"
+ "class UserRepository {\n"
+ " public function find(int $id): string {\n"
+ " if ($id <= 0) throw new NotFoundException(\"User $id not found\");\n"
+ " return \"user:$id\";\n }\n\n"
+ " public function remove(int $id): void {\n"
+ " if ($id <= 0) throw new NotFoundException(\"Cannot remove $id\");\n"
+ " }\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int throws = store ? cbm_store_count_edges_by_type(store, lp.project, "THROWS") : -1;
+ if (throws < 1) {
+ fprintf(stderr, " [ET-THROWS] PHP: THROWS=%d\n", throws);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(throws >= 1);
+ PASS();
+}
+
+/* Scala — `throw new RecordException(...)` — checked */
+TEST(throws_scala) {
+ static const EtFile meaningful[] = {
+ {"Records.scala",
+ "class RecordException(msg: String) extends Exception(msg)\n\n"
+ "def parseRecord(raw: String): String = {\n"
+ " if (raw.isEmpty) throw new RecordException(\"empty record\")\n"
+ " raw.trim\n}\n\n"
+ "def validateRecord(raw: String): Boolean = {\n"
+ " if (raw.length < 2) throw new RecordException(\"too short\")\n"
+ " true\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int throws = store ? cbm_store_count_edges_by_type(store, lp.project, "THROWS") : -1;
+ if (throws < 1) {
+ fprintf(stderr, " [ET-THROWS] Scala: THROWS=%d\n", throws);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(throws >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * RAISES — runtime errors/panics (name contains "Error" or "Panic")
+ * is_checked_exception() returns false → edge type = RAISES.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Python — `raise ValueError(...)` — runtime exception */
+TEST(raises_python) {
+ static const EtFile meaningful[] = {
+ {"parser.py",
+ "class ValueError(Exception):\n pass\n\n\n"
+ "def parse_int(s):\n"
+ " if not s.isdigit():\n"
+ " raise ValueError('not a digit: ' + s)\n"
+ " return int(s)\n\n\n"
+ "def parse_float(s):\n"
+ " try:\n return float(s)\n"
+ " except Exception:\n"
+ " raise ValueError('not a float: ' + s)\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int raises = store ? cbm_store_count_edges_by_type(store, lp.project, "RAISES") : -1;
+ if (raises < 1) {
+ fprintf(stderr, " [ET-RAISES] Python: RAISES=%d\n", raises);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(raises >= 1);
+ PASS();
+}
+
+/* TypeScript — `throw new TypeError(...)` — runtime exception */
+TEST(raises_typescript) {
+ static const EtFile meaningful[] = {
+ {"validators.ts",
+ "export class TypeError {\n"
+ " constructor(public message: string) {}\n}\n"},
+ {"parser.ts",
+ "import { TypeError } from './validators';\n\n"
+ "export function parseNumber(val: unknown): number {\n"
+ " if (typeof val !== 'number') throw new TypeError('not a number');\n"
+ " return val as number;\n}\n\n"
+ "export function parseString(val: unknown): string {\n"
+ " if (typeof val !== 'string') throw new TypeError('not a string');\n"
+ " return val as string;\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int raises = store ? cbm_store_count_edges_by_type(store, lp.project, "RAISES") : -1;
+ if (raises < 1) {
+ fprintf(stderr, " [ET-RAISES] TypeScript: RAISES=%d\n", raises);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(raises >= 1);
+ PASS();
+}
+
+/* Kotlin — `throw IllegalArgumentError(...)` — runtime (name has "Error") */
+TEST(raises_kotlin) {
+ static const EtFile meaningful[] = {
+ {"Errors.kt",
+ "class IllegalArgumentError(msg: String) : RuntimeException(msg)\n\n"
+ "fun requirePositive(n: Int): Int {\n"
+ " if (n <= 0) throw IllegalArgumentError(\"expected positive, got $n\")\n"
+ " return n\n}\n\n"
+ "fun requireNonEmpty(s: String): String {\n"
+ " if (s.isEmpty()) throw IllegalArgumentError(\"string is empty\")\n"
+ " return s\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int raises = store ? cbm_store_count_edges_by_type(store, lp.project, "RAISES") : -1;
+ if (raises < 1) {
+ fprintf(stderr, " [ET-RAISES] Kotlin: RAISES=%d\n", raises);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(raises >= 1);
+ PASS();
+}
+
+/* C# — `throw new ArgumentError(...)` — runtime (name has "Error") */
+TEST(raises_csharp) {
+ static const EtFile meaningful[] = {
+ {"Guards.cs",
+ "using System;\n\n"
+ "namespace App {\n"
+ " class ArgumentError : Exception {\n"
+ " public ArgumentError(string msg) : base(msg) {}\n }\n\n"
+ " static class Guard {\n"
+ " public static void NotNull(object obj, string name) {\n"
+ " if (obj == null) throw new ArgumentError($\"{name} must not be null\");\n"
+ " }\n"
+ " public static void Positive(int n, string name) {\n"
+ " if (n <= 0) throw new ArgumentError($\"{name} must be positive\");\n"
+ " }\n }\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int raises = store ? cbm_store_count_edges_by_type(store, lp.project, "RAISES") : -1;
+ if (raises < 1) {
+ fprintf(stderr, " [ET-RAISES] C#: RAISES=%d\n", raises);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(raises >= 1);
+ PASS();
+}
+
+/* PHP — `throw new RuntimeError(...)` — runtime (name has "Error") */
+TEST(raises_php) {
+ static const EtFile meaningful[] = {
+ {"Exceptions.php",
+ "<?php\n\n"
+ "class RuntimeError extends \\RuntimeException {\n"
+ " public function __construct(string $msg) { parent::__construct($msg); }\n}\n\n"
+ "function divide(int $a, int $b): float {\n"
+ " if ($b === 0) throw new RuntimeError('division by zero');\n"
+ " return $a / $b;\n}\n\n"
+ "function sqrt_positive(float $n): float {\n"
+ " if ($n < 0) throw new RuntimeError('sqrt of negative');\n"
+ " return sqrt($n);\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int raises = store ? cbm_store_count_edges_by_type(store, lp.project, "RAISES") : -1;
+ if (raises < 1) {
+ fprintf(stderr, " [ET-RAISES] PHP: RAISES=%d\n", raises);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(raises >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * WRITES — variable assignment: function writes to a named var
+ * that resolves to a Function/Method node in the same or adjacent file.
+ * Parallel-path only (> 50 files).
+ *
+ * The WRITES edge connects the writing function to the VARIABLE node
+ * whose name matches. Variables must be modeled as nodes (var_declaration /
+ * const_declaration etc.) and the enclosing_func_qn must resolve.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Python — simple module-level variable assignment */
+TEST(writes_python) {
+ static const EtFile meaningful[] = {
+ {"state.py",
+ "registry = {}\n\n\n"
+ "def register(key, value):\n"
+ " registry = {key: value}\n"
+ " return registry\n\n\n"
+ "def clear_registry():\n"
+ " registry = {}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int writes = store ? cbm_store_count_edges_by_type(store, lp.project, "WRITES") : -1;
+ if (writes < 1) {
+ fprintf(stderr, " [ET-WRITES] Python: WRITES=%d\n", writes);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(writes >= 1);
+ PASS();
+}
+
+/* Go — short_var_declaration and assignment_statement */
+TEST(writes_go) {
+ static const EtFile meaningful[] = {
+ {"cache.go",
+ "package cache\n\n"
+ "var store map[string]string\n\n"
+ "func Set(key, value string) {\n"
+ " store = make(map[string]string)\n"
+ " store[key] = value\n}\n\n"
+ "func Reset() {\n"
+ " store = nil\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int writes = store ? cbm_store_count_edges_by_type(store, lp.project, "WRITES") : -1;
+ if (writes < 1) {
+ fprintf(stderr, " [ET-WRITES] Go: WRITES=%d\n", writes);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(writes >= 1);
+ PASS();
+}
+
+/* Java — field assignment inside a method */
+TEST(writes_java) {
+ static const EtFile meaningful[] = {
+ {"Counter.java",
+ "package app;\n\n"
+ "class Counter {\n"
+ " private int count = 0;\n\n"
+ " public void increment() {\n"
+ " count = count + 1;\n }\n\n"
+ " public void reset() {\n"
+ " count = 0;\n }\n\n"
+ " public int get() {\n return count;\n }\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int writes = store ? cbm_store_count_edges_by_type(store, lp.project, "WRITES") : -1;
+ if (writes < 1) {
+ fprintf(stderr, " [ET-WRITES] Java: WRITES=%d\n", writes);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(writes >= 1);
+ PASS();
+}
+
+/* Rust — local variable assignment (assignment_expression) */
+TEST(writes_rust) {
+ static const EtFile meaningful[] = {
+ {"accumulator.rs",
+ "pub struct Accumulator {\n pub total: i64,\n}\n\n"
+ "impl Accumulator {\n"
+ " pub fn add(&mut self, n: i64) {\n"
+ " let total = self.total + n;\n"
+ " self.total = total;\n }\n\n"
+ " pub fn clear(&mut self) {\n"
+ " self.total = 0;\n }\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int writes = store ? cbm_store_count_edges_by_type(store, lp.project, "WRITES") : -1;
+ if (writes < 1) {
+ fprintf(stderr, " [ET-WRITES] Rust: WRITES=%d\n", writes);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(writes >= 1);
+ PASS();
+}
+
+/* C# — property assignment inside methods */
+TEST(writes_csharp) {
+ static const EtFile meaningful[] = {
+ {"Config.cs",
+ "namespace App {\n"
+ " class Config {\n"
+ " public string Host = \"localhost\";\n"
+ " public int Port = 8080;\n\n"
+ " public void SetHost(string host) {\n"
+ " Host = host;\n }\n\n"
+ " public void SetPort(int port) {\n"
+ " Port = port;\n }\n }\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int writes = store ? cbm_store_count_edges_by_type(store, lp.project, "WRITES") : -1;
+ if (writes < 1) {
+ fprintf(stderr, " [ET-WRITES] C#: WRITES=%d\n", writes);
+ }
+ et_cleanup(&lp, store);
+ ASSERT_TRUE(writes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * DEFINES_METHOD — Class/Struct→Method (structural)
+ *
+ * Sequential path. A Class node with methods must produce DEFINES_METHOD
+ * edges when the method's parent_class_qn resolves to the Class node.
+ * The P6 contract in test_lang_contract.c only uses Python; we broaden
+ * to Go (via pass_semantic.c receiver methods), Rust, Java, C#, PHP,
+ * Ruby, Kotlin, TypeScript, and Scala.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Go — struct with methods */
+TEST(defines_method_go) {
+ static const EtFile f[] = {
+ {"service.go",
+ "package svc\n\n"
+ "type OrderService struct {\n db interface{}\n}\n\n"
+ "func (s *OrderService) Create(name string) string {\n return name\n}\n\n"
+ "func (s *OrderService) Delete(id int) bool {\n return id > 0\n}\n\n"
+ "func (s *OrderService) List() []string {\n return nil\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* Rust — struct impl methods */
+TEST(defines_method_rust) {
+ static const EtFile f[] = {
+ {"product.rs",
+ "pub struct Product {\n pub name: String,\n pub price: f64,\n}\n\n"
+ "impl Product {\n"
+ " pub fn new(name: &str, price: f64) -> Self {\n"
+ " Product { name: name.to_owned(), price }\n }\n\n"
+ " pub fn discount(&self, pct: f64) -> f64 {\n"
+ " self.price * (1.0 - pct)\n }\n\n"
+ " pub fn is_free(&self) -> bool {\n self.price == 0.0\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* Java — class with instance and static methods */
+TEST(defines_method_java) {
+ static const EtFile f[] = {
+ {"Account.java",
+ "package bank;\n\n"
+ "public class Account {\n"
+ " private double balance;\n\n"
+ " public Account(double initial) { this.balance = initial; }\n\n"
+ " public void deposit(double amount) { balance += amount; }\n"
+ " public boolean withdraw(double amount) {\n"
+ " if (amount > balance) return false;\n"
+ " balance -= amount;\n return true;\n }\n"
+ " public double getBalance() { return balance; }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* C# — class with multiple methods */
+TEST(defines_method_csharp) {
+ static const EtFile f[] = {
+ {"Queue.cs",
+ "using System.Collections.Generic;\n\n"
+ "namespace Collections {\n"
+ " public class Queue<T> {\n"
+ " private List<T> items = new List<T>();\n\n"
+ " public void Enqueue(T item) { items.Add(item); }\n"
+ " public T Dequeue() {\n"
+ " T item = items[0];\n"
+ " items.RemoveAt(0);\n"
+ " return item;\n }\n"
+ " public int Count() { return items.Count; }\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* PHP — class with methods */
+TEST(defines_method_php) {
+ static const EtFile f[] = {
+ {"Cart.php",
+ "<?php\n\n"
+ "class Cart {\n"
+ " private array $items = [];\n\n"
+ " public function add(string $sku, int $qty): void {\n"
+ " $this->items[$sku] = $qty;\n }\n\n"
+ " public function remove(string $sku): void {\n"
+ " unset($this->items[$sku]);\n }\n\n"
+ " public function total(): int {\n"
+ " return array_sum($this->items);\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* Ruby — class with instance methods */
+TEST(defines_method_ruby) {
+ static const EtFile f[] = {
+ {"stack.rb",
+ "class Stack\n"
+ " def initialize\n @items = []\n end\n\n"
+ " def push(item)\n @items.push(item)\n end\n\n"
+ " def pop\n @items.pop\n end\n\n"
+ " def peek\n @items.last\n end\n\n"
+ " def empty?\n @items.empty?\n end\nend\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* Kotlin — class with methods */
+TEST(defines_method_kotlin) {
+ static const EtFile f[] = {
+ {"Wallet.kt",
+ "class Wallet(private var balance: Double) {\n"
+ " fun deposit(amount: Double) {\n balance += amount\n }\n\n"
+ " fun withdraw(amount: Double): Boolean {\n"
+ " if (amount > balance) return false\n"
+ " balance -= amount\n return true\n }\n\n"
+ " fun getBalance(): Double = balance\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* TypeScript — class with methods and constructor */
+TEST(defines_method_typescript) {
+ static const EtFile f[] = {
+ {"Logger.ts",
+ "export class Logger {\n"
+ " private prefix: string;\n\n"
+ " constructor(prefix: string) {\n this.prefix = prefix;\n }\n\n"
+ " info(msg: string): void {\n console.log(`[${this.prefix}] INFO: ${msg}`);\n }\n\n"
+ " warn(msg: string): void {\n console.warn(`[${this.prefix}] WARN: ${msg}`);\n }\n\n"
+ " error(msg: string): void {\n console.error(`[${this.prefix}] ERR: ${msg}`);\n }\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* Scala — class with methods */
+TEST(defines_method_scala) {
+ static const EtFile f[] = {
+ {"Buffer.scala",
+ "class Buffer[T] {\n"
+ " private var items: List[T] = List.empty\n\n"
+ " def append(item: T): Unit = {\n items = items :+ item\n }\n\n"
+ " def prepend(item: T): Unit = {\n items = item :: items\n }\n\n"
+ " def size: Int = items.length\n\n"
+ " def toList: List[T] = items\n}\n"}};
+ ASSERT_TRUE(et_edge_present(f, 1, "DEFINES_METHOD", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * OVERRIDE — Go implicit interface satisfaction.
+ * Produced by pass_semantic.c:cbm_pipeline_implements_go().
+ * Parallel-path only (> 50 files).
+ *
+ * Requires:
+ * 1. Interface node with method elements (method_elem).
+ * 2. Struct node whose methods match the interface's method set.
+ * 3. IMPLEMENTS + OVERRIDE edges emitted by the Go-specific pass.
+ * ══════════════════════════════════════════════════════════════════ */
+
+TEST(override_go_interface) {
+ static const EtFile meaningful[] = {
+ {"shapes.go",
+ "package shapes\n\n"
+ "type Shape interface {\n"
+ " Area() float64\n Perimeter() float64\n}\n\n"
+ "type Circle struct {\n Radius float64\n}\n\n"
+ "func (c *Circle) Area() float64 {\n"
+ " return 3.14159 * c.Radius * c.Radius\n}\n\n"
+ "func (c *Circle) Perimeter() float64 {\n"
+ " return 2.0 * 3.14159 * c.Radius\n}\n\n"
+ "type Rectangle struct {\n Width, Height float64\n}\n\n"
+ "func (r *Rectangle) Area() float64 {\n"
+ " return r.Width * r.Height\n}\n\n"
+ "func (r *Rectangle) Perimeter() float64 {\n"
+ " return 2.0 * (r.Width + r.Height)\n}\n"}};
+ EtProj lp;
+ cbm_store_t *store =
+ et_index_parallel(&lp, meaningful, (int)(sizeof(meaningful) / sizeof(meaningful[0])));
+ int override_edges = store ? cbm_store_count_edges_by_type(store, lp.project, "OVERRIDE") : -1;
+ int implements = store ? cbm_store_count_edges_by_type(store, lp.project, "IMPLEMENTS") : -1;
+ if (override_edges < 1 || implements < 1) {
+ fprintf(stderr, " [ET-OVERRIDE] Go: OVERRIDE=%d IMPLEMENTS=%d\n",
+ override_edges, implements);
+ }
+ et_cleanup(&lp, store);
+ /* Both IMPLEMENTS (struct→interface) and OVERRIDE (method→interface-method) expected. */
+ ASSERT_TRUE(override_edges >= 1);
+ ASSERT_TRUE(implements >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * SUITE
+ * ══════════════════════════════════════════════════════════════════ */
+
+SUITE(edge_types_probe) {
+ /* HANDLES — route→handler across web frameworks (8 frameworks) */
+ RUN_TEST(handles_flask_python);
+ RUN_TEST(handles_fastapi_python);
+ RUN_TEST(handles_express_ts);
+ RUN_TEST(handles_fastify_js);
+ RUN_TEST(handles_gin_go);
+ RUN_TEST(handles_spring_java);
+ RUN_TEST(handles_aspnet_csharp);
+ RUN_TEST(handles_laravel_php);
+ RUN_TEST(handles_rails_ruby);
+ RUN_TEST(handles_actix_rust);
+
+ /* HTTP_CALLS — outbound HTTP clients (9 libraries × languages) */
+ RUN_TEST(http_calls_fetch_js);
+ RUN_TEST(http_calls_axios_ts);
+ RUN_TEST(http_calls_requests_python);
+ RUN_TEST(http_calls_nethttp_go);
+ RUN_TEST(http_calls_resttemplate_java);
+ RUN_TEST(http_calls_restsharp_csharp);
+ RUN_TEST(http_calls_httparty_ruby);
+ RUN_TEST(http_calls_guzzle_php);
+ RUN_TEST(http_calls_reqwest_rust);
+
+ /* ASYNC_CALLS — message queue dispatch (5 brokers × languages) */
+ RUN_TEST(async_calls_celery_python);
+ RUN_TEST(async_calls_sidekiq_ruby);
+ RUN_TEST(async_calls_kafkajs_ts);
+ RUN_TEST(async_calls_sqs_go);
+ RUN_TEST(async_calls_bullmq_js);
+
+ /* THROWS — checked exceptions (7 languages, parallel path) */
+ RUN_TEST(throws_java);
+ RUN_TEST(throws_kotlin);
+ RUN_TEST(throws_python);
+ RUN_TEST(throws_typescript);
+ RUN_TEST(throws_csharp);
+ RUN_TEST(throws_php);
+ RUN_TEST(throws_scala);
+
+ /* RAISES — runtime errors (5 languages, parallel path) */
+ RUN_TEST(raises_python);
+ RUN_TEST(raises_typescript);
+ RUN_TEST(raises_kotlin);
+ RUN_TEST(raises_csharp);
+ RUN_TEST(raises_php);
+
+ /* WRITES — variable assignment (5 languages, parallel path) */
+ RUN_TEST(writes_python);
+ RUN_TEST(writes_go);
+ RUN_TEST(writes_java);
+ RUN_TEST(writes_rust);
+ RUN_TEST(writes_csharp);
+
+ /* DEFINES_METHOD — class→method (9 languages, sequential path) */
+ RUN_TEST(defines_method_go);
+ RUN_TEST(defines_method_rust);
+ RUN_TEST(defines_method_java);
+ RUN_TEST(defines_method_csharp);
+ RUN_TEST(defines_method_php);
+ RUN_TEST(defines_method_ruby);
+ RUN_TEST(defines_method_kotlin);
+ RUN_TEST(defines_method_typescript);
+ RUN_TEST(defines_method_scala);
+
+ /* OVERRIDE — Go interface method override (parallel path) */
+ RUN_TEST(override_go_interface);
+}
diff --git a/tests/test_lsp_resolution_probe.c b/tests/test_lsp_resolution_probe.c
new file mode 100644
index 000000000..4b8dd1ef8
--- /dev/null
+++ b/tests/test_lsp_resolution_probe.c
@@ -0,0 +1,1716 @@
+/*
+ * test_lsp_resolution_probe.c — Aggressive per-scenario LSP type-resolution probe.
+ *
+ * REPRODUCE-FIRST — green cases are permanent regression guards; red cases are
+ * reproduction tests for bugs the call-graph-count check missed. Do NOT
+ * register this suite in test_main.c (a separate agent owns that file).
+ *
+ * ════════════════════════════════════════════════════════════════════════════
+ * WHAT THIS FILE PROBES
+ * ──────────────────────
+ * The hybrid LSP TYPE-RESOLUTION PASS (pass_lsp_cross.c / cbm_run_X_lsp_cross)
+ * is wired for: Go, C, C++, CUDA, Python, JavaScript, TypeScript, TSX, PHP.
+ * It is NOT wired (cbm_pxc_has_cross_lsp returns false) for:
+ * - Rust — cbm_run_rust_lsp_cross EXISTS in rust_lsp.c but is never called
+ * - C# — cbm_run_cs_lsp_cross EXISTS in cs_lsp.c but is never called
+ * - Java — cbm_run_java_lsp_cross EXISTS in java_lsp.h but is never called
+ * - Kotlin — NO cross-file LSP function; uses per-file cbm_run_kotlin_lsp only
+ *
+ * All four missing-wiring cases fall through to the generic name-based resolver
+ * (pass_calls.c). That resolver IS project-wide, so plain same-package function
+ * calls still resolve. What it CANNOT resolve are type-dispatch scenarios where
+ * receiver-type knowledge is required (method dispatch, constructor, static call,
+ * chained call, inherited method, generics, field-type-hint).
+ *
+ * The 8 probe scenarios (applied to each of the 9 hybrid-LSP languages where
+ * applicable):
+ * S1 — cross-file plain function call (already covered by test_edge_structural.c
+ * for CALLS presence; here we add more flavours and double as sanity guards)
+ * S2 — method dispatch via receiver type (obj.method() with known type)
+ * S3 — constructor / instantiation (new T() / T{} / T() → CALLS/USAGE to type)
+ * S4 — static / class-method call (T.staticM() / T::staticM())
+ * S5 — chained call (a.b().c() — second call resolved via first
+ * return type)
+ * S6 — inherited-method call (subclass instance calls base-class method)
+ * S7 — generic/templated call (call through parameterized type)
+ * S8 — field-type-hint (this.field.method() where field has declared type)
+ *
+ * ════════════════════════════════════════════════════════════════════════════
+ * EXPECTED GREEN / RED REASONING
+ * ──────────────────────────────
+ * Languages with lsp_cross WIRED (Go, C, C++, Python, TypeScript, PHP):
+ * S1 (cross-file call): GREEN — generic resolver handles it; lsp_cross adds confidence.
+ * S2 (method dispatch): GREEN (Go/Python/TS/PHP have full type inference).
+ * S3 (constructor): GREEN for most; PHP new T() GREEN, C malloc pattern different.
+ * S4 (static call): GREEN for Go (pkg.Func), TS (Class.static), Python N/A.
+ * S5 (chained): GREEN for Go/TS/Python where return-type inference works.
+ * S6 (inherited): GREEN when inheritance chain is in same index.
+ * S7 (generic): GREEN for Go generics (1.18+) / TS generics with known type arg.
+ * S8 (field type hint): GREEN for Go/TS/Python where field types are declared.
+ *
+ * Languages WITHOUT lsp_cross (Rust, Java, Kotlin, C#):
+ * S1 (plain cross-file): GREEN — the generic name-based resolver handles it.
+ * S2 (method dispatch): RED — receiver type unknown without lsp_cross; resolver
+ * falls through to name-based (may still find it if
+ * the method name is unique; in ambiguous cases: RED).
+ * S3 (constructor): RED — type-instantiation CALLS from new T() needs type
+ * awareness; name-based resolver misses it.
+ * S4 (static call): RED — qualified T.Method() — name resolver finds "Method"
+ * but can't verify it belongs to T without type info.
+ * S5 (chained): RED — intermediate return type unknown → second call lost.
+ * S6 (inherited): RED — base-method call from subclass needs lsp_cross to
+ * resolve upward through the inheritance chain.
+ * S7 (generic): RED — parameterized type erased without lsp_cross.
+ * S8 (field type hint): RED — field-declared type unknown → this.field.method() lost.
+ *
+ * CAVEAT: "RED" means the specific TYPE-RESOLVED CALLS edge that lsp_cross would
+ * produce. For scenarios where the callee name is unambiguous in the project and the
+ * generic resolver finds it, the CALLS count may still be >=1 — we assert >= 1 for
+ * GREEN and diagnose (but don't require 0) for RED scenarios that may be partially
+ * covered by the name-based resolver. Each RED test asserts the CORRECT outcome
+ * (calls >= 1) and will fail / stay RED until lsp_cross is wired for that language.
+ *
+ * ════════════════════════════════════════════════════════════════════════════
+ * HARNESS
+ * ────────
+ * Mirrors test_edge_structural.c — self-contained static helpers with a LRP_
+ * prefix to avoid link conflicts.
+ *
+ * SUITE(lsp_resolution_probe) registers all RUN_TEST groups but is NOT wired
+ * into test_main.c. The harness infrastructure (tf_pass_count etc.) is
+ * declared extern — they live in test_main.c when linked into the full runner.
+ */
+
+#include "../src/foundation/compat.h"
+#include "test_framework.h"
+#include "test_helpers.h"
+#include "cbm.h"
+#include <mcp/mcp.h>
+#include <store/store.h>
+#include <pipeline/pipeline.h>
+#include <foundation/log.h>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#if !defined(_WIN32)
+#include <sys/wait.h>
+#endif
+
+/* ══════════════════════════════════════════════════════════════════════
+ * Harness helpers (LRP_ prefix — avoids collision with other suites).
+ * ══════════════════════════════════════════════════════════════════════ */
+
+typedef struct {
+ char tmpdir[256];
+ char dbpath[512];
+ char *project;
+ cbm_mcp_server_t *srv;
+} LRP_Proj;
+
+typedef struct {
+ const char *name; /* relative filename, may include '/' for subdirs */
+ const char *content;
+} LRP_File;
+
+static void lrp_to_fwd_slashes(char *p) {
+ for (; *p; p++) {
+ if (*p == '\\') *p = '/';
+ }
+}
+
+static cbm_store_t *lrp_open_indexed(LRP_Proj *lp) {
+ lp->project = cbm_project_name_from_path(lp->tmpdir);
+ if (!lp->project) return NULL;
+ const char *home = getenv("HOME");
+ if (!home) home = "/tmp";
+ char cache_dir[512];
+ snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/codebase-memory-mcp", home);
+ cbm_mkdir(cache_dir);
+ snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", cache_dir, lp->project);
+ unlink(lp->dbpath);
+ lp->srv = cbm_mcp_server_new(NULL);
+ if (!lp->srv) return NULL;
+ char args[700];
+ snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir);
+ char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args);
+ if (resp) free(resp);
+ return cbm_store_open_path(lp->dbpath);
+}
+
+static cbm_store_t *lrp_index(LRP_Proj *lp, const LRP_File *files, int nfiles) {
+ memset(lp, 0, sizeof(*lp));
+ snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_lrp_XXXXXX");
+ if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
+ lrp_to_fwd_slashes(lp->tmpdir);
+ for (int i = 0; i < nfiles; i++) {
+ char path[700];
+ snprintf(path, sizeof(path), "%s/%s", lp->tmpdir, files[i].name);
+ char *slash = strrchr(path, '/');
+ if (slash && slash > path + strlen(lp->tmpdir)) {
+ *slash = '\0';
+ cbm_mkdir_p(path, 0755);
+ *slash = '/';
+ }
+ FILE *f = fopen(path, "wb");
+ if (!f) return NULL;
+ fputs(files[i].content, f);
+ fclose(f);
+ }
+ return lrp_open_indexed(lp);
+}
+
+static void lrp_cleanup(LRP_Proj *lp, cbm_store_t *store) {
+ if (store) cbm_store_close(store);
+ if (lp->srv) { cbm_mcp_server_free(lp->srv); lp->srv = NULL; }
+ free(lp->project); lp->project = NULL;
+ th_rmtree(lp->tmpdir);
+ unlink(lp->dbpath);
+ char wal[600], shm[600];
+ snprintf(wal, sizeof(wal), "%s-wal", lp->dbpath);
+ snprintf(shm, sizeof(shm), "%s-shm", lp->dbpath);
+ unlink(wal); unlink(shm);
+}
+
+/* Returns USAGE edge count (-1 on DB failure). */
+static int lrp_usage(LRP_Proj *lp, const LRP_File *files, int nfiles) {
+ cbm_store_t *store = lrp_index(lp, files, nfiles);
+ int n = store ? cbm_store_count_edges_by_type(store, lp->project, "USAGE") : -1;
+ lrp_cleanup(lp, store);
+ return n;
+}
+
+/* Diagnostic: dump edge histogram to stderr on failure. */
+static const char *LRP_ALL_EDGE_TYPES[] = {
+ "CALLS", "DEFINES", "DEFINES_METHOD", "IMPORTS", "INHERITS", "IMPLEMENTS",
+ "USAGE", "DECORATES", "HANDLES", "HTTP_CALLS", "ASYNC_CALLS",
+ "OVERRIDE", "TESTS", "TESTS_FILE", "DATA_FLOWS", NULL};
+
+static void lrp_diag(cbm_store_t *store, const char *project, const char *scenario) {
+ if (!store) { fprintf(stderr, " [LRP] %s: no graph DB\n", scenario); return; }
+ char line[512] = {0};
+ for (int i = 0; LRP_ALL_EDGE_TYPES[i]; i++) {
+ int c = cbm_store_count_edges_by_type(store, project, LRP_ALL_EDGE_TYPES[i]);
+ if (c > 0 && strlen(line) < sizeof(line) - 40) {
+ char one[48];
+ snprintf(one, sizeof(one), "%s=%d ", LRP_ALL_EDGE_TYPES[i], c);
+ strncat(line, one, sizeof(line) - strlen(line) - 1);
+ }
+ }
+ fprintf(stderr, " [LRP] %s edges=[%s]\n", scenario, line[0] ? line : "(none)");
+}
+
+/* Index + assert CALLS >= floor; on failure emit diagnostics.
+ * expect_green=true: ASSERT_TRUE (green guard).
+ * expect_green=false: still asserts CALLS>=1 (the correct outcome), so RED
+ * until the bug is fixed — same pattern as test_edge_structural.c. */
+static int lrp_assert_calls(const LRP_File *files, int nfiles, int min_calls,
+ const char *scenario, int expect_green) {
+ LRP_Proj lp;
+ cbm_store_t *store = lrp_index(&lp, files, nfiles);
+ int got = store ? cbm_store_count_edges_by_type(store, lp.project, "CALLS") : -1;
+ if (got < min_calls) {
+ fprintf(stderr, " [LRP] %s FAIL calls=%d expected>=%d %s\n",
+ scenario, got, min_calls, expect_green ? "(GREEN regression)" : "(RED reproduction)");
+ lrp_diag(store, lp.project, scenario);
+ } else if (!expect_green) {
+ /* Unexpectedly passing — the lsp_cross wiring may have been added. */
+ fprintf(stderr, " [LRP] %s UNEXPECTED PASS calls=%d "
+ "(lsp_cross may now be wired — promote to GREEN)\n", scenario, got);
+ }
+ lrp_cleanup(&lp, store);
+ return got >= min_calls;
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 1: GO (lsp_cross WIRED) ──────────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * Go has the most mature lsp_cross. All 8 scenarios are expected GREEN.
+ * S1–S4 are same-package fixtures so the registry has full visibility.
+ * S5–S8 use two files to exercise cross-file type propagation.
+ */
+
+/* S1 — Go cross-file plain function call. */
+TEST(lrp_go_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"util.go", "package app\n\nfunc Double(x int) int { return x * 2 }\n"},
+ {"main.go", "package app\n\nfunc Run(n int) int { return Double(n) }\n"}};
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — Go method dispatch via receiver type (cross-file). */
+TEST(lrp_go_s2_method_dispatch) {
+ /* Counter is defined in counter.go; Run() in runner.go gets a Counter and
+ * calls its Inc() method. The lsp_cross pass sees Counter's type and
+ * resolves the method call to Counter.Inc. */
+ static const LRP_File f[] = {
+ {"counter.go",
+ "package app\n\ntype Counter struct{ n int }\n\n"
+ "func (c *Counter) Inc() { c.n++ }\n\n"
+ "func (c *Counter) Value() int { return c.n }\n"},
+ {"runner.go",
+ "package app\n\nfunc Run(c *Counter) int {\n"
+ " c.Inc()\n return c.Value()\n}\n"}};
+ /* GREEN: Go lsp_cross resolves *Counter receiver → Inc and Value methods. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S2/method_dispatch", 1));
+ PASS();
+}
+
+/* S3 — Go constructor / struct literal instantiation. */
+TEST(lrp_go_s3_constructor) {
+ /* NewCounter() is a constructor-style function. The caller creates a Counter
+ * literal and calls NewCounter. Both the struct literal usage and the function
+ * call should produce CALLS edges. */
+ static const LRP_File f[] = {
+ {"counter.go",
+ "package app\n\ntype Counter struct{ start int }\n\n"
+ "func NewCounter(start int) *Counter {\n return &Counter{start: start}\n}\n"},
+ {"main.go",
+ "package app\n\nfunc Make(n int) *Counter {\n return NewCounter(n)\n}\n"}};
+ /* GREEN: NewCounter is a top-level function; generic + lsp_cross both see it. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S3/constructor", 1));
+ PASS();
+}
+
+/* S4 — Go package-qualified static call (pkg.Func). */
+TEST(lrp_go_s4_static_call) {
+ /* Go's equivalent of a static call: importing another package and calling
+ * a top-level function via the package alias. */
+ static const LRP_File f[] = {
+ {"math/ops.go", "package math\n\nfunc Square(x int) int { return x * x }\n"},
+ {"main.go",
+ "package main\n\nimport \"math\"\n\n"
+ "func Run(n int) int { return math.Square(n) }\n"}};
+ /* GREEN: lsp_cross maps import alias "math" → package QN, resolves math.Square. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S4/static_call", 1));
+ PASS();
+}
+
+/* S5 — Go chained call (a.b().c()). */
+TEST(lrp_go_s5_chained_call) {
+ /* builder.go defines a Builder with two chainable methods; main.go chains them.
+ * The second call (.Build()) is resolved via the return type of .Add() → *Builder. */
+ static const LRP_File f[] = {
+ {"builder.go",
+ "package app\n\ntype Builder struct{ items []string }\n\n"
+ "func NewBuilder() *Builder { return &Builder{} }\n\n"
+ "func (b *Builder) Add(s string) *Builder {\n b.items = append(b.items, s)\n return b\n}\n\n"
+ "func (b *Builder) Build() []string { return b.items }\n"},
+ {"main.go",
+ "package app\n\nfunc Make() []string {\n"
+ " return NewBuilder().Add(\"x\").Build()\n}\n"}};
+ /* GREEN: lsp_cross infers *Builder from NewBuilder() return type, then
+ * resolves Add() → *Builder, then resolves Build(). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S5/chained_call", 1));
+ PASS();
+}
+
+/* S6 — Go embedded-struct method call (Go's "inheritance"). */
+TEST(lrp_go_s6_inherited_method) {
+ /* Dog embeds Animal. Calling dog.Speak() should resolve to Animal.Speak. */
+ static const LRP_File f[] = {
+ {"animal.go",
+ "package zoo\n\ntype Animal struct{ Name string }\n\n"
+ "func (a *Animal) Speak() string { return a.Name }\n"},
+ {"dog.go",
+ "package zoo\n\ntype Dog struct{ Animal }\n\n"
+ "func Run(d *Dog) string { return d.Speak() }\n"}};
+ /* GREEN: Go lsp_cross handles embedded-struct field promotion; Speak() is
+ * resolved to Animal.Speak via the embedded Animal field. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S6/inherited_method", 1));
+ PASS();
+}
+
+/* S7 — Go generic function call (Go 1.18 generics). */
+TEST(lrp_go_s7_generic_call) {
+ /* Map is a generic function in util.go; called from main.go with a concrete type. */
+ static const LRP_File f[] = {
+ {"util.go",
+ "package app\n\nfunc Map[T, U any](xs []T, fn func(T) U) []U {\n"
+ " out := make([]U, len(xs))\n"
+ " for i, x := range xs {\n out[i] = fn(x)\n }\n return out\n}\n"},
+ {"main.go",
+ "package app\n\nfunc Double(xs []int) []int {\n"
+ " return Map(xs, func(x int) int { return x * 2 })\n}\n"}};
+ /* GREEN: Map is a top-level generic function; both generic + lsp_cross resolvers
+ * find it by name regardless of the type parameter instantiation. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S7/generic_call", 1));
+ PASS();
+}
+
+/* S8 — Go field-type-hint (this.field.method()). */
+TEST(lrp_go_s8_field_type_hint) {
+ /* Service has a field `repo *Repo`; its methods call repo.Find(). */
+ static const LRP_File f[] = {
+ {"repo.go",
+ "package app\n\ntype Repo struct{}\n\n"
+ "func (r *Repo) Find(id int) string { return \"\" }\n"},
+ {"service.go",
+ "package app\n\ntype Service struct{ repo *Repo }\n\n"
+ "func (s *Service) Get(id int) string { return s.repo.Find(id) }\n"}};
+ /* GREEN: lsp_cross sees s.repo field of type *Repo, resolves repo.Find. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "go/S8/field_type_hint", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 2: C (lsp_cross WIRED) ───────────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * C has lsp_cross via cbm_run_c_lsp_cross. Function-pointer dispatch,
+ * struct-field calls, and pointer-to-function calls are the risky paths.
+ */
+
+/* S1 — C cross-file plain function call. */
+TEST(lrp_c_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"util.c", "int add(int a, int b) { return a + b; }\n"},
+ {"main.c", "int add(int a, int b);\n\nint run(int x) { return add(x, 1); }\n"}};
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "c/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — C method-like call via function pointer in struct. */
+TEST(lrp_c_s2_funcptr_in_struct) {
+ /* The C lsp_cross should detect obj.method() where method is a function
+ * pointer field with a known type. This is the C approximation of S2. */
+ static const LRP_File f[] = {
+ {"ops.c",
+ "typedef struct { int (*compute)(int); } Ops;\n\n"
+ "static int double_it(int x) { return x * 2; }\n\n"
+ "Ops make_ops(void) {\n Ops o;\n o.compute = double_it;\n return o;\n}\n"},
+ {"main.c",
+ "typedef struct { int (*compute)(int); } Ops;\n"
+ "Ops make_ops(void);\n\n"
+ "int run(int n) {\n Ops o = make_ops();\n return o.compute(n);\n}\n"}};
+ /* Uncertain: C lsp_cross may not track function-pointer fields through a
+ * cross-file struct. Assert the CORRECT outcome; RED if unresolved. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "c/S2/funcptr_in_struct", 1));
+ PASS();
+}
+
+/* S3 — C "constructor" pattern (factory function returns pointer). */
+TEST(lrp_c_s3_constructor) {
+ static const LRP_File f[] = {
+ {"buf.c",
+ "#include <stdlib.h>\n"
+ "typedef struct { int cap; int *data; } Buf;\n\n"
+ "Buf *buf_new(int cap) {\n Buf *b = malloc(sizeof(Buf));\n"
+ " b->cap = cap;\n return b;\n}\n"},
+ {"main.c",
+ "typedef struct { int cap; int *data; } Buf;\n"
+ "Buf *buf_new(int cap);\n\n"
+ "Buf *make_buf(int n) { return buf_new(n); }\n"}};
+ /* GREEN: buf_new is a plain function; both resolvers find it. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "c/S3/constructor", 1));
+ PASS();
+}
+
+/* S4 — C "static" pattern: file-scoped helper called across TUs. */
+TEST(lrp_c_s4_static_local) {
+ /* Note: `static` in C means file-scoped — a static helper in util.c
+ * should NOT be resolvable from main.c. This probes that the resolver
+ * does NOT create a spurious cross-file CALLS edge for a static function.
+ * Correct outcome: calls == 0 from main.c to helper (it's not exported). */
+ static const LRP_File f[] = {
+ {"util.c", "static int helper(int x) { return x + 1; }\n\n"
+ "int exported(int x) { return helper(x); }\n"},
+ {"main.c", "int exported(int x);\n\nint run(int n) { return exported(n); }\n"}};
+ /* The CALLS edge run -> exported should exist.
+ * The CALLS edge anything -> helper (static) should NOT span files.
+ * We check that at least 1 CALLS edge resolves (run -> exported). */
+ LRP_Proj lp;
+ cbm_store_t *store = lrp_index(&lp, f, 2);
+ int calls = store ? cbm_store_count_edges_by_type(store, lp.project, "CALLS") : -1;
+ lrp_cleanup(&lp, store);
+ /* GREEN guard: exported() is a public function; run->exported resolves. */
+ ASSERT_TRUE(calls >= 1);
+ PASS();
+}
+
+/* S5 — C chained dereference call (ptr->field->method). */
+TEST(lrp_c_s5_chained_deref) {
+ static const LRP_File f[] = {
+ {"node.c",
+ "typedef struct Node { int val; struct Node *next; } Node;\n\n"
+ "int node_val(const Node *n) { return n->val; }\n"},
+ {"main.c",
+ "typedef struct Node { int val; struct Node *next; } Node;\n"
+ "int node_val(const Node *n);\n\n"
+ "int run(Node *head) { return node_val(head->next); }\n"}};
+ /* GREEN: node_val is a plain function; run->node_val resolves regardless. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "c/S5/chained_deref", 1));
+ PASS();
+}
+
+/* S6 — C "inheritance" pattern: base struct embedded at start. */
+TEST(lrp_c_s6_base_method) {
+ static const LRP_File f[] = {
+ {"shape.c",
+ "typedef struct { int color; } Shape;\n\n"
+ "int shape_color(const Shape *s) { return s->color; }\n"},
+ {"circle.c",
+ "typedef struct { int color; } Shape;\n"
+ "typedef struct { Shape base; float radius; } Circle;\n"
+ "int shape_color(const Shape *s);\n\n"
+ "int run(Circle *c) { return shape_color(&c->base); }\n"}};
+ /* GREEN: shape_color is a plain function; run->shape_color resolves. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "c/S6/base_method", 1));
+ PASS();
+}
+
+/* S7 — C void* generic callback dispatch. */
+TEST(lrp_c_s7_generic_callback) {
+ static const LRP_File f[] = {
+ {"compare.c",
+ "int int_cmp(const void *a, const void *b) {\n"
+ " return *(const int*)a - *(const int*)b;\n}\n"},
+ {"sort.c",
+ "typedef int (*CmpFn)(const void *, const void *);\n"
+ "int int_cmp(const void *a, const void *b);\n\n"
+ "void my_sort(int *arr, int n) {\n"
+ " CmpFn fn = int_cmp;\n (void)fn;\n}\n"}};
+ /* Uncertain: assigning int_cmp to a function-pointer variable may or may
+ * not produce a CALLS edge. Assert the correct outcome (CALLS >= 1 for
+ * the function-pointer assignment path). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "c/S7/generic_callback", 1));
+ PASS();
+}
+
+/* S8 — C field-type-hint: accessing a known struct member's address. */
+TEST(lrp_c_s8_field_call) {
+ static const LRP_File f[] = {
+ {"logger.c",
+ "typedef struct { int level; } Logger;\n\n"
+ "void log_msg(const Logger *l, const char *msg) { (void)l; (void)msg; }\n"},
+ {"service.c",
+ "typedef struct { int level; } Logger;\n"
+ "typedef struct { Logger logger; int id; } Service;\n"
+ "void log_msg(const Logger *l, const char *msg);\n\n"
+ "void run(Service *svc, const char *m) { log_msg(&svc->logger, m); }\n"}};
+ /* GREEN: log_msg is a plain function; run->log_msg resolves. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "c/S8/field_call", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 3: C++ (lsp_cross WIRED) ──────────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * C++ uses the same c_lsp_cross with cpp_mode=true. Virtual dispatch,
+ * templates, and namespace-qualified calls are the interesting paths.
+ */
+
+/* S1 — C++ cross-file plain function call. */
+TEST(lrp_cpp_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"util.cpp", "int square(int x) { return x * x; }\n"},
+ {"main.cpp", "int square(int x);\n\nint run(int n) { return square(n); }\n"}};
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — C++ method dispatch on object (non-virtual). */
+TEST(lrp_cpp_s2_method_dispatch) {
+ static const LRP_File f[] = {
+ {"counter.cpp",
+ "class Counter {\npublic:\n"
+ " int n;\n Counter() : n(0) {}\n"
+ " void inc() { n++; }\n int val() const { return n; }\n};\n"},
+ {"main.cpp",
+ "class Counter;\n\n"
+ "int run() {\n Counter c;\n c.inc();\n return c.val();\n}\n"}};
+ /* Uncertain: forward-declaring a class without definition may limit lsp_cross
+ * type inference. Assert the correct outcome. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S2/method_dispatch", 1));
+ PASS();
+}
+
+/* S3 — C++ constructor call. */
+TEST(lrp_cpp_s3_constructor) {
+ static const LRP_File f[] = {
+ {"widget.cpp",
+ "class Widget {\npublic:\n int id;\n"
+ " Widget(int id) : id(id) {}\n"
+ " int get_id() const { return id; }\n};\n"},
+ {"main.cpp",
+ "class Widget { public: Widget(int); int get_id() const; };\n\n"
+ "int run(int n) {\n Widget w(n);\n return w.get_id();\n}\n"}};
+ /* GREEN: Widget(n) constructor call + get_id() method call. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S3/constructor", 1));
+ PASS();
+}
+
+/* S4 — C++ static method call (Class::method). */
+TEST(lrp_cpp_s4_static_method) {
+ static const LRP_File f[] = {
+ {"registry.cpp",
+ "class Registry {\npublic:\n"
+ " static int count() { return 42; }\n};\n"},
+ {"main.cpp",
+ "class Registry { public: static int count(); };\n\n"
+ "int run() { return Registry::count(); }\n"}};
+ /* GREEN: Registry::count is a static method; lsp_cross (cpp_mode) resolves
+ * the qualified name to the method node. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S4/static_method", 1));
+ PASS();
+}
+
+/* S5 — C++ chained method call. */
+TEST(lrp_cpp_s5_chained) {
+ static const LRP_File f[] = {
+ {"builder.cpp",
+ "class Builder {\npublic:\n"
+ " Builder& add(int x) { (void)x; return *this; }\n"
+ " int build() { return 1; }\n};\n"},
+ {"main.cpp",
+ "class Builder { public: Builder& add(int); int build(); };\n\n"
+ "int run() { return Builder().add(1).build(); }\n"}};
+ /* GREEN: Builder() + add() + build() chain; lsp_cross resolves return types. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S5/chained", 1));
+ PASS();
+}
+
+/* S6 — C++ virtual inherited method call. */
+TEST(lrp_cpp_s6_virtual_inherited) {
+ static const LRP_File f[] = {
+ {"shape.cpp",
+ "class Shape {\npublic:\n virtual int area() const { return 0; }\n};\n"},
+ {"circle.cpp",
+ "class Shape { public: virtual int area() const; };\n\n"
+ "class Circle : public Shape {\npublic:\n"
+ " int r;\n Circle(int r) : r(r) {}\n"
+ " int area() const override { return r * r * 3; }\n"
+ " int run() const { return Shape::area(); }\n};\n"}};
+ /* The base call Shape::area() from Circle::run() — lsp_cross should resolve
+ * this cross-file qualified call. Assert CALLS >= 1. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S6/virtual_inherited", 1));
+ PASS();
+}
+
+/* S7 — C++ template function call. */
+TEST(lrp_cpp_s7_template) {
+ static const LRP_File f[] = {
+ {"algo.cpp",
+ "template<typename T>\nT clamp(T v, T lo, T hi) {\n"
+ " if (v < lo) return lo;\n if (v > hi) return hi;\n return v;\n}\n"},
+ {"main.cpp",
+ "template<typename T> T clamp(T v, T lo, T hi);\n\n"
+ "int run(int n) { return clamp(n, 0, 100); }\n"}};
+ /* Uncertain: template functions require instantiation to resolve precisely.
+ * The name-based resolver may find clamp regardless; assert CALLS >= 1. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S7/template", 1));
+ PASS();
+}
+
+/* S8 — C++ member field method call. */
+TEST(lrp_cpp_s8_field_call) {
+ static const LRP_File f[] = {
+ {"logger.cpp",
+ "class Logger {\npublic:\n void log(const char *msg) { (void)msg; }\n};\n"},
+ {"service.cpp",
+ "class Logger { public: void log(const char *); };\n\n"
+ "class Service {\n Logger logger;\npublic:\n"
+ " void run(const char *m) { logger.log(m); }\n};\n"}};
+ /* Uncertain: logger.log() — lsp_cross must see logger's type (Logger) from
+ * the Service class definition in the same file. Assert CALLS >= 1. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "cpp/S8/field_call", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 4: RUST (lsp_cross NOT WIRED) ────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * cbm_run_rust_lsp_cross EXISTS in rust_lsp.c but cbm_pxc_has_cross_lsp
+ * returns false for CBM_LANG_RUST — the pass is NEVER called by the
+ * pipeline. The generic name-based resolver handles S1 (plain call).
+ * S2–S8 require type information and are expected RED (assert the correct
+ * outcome; they FAIL until cbm_pxc_has_cross_lsp is updated to include Rust).
+ *
+ * ROOT CAUSE: pass_lsp_cross.c cbm_pxc_has_cross_lsp() switch missing
+ * CBM_LANG_RUST case.
+ * FIX LOCATION: src/pipeline/pass_lsp_cross.c line ~280.
+ */
+
+/* S1 — Rust cross-file plain function call (GREEN: name resolver handles it). */
+TEST(lrp_rust_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"lib.rs", "pub fn square(x: i32) -> i32 { x * x }\n"},
+ {"main.rs", "mod lib;\n\nfn run(n: i32) -> i32 { lib::square(n) }\n"}};
+ /* GREEN: lib::square is found by the name resolver (qualified name matches). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "rust/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — Rust method dispatch via impl block (receiver type). */
+TEST(lrp_rust_s2_method_dispatch) {
+ /* Counter is in counter.rs; run() in runner.rs calls c.inc() and c.value().
+ * Without lsp_cross, the receiver type Counter is unknown in runner.rs,
+ * so the method calls may not resolve to the correct impl methods. */
+ static const LRP_File f[] = {
+ {"counter.rs",
+ "pub struct Counter { n: i32 }\n\n"
+ "impl Counter {\n"
+ " pub fn new(n: i32) -> Self { Counter { n } }\n"
+ " pub fn inc(&mut self) { self.n += 1; }\n"
+ " pub fn value(&self) -> i32 { self.n }\n}\n"},
+ {"runner.rs",
+ "mod counter;\n\nfn run(c: &mut counter::Counter) -> i32 {\n"
+ " c.inc();\n c.value()\n}\n"}};
+ /* RED (expected to fail): lsp_cross not wired for Rust → method dispatch
+ * through typed receiver not resolved by the generic resolver.
+ * Root cause: cbm_pxc_has_cross_lsp returns false for CBM_LANG_RUST.
+ * This test asserts the CORRECT outcome: calls >= 1. FAILS until fixed. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "rust/S2/method_dispatch", 0));
+ PASS();
+}
+
+/* S3 — Rust constructor (associated fn new). */
+TEST(lrp_rust_s3_constructor) {
+ static const LRP_File f[] = {
+ {"point.rs",
+ "pub struct Point { pub x: f64, pub y: f64 }\n\n"
+ "impl Point {\n pub fn new(x: f64, y: f64) -> Self { Point { x, y } }\n"
+ " pub fn dist(&self) -> f64 { (self.x * self.x + self.y * self.y).sqrt() }\n}\n"},
+ {"main.rs",
+ "mod point;\n\nfn run() -> f64 {\n"
+ " let p = point::Point::new(3.0, 4.0);\n p.dist()\n}\n"}};
+ /* RED: Point::new is a qualified associated function; the name resolver may find
+ * "new" generically, but Point::new in context requires lsp_cross.
+ * p.dist() requires receiver type Point — lsp_cross needed.
+ * Assert CALLS >= 1 (correct outcome). Fails until lsp_cross wired for Rust. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "rust/S3/constructor", 0));
+ PASS();
+}
+
+/* S4 — Rust static / associated method call (Type::method). */
+TEST(lrp_rust_s4_static_method) {
+ static const LRP_File f[] = {
+ {"config.rs",
+ "pub struct Config { pub debug: bool }\n\n"
+ "impl Config {\n pub fn default() -> Self { Config { debug: false } }\n"
+ " pub fn is_debug(&self) -> bool { self.debug }\n}\n"},
+ {"app.rs",
+ "mod config;\n\nfn run() -> bool {\n"
+ " let cfg = config::Config::default();\n cfg.is_debug()\n}\n"}};
+ /* RED: Config::default() is an associated (static-like) function.
+ * Without lsp_cross the receiver of is_debug() is unknown. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "rust/S4/static_method", 0));
+ PASS();
+}
+
+/* S5 — Rust chained method call. */
+TEST(lrp_rust_s5_chained) {
+ static const LRP_File f[] = {
+ {"builder.rs",
+ "pub struct Builder { items: Vec<i32> }\n\n"
+ "impl Builder {\n"
+ " pub fn new() -> Self { Builder { items: vec![] } }\n"
+ " pub fn add(mut self, x: i32) -> Self { self.items.push(x); self }\n"
+ " pub fn build(self) -> Vec<i32> { self.items }\n}\n"},
+ {"main.rs",
+ "mod builder;\n\nfn run() -> Vec<i32> {\n"
+ " builder::Builder::new().add(1).add(2).build()\n}\n"}};
+ /* RED: the chain new() → add() → add() → build() requires lsp_cross to track
+ * that each add() returns Self (Builder), which is needed to resolve build(). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "rust/S5/chained", 0));
+ PASS();
+}
+
+/* S6 — Rust trait method call on concrete type. */
+TEST(lrp_rust_s6_trait_method) {
+ /* Trait Display is defined in display.rs; Dog implements it in dog.rs.
+ * run() in main.rs calls d.show() on a Dog where show() comes from the trait. */
+ static const LRP_File f[] = {
+ {"display.rs",
+ "pub trait Display {\n fn show(&self) -> String;\n}\n"},
+ {"dog.rs",
+ "mod display;\n\npub struct Dog { pub name: String }\n\n"
+ "impl display::Display for Dog {\n"
+ " fn show(&self) -> String { self.name.clone() }\n}\n"},
+ {"main.rs",
+ "mod dog;\n\nfn run(d: &dog::Dog) -> String {\n d.show()\n}\n"}};
+ /* RED: d.show() on &Dog requires knowing Dog implements Display and that
+ * show() maps to Dog's impl — needs lsp_cross + trait resolution. */
+ ASSERT_TRUE(lrp_assert_calls(f, 3, 1, "rust/S6/trait_method", 0));
+ PASS();
+}
+
+/* S7 — Rust generic function call. */
+TEST(lrp_rust_s7_generic) {
+ static const LRP_File f[] = {
+ {"algo.rs",
+ "pub fn max_of<T: PartialOrd>(a: T, b: T) -> T {\n"
+ " if a > b { a } else { b }\n}\n"},
+ {"main.rs",
+ "mod algo;\n\nfn run(x: i32, y: i32) -> i32 {\n algo::max_of(x, y)\n}\n"}};
+ /* Uncertain: algo::max_of is a qualified name; the generic name resolver may
+ * find it. Assert CALLS >= 1. If GREEN despite no lsp_cross, it's because
+ * the name resolver handles the qualified path — that's acceptable. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "rust/S7/generic", 0));
+ PASS();
+}
+
+/* S8 — Rust field method call. */
+TEST(lrp_rust_s8_field_call) {
+ static const LRP_File f[] = {
+ {"logger.rs",
+ "pub struct Logger;\n\nimpl Logger {\n"
+ " pub fn log(&self, msg: &str) { let _ = msg; }\n}\n"},
+ {"service.rs",
+ "mod logger;\n\npub struct Service { pub logger: logger::Logger }\n\n"
+ "impl Service {\n"
+ " pub fn run(&self, msg: &str) { self.logger.log(msg); }\n}\n"}};
+ /* RED: self.logger.log() — lsp_cross must see that self.logger is of type
+ * logger::Logger and resolve log() to Logger::log.
+ * Without lsp_cross the receiver type is unknown. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "rust/S8/field_call", 0));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 5: PYTHON (lsp_cross WIRED) ──────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * Python has cbm_run_py_lsp_cross. Type inference is limited by duck
+ * typing, but explicit type annotations (PEP 484) help the LSP.
+ */
+
+/* S1 — Python cross-file plain function call. */
+TEST(lrp_python_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"util.py", "def triple(x):\n return x * 3\n"},
+ {"main.py", "from .util import triple\n\n\ndef run(n):\n return triple(n)\n"}};
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — Python method dispatch via known class. */
+TEST(lrp_python_s2_method_dispatch) {
+ static const LRP_File f[] = {
+ {"counter.py",
+ "class Counter:\n"
+ " def __init__(self):\n self.n = 0\n\n"
+ " def inc(self):\n self.n += 1\n\n"
+ " def value(self):\n return self.n\n"},
+ {"main.py",
+ "from .counter import Counter\n\n\n"
+ "def run():\n c = Counter()\n c.inc()\n return c.value()\n"}};
+ /* GREEN: py_lsp_cross tracks c = Counter() → type Counter; resolves c.inc()
+ * and c.value() to Counter.inc / Counter.value. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S2/method_dispatch", 1));
+ PASS();
+}
+
+/* S3 — Python constructor call (class instantiation). */
+TEST(lrp_python_s3_constructor) {
+ static const LRP_File f[] = {
+ {"widget.py",
+ "class Widget:\n def __init__(self, name):\n self.name = name\n\n"
+ " def label(self):\n return self.name\n"},
+ {"main.py",
+ "from .widget import Widget\n\n\ndef make(name):\n return Widget(name)\n"}};
+ /* GREEN: Widget(name) is a constructor call; py_lsp_cross sees Widget type from
+ * the import and creates a CALLS edge make -> Widget.__init__. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S3/constructor", 1));
+ PASS();
+}
+
+/* S4 — Python class method call (classmethod / staticmethod). */
+TEST(lrp_python_s4_class_method) {
+ static const LRP_File f[] = {
+ {"factory.py",
+ "class Factory:\n"
+ " @classmethod\n def create(cls, n):\n return cls()\n\n"
+ " @staticmethod\n def version():\n return '1.0'\n"},
+ {"main.py",
+ "from .factory import Factory\n\n\ndef run():\n"
+ " v = Factory.version()\n return v\n"}};
+ /* GREEN: Factory.version() is a static method call; lsp_cross resolves it. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S4/class_method", 1));
+ PASS();
+}
+
+/* S5 — Python chained call. */
+TEST(lrp_python_s5_chained) {
+ static const LRP_File f[] = {
+ {"builder.py",
+ "class Builder:\n def __init__(self):\n self.items = []\n\n"
+ " def add(self, x):\n self.items.append(x)\n return self\n\n"
+ " def build(self):\n return list(self.items)\n"},
+ {"main.py",
+ "from .builder import Builder\n\n\ndef make():\n"
+ " return Builder().add(1).add(2).build()\n"}};
+ /* GREEN: Builder() returns Builder; add() returns self (Builder); build()
+ * resolves via return-type chain. py_lsp_cross handles self-returning methods. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S5/chained", 1));
+ PASS();
+}
+
+/* S6 — Python inherited method call. */
+TEST(lrp_python_s6_inherited_method) {
+ static const LRP_File f[] = {
+ {"base.py",
+ "class Base:\n def describe(self):\n return 'base'\n"},
+ {"child.py",
+ "from .base import Base\n\n\nclass Child(Base):\n"
+ " def extra(self):\n return 'extra'\n\n\n"
+ "def run(c):\n return c.describe()\n"}};
+ /* Uncertain: c.describe() on a Child — py_lsp_cross must see Child inherits Base
+ * (requires INHERITS edge resolution). Given the Python extraction bug for
+ * base_classes, this may be RED end-to-end even if py_lsp_cross is correct.
+ * Assert the correct outcome; RED if extraction bug blocks resolution. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S6/inherited_method", 0));
+ PASS();
+}
+
+/* S7 — Python type-annotated call (PEP 484 type hint). */
+TEST(lrp_python_s7_annotated_call) {
+ static const LRP_File f[] = {
+ {"repo.py",
+ "class Repo:\n def find(self, id: int) -> str:\n return ''\n"},
+ {"service.py",
+ "from .repo import Repo\n\n\nclass Service:\n"
+ " def __init__(self, repo: Repo):\n self.repo = repo\n\n"
+ " def get(self, id: int) -> str:\n return self.repo.find(id)\n"}};
+ /* GREEN: self.repo is annotated as Repo; py_lsp_cross reads the annotation
+ * and resolves self.repo.find() to Repo.find. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S7/annotated_call", 1));
+ PASS();
+}
+
+/* S8 — Python field-type-hint (self.field.method()). */
+TEST(lrp_python_s8_field_type_hint) {
+ /* Service stores a logger field and calls logger.log() in methods. */
+ static const LRP_File f[] = {
+ {"logger.py",
+ "class Logger:\n def log(self, msg: str) -> None:\n pass\n"},
+ {"service.py",
+ "from .logger import Logger\n\n\nclass Service:\n"
+ " def __init__(self):\n self.logger: Logger = Logger()\n\n"
+ " def run(self, msg: str):\n self.logger.log(msg)\n"}};
+ /* GREEN: self.logger is annotated as Logger; py_lsp_cross resolves
+ * self.logger.log() to Logger.log. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "python/S8/field_type_hint", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 6: TYPESCRIPT (lsp_cross WIRED) ───────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * TypeScript has cbm_run_ts_lsp_cross. Static types make S2–S8 more
+ * tractable than Python.
+ */
+
+/* S1 — TypeScript cross-file plain function call. */
+TEST(lrp_ts_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"util.ts", "export function format(s: string): string { return s.trim(); }\n"},
+ {"main.ts",
+ "import { format } from './util';\n\n"
+ "export function run(s: string): string { return format(s); }\n"}};
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — TypeScript method dispatch via typed variable. */
+TEST(lrp_ts_s2_method_dispatch) {
+ static const LRP_File f[] = {
+ {"counter.ts",
+ "export class Counter {\n private n = 0;\n"
+ " inc(): void { this.n++; }\n value(): number { return this.n; }\n}\n"},
+ {"main.ts",
+ "import { Counter } from './counter';\n\n"
+ "export function run(): number {\n"
+ " const c = new Counter();\n c.inc();\n return c.value();\n}\n"}};
+ /* GREEN: ts_lsp_cross resolves c: Counter → inc() and value(). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S2/method_dispatch", 1));
+ PASS();
+}
+
+/* S3 — TypeScript constructor call. */
+TEST(lrp_ts_s3_constructor) {
+ static const LRP_File f[] = {
+ {"widget.ts",
+ "export class Widget {\n constructor(public name: string) {}\n"
+ " label(): string { return this.name; }\n}\n"},
+ {"main.ts",
+ "import { Widget } from './widget';\n\n"
+ "export function make(name: string): Widget {\n return new Widget(name);\n}\n"}};
+ /* GREEN: new Widget(name) — ts_lsp_cross sees Widget constructor from import. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S3/constructor", 1));
+ PASS();
+}
+
+/* S4 — TypeScript static method call. */
+TEST(lrp_ts_s4_static_method) {
+ static const LRP_File f[] = {
+ {"factory.ts",
+ "export class Factory {\n static version(): string { return '1.0'; }\n"
+ " static create(): Factory { return new Factory(); }\n}\n"},
+ {"main.ts",
+ "import { Factory } from './factory';\n\n"
+ "export function run(): string { return Factory.version(); }\n"}};
+ /* GREEN: Factory.version() is a static method; ts_lsp_cross resolves it via
+ * the imported Factory class. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S4/static_method", 1));
+ PASS();
+}
+
+/* S5 — TypeScript chained method call. */
+TEST(lrp_ts_s5_chained) {
+ static const LRP_File f[] = {
+ {"builder.ts",
+ "export class Builder {\n private items: number[] = [];\n"
+ " add(x: number): Builder { this.items.push(x); return this; }\n"
+ " build(): number[] { return this.items; }\n}\n"},
+ {"main.ts",
+ "import { Builder } from './builder';\n\n"
+ "export function run(): number[] {\n"
+ " return new Builder().add(1).add(2).build();\n}\n"}};
+ /* GREEN: ts_lsp_cross infers Builder from new Builder(), add() returns Builder,
+ * build() resolves through the chain. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S5/chained", 1));
+ PASS();
+}
+
+/* S6 — TypeScript inherited method call. */
+TEST(lrp_ts_s6_inherited_method) {
+ static const LRP_File f[] = {
+ {"base.ts",
+ "export class Base {\n describe(): string { return 'base'; }\n}\n"},
+ {"child.ts",
+ "import { Base } from './base';\n\n"
+ "export class Child extends Base {\n extra(): string { return 'child'; }\n}\n\n"
+ "export function run(c: Child): string { return c.describe(); }\n"}};
+ /* Uncertain: c.describe() on Child — ts_lsp_cross must see Child extends Base
+ * (requires TS INHERITS resolution, which has a known extraction bug).
+ * Assert the correct outcome; RED if TS inheritance extraction bug blocks it. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S6/inherited_method", 0));
+ PASS();
+}
+
+/* S7 — TypeScript generic function call. */
+TEST(lrp_ts_s7_generic) {
+ static const LRP_File f[] = {
+ {"algo.ts",
+ "export function maxOf<T>(a: T, b: T, cmp: (x: T, y: T) => number): T {\n"
+ " return cmp(a, b) >= 0 ? a : b;\n}\n"},
+ {"main.ts",
+ "import { maxOf } from './algo';\n\n"
+ "export function run(a: number, b: number): number {\n"
+ " return maxOf(a, b, (x, y) => x - y);\n}\n"}};
+ /* GREEN: maxOf is a named import; ts_lsp_cross resolves it regardless of
+ * type parameter instantiation. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S7/generic", 1));
+ PASS();
+}
+
+/* S8 — TypeScript field-type-hint (this.field.method()). */
+TEST(lrp_ts_s8_field_type_hint) {
+ static const LRP_File f[] = {
+ {"logger.ts",
+ "export class Logger {\n log(msg: string): void { console.log(msg); }\n}\n"},
+ {"service.ts",
+ "import { Logger } from './logger';\n\n"
+ "export class Service {\n private logger: Logger;\n"
+ " constructor() { this.logger = new Logger(); }\n"
+ " run(msg: string): void { this.logger.log(msg); }\n}\n"}};
+ /* GREEN: this.logger is typed as Logger; ts_lsp_cross sees the field type
+ * and resolves this.logger.log() to Logger.log. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "ts/S8/field_type_hint", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 7: JAVA (lsp_cross NOT WIRED) ─────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * cbm_run_java_lsp_cross EXISTS (java_lsp.h) but cbm_pxc_has_cross_lsp
+ * returns false for CBM_LANG_JAVA.
+ * S1 (plain call via Util.method()): GREEN via name-based resolver.
+ * S2–S8: RED until cbm_pxc_has_cross_lsp is updated.
+ *
+ * ROOT CAUSE: pass_lsp_cross.c cbm_pxc_has_cross_lsp() missing CBM_LANG_JAVA.
+ * FIX LOCATION: src/pipeline/pass_lsp_cross.c line ~280.
+ */
+
+/* S1 — Java cross-file plain method call (same package). */
+TEST(lrp_java_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"Util.java", "package app;\n\nclass Util {\n static int square(int x) { return x * x; }\n}\n"},
+ {"Main.java", "package app;\n\nclass Main {\n int run(int n) { return Util.square(n); }\n}\n"}};
+ /* GREEN: Util.square is resolved by the name-based resolver (class.method name match). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — Java method dispatch on instance (receiver type from field). */
+TEST(lrp_java_s2_method_dispatch) {
+ static const LRP_File f[] = {
+ {"Counter.java",
+ "package app;\n\nclass Counter {\n private int n = 0;\n"
+ " public void inc() { n++; }\n public int value() { return n; }\n}\n"},
+ {"Runner.java",
+ "package app;\n\nclass Runner {\n"
+ " public int run() {\n Counter c = new Counter();\n"
+ " c.inc();\n return c.value();\n }\n}\n"}};
+ /* RED: c.inc() / c.value() on Counter — without java_lsp_cross the
+ * receiver type (Counter) is not known; the name-based resolver may find
+ * "inc" and "value" by name, but won't guarantee the correct attribution.
+ * Assert the correct outcome (CALLS >= 1). Fails until lsp_cross wired. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S2/method_dispatch", 0));
+ PASS();
+}
+
+/* S3 — Java constructor call (new T()). */
+TEST(lrp_java_s3_constructor) {
+ static const LRP_File f[] = {
+ {"Widget.java",
+ "package app;\n\nclass Widget {\n private String name;\n"
+ " public Widget(String name) { this.name = name; }\n"
+ " public String label() { return name; }\n}\n"},
+ {"Factory.java",
+ "package app;\n\nclass Factory {\n"
+ " public Widget make(String name) { return new Widget(name); }\n}\n"}};
+ /* RED: new Widget(name) — constructor call requires type knowledge.
+ * The name resolver cannot reliably connect new Widget() to Widget.<init>. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S3/constructor", 0));
+ PASS();
+}
+
+/* S4 — Java static method call (Class.staticMethod). */
+TEST(lrp_java_s4_static_method) {
+ static const LRP_File f[] = {
+ {"MathUtil.java",
+ "package app;\n\nclass MathUtil {\n"
+ " public static int clamp(int v, int lo, int hi) {\n"
+ " return v < lo ? lo : v > hi ? hi : v;\n }\n}\n"},
+ {"App.java",
+ "package app;\n\nclass App {\n"
+ " public int run(int n) { return MathUtil.clamp(n, 0, 100); }\n}\n"}};
+ /* Uncertain: MathUtil.clamp — the name resolver may find "clamp" via name match.
+ * Assert CALLS >= 1; may be GREEN even without lsp_cross if name is unique. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S4/static_method", 0));
+ PASS();
+}
+
+/* S5 — Java chained method call. */
+TEST(lrp_java_s5_chained) {
+ static const LRP_File f[] = {
+ {"Builder.java",
+ "package app;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n"
+ "class Builder {\n private List<Integer> items = new ArrayList<>();\n"
+ " public Builder add(int x) { items.add(x); return this; }\n"
+ " public List<Integer> build() { return items; }\n}\n"},
+ {"Main.java",
+ "package app;\n\nimport java.util.List;\n\n"
+ "class Main {\n public List<Integer> run() {\n"
+ " return new Builder().add(1).add(2).build();\n }\n}\n"}};
+ /* RED: chained calls new Builder().add(1).add(2).build() require type tracking.
+ * Without lsp_cross the intermediate types are unknown. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S5/chained", 0));
+ PASS();
+}
+
+/* S6 — Java inherited method call (subclass calls base method). */
+TEST(lrp_java_s6_inherited_method) {
+ static const LRP_File f[] = {
+ {"Animal.java",
+ "package zoo;\n\nclass Animal {\n public String describe() { return \"animal\"; }\n}\n"},
+ {"Dog.java",
+ "package zoo;\n\nclass Dog extends Animal {\n"
+ " public String run() { return describe(); }\n}\n"}};
+ /* Uncertain: describe() in Dog.run() — the name-based resolver may find it
+ * if "describe" is unique in the project. Assert CALLS >= 1. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S6/inherited_method", 0));
+ PASS();
+}
+
+/* S7 — Java generic method call. */
+TEST(lrp_java_s7_generic) {
+ static const LRP_File f[] = {
+ {"Util.java",
+ "package app;\n\nimport java.util.List;\n\n"
+ "class Util {\n public static <T> T first(List<T> list) {\n"
+ " return list.isEmpty() ? null : list.get(0);\n }\n}\n"},
+ {"App.java",
+ "package app;\n\nimport java.util.List;\nimport java.util.ArrayList;\n\n"
+ "class App {\n public String run() {\n"
+ " List<String> xs = new ArrayList<>();\n"
+ " xs.add(\"hello\");\n return Util.first(xs);\n }\n}\n"}};
+ /* Uncertain: Util.first is a generic static; name resolver may find it. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S7/generic", 0));
+ PASS();
+}
+
+/* S8 — Java field-type-hint (this.field.method()). */
+TEST(lrp_java_s8_field_type_hint) {
+ static const LRP_File f[] = {
+ {"Logger.java",
+ "package app;\n\nclass Logger {\n"
+ " public void log(String msg) { System.out.println(msg); }\n}\n"},
+ {"Service.java",
+ "package app;\n\nclass Service {\n private Logger logger = new Logger();\n"
+ " public void run(String msg) { logger.log(msg); }\n}\n"}};
+ /* RED: logger.log() — without lsp_cross the receiver type Logger is not
+ * tracked from the field declaration across to the call site. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "java/S8/field_type_hint", 0));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 8: KOTLIN (lsp_cross NOT IMPLEMENTED) ─────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * Kotlin has cbm_run_kotlin_lsp (per-file) but NO cbm_run_kotlin_lsp_cross.
+ * The generic name-based resolver covers S1. S2–S8 are RED.
+ *
+ * ROOT CAUSE: No cross-file LSP function exists for Kotlin; the per-file
+ * cbm_run_kotlin_lsp is never invoked with cross-file project-wide defs.
+ * FIX LOCATION: internal/cbm/lsp/kotlin_lsp.c — add cbm_run_kotlin_lsp_cross,
+ * then wire it in pass_lsp_cross.c.
+ */
+
+/* S1 — Kotlin cross-file plain function call. */
+TEST(lrp_kotlin_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"Util.kt", "fun double(x: Int): Int = x * 2\n"},
+ {"Main.kt", "fun run(n: Int): Int = double(n)\n"}};
+ /* GREEN: double is a top-level function; the name resolver finds it. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — Kotlin method dispatch on typed receiver. */
+TEST(lrp_kotlin_s2_method_dispatch) {
+ static const LRP_File f[] = {
+ {"Counter.kt",
+ "class Counter {\n private var n = 0\n"
+ " fun inc() { n++ }\n fun value(): Int = n\n}\n"},
+ {"Runner.kt",
+ "fun run(c: Counter): Int {\n c.inc()\n return c.value()\n}\n"}};
+ /* RED: c.inc() / c.value() require knowing c: Counter and resolving
+ * methods through the class definition in Counter.kt. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S2/method_dispatch", 0));
+ PASS();
+}
+
+/* S3 — Kotlin constructor call. */
+TEST(lrp_kotlin_s3_constructor) {
+ static const LRP_File f[] = {
+ {"Widget.kt",
+ "class Widget(val name: String) {\n fun label(): String = name\n}\n"},
+ {"Main.kt",
+ "fun make(name: String): Widget = Widget(name)\n"}};
+ /* RED: Widget(name) is a constructor call; without cross-file LSP the type
+ * Widget from Widget.kt is not in the per-file resolver scope. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S3/constructor", 0));
+ PASS();
+}
+
+/* S4 — Kotlin companion-object static call. */
+TEST(lrp_kotlin_s4_companion_static) {
+ static const LRP_File f[] = {
+ {"Config.kt",
+ "class Config(val debug: Boolean) {\n"
+ " companion object {\n fun default(): Config = Config(false)\n }\n}\n"},
+ {"App.kt",
+ "fun run(): Config = Config.default()\n"}};
+ /* RED: Config.default() is a companion-object call; requires cross-file type
+ * knowledge of Config and its companion object. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S4/companion_static", 0));
+ PASS();
+}
+
+/* S5 — Kotlin chained method call. */
+TEST(lrp_kotlin_s5_chained) {
+ static const LRP_File f[] = {
+ {"Builder.kt",
+ "class Builder {\n private val items = mutableListOf<Int>()\n"
+ " fun add(x: Int): Builder { items.add(x); return this }\n"
+ " fun build(): List<Int> = items.toList()\n}\n"},
+ {"Main.kt",
+ "fun run(): List<Int> = Builder().add(1).add(2).build()\n"}};
+ /* RED: Builder() → add() → build() chain requires type tracking across files. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S5/chained", 0));
+ PASS();
+}
+
+/* S6 — Kotlin inherited method call (open class). */
+TEST(lrp_kotlin_s6_inherited_method) {
+ static const LRP_File f[] = {
+ {"Base.kt",
+ "open class Base {\n open fun describe(): String = \"base\"\n}\n"},
+ {"Child.kt",
+ "class Child : Base() {\n fun run(): String = describe()\n}\n"}};
+ /* RED: describe() in Child.run() requires knowing Child extends Base.
+ * Kotlin extraction bug (`:` supertype not parsed) compounds this. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S6/inherited_method", 0));
+ PASS();
+}
+
+/* S7 — Kotlin generic function call. */
+TEST(lrp_kotlin_s7_generic) {
+ static const LRP_File f[] = {
+ {"Algo.kt",
+ "fun <T : Comparable<T>> maxOf(a: T, b: T): T = if (a > b) a else b\n"},
+ {"Main.kt",
+ "fun run(a: Int, b: Int): Int = maxOf(a, b)\n"}};
+ /* Uncertain: maxOf is a top-level generic function; name resolver may find
+ * it. Assert CALLS >= 1; may be GREEN via name resolver. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S7/generic", 0));
+ PASS();
+}
+
+/* S8 — Kotlin field-type-hint (this.field.method()). */
+TEST(lrp_kotlin_s8_field_type_hint) {
+ static const LRP_File f[] = {
+ {"Logger.kt",
+ "class Logger {\n fun log(msg: String): Unit { println(msg) }\n}\n"},
+ {"Service.kt",
+ "class Service {\n private val logger = Logger()\n"
+ " fun run(msg: String) { logger.log(msg) }\n}\n"}};
+ /* RED: logger.log() — without cross-file LSP the type of logger (Logger)
+ * is not known; name resolver may find "log" by name alone. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "kotlin/S8/field_type_hint", 0));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── GROUP 9: C# (lsp_cross NOT WIRED) ───────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * cbm_run_cs_lsp_cross EXISTS (cs_lsp.c) and the CBMCrossLspRegistries
+ * struct even has a `cs` field — but cbm_pxc_has_cross_lsp returns false
+ * for CBM_LANG_CSHARP. The cross-LSP pass is never invoked for C# files.
+ *
+ * ROOT CAUSE: pass_lsp_cross.c cbm_pxc_has_cross_lsp() missing CBM_LANG_CSHARP.
+ * FIX LOCATION: src/pipeline/pass_lsp_cross.c line ~280.
+ * NOTE: CBMCrossLspRegistries.cs is already defined and cbm_pxc_registry_for_lang
+ * handles CSHARP — so the fix is a 1-line addition to cbm_pxc_has_cross_lsp().
+ */
+
+/* S1 — C# cross-file plain static call. */
+TEST(lrp_csharp_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"Util.cs",
+ "namespace App {\n class Util {\n"
+ " public static int Square(int x) { return x * x; }\n }\n}\n"},
+ {"Main.cs",
+ "namespace App {\n class Main {\n"
+ " public int Run(int n) { return Util.Square(n); }\n }\n}\n"}};
+ /* GREEN: Util.Square found by name-based resolver (class.method pattern). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — C# method dispatch on typed instance. */
+TEST(lrp_csharp_s2_method_dispatch) {
+ static const LRP_File f[] = {
+ {"Counter.cs",
+ "namespace App {\n class Counter {\n private int n = 0;\n"
+ " public void Inc() { n++; }\n public int Value() { return n; }\n }\n}\n"},
+ {"Runner.cs",
+ "namespace App {\n class Runner {\n"
+ " public int Run() {\n var c = new Counter();\n"
+ " c.Inc();\n return c.Value();\n }\n }\n}\n"}};
+ /* RED: c.Inc() / c.Value() on Counter — without cs_lsp_cross the receiver
+ * type Counter is not tracked from new Counter() to the call site. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S2/method_dispatch", 0));
+ PASS();
+}
+
+/* S3 — C# constructor call (new T()). */
+TEST(lrp_csharp_s3_constructor) {
+ static const LRP_File f[] = {
+ {"Widget.cs",
+ "namespace App {\n class Widget {\n public string Name;\n"
+ " public Widget(string name) { Name = name; }\n"
+ " public string Label() { return Name; }\n }\n}\n"},
+ {"Factory.cs",
+ "namespace App {\n class Factory {\n"
+ " public Widget Make(string name) { return new Widget(name); }\n }\n}\n"}};
+ /* RED: new Widget(name) — constructor call requires type knowledge. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S3/constructor", 0));
+ PASS();
+}
+
+/* S4 — C# static method call. */
+TEST(lrp_csharp_s4_static_method) {
+ static const LRP_File f[] = {
+ {"MathHelper.cs",
+ "namespace App {\n class MathHelper {\n"
+ " public static int Clamp(int v, int lo, int hi) {\n"
+ " return v < lo ? lo : v > hi ? hi : v;\n }\n }\n}\n"},
+ {"App.cs",
+ "namespace App {\n class AppEntry {\n"
+ " public int Run(int n) { return MathHelper.Clamp(n, 0, 100); }\n }\n}\n"}};
+ /* Uncertain: MathHelper.Clamp — name resolver may find "Clamp" if unique. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S4/static_method", 0));
+ PASS();
+}
+
+/* S5 — C# chained method call. */
+TEST(lrp_csharp_s5_chained) {
+ static const LRP_File f[] = {
+ {"Builder.cs",
+ "namespace App {\n using System.Collections.Generic;\n"
+ " class Builder {\n private List<int> items = new List<int>();\n"
+ " public Builder Add(int x) { items.Add(x); return this; }\n"
+ " public List<int> Build() { return items; }\n }\n}\n"},
+ {"Main.cs",
+ "namespace App {\n using System.Collections.Generic;\n"
+ " class Main {\n public List<int> Run() {\n"
+ " return new Builder().Add(1).Add(2).Build();\n }\n }\n}\n"}};
+ /* RED: chained calls new Builder().Add(1).Add(2).Build() — type tracking needed. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S5/chained", 0));
+ PASS();
+}
+
+/* S6 — C# inherited method call. */
+TEST(lrp_csharp_s6_inherited_method) {
+ static const LRP_File f[] = {
+ {"Base.cs",
+ "namespace App {\n class Base {\n"
+ " public virtual string Describe() { return \"base\"; }\n }\n}\n"},
+ {"Child.cs",
+ "namespace App {\n class Child : Base {\n"
+ " public string Run() { return Describe(); }\n }\n}\n"}};
+ /* Uncertain: Describe() in Child.Run() — name resolver may find it if unique. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S6/inherited_method", 0));
+ PASS();
+}
+
+/* S7 — C# generic method call. */
+TEST(lrp_csharp_s7_generic) {
+ static const LRP_File f[] = {
+ {"Container.cs",
+ "namespace App {\n using System.Collections.Generic;\n"
+ " class Container {\n"
+ " public static T First<T>(List<T> xs) {\n"
+ " return xs.Count > 0 ? xs[0] : default;\n }\n }\n}\n"},
+ {"App.cs",
+ "namespace App {\n using System.Collections.Generic;\n"
+ " class AppEntry {\n"
+ " public string Run() {\n"
+ " var xs = new List<string> { \"hello\" };\n"
+ " return Container.First(xs);\n }\n }\n}\n"}};
+ /* Uncertain: Container.First is a static generic method. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S7/generic", 0));
+ PASS();
+}
+
+/* S8 — C# field-type-hint (this.field.method()). */
+TEST(lrp_csharp_s8_field_type_hint) {
+ static const LRP_File f[] = {
+ {"Logger.cs",
+ "namespace App {\n class Logger {\n"
+ " public void Log(string msg) { }\n }\n}\n"},
+ {"Service.cs",
+ "namespace App {\n class Service {\n"
+ " private Logger logger = new Logger();\n"
+ " public void Run(string msg) { logger.Log(msg); }\n }\n}\n"}};
+ /* RED: logger.Log() — without cs_lsp_cross the receiver type Logger is not
+ * tracked from the field declaration. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "csharp/S8/field_type_hint", 0));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── BONUS: PHP (lsp_cross WIRED) ────────────────────────────────────
+ * ══════════════════════════════════════════════════════════════════════
+ * PHP has cbm_run_php_lsp_cross. Key scenarios: $this->method(),
+ * new T(), static T::method(), chaining.
+ */
+
+/* S1 — PHP cross-file function call. */
+TEST(lrp_php_s1_crossfile_call) {
+ static const LRP_File f[] = {
+ {"util.php", "<?php\nfunction triple($x) { return $x * 3; }\n"},
+ {"main.php", "<?php\nrequire_once 'util.php';\nfunction run($n) { return triple($n); }\n"}};
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "php/S1/crossfile_call", 1));
+ PASS();
+}
+
+/* S2 — PHP method dispatch via $this (cross-file). */
+TEST(lrp_php_s2_method_dispatch) {
+ static const LRP_File f[] = {
+ {"Counter.php",
+ "<?php\nclass Counter {\n private $n = 0;\n"
+ " public function inc() { $this->n++; }\n"
+ " public function value() { return $this->n; }\n}\n"},
+ {"main.php",
+ "<?php\nrequire_once 'Counter.php';\n"
+ "function run() {\n $c = new Counter();\n"
+ " $c->inc();\n return $c->value();\n}\n"}};
+ /* GREEN: php_lsp_cross tracks $c = new Counter() → type Counter;
+ * resolves $c->inc() / $c->value(). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "php/S2/method_dispatch", 1));
+ PASS();
+}
+
+/* S3 — PHP constructor (new T()). */
+TEST(lrp_php_s3_constructor) {
+ static const LRP_File f[] = {
+ {"Widget.php",
+ "<?php\nclass Widget {\n public $name;\n"
+ " public function __construct($name) { $this->name = $name; }\n"
+ " public function label() { return $this->name; }\n}\n"},
+ {"factory.php",
+ "<?php\nrequire_once 'Widget.php';\n"
+ "function make($name) { return new Widget($name); }\n"}};
+ /* GREEN: new Widget($name) — php_lsp_cross resolves the constructor. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "php/S3/constructor", 1));
+ PASS();
+}
+
+/* S4 — PHP static method call (Class::method). */
+TEST(lrp_php_s4_static_method) {
+ static const LRP_File f[] = {
+ {"Config.php",
+ "<?php\nclass Config {\n public static function version() { return '1.0'; }\n}\n"},
+ {"app.php",
+ "<?php\nrequire_once 'Config.php';\n"
+ "function run() { return Config::version(); }\n"}};
+ /* GREEN: Config::version() — php_lsp_cross resolves static method call. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "php/S4/static_method", 1));
+ PASS();
+}
+
+/* S5 — PHP chained method call. */
+TEST(lrp_php_s5_chained) {
+ static const LRP_File f[] = {
+ {"Builder.php",
+ "<?php\nclass Builder {\n private $items = [];\n"
+ " public function add($x) { $this->items[] = $x; return $this; }\n"
+ " public function build() { return $this->items; }\n}\n"},
+ {"main.php",
+ "<?php\nrequire_once 'Builder.php';\n"
+ "function run() { return (new Builder())->add(1)->add(2)->build(); }\n"}};
+ /* GREEN: (new Builder())->add()->add()->build() — php_lsp_cross tracks
+ * self-returning methods (return $this). */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "php/S5/chained", 1));
+ PASS();
+}
+
+/* S6 — PHP inherited method call. */
+TEST(lrp_php_s6_inherited_method) {
+ static const LRP_File f[] = {
+ {"Base.php",
+ "<?php\nclass Base {\n public function describe() { return 'base'; }\n}\n"},
+ {"Child.php",
+ "<?php\nrequire_once 'Base.php';\nclass Child extends Base {\n"
+ " public function run() { return $this->describe(); }\n}\n"}};
+ /* Uncertain: $this->describe() in Child::run() — php_lsp_cross must see
+ * Child extends Base. PHP extraction bug (base_classes not populated)
+ * may block this end-to-end. Assert CALLS >= 1. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "php/S6/inherited_method", 0));
+ PASS();
+}
+
+/* S7 — PHP interface method call (type-hinted parameter). */
+TEST(lrp_php_s7_interface_call) {
+ static const LRP_File f[] = {
+ {"LoggerInterface.php",
+ "<?php\ninterface LoggerInterface {\n public function log($msg);\n}\n"},
+ {"FileLogger.php",
+ "<?php\nrequire_once 'LoggerInterface.php';\n"
+ "class FileLogger implements LoggerInterface {\n"
+ " public function log($msg) { file_put_contents('/tmp/log', $msg); }\n}\n"},
+ {"Service.php",
+ "<?php\nrequire_once 'LoggerInterface.php';\n"
+ "class Service {\n private $logger;\n"
+ " public function __construct(LoggerInterface $logger) {\n"
+ " $this->logger = $logger;\n }\n"
+ " public function run($msg) { $this->logger->log($msg); }\n}\n"}};
+ /* GREEN: $this->logger is type-hinted as LoggerInterface; php_lsp_cross
+ * resolves $this->logger->log() to LoggerInterface::log. */
+ ASSERT_TRUE(lrp_assert_calls(f, 3, 1, "php/S7/interface_call", 1));
+ PASS();
+}
+
+/* S8 — PHP field-type-hint (property with docblock type). */
+TEST(lrp_php_s8_field_type_hint) {
+ static const LRP_File f[] = {
+ {"Mailer.php",
+ "<?php\nclass Mailer {\n public function send($to, $body) { return true; }\n}\n"},
+ {"Notifier.php",
+ "<?php\nrequire_once 'Mailer.php';\n"
+ "class Notifier {\n /** @var Mailer */\n private $mailer;\n"
+ " public function __construct(Mailer $mailer) {\n"
+ " $this->mailer = $mailer;\n }\n"
+ " public function notify($to, $msg) {\n"
+ " $this->mailer->send($to, $msg);\n }\n}\n"}};
+ /* GREEN: $this->mailer is type-hinted as Mailer in constructor parameter;
+ * php_lsp_cross resolves $this->mailer->send() to Mailer::send. */
+ ASSERT_TRUE(lrp_assert_calls(f, 2, 1, "php/S8/field_type_hint", 1));
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * ─── BONUS: USAGE-EDGE PROBES (type references, not calls) ───────────
+ * ══════════════════════════════════════════════════════════════════════
+ * USAGE edges are created for type references (not calls). These probe
+ * whether the LSP pass emits USAGE in addition to CALLS for instantiation
+ * and typed-parameter scenarios.
+ */
+
+/* Go: struct literal usage of a cross-file type. */
+TEST(lrp_go_usage_struct_literal) {
+ static const LRP_File f[] = {
+ {"types.go", "package app\n\ntype Config struct{ Port int }\n"},
+ {"main.go",
+ "package app\n\nfunc Make() Config { return Config{Port: 8080} }\n"}};
+ LRP_Proj lp;
+ int n = lrp_usage(&lp, f, 2);
+ /* GREEN: USAGE edge from Make to Config type (struct literal). */
+ if (n < 1) {
+ fprintf(stderr, " [LRP] go/USAGE/struct_literal n=%d expected>=1\n", n);
+ }
+ ASSERT_TRUE(n >= 1);
+ PASS();
+}
+
+/* TypeScript: type reference as parameter annotation. */
+TEST(lrp_ts_usage_type_param) {
+ static const LRP_File f[] = {
+ {"types.ts", "export interface Config { timeout: number; }\n"},
+ {"main.ts",
+ "import { Config } from './types';\n\n"
+ "export function run(cfg: Config): number { return cfg.timeout; }\n"}};
+ LRP_Proj lp;
+ int n = lrp_usage(&lp, f, 2);
+ /* GREEN: USAGE edge from run to Config type (parameter annotation). */
+ if (n < 1) {
+ fprintf(stderr, " [LRP] ts/USAGE/type_param n=%d expected>=1\n", n);
+ }
+ ASSERT_TRUE(n >= 1);
+ PASS();
+}
+
+/* Python: class instantiation USAGE. */
+TEST(lrp_python_usage_instantiation) {
+ static const LRP_File f[] = {
+ {"model.py", "class User:\n def __init__(self, name):\n self.name = name\n"},
+ {"main.py",
+ "from .model import User\n\n\ndef create(name):\n return User(name)\n"}};
+ LRP_Proj lp;
+ int n = lrp_usage(&lp, f, 2);
+ /* Uncertain: USAGE edge for Python instantiation. Diagnose but assert correct. */
+ if (n < 1) {
+ fprintf(stderr, " [LRP] python/USAGE/instantiation n=%d (uncertain)\n", n);
+ }
+ ASSERT_TRUE(n >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════════
+ * SUITE registration
+ * ══════════════════════════════════════════════════════════════════════ */
+
+SUITE(lsp_resolution_probe) {
+
+ /* ── Go (lsp_cross WIRED) — all 8 scenarios GREEN ── */
+ RUN_TEST(lrp_go_s1_crossfile_call);
+ RUN_TEST(lrp_go_s2_method_dispatch);
+ RUN_TEST(lrp_go_s3_constructor);
+ RUN_TEST(lrp_go_s4_static_call);
+ RUN_TEST(lrp_go_s5_chained_call);
+ RUN_TEST(lrp_go_s6_inherited_method);
+ RUN_TEST(lrp_go_s7_generic_call);
+ RUN_TEST(lrp_go_s8_field_type_hint);
+
+ /* ── C (lsp_cross WIRED) — S1/S3/S5–S8 GREEN, S2/S4/S7 uncertain ── */
+ RUN_TEST(lrp_c_s1_crossfile_call);
+ RUN_TEST(lrp_c_s2_funcptr_in_struct);
+ RUN_TEST(lrp_c_s3_constructor);
+ RUN_TEST(lrp_c_s4_static_local);
+ RUN_TEST(lrp_c_s5_chained_deref);
+ RUN_TEST(lrp_c_s6_base_method);
+ RUN_TEST(lrp_c_s7_generic_callback);
+ RUN_TEST(lrp_c_s8_field_call);
+
+ /* ── C++ (lsp_cross WIRED) — GREEN expected; virtual/template uncertain ── */
+ RUN_TEST(lrp_cpp_s1_crossfile_call);
+ RUN_TEST(lrp_cpp_s2_method_dispatch);
+ RUN_TEST(lrp_cpp_s3_constructor);
+ RUN_TEST(lrp_cpp_s4_static_method);
+ RUN_TEST(lrp_cpp_s5_chained);
+ RUN_TEST(lrp_cpp_s6_virtual_inherited);
+ RUN_TEST(lrp_cpp_s7_template);
+ RUN_TEST(lrp_cpp_s8_field_call);
+
+ /* ── Rust (lsp_cross NOT WIRED) — S1 GREEN, S2–S8 RED reproductions ── */
+ RUN_TEST(lrp_rust_s1_crossfile_call);
+ RUN_TEST(lrp_rust_s2_method_dispatch);
+ RUN_TEST(lrp_rust_s3_constructor);
+ RUN_TEST(lrp_rust_s4_static_method);
+ RUN_TEST(lrp_rust_s5_chained);
+ RUN_TEST(lrp_rust_s6_trait_method);
+ RUN_TEST(lrp_rust_s7_generic);
+ RUN_TEST(lrp_rust_s8_field_call);
+
+ /* ── Python (lsp_cross WIRED) — S1–S5,S7,S8 GREEN; S6 uncertain (extraction bug) ── */
+ RUN_TEST(lrp_python_s1_crossfile_call);
+ RUN_TEST(lrp_python_s2_method_dispatch);
+ RUN_TEST(lrp_python_s3_constructor);
+ RUN_TEST(lrp_python_s4_class_method);
+ RUN_TEST(lrp_python_s5_chained);
+ RUN_TEST(lrp_python_s6_inherited_method);
+ RUN_TEST(lrp_python_s7_annotated_call);
+ RUN_TEST(lrp_python_s8_field_type_hint);
+
+ /* ── TypeScript (lsp_cross WIRED) — S1–S5,S7,S8 GREEN; S6 uncertain ── */
+ RUN_TEST(lrp_ts_s1_crossfile_call);
+ RUN_TEST(lrp_ts_s2_method_dispatch);
+ RUN_TEST(lrp_ts_s3_constructor);
+ RUN_TEST(lrp_ts_s4_static_method);
+ RUN_TEST(lrp_ts_s5_chained);
+ RUN_TEST(lrp_ts_s6_inherited_method);
+ RUN_TEST(lrp_ts_s7_generic);
+ RUN_TEST(lrp_ts_s8_field_type_hint);
+
+ /* ── Java (lsp_cross NOT WIRED) — S1 GREEN, S2–S8 RED reproductions ── */
+ RUN_TEST(lrp_java_s1_crossfile_call);
+ RUN_TEST(lrp_java_s2_method_dispatch);
+ RUN_TEST(lrp_java_s3_constructor);
+ RUN_TEST(lrp_java_s4_static_method);
+ RUN_TEST(lrp_java_s5_chained);
+ RUN_TEST(lrp_java_s6_inherited_method);
+ RUN_TEST(lrp_java_s7_generic);
+ RUN_TEST(lrp_java_s8_field_type_hint);
+
+ /* ── Kotlin (no cross-file LSP) — S1 GREEN, S2–S8 RED reproductions ── */
+ RUN_TEST(lrp_kotlin_s1_crossfile_call);
+ RUN_TEST(lrp_kotlin_s2_method_dispatch);
+ RUN_TEST(lrp_kotlin_s3_constructor);
+ RUN_TEST(lrp_kotlin_s4_companion_static);
+ RUN_TEST(lrp_kotlin_s5_chained);
+ RUN_TEST(lrp_kotlin_s6_inherited_method);
+ RUN_TEST(lrp_kotlin_s7_generic);
+ RUN_TEST(lrp_kotlin_s8_field_type_hint);
+
+ /* ── C# (lsp_cross NOT WIRED — but cbm_run_cs_lsp_cross EXISTS) ── */
+ /* S1 GREEN, S2–S8 RED reproductions */
+ RUN_TEST(lrp_csharp_s1_crossfile_call);
+ RUN_TEST(lrp_csharp_s2_method_dispatch);
+ RUN_TEST(lrp_csharp_s3_constructor);
+ RUN_TEST(lrp_csharp_s4_static_method);
+ RUN_TEST(lrp_csharp_s5_chained);
+ RUN_TEST(lrp_csharp_s6_inherited_method);
+ RUN_TEST(lrp_csharp_s7_generic);
+ RUN_TEST(lrp_csharp_s8_field_type_hint);
+
+ /* ── PHP (lsp_cross WIRED) — S1–S5 GREEN; S6 uncertain; S7,S8 GREEN ── */
+ RUN_TEST(lrp_php_s1_crossfile_call);
+ RUN_TEST(lrp_php_s2_method_dispatch);
+ RUN_TEST(lrp_php_s3_constructor);
+ RUN_TEST(lrp_php_s4_static_method);
+ RUN_TEST(lrp_php_s5_chained);
+ RUN_TEST(lrp_php_s6_inherited_method);
+ RUN_TEST(lrp_php_s7_interface_call);
+ RUN_TEST(lrp_php_s8_field_type_hint);
+
+ /* ── USAGE-edge bonus probes ── */
+ RUN_TEST(lrp_go_usage_struct_literal);
+ RUN_TEST(lrp_ts_usage_type_param);
+ RUN_TEST(lrp_python_usage_instantiation);
+}
diff --git a/tests/test_main.c b/tests/test_main.c
index 7f2364f99..1f69da988 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -80,6 +80,9 @@ extern void suite_integration(void);
extern void suite_lang_contract(void);
extern void suite_edge_imports(void);
extern void suite_edge_structural(void);
+extern void suite_lsp_resolution_probe(void);
+extern void suite_node_creation_probe(void);
+extern void suite_edge_types_probe(void);
extern void suite_incremental(void);
extern void suite_simhash(void);
extern void suite_stack_overflow(void);
@@ -217,6 +220,9 @@ int main(void) {
RUN_SUITE(lang_contract);
RUN_SUITE(edge_imports);
RUN_SUITE(edge_structural);
+ RUN_SUITE(lsp_resolution_probe);
+ RUN_SUITE(node_creation_probe);
+ RUN_SUITE(edge_types_probe);
RUN_SUITE(incremental);
diff --git a/tests/test_node_creation_probe.c b/tests/test_node_creation_probe.c
new file mode 100644
index 000000000..a9b3dce13
--- /dev/null
+++ b/tests/test_node_creation_probe.c
@@ -0,0 +1,1839 @@
+/*
+ * test_node_creation_probe.c — Reproduce-first node-creation probe.
+ *
+ * Green = guard (node/edge already created correctly).
+ * Red = bug found (node/edge not produced; keep until fixed).
+ *
+ * Each per-language group indexes a fixture through the FULL pipeline via the
+ * same lang_index / lang_metrics harness as test_lang_contract.c (the helpers
+ * are copy-included here so this file compiles stand-alone without touching
+ * test_main.c or test_lang_contract.c).
+ *
+ * Coverage strategy:
+ * - 9 hybrid-LSP languages (Go, C, C++, Rust, Python, TypeScript, Java,
+ * Kotlin, C#): functions, methods, classes/structs, enums, interfaces/
+ * traits, nested functions, lambdas/closures, generics, type aliases,
+ * constants/global vars. ~6-12 cases each.
+ * - 14 grammar-only languages (Ruby, Swift, Scala, Lua, Bash, Dart, Elixir,
+ * Haskell, Zig, OCaml, Erlang, Groovy, Nim, GDScript): functions + a
+ * class/module + intra-file call. ~3-6 cases each.
+ *
+ * How languages were confirmed supported: each uses a CBM_LANG_* constant
+ * from cbm.h (the canonical enum); the label-golden table in
+ * test_grammar_labels.c provides the expected histogram per grammar.
+ *
+ * Known expected-RED cases (document the gap, keep for fix-phase):
+ * - Dart CALLS edge: extract_calls.c has no dart branch (selector call).
+ * - Groovy CALLS edge: function_call callee resolution unhandled.
+ *
+ * Do NOT register in test_main.c — run via standalone suite.
+ */
+#include "../src/foundation/compat.h"
+#include "test_framework.h"
+#include "test_helpers.h"
+#include "cbm.h"
+#include <mcp/mcp.h>
+#include <store/store.h>
+#include <pipeline/pipeline.h>
+#include <foundation/log.h>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+/* ══════════════════════════════════════════════════════════════════
+ * Harness — copy of the static helpers from test_lang_contract.c.
+ * (Duplicated here so the probe file is self-contained and does not
+ * require test_main.c changes.)
+ * ══════════════════════════════════════════════════════════════════ */
+
+typedef struct {
+ char tmpdir[256];
+ char dbpath[512];
+ char *project;
+ cbm_mcp_server_t *srv;
+} NcpLangProj;
+
+typedef struct {
+ const char *name;
+ const char *content;
+} NcpLangFile;
+
+static void ncp_to_fwd_slashes(char *p) {
+ for (; *p; p++) {
+ if (*p == '\\') *p = '/';
+ }
+}
+
+static cbm_store_t *ncp_open_indexed(NcpLangProj *lp) {
+ lp->project = cbm_project_name_from_path(lp->tmpdir);
+ if (!lp->project) return NULL;
+ const char *home = getenv("HOME");
+ if (!home) home = "/tmp";
+ char cache_dir[512];
+ snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/codebase-memory-mcp", home);
+ cbm_mkdir(cache_dir);
+ snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", cache_dir, lp->project);
+ unlink(lp->dbpath);
+ lp->srv = cbm_mcp_server_new(NULL);
+ if (!lp->srv) return NULL;
+ char args[700];
+ snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir);
+ char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args);
+ if (resp) free(resp);
+ return cbm_store_open_path(lp->dbpath);
+}
+
+static cbm_store_t *ncp_index_files(NcpLangProj *lp, const NcpLangFile *files, int nfiles) {
+ memset(lp, 0, sizeof(*lp));
+ snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_ncp_XXXXXX");
+ if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
+ ncp_to_fwd_slashes(lp->tmpdir);
+ for (int i = 0; i < nfiles; i++) {
+ char path[700];
+ snprintf(path, sizeof(path), "%s/%s", lp->tmpdir, files[i].name);
+ char *slash = strrchr(path, '/');
+ if (slash && slash > path + strlen(lp->tmpdir)) {
+ *slash = '\0';
+ cbm_mkdir_p(path, 0755);
+ *slash = '/';
+ }
+ FILE *f = fopen(path, "wb");
+ if (!f) return NULL;
+ fputs(files[i].content, f);
+ fclose(f);
+ }
+ return ncp_open_indexed(lp);
+}
+
+static void ncp_cleanup(NcpLangProj *lp, cbm_store_t *store) {
+ if (store) cbm_store_close(store);
+ if (lp->srv) { cbm_mcp_server_free(lp->srv); lp->srv = NULL; }
+ free(lp->project);
+ lp->project = NULL;
+ th_rmtree(lp->tmpdir);
+ unlink(lp->dbpath);
+ char wal[600], shm[600];
+ snprintf(wal, sizeof(wal), "%s-wal", lp->dbpath);
+ unlink(wal);
+ snprintf(shm, sizeof(shm), "%s-shm", lp->dbpath);
+ unlink(shm);
+}
+
+/* Count nodes with a given label. Returns -1 on error. */
+static int ncp_count_label(cbm_store_t *store, const char *project, const char *label) {
+ cbm_node_t *nodes = NULL;
+ int count = 0;
+ if (cbm_store_find_nodes_by_label(store, project, label, &nodes, &count) != CBM_STORE_OK)
+ return -1;
+ cbm_store_free_nodes(nodes, count);
+ return count;
+}
+
+/* Sum type-like nodes (Class + Struct + Interface + Enum + Trait + Type). */
+static int ncp_type_nodes(cbm_store_t *store, const char *project) {
+ static const char *labels[] = {"Class", "Struct", "Interface", "Enum", "Trait", "Type", NULL};
+ int total = 0;
+ for (int i = 0; labels[i]; i++) {
+ int n = ncp_count_label(store, project, labels[i]);
+ if (n > 0) total += n;
+ }
+ return total;
+}
+
+/* Callable nodes (Function + Method) with >=1 outbound edge. */
+static int ncp_callables_with_outbound(cbm_store_t *store, const char *project) {
+ static const char *callable_labels[] = {"Function", "Method", NULL};
+ int total = 0;
+ for (int i = 0; callable_labels[i]; i++) {
+ cbm_search_params_t p = {0};
+ p.project = project;
+ p.label = callable_labels[i];
+ p.min_degree = 1;
+ p.max_degree = -1;
+ p.limit = 100;
+ cbm_search_output_t out = {0};
+ if (cbm_store_search(store, &p, &out) == CBM_STORE_OK)
+ total += out.count;
+ cbm_store_search_free(&out);
+ }
+ return total;
+}
+
+/* Metrics collected in one index pass. */
+typedef struct {
+ int ok;
+ int total_nodes;
+ int functions;
+ int methods;
+ int classes; /* Class */
+ int structs; /* Struct */
+ int enums; /* Enum */
+ int interfaces;/* Interface */
+ int traits; /* Trait */
+ int types; /* all type-like combined */
+ int calls; /* CALLS edges */
+ int callers; /* callables with outbound */
+ int imports; /* IMPORTS edges */
+} NcpMetrics;
+
+static NcpMetrics ncp_metrics_files(const NcpLangFile *files, int nfiles) {
+ NcpLangProj lp;
+ cbm_store_t *store = ncp_index_files(&lp, files, nfiles);
+ NcpMetrics m = {0};
+ if (store) {
+ m.ok = 1;
+ m.total_nodes = cbm_store_count_nodes(store, lp.project);
+ m.functions = ncp_count_label(store, lp.project, "Function");
+ m.methods = ncp_count_label(store, lp.project, "Method");
+ m.classes = ncp_count_label(store, lp.project, "Class");
+ m.structs = ncp_count_label(store, lp.project, "Struct");
+ m.enums = ncp_count_label(store, lp.project, "Enum");
+ m.interfaces = ncp_count_label(store, lp.project, "Interface");
+ m.traits = ncp_count_label(store, lp.project, "Trait");
+ m.types = ncp_type_nodes(store, lp.project);
+ m.calls = cbm_store_count_edges_by_type(store, lp.project, "CALLS");
+ m.callers = ncp_callables_with_outbound(store, lp.project);
+ m.imports = cbm_store_count_edges_by_type(store, lp.project, "IMPORTS");
+ }
+ ncp_cleanup(&lp, store);
+ return m;
+}
+
+static NcpMetrics ncp_metrics(const char *filename, const char *content) {
+ NcpLangFile f = {filename, content};
+ return ncp_metrics_files(&f, 1);
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 1 — Go (hybrid LSP)
+ * Labels: Function, Module
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Go: two top-level functions; both must become Function nodes. */
+TEST(probe_go_functions) {
+ NcpMetrics m = ncp_metrics("svc.go",
+ "package svc\n\n"
+ "func add(a, b int) int { return a + b }\n\n"
+ "func sub(a, b int) int { return a - b }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* Go: intra-package CALLS edge (function -> function). */
+TEST(probe_go_calls_edge) {
+ NcpMetrics m = ncp_metrics("calc.go",
+ "package calc\n\n"
+ "func double(n int) int { return n * 2 }\n\n"
+ "func quadruple(n int) int { return double(double(n)) }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.calls >= 1);
+ ASSERT_TRUE(m.callers >= 1);
+ PASS();
+}
+
+/* Go: variadic + named return (syntactic variants must not drop the node). */
+TEST(probe_go_variadic_named_return) {
+ NcpMetrics m = ncp_metrics("util.go",
+ "package util\n\n"
+ "func sum(vals ...int) (total int) {\n"
+ " for _, v := range vals { total += v }\n"
+ " return\n"
+ "}\n\n"
+ "func wrap(vals ...int) int { return sum(vals...) }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Go: method on a named struct type (Go labels methods as Function, not Method). */
+TEST(probe_go_method_on_struct) {
+ NcpMetrics m = ncp_metrics("model.go",
+ "package model\n\n"
+ "type Counter struct{ n int }\n\n"
+ "func (c *Counter) Inc() { c.n++ }\n\n"
+ "func (c *Counter) Get() int { return c.n }\n\n"
+ "func NewCounter() *Counter { return &Counter{} }\n");
+ ASSERT_TRUE(m.ok);
+ /* At minimum NewCounter + Inc + Get must appear as Function nodes. */
+ ASSERT_TRUE(m.functions >= 3);
+ PASS();
+}
+
+/* Go: interface declaration must produce a type-like node. */
+TEST(probe_go_interface_node) {
+ NcpMetrics m = ncp_metrics("iface.go",
+ "package iface\n\n"
+ "type Reader interface{ Read(p []byte) (int, error) }\n\n"
+ "type Writer interface{ Write(p []byte) (int, error) }\n\n"
+ "func Noop() {}\n");
+ ASSERT_TRUE(m.ok);
+ /* Go interfaces are typically labelled Class or Interface. */
+ ASSERT_TRUE(m.types >= 1 || m.functions >= 1);
+ PASS();
+}
+
+/* Go: closure assigned to a variable must not prevent enclosing function from
+ * appearing as a node. */
+TEST(probe_go_closure) {
+ NcpMetrics m = ncp_metrics("cb.go",
+ "package cb\n\n"
+ "func MakeAdder(base int) func(int) int {\n"
+ " return func(x int) int { return base + x }\n"
+ "}\n\n"
+ "func Apply(f func(int) int, n int) int { return f(n) }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* Go: generic function (Go 1.18+) must still create a Function node. */
+TEST(probe_go_generic_function) {
+ NcpMetrics m = ncp_metrics("gen.go",
+ "package gen\n\n"
+ "func Map[T, U any](s []T, f func(T) U) []U {\n"
+ " r := make([]U, len(s))\n"
+ " for i, v := range s { r[i] = f(v) }\n"
+ " return r\n"
+ "}\n\n"
+ "func Filter[T any](s []T, pred func(T) bool) []T {\n"
+ " var r []T\n"
+ " for _, v := range s { if pred(v) { r = append(r, v) } }\n"
+ " return r\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 2 — C (hybrid LSP)
+ * Labels: Function, Module
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* C: two top-level functions → 2 Function nodes. */
+TEST(probe_c_functions) {
+ NcpMetrics m = ncp_metrics("math.c",
+ "static int add(int a, int b) { return a + b; }\n"
+ "int run(int x) { return add(x, 1); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* C: intra-file CALLS edge attributed to a Function, not the Module. */
+TEST(probe_c_calls_edge) {
+ NcpMetrics m = ncp_metrics("proc.c",
+ "static void helper(int x) { (void)x; }\n"
+ "void run(void) { helper(42); helper(1); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.calls >= 1);
+ ASSERT_TRUE(m.callers >= 1);
+ PASS();
+}
+
+/* C: function pointer typedef must not prevent the wrapping function node. */
+TEST(probe_c_function_pointer) {
+ NcpMetrics m = ncp_metrics("fp.c",
+ "typedef int (*transform_fn)(int);\n"
+ "static int double_it(int x) { return x * 2; }\n"
+ "int apply(transform_fn fn, int v) { return fn(v); }\n"
+ "int main(void) { return apply(double_it, 21); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 3); /* double_it, apply, main */
+ PASS();
+}
+
+/* C: macro + inline function — inline keyword must not hide the function. */
+TEST(probe_c_inline_function) {
+ NcpMetrics m = ncp_metrics("inl.c",
+ "static inline int clamp(int v, int lo, int hi) {\n"
+ " return v < lo ? lo : v > hi ? hi : v;\n"
+ "}\n"
+ "int normalise(int v) { return clamp(v, 0, 100); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* C: struct declaration creates at least a type-like node (or is labelled
+ * Class/Struct/Type depending on the extractor). */
+TEST(probe_c_struct_node) {
+ NcpMetrics m = ncp_metrics("point.c",
+ "typedef struct { float x; float y; } Point;\n"
+ "float dist_sq(Point a, Point b) {\n"
+ " float dx = a.x - b.x, dy = a.y - b.y;\n"
+ " return dx*dx + dy*dy;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* The function must always appear. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 3 — C++ (hybrid LSP)
+ * Labels: Class:1, Function:1, Module:1 (from grammar golden)
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* C++: class with constructor + methods → Class node + Method/Function nodes. */
+TEST(probe_cpp_class_methods) {
+ NcpMetrics m = ncp_metrics("counter.cpp",
+ "#include <cstdio>\n"
+ "class Counter {\n"
+ " int n;\n"
+ "public:\n"
+ " Counter() : n(0) {}\n"
+ " void inc() { ++n; }\n"
+ " int get() const { return n; }\n"
+ "};\n"
+ "int main() {\n"
+ " Counter c;\n"
+ " c.inc(); c.inc();\n"
+ " return c.get();\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* Counter class */
+ ASSERT_TRUE(m.functions + m.methods >= 1);
+ PASS();
+}
+
+/* C++: class -> class CALLS edge. */
+TEST(probe_cpp_calls_edge) {
+ NcpMetrics m = ncp_metrics("calc.cpp",
+ "static int square(int x) { return x * x; }\n"
+ "int sumSquares(int a, int b) { return square(a) + square(b); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.calls >= 1);
+ ASSERT_TRUE(m.callers >= 1);
+ PASS();
+}
+
+/* C++: template function — template keyword must not prevent the node. */
+TEST(probe_cpp_template_function) {
+ NcpMetrics m = ncp_metrics("tpl.cpp",
+ "template <typename T>\n"
+ "T clamp(T v, T lo, T hi) {\n"
+ " return v < lo ? lo : v > hi ? hi : v;\n"
+ "}\n"
+ "int apply() { return clamp<int>(5, 0, 10); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* C++: enum class must produce a type node. */
+TEST(probe_cpp_enum_class) {
+ NcpMetrics m = ncp_metrics("color.cpp",
+ "enum class Color { Red, Green, Blue };\n"
+ "bool isRed(Color c) { return c == Color::Red; }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1);
+ /* Enum may or may not be modeled as a node; at least function must appear. */
+ PASS();
+}
+
+/* C++: struct with operator overload. */
+TEST(probe_cpp_struct_operator) {
+ NcpMetrics m = ncp_metrics("vec.cpp",
+ "struct Vec2 { float x, y; };\n"
+ "Vec2 operator+(Vec2 a, Vec2 b) { return {a.x+b.x, a.y+b.y}; }\n"
+ "float dot(Vec2 a, Vec2 b) { return a.x*b.x + a.y*b.y; }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1 || m.functions >= 1);
+ PASS();
+}
+
+/* C++: inheritance — derived class must appear as a type node. */
+TEST(probe_cpp_inheritance) {
+ NcpMetrics m = ncp_metrics("shape.cpp",
+ "class Shape {\n"
+ "public:\n"
+ " virtual double area() const = 0;\n"
+ "};\n"
+ "class Circle : public Shape {\n"
+ " double r;\n"
+ "public:\n"
+ " Circle(double r) : r(r) {}\n"
+ " double area() const override { return 3.14159 * r * r; }\n"
+ "};\n"
+ "double total(Circle c) { return c.area(); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 4 — Rust (hybrid LSP)
+ * Labels: Class:1, Function:1, Module:1 (struct -> Class)
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Rust: struct + impl with multiple methods. */
+TEST(probe_rust_struct_impl) {
+ NcpMetrics m = ncp_metrics("stack.rs",
+ "struct Stack<T> { items: Vec<T> }\n\n"
+ "impl<T> Stack<T> {\n"
+ " fn new() -> Self { Stack { items: Vec::new() } }\n"
+ " fn push(&mut self, item: T) { self.items.push(item); }\n"
+ " fn pop(&mut self) -> Option<T> { self.items.pop() }\n"
+ " fn is_empty(&self) -> bool { self.items.is_empty() }\n"
+ "}\n"
+ "fn demo() {\n"
+ " let mut s: Stack<i32> = Stack::new();\n"
+ " s.push(1); let _ = s.pop();\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* struct Stack */
+ ASSERT_TRUE(m.functions + m.methods >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Rust: enum with variants. */
+TEST(probe_rust_enum) {
+ NcpMetrics m = ncp_metrics("result.rs",
+ "#[derive(Debug)]\n"
+ "enum MyResult { Ok(i32), Err(String) }\n\n"
+ "fn wrap(v: i32) -> MyResult { MyResult::Ok(v) }\n\n"
+ "fn unwrap_or(r: MyResult, default: i32) -> i32 {\n"
+ " match r { MyResult::Ok(v) => v, MyResult::Err(_) => default }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* enum and functions must appear */
+ ASSERT_TRUE(m.types >= 1 || m.functions >= 1);
+ PASS();
+}
+
+/* Rust: trait definition + impl for a struct. */
+TEST(probe_rust_trait_impl) {
+ NcpMetrics m = ncp_metrics("greet.rs",
+ "trait Greet {\n"
+ " fn hello(&self) -> String;\n"
+ "}\n\n"
+ "struct English;\n"
+ "struct Spanish;\n\n"
+ "impl Greet for English {\n"
+ " fn hello(&self) -> String { String::from(\"hello\") }\n"
+ "}\n"
+ "impl Greet for Spanish {\n"
+ " fn hello(&self) -> String { String::from(\"hola\") }\n"
+ "}\n"
+ "fn greet_all(gs: &[&dyn Greet]) {\n"
+ " for g in gs { println!(\"{}\", g.hello()); }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* trait and/or struct nodes */
+ ASSERT_TRUE(m.functions + m.methods >= 1);
+ PASS();
+}
+
+/* Rust: intra-file CALLS edge. */
+TEST(probe_rust_calls_edge) {
+ NcpMetrics m = ncp_metrics("math.rs",
+ "fn square(x: i32) -> i32 { x * x }\n\n"
+ "fn sum_squares(a: i32, b: i32) -> i32 { square(a) + square(b) }\n\n"
+ "fn main() { let _ = sum_squares(3, 4); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.calls >= 1);
+ ASSERT_TRUE(m.callers >= 1);
+ PASS();
+}
+
+/* Rust: closure must not hide the enclosing function node. */
+TEST(probe_rust_closure) {
+ NcpMetrics m = ncp_metrics("fmap.rs",
+ "fn double_all(v: &[i32]) -> Vec<i32> {\n"
+ " v.iter().map(|x| x * 2).collect()\n"
+ "}\n\n"
+ "fn sum(v: &[i32]) -> i32 { v.iter().sum() }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* Rust: type alias must not prevent the surrounding function nodes. */
+TEST(probe_rust_type_alias) {
+ NcpMetrics m = ncp_metrics("alias.rs",
+ "type Meters = f64;\n"
+ "type Seconds = f64;\n\n"
+ "fn speed(dist: Meters, time: Seconds) -> f64 { dist / time }\n\n"
+ "fn run() -> f64 { speed(100.0, 9.58) }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 5 — Python (hybrid LSP)
+ * Labels: Class:1, Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Python: top-level functions → Function nodes. */
+TEST(probe_python_functions) {
+ NcpMetrics m = ncp_metrics("math.py",
+ "def add(a, b):\n return a + b\n\n\n"
+ "def mul(a, b):\n return a * b\n\n\n"
+ "def run():\n return add(mul(2, 3), 1)\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 3);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Python: class with methods → Class node + Function/Method nodes. */
+TEST(probe_python_class) {
+ NcpMetrics m = ncp_metrics("model.py",
+ "class Account:\n"
+ " def __init__(self, owner, balance=0):\n"
+ " self.owner = owner\n"
+ " self.balance = balance\n\n"
+ " def deposit(self, amount):\n"
+ " self.balance += amount\n\n"
+ " def withdraw(self, amount):\n"
+ " if amount <= self.balance:\n"
+ " self.balance -= amount\n"
+ " return True\n"
+ " return False\n\n"
+ " def get_balance(self):\n"
+ " return self.balance\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* class Account */
+ ASSERT_TRUE(m.functions + m.methods >= 3);
+ PASS();
+}
+
+/* Python: nested function must not prevent outer function node. */
+TEST(probe_python_nested_function) {
+ NcpMetrics m = ncp_metrics("closure.py",
+ "def make_counter(start=0):\n"
+ " count = [start]\n\n"
+ " def inc():\n"
+ " count[0] += 1\n"
+ " return count[0]\n\n"
+ " return inc\n\n\n"
+ "def demo():\n"
+ " c = make_counter()\n"
+ " return c()\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2); /* make_counter, demo (inc is nested) */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Python: decorator syntax must not prevent the decorated function node. */
+TEST(probe_python_decorator) {
+ NcpMetrics m = ncp_metrics("deco.py",
+ "def log_call(fn):\n"
+ " def wrapper(*args, **kwargs):\n"
+ " result = fn(*args, **kwargs)\n"
+ " return result\n"
+ " return wrapper\n\n\n"
+ "@log_call\n"
+ "def compute(x):\n"
+ " return x * x\n\n\n"
+ "@log_call\n"
+ "def add(a, b):\n"
+ " return a + b\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 3); /* log_call, compute, add */
+ PASS();
+}
+
+/* Python: lambda in assignment must not prevent surrounding function. */
+TEST(probe_python_lambda) {
+ NcpMetrics m = ncp_metrics("lmb.py",
+ "double = lambda x: x * 2\n\n\n"
+ "def apply(fn, items):\n"
+ " return [fn(i) for i in items]\n\n\n"
+ "def run():\n"
+ " return apply(double, [1, 2, 3])\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2); /* apply + run */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Python: dataclass + multiple methods. */
+TEST(probe_python_dataclass) {
+ NcpMetrics m = ncp_metrics("point.py",
+ "from dataclasses import dataclass\n\n\n"
+ "@dataclass\n"
+ "class Point:\n"
+ " x: float\n"
+ " y: float\n\n"
+ " def distance_sq(self, other):\n"
+ " return (self.x - other.x)**2 + (self.y - other.y)**2\n\n"
+ " def move(self, dx, dy):\n"
+ " return Point(self.x + dx, self.y + dy)\n\n\n"
+ "def origin():\n"
+ " return Point(0.0, 0.0)\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 6 — TypeScript (hybrid LSP)
+ * Labels: Class:1, Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* TypeScript: interface + class implementing it. */
+TEST(probe_ts_interface_class) {
+ NcpMetrics m = ncp_metrics("iface.ts",
+ "interface Shape {\n"
+ " area(): number;\n"
+ " perimeter(): number;\n"
+ "}\n\n"
+ "class Rectangle implements Shape {\n"
+ " constructor(private w: number, private h: number) {}\n"
+ " area(): number { return this.w * this.h; }\n"
+ " perimeter(): number { return 2 * (this.w + this.h); }\n"
+ "}\n\n"
+ "function describe(s: Shape): string {\n"
+ " return `area=${s.area()} perimeter=${s.perimeter()}`;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* class Rectangle, possibly interface Shape */
+ ASSERT_TRUE(m.functions + m.methods >= 1);
+ PASS();
+}
+
+/* TypeScript: generic function + arrow function. */
+TEST(probe_ts_generic_arrow) {
+ NcpMetrics m = ncp_metrics("util.ts",
+ "export function identity<T>(x: T): T { return x; }\n\n"
+ "export const double = (n: number): number => n * 2;\n\n"
+ "export function applyTwice<T>(f: (x: T) => T, x: T): T {\n"
+ " return f(f(x));\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1); /* identity + applyTwice at minimum */
+ PASS();
+}
+
+/* TypeScript: enum must produce a type-like node. */
+TEST(probe_ts_enum) {
+ NcpMetrics m = ncp_metrics("status.ts",
+ "export enum Status { Active = 'active', Inactive = 'inactive', Pending = 'pending' }\n\n"
+ "export function isActive(s: Status): boolean {\n"
+ " return s === Status.Active;\n"
+ "}\n\n"
+ "export function toggle(s: Status): Status {\n"
+ " return s === Status.Active ? Status.Inactive : Status.Active;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* TypeScript: CALLS edge via intra-file call. */
+TEST(probe_ts_calls_edge) {
+ NcpMetrics m = ncp_metrics("chain.ts",
+ "function square(n: number): number { return n * n; }\n\n"
+ "function cube(n: number): number { return n * square(n); }\n\n"
+ "function run(n: number): number { return cube(n) + square(n); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.calls >= 1);
+ ASSERT_TRUE(m.callers >= 1);
+ PASS();
+}
+
+/* TypeScript: class inheritance. */
+TEST(probe_ts_class_extends) {
+ NcpMetrics m = ncp_metrics("vehicle.ts",
+ "class Vehicle {\n"
+ " constructor(public speed: number) {}\n"
+ " move(): string { return `moving at ${this.speed}`; }\n"
+ "}\n\n"
+ "class Car extends Vehicle {\n"
+ " constructor(speed: number, public brand: string) { super(speed); }\n"
+ " describe(): string { return `${this.brand}: ${this.move()}`; }\n"
+ "}\n\n"
+ "function demo(): string {\n"
+ " const c = new Car(100, 'Toyota');\n"
+ " return c.describe();\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* TypeScript: type alias + union type function. */
+TEST(probe_ts_type_alias) {
+ NcpMetrics m = ncp_metrics("types.ts",
+ "type ID = string | number;\n"
+ "type Result<T> = { ok: true; value: T } | { ok: false; error: string };\n\n"
+ "function parseId(raw: string): Result<ID> {\n"
+ " const n = Number(raw);\n"
+ " return isNaN(n) ? { ok: true, value: raw } : { ok: true, value: n };\n"
+ "}\n\n"
+ "function formatId(id: ID): string { return String(id); }\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 7 — Java (hybrid LSP)
+ * Labels: Class:1, Method:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Java: class + multiple methods → Class node + Method nodes. */
+TEST(probe_java_class_methods) {
+ NcpMetrics m = ncp_metrics("Calc.java",
+ "package app;\n\n"
+ "class Calc {\n"
+ " private int base;\n\n"
+ " public Calc(int base) { this.base = base; }\n\n"
+ " public int add(int x) { return base + x; }\n\n"
+ " public int mul(int x) { return base * x; }\n\n"
+ " public int addThenMul(int x) { return mul(add(x)); }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* class Calc */
+ ASSERT_TRUE(m.methods >= 2); /* add, mul, addThenMul */
+ ASSERT_TRUE(m.calls >= 1); /* addThenMul -> add + mul */
+ PASS();
+}
+
+/* Java: interface declaration → type-like node. */
+TEST(probe_java_interface) {
+ NcpMetrics m = ncp_metrics("Printable.java",
+ "package app;\n\n"
+ "interface Printable {\n"
+ " String format();\n"
+ " default void print() { System.out.println(format()); }\n"
+ "}\n\n"
+ "class Doc implements Printable {\n"
+ " private String text;\n"
+ " Doc(String t) { this.text = t; }\n"
+ " public String format() { return \"[\" + text + \"]\"; }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Java: enum → type-like node. */
+TEST(probe_java_enum) {
+ NcpMetrics m = ncp_metrics("Day.java",
+ "package app;\n\n"
+ "enum Day { MON, TUE, WED, THU, FRI, SAT, SUN;\n"
+ " public boolean isWeekend() {\n"
+ " return this == SAT || this == SUN;\n"
+ " }\n"
+ "}\n\n"
+ "class DayUtil {\n"
+ " static String label(Day d) { return d.isWeekend() ? \"rest\" : \"work\"; }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Java: inner class inside outer class. */
+TEST(probe_java_inner_class) {
+ NcpMetrics m = ncp_metrics("Outer.java",
+ "package app;\n\n"
+ "class Outer {\n"
+ " private int x;\n"
+ " Outer(int x) { this.x = x; }\n\n"
+ " class Inner {\n"
+ " int doubled() { return x * 2; }\n"
+ " }\n\n"
+ " int run() {\n"
+ " return new Inner().doubled();\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* Outer (and optionally Inner) */
+ PASS();
+}
+
+/* Java: lambda / method reference — enclosing method node must still appear. */
+TEST(probe_java_lambda) {
+ NcpMetrics m = ncp_metrics("Streams.java",
+ "package app;\n\n"
+ "import java.util.List;\n"
+ "import java.util.stream.Collectors;\n\n"
+ "class Streams {\n"
+ " static List<Integer> doubleAll(List<Integer> xs) {\n"
+ " return xs.stream().map(x -> x * 2).collect(Collectors.toList());\n"
+ " }\n"
+ " static List<String> names(List<Object> objs) {\n"
+ " return objs.stream().map(Object::toString).collect(Collectors.toList());\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.methods >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 8 — Kotlin (hybrid LSP)
+ * Labels: Class:1, Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Kotlin: data class + companion object + extension function. */
+TEST(probe_kotlin_data_class) {
+ NcpMetrics m = ncp_metrics("User.kt",
+ "data class User(val name: String, val age: Int) {\n"
+ " fun greet(): String = \"Hi, I'm ${name}\"\n\n"
+ " companion object {\n"
+ " fun anonymous(): User = User(\"anon\", 0)\n"
+ " }\n"
+ "}\n\n"
+ "fun User.isAdult(): Boolean = age >= 18\n\n"
+ "fun demo(): String {\n"
+ " val u = User.anonymous()\n"
+ " return u.greet()\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* data class User */
+ ASSERT_TRUE(m.functions + m.methods >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Kotlin: sealed class hierarchy → type nodes. */
+TEST(probe_kotlin_sealed_class) {
+ NcpMetrics m = ncp_metrics("Result.kt",
+ "sealed class Result<out T> {\n"
+ " data class Success<T>(val value: T) : Result<T>()\n"
+ " data class Failure(val error: String) : Result<Nothing>()\n"
+ "}\n\n"
+ "fun <T> unwrap(r: Result<T>, default: T): T =\n"
+ " when (r) {\n"
+ " is Result.Success -> r.value\n"
+ " is Result.Failure -> default\n"
+ " }\n\n"
+ "fun run(): String = unwrap(Result.Success(\"ok\"), \"fail\")\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Kotlin: interface + lambda / higher-order function. */
+TEST(probe_kotlin_interface_lambda) {
+ NcpMetrics m = ncp_metrics("Filter.kt",
+ "interface Predicate<T> {\n"
+ " fun test(item: T): Boolean\n"
+ "}\n\n"
+ "fun <T> filterList(items: List<T>, pred: Predicate<T>): List<T> =\n"
+ " items.filter { pred.test(it) }\n\n"
+ "fun evens(xs: List<Int>): List<Int> =\n"
+ " filterList(xs, object : Predicate<Int> { override fun test(item: Int) = item % 2 == 0 })\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Kotlin: CALLS edge between top-level functions. */
+TEST(probe_kotlin_calls_edge) {
+ NcpMetrics m = ncp_metrics("Math.kt",
+ "fun square(n: Int): Int = n * n\n\n"
+ "fun cube(n: Int): Int = n * square(n)\n\n"
+ "fun sumOfCubes(a: Int, b: Int): Int = cube(a) + cube(b)\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.calls >= 1);
+ ASSERT_TRUE(m.callers >= 1);
+ PASS();
+}
+
+/* Kotlin: enum class. */
+TEST(probe_kotlin_enum) {
+ NcpMetrics m = ncp_metrics("Color.kt",
+ "enum class Color(val hex: String) {\n"
+ " RED(\"#FF0000\"), GREEN(\"#00FF00\"), BLUE(\"#0000FF\");\n\n"
+ " fun isDark(): Boolean = hex.substring(1).toLong(16) < 0x888888L\n"
+ "}\n\n"
+ "fun redHex(): String = Color.RED.hex\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* enum class Color */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 9 — C# (hybrid LSP)
+ * Labels: Class:1, Method:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* C#: class + multiple methods + intra-class CALLS. */
+TEST(probe_cs_class_methods) {
+ NcpMetrics m = ncp_metrics("Calc.cs",
+ "namespace App {\n"
+ " class Calc {\n"
+ " private int offset;\n"
+ " public Calc(int offset) { this.offset = offset; }\n"
+ " public int Add(int x) { return offset + x; }\n"
+ " public int Double(int x) { return Add(Add(x)); }\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.methods >= 2); /* Add, Double */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* C#: interface + class implementing it. */
+TEST(probe_cs_interface) {
+ NcpMetrics m = ncp_metrics("IRepo.cs",
+ "namespace App {\n"
+ " interface IRepo<T> {\n"
+ " T Get(int id);\n"
+ " void Save(T item);\n"
+ " }\n\n"
+ " class MemRepo<T> : IRepo<T> {\n"
+ " private System.Collections.Generic.Dictionary<int, T> store = new();\n"
+ " public T Get(int id) => store[id];\n"
+ " public void Save(T item) { store[store.Count] = item; }\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* C#: enum type. */
+TEST(probe_cs_enum) {
+ NcpMetrics m = ncp_metrics("Status.cs",
+ "namespace App {\n"
+ " enum Status { Active, Inactive, Pending }\n\n"
+ " class StatusHelper {\n"
+ " public static bool IsActive(Status s) => s == Status.Active;\n"
+ " public static string Label(Status s) => IsActive(s) ? \"on\" : \"off\";\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.methods >= 1);
+ PASS();
+}
+
+/* C#: generic class. */
+TEST(probe_cs_generic_class) {
+ NcpMetrics m = ncp_metrics("Box.cs",
+ "namespace App {\n"
+ " class Box<T> {\n"
+ " private T value;\n"
+ " public Box(T v) { this.value = v; }\n"
+ " public T Unwrap() { return value; }\n"
+ " public Box<U> Map<U>(System.Func<T, U> f) {\n"
+ " return new Box<U>(f(Unwrap()));\n"
+ " }\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.methods >= 2);
+ PASS();
+}
+
+/* C#: struct type (value type). */
+TEST(probe_cs_struct) {
+ NcpMetrics m = ncp_metrics("Point.cs",
+ "namespace App {\n"
+ " struct Point {\n"
+ " public float X, Y;\n"
+ " public Point(float x, float y) { X = x; Y = y; }\n"
+ " public float MagnitudeSq() { return X * X + Y * Y; }\n"
+ " public Point Add(Point other) { return new Point(X + other.X, Y + other.Y); }\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* struct Point */
+ ASSERT_TRUE(m.methods >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 10 — Ruby (grammar-only)
+ * Labels: Class:1, Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Ruby: class with methods + CALLS edge. */
+TEST(probe_ruby_class_calls) {
+ NcpMetrics m = ncp_metrics("greeter.rb",
+ "class Greeter\n"
+ " def initialize(name)\n"
+ " @name = name\n"
+ " end\n\n"
+ " def greet\n"
+ " format_greeting(@name)\n"
+ " end\n\n"
+ " private\n\n"
+ " def format_greeting(n)\n"
+ " \"Hello, #{n}!\"\n"
+ " end\n"
+ "end\n\n"
+ "def make_greeter(name)\n"
+ " Greeter.new(name)\n"
+ "end\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* class Greeter */
+ ASSERT_TRUE(m.functions >= 1);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Ruby: module definition creates a type-like node. */
+TEST(probe_ruby_module) {
+ NcpMetrics m = ncp_metrics("utils.rb",
+ "module MathUtils\n"
+ " def self.square(x)\n"
+ " x * x\n"
+ " end\n\n"
+ " def self.cube(x)\n"
+ " x * square(x)\n"
+ " end\n"
+ "end\n");
+ ASSERT_TRUE(m.ok);
+ /* A Module might be modelled as a Class or Function label. */
+ ASSERT_TRUE(m.types >= 1 || m.functions >= 1);
+ PASS();
+}
+
+/* Ruby: multiple top-level functions → Function nodes. */
+TEST(probe_ruby_toplevel_functions) {
+ NcpMetrics m = ncp_metrics("calc.rb",
+ "def add(a, b)\n a + b\nend\n\n"
+ "def mul(a, b)\n a * b\nend\n\n"
+ "def run\n add(mul(2, 3), 1)\nend\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 3); /* add, mul, run */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 11 — Swift (grammar-only)
+ * Labels: Class:1, Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Swift: struct + functions + CALLS edge. */
+TEST(probe_swift_struct_calls) {
+ NcpMetrics m = ncp_metrics("geo.swift",
+ "struct Point {\n"
+ " var x: Double\n"
+ " var y: Double\n\n"
+ " func distanceTo(_ other: Point) -> Double {\n"
+ " let dx = x - other.x\n"
+ " let dy = y - other.y\n"
+ " return sqrt(dx*dx + dy*dy)\n"
+ " }\n"
+ "}\n\n"
+ "func origin() -> Point { return Point(x: 0, y: 0) }\n\n"
+ "func run() -> Double {\n"
+ " let p = origin()\n"
+ " return p.distanceTo(Point(x: 3, y: 4))\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.functions >= 1);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Swift: class with inheritance. */
+TEST(probe_swift_class_inherit) {
+ NcpMetrics m = ncp_metrics("shape.swift",
+ "class Shape {\n"
+ " func area() -> Double { return 0.0 }\n"
+ "}\n\n"
+ "class Circle: Shape {\n"
+ " let radius: Double\n"
+ " init(radius: Double) { self.radius = radius }\n"
+ " override func area() -> Double { return 3.14159 * radius * radius }\n"
+ "}\n\n"
+ "func totalArea(_ shapes: [Shape]) -> Double {\n"
+ " return shapes.reduce(0.0) { $0 + $1.area() }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Swift: enum with associated values. */
+TEST(probe_swift_enum) {
+ NcpMetrics m = ncp_metrics("result.swift",
+ "enum AppError: Error {\n"
+ " case notFound(String)\n"
+ " case invalid\n"
+ "}\n\n"
+ "func lookup(_ key: String) -> Result<Int, AppError> {\n"
+ " if key == \"x\" { return .success(42) }\n"
+ " return .failure(.notFound(key))\n"
+ "}\n\n"
+ "func run() -> Int {\n"
+ " switch lookup(\"x\") {\n"
+ " case .success(let v): return v\n"
+ " case .failure: return -1\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 12 — Scala (grammar-only)
+ * Labels: Class:1, Function:1, Method:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Scala: object + class + methods. */
+TEST(probe_scala_class_object) {
+ NcpMetrics m = ncp_metrics("calc.scala",
+ "class Calc(base: Int) {\n"
+ " def add(x: Int): Int = base + x\n"
+ " def mul(x: Int): Int = base * x\n"
+ " def addThenMul(x: Int): Int = mul(add(x))\n"
+ "}\n\n"
+ "object CalcApp {\n"
+ " def main(args: Array[String]): Unit = {\n"
+ " val c = new Calc(10)\n"
+ " println(c.addThenMul(5))\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.functions + m.methods >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Scala: trait definition. */
+TEST(probe_scala_trait) {
+ NcpMetrics m = ncp_metrics("greet.scala",
+ "trait Greeter {\n"
+ " def greet(name: String): String\n"
+ " def greetAll(names: List[String]): List[String] =\n"
+ " names.map(greet)\n"
+ "}\n\n"
+ "class PoliteGreeter extends Greeter {\n"
+ " def greet(name: String): String = s\"Good day, $name\"\n"
+ "}\n\n"
+ "def run(): List[String] = new PoliteGreeter().greetAll(List(\"Alice\", \"Bob\"))\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.functions + m.methods >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 13 — Lua (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Lua: top-level functions + CALLS edge. */
+TEST(probe_lua_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.lua",
+ "local function square(x)\n"
+ " return x * x\n"
+ "end\n\n"
+ "local function hypotenuse(a, b)\n"
+ " return math.sqrt(square(a) + square(b))\n"
+ "end\n\n"
+ "function run(a, b)\n"
+ " return hypotenuse(a, b)\n"
+ "end\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2); /* square, hypotenuse (or run) */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Lua: table acting as class-like module — functions must appear. */
+TEST(probe_lua_table_class) {
+ NcpMetrics m = ncp_metrics("counter.lua",
+ "local Counter = {}\n"
+ "Counter.__index = Counter\n\n"
+ "function Counter.new(start)\n"
+ " local self = setmetatable({}, Counter)\n"
+ " self.value = start or 0\n"
+ " return self\n"
+ "end\n\n"
+ "function Counter:inc()\n"
+ " self.value = self.value + 1\n"
+ "end\n\n"
+ "function Counter:get()\n"
+ " return self.value\n"
+ "end\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 14 — Bash (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Bash: function declarations + CALLS edge. */
+TEST(probe_bash_functions_calls) {
+ NcpMetrics m = ncp_metrics("deploy.sh",
+ "#!/usr/bin/env bash\n\n"
+ "log() {\n"
+ " echo \"[INFO] $*\"\n"
+ "}\n\n"
+ "build() {\n"
+ " log \"building...\"\n"
+ " make all\n"
+ "}\n\n"
+ "deploy() {\n"
+ " log \"deploying...\"\n"
+ " build\n"
+ "}\n\n"
+ "main() {\n"
+ " deploy \"$@\"\n"
+ "}\n\n"
+ "main \"$@\"\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 3); /* log, build, deploy, main */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Bash: function() { } syntax variant. */
+TEST(probe_bash_function_keyword) {
+ NcpMetrics m = ncp_metrics("lib.sh",
+ "function helper {\n"
+ " echo \"help: $1\"\n"
+ "}\n\n"
+ "function runner {\n"
+ " helper \"start\"\n"
+ " helper \"stop\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 15 — Dart (grammar-only)
+ * Labels: Class:1, Function:1, Module:1
+ *
+ * KNOWN GAP: CALLS edge NOT expected — extract_calls.c has no Dart branch.
+ * Node-creation (Function/Class nodes) IS expected to work.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Dart: top-level functions → Function nodes (GREEN expected). */
+TEST(probe_dart_functions) {
+ NcpMetrics m = ncp_metrics("math.dart",
+ "int square(int x) => x * x;\n\n"
+ "int cube(int x) => x * square(x);\n\n"
+ "void main() {\n"
+ " print(cube(3));\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2); /* square, cube (main may also appear) */
+ PASS();
+}
+
+/* Dart: class with methods → Class node + Function nodes (GREEN expected). */
+TEST(probe_dart_class) {
+ NcpMetrics m = ncp_metrics("account.dart",
+ "class Account {\n"
+ " String owner;\n"
+ " double balance;\n\n"
+ " Account(this.owner, {this.balance = 0.0});\n\n"
+ " void deposit(double amount) {\n"
+ " balance += amount;\n"
+ " }\n\n"
+ " bool withdraw(double amount) {\n"
+ " if (amount > balance) return false;\n"
+ " balance -= amount;\n"
+ " return true;\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* class Account */
+ PASS();
+}
+
+/* Dart CALLS edge — KNOWN EXPECTED RED: extract_calls.c lacks Dart branch.
+ * Kept as a reproduction: turns GREEN when the fix is shipped. */
+TEST(probe_dart_calls_edge_known_gap) {
+ NcpMetrics m = ncp_metrics("chain.dart",
+ "void helper() {\n print('helper');\n}\n\n"
+ "void run() {\n helper();\n}\n");
+ ASSERT_TRUE(m.ok);
+ /* This assertion SHOULD fail until the Dart CALLS branch is added. */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 16 — Elixir (grammar-only)
+ * Labels: Class:1, Function:1, Module:1 (module -> Class)
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Elixir: defmodule with multiple defs + CALLS edge. */
+TEST(probe_elixir_module_calls) {
+ NcpMetrics m = ncp_metrics("calc.ex",
+ "defmodule Calc do\n"
+ " def add(a, b), do: a + b\n\n"
+ " def mul(a, b), do: a * b\n\n"
+ " def add_then_mul(x, y) do\n"
+ " sum = add(x, y)\n"
+ " mul(sum, 2)\n"
+ " end\n"
+ "end\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1 || m.functions >= 1); /* module as Class or Function */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Elixir: nested module. */
+TEST(probe_elixir_nested_module) {
+ NcpMetrics m = ncp_metrics("server.ex",
+ "defmodule Server.Router do\n"
+ " def dispatch(path) do\n"
+ " handle(path)\n"
+ " end\n\n"
+ " defp handle(\"/health\"), do: :ok\n"
+ " defp handle(_), do: :not_found\n"
+ "end\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 17 — Haskell (grammar-only)
+ * Labels: Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Haskell: multiple top-level function definitions + CALLS edge. */
+TEST(probe_haskell_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.hs",
+ "module Math where\n\n"
+ "square :: Int -> Int\n"
+ "square x = x * x\n\n"
+ "cube :: Int -> Int\n"
+ "cube x = x * square x\n\n"
+ "run :: Int -> Int\n"
+ "run n = cube n + square n\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1); /* at least one of square/cube/run */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Haskell: data type definition must not break function node extraction. */
+TEST(probe_haskell_data_type) {
+ NcpMetrics m = ncp_metrics("tree.hs",
+ "module Tree where\n\n"
+ "data Tree a = Leaf | Node (Tree a) a (Tree a)\n\n"
+ "insert :: Ord a => a -> Tree a -> Tree a\n"
+ "insert x Leaf = Node Leaf x Leaf\n"
+ "insert x (Node l v r)\n"
+ " | x < v = Node (insert x l) v r\n"
+ " | x > v = Node l v (insert x r)\n"
+ " | otherwise = Node l v r\n\n"
+ "depth :: Tree a -> Int\n"
+ "depth Leaf = 0\n"
+ "depth (Node l _ r) = 1 + max (depth l) (depth r)\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 18 — Zig (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Zig: pub functions + CALLS edge. */
+TEST(probe_zig_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.zig",
+ "const std = @import(\"std\");\n\n"
+ "fn square(x: i32) i32 {\n"
+ " return x * x;\n"
+ "}\n\n"
+ "pub fn sumSquares(a: i32, b: i32) i32 {\n"
+ " return square(a) + square(b);\n"
+ "}\n\n"
+ "pub fn main() void {\n"
+ " const result = sumSquares(3, 4);\n"
+ " std.debug.print(\"{d}\\n\", .{result});\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* Zig: struct with methods. */
+TEST(probe_zig_struct_methods) {
+ NcpMetrics m = ncp_metrics("stack.zig",
+ "const Stack = struct {\n"
+ " items: [64]i32 = undefined,\n"
+ " top: usize = 0,\n\n"
+ " pub fn push(self: *Stack, v: i32) void {\n"
+ " self.items[self.top] = v;\n"
+ " self.top += 1;\n"
+ " }\n\n"
+ " pub fn pop(self: *Stack) i32 {\n"
+ " self.top -= 1;\n"
+ " return self.items[self.top];\n"
+ " }\n"
+ "};\n\n"
+ "pub fn run() void {\n"
+ " var s = Stack{};\n"
+ " s.push(1);\n"
+ " _ = s.pop();\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1); /* run must be present */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 19 — OCaml (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* OCaml: let bindings + application call. */
+TEST(probe_ocaml_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.ml",
+ "let square x = x * x\n\n"
+ "let cube x = x * square x\n\n"
+ "let sum_squares a b = square a + square b\n\n"
+ "let () =\n"
+ " let _ = cube 3 in\n"
+ " let _ = sum_squares 3 4 in\n"
+ " ()\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 20 — Erlang (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Erlang: module + exported functions + CALLS edge. */
+TEST(probe_erlang_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.erl",
+ "-module(math).\n"
+ "-export([run/0, sum_squares/2]).\n\n"
+ "square(X) -> X * X.\n\n"
+ "sum_squares(A, B) -> square(A) + square(B).\n\n"
+ "run() ->\n"
+ " io:format(\"~p~n\", [sum_squares(3, 4)]).\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 21 — Groovy (grammar-only)
+ * Labels: Class:1, Method:1, Module:1
+ *
+ * KNOWN GAP: CALLS edge NOT expected — function_call callee resolution
+ * unhandled in extract_calls.c for Groovy.
+ * Node creation (Class/Method) IS expected to work.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Groovy: class + methods → Class + Method nodes (GREEN expected). */
+TEST(probe_groovy_class_methods) {
+ NcpMetrics m = ncp_metrics("Calc.groovy",
+ "class Calc {\n"
+ " int base\n\n"
+ " Calc(int base) { this.base = base }\n\n"
+ " int add(int x) { base + x }\n\n"
+ " int mul(int x) { base * x }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.types >= 1); /* class Calc */
+ ASSERT_TRUE(m.methods >= 1);
+ PASS();
+}
+
+/* Groovy CALLS edge — KNOWN EXPECTED RED: callee extraction not handled.
+ * Kept as reproduction; turns GREEN when the fix ships. */
+TEST(probe_groovy_calls_edge_known_gap) {
+ NcpMetrics m = ncp_metrics("funcs.groovy",
+ "def helper() {\n println 'helping'\n}\n\n"
+ "def runner() {\n helper()\n}\n");
+ ASSERT_TRUE(m.ok);
+ /* This assertion SHOULD fail until Groovy callee extraction is added. */
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 22 — Nim (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Nim: proc definitions + CALLS edge. */
+TEST(probe_nim_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.nim",
+ "proc square(x: int): int =\n"
+ " x * x\n\n"
+ "proc sumSquares(a, b: int): int =\n"
+ " square(a) + square(b)\n\n"
+ "proc main() =\n"
+ " echo sumSquares(3, 4)\n\n"
+ "main()\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 23 — GDScript (grammar-only)
+ * Labels: Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* GDScript: func declarations + CALLS edge. */
+TEST(probe_gdscript_functions_calls) {
+ NcpMetrics m = ncp_metrics("player.gd",
+ "extends Node\n\n"
+ "var health: int = 100\n\n"
+ "func take_damage(amount: int) -> void:\n"
+ "\thealth -= amount\n"
+ "\tif health <= 0:\n"
+ "\t\tdie()\n\n"
+ "func die() -> void:\n"
+ "\tprint(\"died\")\n\n"
+ "func heal(amount: int) -> void:\n"
+ "\thealth = min(health + amount, 100)\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2); /* take_damage, die, heal */
+ ASSERT_TRUE(m.calls >= 1); /* take_damage -> die */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 24 — Perl (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Perl: sub declarations + CALLS edge. */
+TEST(probe_perl_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.pl",
+ "#!/usr/bin/perl\n"
+ "use strict;\n"
+ "use warnings;\n\n"
+ "sub square {\n"
+ " my ($x) = @_;\n"
+ " return $x * $x;\n"
+ "}\n\n"
+ "sub sum_squares {\n"
+ " my ($a, $b) = @_;\n"
+ " return square($a) + square($b);\n"
+ "}\n\n"
+ "sub run {\n"
+ " print sum_squares(3, 4), \"\\n\";\n"
+ "}\n\n"
+ "run();\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 25 — R (grammar-only)
+ * Labels: Function:2, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* R: function assignments + CALLS edge. */
+TEST(probe_r_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.R",
+ "square <- function(x) {\n"
+ " x * x\n"
+ "}\n\n"
+ "sum_squares <- function(a, b) {\n"
+ " square(a) + square(b)\n"
+ "}\n\n"
+ "run <- function() {\n"
+ " cat(sum_squares(3, 4), \"\\n\")\n"
+ "}\n\n"
+ "run()\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 2);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 26 — Fortran (grammar-only)
+ * Labels: Function:1, Module:1
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Fortran: function + subroutine + call. */
+TEST(probe_fortran_functions_calls) {
+ NcpMetrics m = ncp_metrics("math.f90",
+ "function square(x) result(y)\n"
+ " integer, intent(in) :: x\n"
+ " integer :: y\n"
+ " y = x * x\n"
+ "end function square\n\n"
+ "function sum_sq(a, b) result(total)\n"
+ " integer, intent(in) :: a, b\n"
+ " integer :: total\n"
+ " total = square(a) + square(b)\n"
+ "end function sum_sq\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.functions >= 1);
+ ASSERT_TRUE(m.calls >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * SUITE REGISTRATION
+ * ══════════════════════════════════════════════════════════════════ */
+
+SUITE(node_creation_probe) {
+ /* Go (hybrid LSP) */
+ RUN_TEST(probe_go_functions);
+ RUN_TEST(probe_go_calls_edge);
+ RUN_TEST(probe_go_variadic_named_return);
+ RUN_TEST(probe_go_method_on_struct);
+ RUN_TEST(probe_go_interface_node);
+ RUN_TEST(probe_go_closure);
+ RUN_TEST(probe_go_generic_function);
+
+ /* C (hybrid LSP) */
+ RUN_TEST(probe_c_functions);
+ RUN_TEST(probe_c_calls_edge);
+ RUN_TEST(probe_c_function_pointer);
+ RUN_TEST(probe_c_inline_function);
+ RUN_TEST(probe_c_struct_node);
+
+ /* C++ (hybrid LSP) */
+ RUN_TEST(probe_cpp_class_methods);
+ RUN_TEST(probe_cpp_calls_edge);
+ RUN_TEST(probe_cpp_template_function);
+ RUN_TEST(probe_cpp_enum_class);
+ RUN_TEST(probe_cpp_struct_operator);
+ RUN_TEST(probe_cpp_inheritance);
+
+ /* Rust (hybrid LSP) */
+ RUN_TEST(probe_rust_struct_impl);
+ RUN_TEST(probe_rust_enum);
+ RUN_TEST(probe_rust_trait_impl);
+ RUN_TEST(probe_rust_calls_edge);
+ RUN_TEST(probe_rust_closure);
+ RUN_TEST(probe_rust_type_alias);
+
+ /* Python (hybrid LSP) */
+ RUN_TEST(probe_python_functions);
+ RUN_TEST(probe_python_class);
+ RUN_TEST(probe_python_nested_function);
+ RUN_TEST(probe_python_decorator);
+ RUN_TEST(probe_python_lambda);
+ RUN_TEST(probe_python_dataclass);
+
+ /* TypeScript (hybrid LSP) */
+ RUN_TEST(probe_ts_interface_class);
+ RUN_TEST(probe_ts_generic_arrow);
+ RUN_TEST(probe_ts_enum);
+ RUN_TEST(probe_ts_calls_edge);
+ RUN_TEST(probe_ts_class_extends);
+ RUN_TEST(probe_ts_type_alias);
+
+ /* Java (hybrid LSP) */
+ RUN_TEST(probe_java_class_methods);
+ RUN_TEST(probe_java_interface);
+ RUN_TEST(probe_java_enum);
+ RUN_TEST(probe_java_inner_class);
+ RUN_TEST(probe_java_lambda);
+
+ /* Kotlin (hybrid LSP) */
+ RUN_TEST(probe_kotlin_data_class);
+ RUN_TEST(probe_kotlin_sealed_class);
+ RUN_TEST(probe_kotlin_interface_lambda);
+ RUN_TEST(probe_kotlin_calls_edge);
+ RUN_TEST(probe_kotlin_enum);
+
+ /* C# (hybrid LSP) */
+ RUN_TEST(probe_cs_class_methods);
+ RUN_TEST(probe_cs_interface);
+ RUN_TEST(probe_cs_enum);
+ RUN_TEST(probe_cs_generic_class);
+ RUN_TEST(probe_cs_struct);
+
+ /* Ruby (grammar-only) */
+ RUN_TEST(probe_ruby_class_calls);
+ RUN_TEST(probe_ruby_module);
+ RUN_TEST(probe_ruby_toplevel_functions);
+
+ /* Swift (grammar-only) */
+ RUN_TEST(probe_swift_struct_calls);
+ RUN_TEST(probe_swift_class_inherit);
+ RUN_TEST(probe_swift_enum);
+
+ /* Scala (grammar-only) */
+ RUN_TEST(probe_scala_class_object);
+ RUN_TEST(probe_scala_trait);
+
+ /* Lua (grammar-only) */
+ RUN_TEST(probe_lua_functions_calls);
+ RUN_TEST(probe_lua_table_class);
+
+ /* Bash (grammar-only) */
+ RUN_TEST(probe_bash_functions_calls);
+ RUN_TEST(probe_bash_function_keyword);
+
+ /* Dart (grammar-only; CALLS gap is a known-red reproduction) */
+ RUN_TEST(probe_dart_functions);
+ RUN_TEST(probe_dart_class);
+ RUN_TEST(probe_dart_calls_edge_known_gap);
+
+ /* Elixir (grammar-only) */
+ RUN_TEST(probe_elixir_module_calls);
+ RUN_TEST(probe_elixir_nested_module);
+
+ /* Haskell (grammar-only) */
+ RUN_TEST(probe_haskell_functions_calls);
+ RUN_TEST(probe_haskell_data_type);
+
+ /* Zig (grammar-only) */
+ RUN_TEST(probe_zig_functions_calls);
+ RUN_TEST(probe_zig_struct_methods);
+
+ /* OCaml (grammar-only) */
+ RUN_TEST(probe_ocaml_functions_calls);
+
+ /* Erlang (grammar-only) */
+ RUN_TEST(probe_erlang_functions_calls);
+
+ /* Groovy (grammar-only; CALLS gap is a known-red reproduction) */
+ RUN_TEST(probe_groovy_class_methods);
+ RUN_TEST(probe_groovy_calls_edge_known_gap);
+
+ /* Nim (grammar-only) */
+ RUN_TEST(probe_nim_functions_calls);
+
+ /* GDScript (grammar-only) */
+ RUN_TEST(probe_gdscript_functions_calls);
+
+ /* Perl (grammar-only) */
+ RUN_TEST(probe_perl_functions_calls);
+
+ /* R (grammar-only) */
+ RUN_TEST(probe_r_functions_calls);
+
+ /* Fortran (grammar-only) */
+ RUN_TEST(probe_fortran_functions_calls);
+}