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.

Complete 159-grammar coverage: IDL/template/IaC/markup/remaining-code probes; +1 new class

Martin Vogel05182747838b
diff --git a/Makefile.cbm b/Makefile.cbm
index 3d8fbba38..5948398d7 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 tests/test_lsp_resolution_probe.c tests/test_node_creation_probe.c tests/test_edge_types_probe.c tests/test_convergence_probe.c tests/test_matrix_known_classes.c tests/test_matrix_new_constructs.c tests/test_grammar_probe_a.c tests/test_grammar_probe_b.c tests/test_grammar_probe_c.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 tests/test_convergence_probe.c tests/test_matrix_known_classes.c tests/test_matrix_new_constructs.c tests/test_grammar_probe_a.c tests/test_grammar_probe_b.c tests/test_grammar_probe_c.c tests/test_grammar_probe_d.c tests/test_grammar_probe_e.c tests/test_grammar_probe_f.c tests/test_grammar_probe_g.c
TEST_TRACES_SRCS = tests/test_traces.c
diff --git a/tests/test_grammar_probe_d.c b/tests/test_grammar_probe_d.c
new file mode 100644
index 000000000..de02097c6
--- /dev/null
+++ b/tests/test_grammar_probe_d.c
@@ -0,0 +1,1919 @@
+/*
+ * test_grammar_probe_d.c — Remaining code-grammar node/import/inheritance probe.
+ *
+ * SCOPE
+ * ─────
+ * Probes 25 grammar-only code languages not yet covered by probes _a, _b, _c:
+ * agda, assembly, bicep, cfml, cfscript, cobol, elm, func, janet, lean,
+ * llvm_ir, magma, move, nasm, objc, pony, purescript, pine, qml, smali,
+ * tablegen, tlaplus, verilog, vhdl, wolfram.
+ *
+ * SKIPPED (with reason):
+ * systemverilog — CBM_LANG_SYSTEMVERILOG has no extension entry in the
+ * EXT_TABLE (language.c); the only SV extension ".sv" maps to
+ * CBM_LANG_VERILOG. File-based index_repository cannot route to
+ * CBM_LANG_SYSTEMVERILOG via extension alone. It is already exercised
+ * by the test_grammar_regression.c direct-language fixture and the
+ * grammar_labels histogram (Class:1,Function:1,Module:1).
+ *
+ * COLOUR LEGEND
+ * ─────────────
+ * GREEN = guard: pipeline already produces the correct result; a failure
+ * here is a real regression.
+ * RED = bug reproduction: pipeline does NOT yet produce the expected
+ * node/edge; test FAILS until fixed. Brief inline comment names
+ * root-cause class.
+ *
+ * CALLS dimensions are intentionally omitted (covered by P5 breadth).
+ * Do NOT register this suite in test_main.c.
+ *
+ * SUITE(grammar_probe_d)
+ */
+
+#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 — mirrors test_grammar_probe_a.c exactly.
+ * Prefix "gpd_" to avoid symbol clashes with sibling probe files.
+ * ══════════════════════════════════════════════════════════════════ */
+
+typedef struct {
+ char tmpdir[256];
+ char dbpath[512];
+ char *project;
+ cbm_mcp_server_t *srv;
+} GpdProj;
+
+typedef struct {
+ const char *name; /* relative filename, may include '/' for subdirs */
+ const char *content;
+} GpdFile;
+
+static void gpd_to_fwd_slashes(char *p) {
+ for (; *p; p++) {
+ if (*p == '\\') *p = '/';
+ }
+}
+
+static cbm_store_t *gpd_open_indexed(GpdProj *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 *gpd_index_files(GpdProj *lp, const GpdFile *files, int nfiles) {
+ memset(lp, 0, sizeof(*lp));
+ snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_gpd_XXXXXX");
+ if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
+ gpd_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 gpd_open_indexed(lp);
+}
+
+static void gpd_cleanup(GpdProj *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);
+}
+
+/* ── Node-count helpers ─────────────────────────────────────────── */
+
+static int gpd_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 of all type-like labels. */
+static int gpd_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 = gpd_count_label(store, project, labels[i]);
+ if (n > 0) total += n;
+ }
+ return total;
+}
+
+/* Metrics bundled per index pass. */
+typedef struct {
+ int ok;
+ int total_nodes;
+ int functions;
+ int methods;
+ int types; /* type-like sum */
+ int imports; /* IMPORTS edges */
+ int inherits; /* INHERITS edges */
+} GpdMetrics;
+
+static GpdMetrics gpd_metrics_files(const GpdFile *files, int nfiles) {
+ GpdProj lp;
+ cbm_store_t *store = gpd_index_files(&lp, files, nfiles);
+ GpdMetrics m = {0};
+ if (store) {
+ m.ok = 1;
+ m.total_nodes = cbm_store_count_nodes(store, lp.project);
+ m.functions = gpd_count_label(store, lp.project, "Function");
+ m.methods = gpd_count_label(store, lp.project, "Method");
+ m.types = gpd_type_nodes(store, lp.project);
+ m.imports = cbm_store_count_edges_by_type(store, lp.project, "IMPORTS");
+ m.inherits = cbm_store_count_edges_by_type(store, lp.project, "INHERITS");
+ }
+ gpd_cleanup(&lp, store);
+ return m;
+}
+
+static GpdMetrics gpd_metrics(const char *filename, const char *content) {
+ GpdFile f = {filename, content};
+ return gpd_metrics_files(&f, 1);
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 1 — Agda (.agda)
+ *
+ * Agda label histogram: Function:1, Module:1 (grammar_labels histogram).
+ * Spec: agda_func_types = {"function"}, agda_class_types = {"data","record"},
+ * agda_import_types = {"import","open","import_directive","instance"}.
+ * Extension: .agda → CBM_LANG_AGDA.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Agda: function definition → Function node. */
+TEST(probe_agda_function) {
+ GpdMetrics m = gpd_metrics("Nat.agda",
+ "module Nat where\n"
+ "\n"
+ "double : Nat -> Nat\n"
+ "double n = n + n\n"
+ "\n"
+ "triple : Nat -> Nat\n"
+ "triple n = n + n + n\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: function definitions must reach the graph as Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Agda: data type definition → type-like node.
+ * RED: histogram shows Function:1/Module:1 only; data/record types not
+ * extracted as Class/Type nodes despite agda_class_types spec. */
+TEST(probe_agda_data_type) {
+ GpdMetrics m = gpd_metrics("Shape.agda",
+ "module Shape where\n"
+ "\n"
+ "data Shape : Set where\n"
+ " Circle : Shape\n"
+ " Square : Shape\n"
+ "\n"
+ "area : Shape -> Nat\n"
+ "area Circle = 1\n"
+ "area Square = 2\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: Agda data/record type not extracted as type-like node (node-extraction gap). */
+ ASSERT_TRUE(m.types >= 1); /* expected RED */
+ PASS();
+}
+
+/* Agda: `import` in two-file fixture → IMPORTS edge.
+ * RED: grammar-only Agda has no module-import resolver in the pipeline. */
+TEST(probe_agda_imports_edge) {
+ static const GpdFile files[] = {
+ {"Utils.agda",
+ "module Utils where\n"
+ "\n"
+ "double : Nat -> Nat\n"
+ "double n = n + n\n"},
+ {"Main.agda",
+ "module Main where\n"
+ "\n"
+ "import Utils\n"
+ "\n"
+ "quad : Nat -> Nat\n"
+ "quad n = Utils.double (Utils.double n)\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Agda `import` not resolved into IMPORTS edges by the pipeline. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 2 — Assembly (.s)
+ *
+ * Assembly label histogram: Function:1, Module:1.
+ * Spec: assembly_func_types = {"label"}, no class/import types.
+ * Extension: .s → CBM_LANG_ASSEMBLY.
+ * Assembly has no OOP, no imports — only labels extracted as Functions.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Assembly: global label → Function node. */
+TEST(probe_assembly_label_function) {
+ GpdMetrics m = gpd_metrics("add.s",
+ ".global add\n"
+ "add:\n"
+ " add x0, x0, x1\n"
+ " ret\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: global label must be extracted as a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Assembly: multiple labels → multiple Function nodes. */
+TEST(probe_assembly_multiple_labels) {
+ GpdMetrics m = gpd_metrics("math.s",
+ ".global square\n"
+ "square:\n"
+ " mul x0, x0, x0\n"
+ " ret\n"
+ "\n"
+ ".global negate\n"
+ "negate:\n"
+ " neg x0, x0\n"
+ " ret\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both labels should produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* Assembly: no OOP — no type-like nodes expected. */
+TEST(probe_assembly_no_type_nodes) {
+ GpdMetrics m = gpd_metrics("noop.s",
+ ".global noop\n"
+ "noop:\n"
+ " ret\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: assembly produces 0 type-like nodes. */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 3 — Bicep (.bicep)
+ *
+ * Bicep label histogram: Function:1, Module:1 (from grammar_labels).
+ * Spec: bicep_func_types = {"user_defined_function","lambda_expression"},
+ * bicep_class_types = {"resource_declaration","type_declaration","module_declaration"},
+ * bicep_import_types = {"import_statement","module_declaration","import","using_statement"}.
+ * Extension: .bicep → CBM_LANG_BICEP.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Bicep: user-defined function → Function node. */
+TEST(probe_bicep_function) {
+ GpdMetrics m = gpd_metrics("funcs.bicep",
+ "func greet(name string) string => 'Hello, ${name}!'\n"
+ "\n"
+ "func square(n int) int => n * n\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both user-defined functions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Bicep: resource declaration → type-like node.
+ * RED: histogram shows Function:1/Module:1 only; resource_declaration not
+ * extracted as Class/Type node despite bicep_class_types spec. */
+TEST(probe_bicep_resource_node) {
+ GpdMetrics m = gpd_metrics("storage.bicep",
+ "resource storageAccount 'Microsoft.Storage/storageAccounts@2021-02-01' = {\n"
+ " name: 'mystorage'\n"
+ " location: 'eastus'\n"
+ " kind: 'StorageV2'\n"
+ " sku: {\n"
+ " name: 'Standard_LRS'\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: Bicep resource_declaration not yet extracted as type-like node. */
+ ASSERT_TRUE(m.types >= 1); /* expected RED */
+ PASS();
+}
+
+/* Bicep: module declaration (cross-file reference) → IMPORTS edge.
+ * RED: grammar-only Bicep has no module-resolver in the pipeline. */
+TEST(probe_bicep_module_import) {
+ static const GpdFile files[] = {
+ {"storage.bicep",
+ "param name string\n"
+ "resource sa 'Microsoft.Storage/storageAccounts@2021-02-01' = {\n"
+ " name: name\n"
+ " location: 'eastus'\n"
+ " kind: 'StorageV2'\n"
+ " sku: { name: 'Standard_LRS' }\n"
+ "}\n"},
+ {"main.bicep",
+ "module storage './storage.bicep' = {\n"
+ " name: 'storageDeploy'\n"
+ " params: { name: 'mystore' }\n"
+ "}\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Bicep module cross-reference not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 4 — CFML (.cfm — tag dialect)
+ *
+ * CFML label histogram: Function:1, Module:1.
+ * Spec: cfml_func_types = {"function_declaration","function_expression"};
+ * cffunction tags handled separately as cf_function_tag.
+ * Extension: .cfm → CBM_LANG_CFML.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* CFML: <cffunction> tag → Function node. */
+TEST(probe_cfml_function_tag) {
+ GpdMetrics m = gpd_metrics("greet.cfm",
+ "<cffunction name=\"greet\" returntype=\"string\">\n"
+ " <cfargument name=\"name\" type=\"string\">\n"
+ " <cfreturn \"Hello, \" & name>\n"
+ "</cffunction>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: <cffunction> tag must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* CFML: two <cffunction> tags → at least 2 Function nodes. */
+TEST(probe_cfml_two_functions) {
+ GpdMetrics m = gpd_metrics("utils.cfm",
+ "<cffunction name=\"double\" returntype=\"numeric\">\n"
+ " <cfargument name=\"n\" type=\"numeric\">\n"
+ " <cfreturn n * 2>\n"
+ "</cffunction>\n"
+ "\n"
+ "<cffunction name=\"triple\" returntype=\"numeric\">\n"
+ " <cfargument name=\"n\" type=\"numeric\">\n"
+ " <cfreturn n * 3>\n"
+ "</cffunction>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both cffunction tags must be extracted as Function nodes. */
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* CFML: no OOP class nodes expected (tag dialect has no class construct). */
+TEST(probe_cfml_no_type_nodes) {
+ GpdMetrics m = gpd_metrics("simple.cfm",
+ "<cffunction name=\"noop\" returntype=\"void\">\n"
+ "</cffunction>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: CFML tag dialect produces 0 type-like nodes. */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 5 — CFScript (.cfc — script dialect)
+ *
+ * CFScript label histogram: Function:2, Module:1 (from grammar_labels for cfscript).
+ * Spec: cfscript_func_types = {"function_declaration","function_expression",
+ * "arrow_function","method_definition"}.
+ * Extension: .cfc → CBM_LANG_CFSCRIPT.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* CFScript: component with two function declarations → 2 Function nodes. */
+TEST(probe_cfscript_functions) {
+ GpdMetrics m = gpd_metrics("MathService.cfc",
+ "component {\n"
+ " function double(numeric n) {\n"
+ " return n * 2;\n"
+ " }\n"
+ "\n"
+ " function triple(numeric n) {\n"
+ " return n * 3;\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both function declarations must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* CFScript: no cross-file import syntax modeled — pipeline produces 0 IMPORTS. */
+TEST(probe_cfscript_no_import_edges) {
+ GpdMetrics m = gpd_metrics("Single.cfc",
+ "component {\n"
+ " function greet(string name) {\n"
+ " return \"Hello, \" & name;\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: single-file CFScript produces 0 IMPORTS edges. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 6 — COBOL (.cob)
+ *
+ * COBOL label histogram: Class:1, Function:1 (from MUST_EXTRACT_DEFS fixture).
+ * Spec: cobol_func_types = {"program_definition"},
+ * cobol_import_types = {"open_statement","use_statement","with_clause"}.
+ * Extension: .cob → CBM_LANG_COBOL.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* COBOL: PROGRAM-ID → Function (program_definition) node. */
+TEST(probe_cobol_program_node) {
+ GpdMetrics m = gpd_metrics("hello.cob",
+ " IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. HELLO.\n"
+ " PROCEDURE DIVISION.\n"
+ " MAIN-PARA.\n"
+ " DISPLAY 'Hello, World!'.\n"
+ " STOP RUN.\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: PROGRAM-ID must produce a Function node (program_definition). */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* COBOL: pipeline indexes the file and produces at least 1 node. */
+TEST(probe_cobol_no_crash) {
+ GpdMetrics m = gpd_metrics("calc.cob",
+ " IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. CALC.\n"
+ " DATA DIVISION.\n"
+ " WORKING-STORAGE SECTION.\n"
+ " 01 NUM PIC 9(4) VALUE 0.\n"
+ " PROCEDURE DIVISION.\n"
+ " COMPUTE NUM = 2 + 2.\n"
+ " STOP RUN.\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 7 — Elm (.elm)
+ *
+ * Elm label histogram: Class:1, Function:1, Module:1.
+ * Spec: elm_func_types = {"value_declaration","function_declaration"},
+ * elm_class_types = {"type_declaration","type_alias_declaration","module_declaration"},
+ * elm_import_types = {"import"}.
+ * Extension: .elm → CBM_LANG_ELM.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Elm: function definition → Function node. */
+TEST(probe_elm_function) {
+ GpdMetrics m = gpd_metrics("Math.elm",
+ "module Math exposing (..)\n"
+ "\n"
+ "double : Int -> Int\n"
+ "double n = n * 2\n"
+ "\n"
+ "triple : Int -> Int\n"
+ "triple n = n * 3\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both function definitions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Elm: type alias declaration → type-like node. */
+TEST(probe_elm_type_alias) {
+ GpdMetrics m = gpd_metrics("Types.elm",
+ "module Types exposing (..)\n"
+ "\n"
+ "type alias Point = { x : Float, y : Float }\n"
+ "\n"
+ "type Shape\n"
+ " = Circle Float\n"
+ " | Rectangle Float Float\n"
+ "\n"
+ "area : Shape -> Float\n"
+ "area s =\n"
+ " case s of\n"
+ " Circle r -> 3.14159 * r * r\n"
+ " Rectangle w h -> w * h\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: type alias/type declaration must produce type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Elm: `import` in two-file fixture → IMPORTS edge.
+ * RED: grammar-only Elm has no import-resolver in the pipeline. */
+TEST(probe_elm_imports_edge) {
+ static const GpdFile files[] = {
+ {"Utils.elm",
+ "module Utils exposing (..)\n"
+ "\n"
+ "double : Int -> Int\n"
+ "double n = n * 2\n"},
+ {"Main.elm",
+ "module Main exposing (..)\n"
+ "\n"
+ "import Utils\n"
+ "\n"
+ "quad : Int -> Int\n"
+ "quad n = Utils.double (Utils.double n)\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Elm `import` not resolved into IMPORTS edges by the pipeline. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 8 — FunC (.fc)
+ *
+ * FunC label histogram: Function:1, Module:1.
+ * Spec: func_func_types = {"function_definition"},
+ * func_import_types = {"include_directive"}.
+ * Extension: .fc → CBM_LANG_FUNC.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* FunC: function definition → Function node. */
+TEST(probe_func_function) {
+ GpdMetrics m = gpd_metrics("math.fc",
+ "int square(int n) {\n"
+ " return n * n;\n"
+ "}\n"
+ "\n"
+ "int cube(int n) {\n"
+ " return n * square(n);\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both function definitions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* FunC: `#include` in two-file fixture → IMPORTS edge.
+ * RED: grammar-only FunC has no include-resolver in the pipeline. */
+TEST(probe_func_imports_edge) {
+ static const GpdFile files[] = {
+ {"utils.fc",
+ "int double_val(int n) {\n"
+ " return n * 2;\n"
+ "}\n"},
+ {"main.fc",
+ "#include \"utils.fc\"\n"
+ "\n"
+ "int run(int n) {\n"
+ " return double_val(n);\n"
+ "}\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: FunC #include not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* FunC: no OOP — no type-like nodes expected. */
+TEST(probe_func_no_type_nodes) {
+ GpdMetrics m = gpd_metrics("noop.fc",
+ "() noop() {\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: FunC produces 0 type-like nodes. */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 9 — Janet (.janet)
+ *
+ * Janet label histogram: Module:1 only (from grammar_labels MUST_EXTRACT_DEFS).
+ * Spec: CBM_LANG_JANET uses empty_types for all definition types — no function
+ * extraction is configured; the grammar emits only a source/Module node.
+ * Extension: .janet → CBM_LANG_JANET.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Janet: pipeline indexes the file without crashing — total_nodes >= 1. */
+TEST(probe_janet_no_crash) {
+ GpdMetrics m = gpd_metrics("math.janet",
+ "(defn double [n] (* 2 n))\n"
+ "\n"
+ "(defn square [n] (* n n))\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash; at least Module node expected. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Janet: functions NOT extracted — the spec has empty_types for func.
+ * RED: defn forms not configured in the lang spec; 0 Function nodes is the
+ * current behaviour and a known gap. */
+TEST(probe_janet_function_extraction_gap) {
+ GpdMetrics m = gpd_metrics("ops.janet",
+ "(defn add [a b] (+ a b))\n"
+ "(defn sub [a b] (- a b))\n"
+ "(defn mul [a b] (* a b))\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: Janet defn forms not configured in lang_spec → 0 Function nodes. */
+ ASSERT_TRUE(m.functions >= 1); /* expected RED — empty func_types in spec */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 10 — Lean (.lean)
+ *
+ * Lean label histogram: Function:2, Module:1.
+ * Spec: lean_func_types = {"def","theorem","instance","abbrev"},
+ * lean_class_types = {"structure","class_inductive","inductive"},
+ * lean_import_types = {"import","extends","instance"}.
+ * Extension: .lean → CBM_LANG_LEAN.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Lean: two `def` definitions → 2 Function nodes. */
+TEST(probe_lean_def_functions) {
+ GpdMetrics m = gpd_metrics("math.lean",
+ "def double (n : Nat) : Nat := n * 2\n"
+ "\n"
+ "def square (n : Nat) : Nat := n * n\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both def bindings must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* Lean: theorem definition → Function node. */
+TEST(probe_lean_theorem) {
+ GpdMetrics m = gpd_metrics("proofs.lean",
+ "theorem add_comm (a b : Nat) : a + b = b + a := by\n"
+ " omega\n"
+ "\n"
+ "theorem mul_comm (a b : Nat) : a * b = b * a := by\n"
+ " omega\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: theorem definitions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Lean: structure definition → type-like node.
+ * RED: histogram shows Function/Module only; structure not yet extracted as
+ * type node despite lean_class_types having "structure". */
+TEST(probe_lean_structure_type) {
+ GpdMetrics m = gpd_metrics("types.lean",
+ "structure Point where\n"
+ " x : Float\n"
+ " y : Float\n"
+ "\n"
+ "def origin : Point := { x := 0, y := 0 }\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: Lean structure not extracted as type-like node (node-extraction gap). */
+ ASSERT_TRUE(m.types >= 1); /* expected RED */
+ PASS();
+}
+
+/* Lean: `import` in two-file fixture → IMPORTS edge.
+ * RED: grammar-only Lean has no import-resolver in the pipeline. */
+TEST(probe_lean_imports_edge) {
+ static const GpdFile files[] = {
+ {"MathUtils.lean",
+ "def double (n : Nat) : Nat := n * 2\n"},
+ {"Main.lean",
+ "import MathUtils\n"
+ "\n"
+ "def quad (n : Nat) : Nat := double (double n)\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Lean `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 11 — LLVM IR (.ll)
+ *
+ * LLVM IR label histogram: Function:1, Module:1.
+ * Spec: llvm_func_types = {"function_header"}, no class/import types.
+ * Extension: .ll → CBM_LANG_LLVM_IR.
+ * LLVM IR has no OOP and no import mechanism at the IR level.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* LLVM IR: function definition → Function node. */
+TEST(probe_llvmir_function) {
+ GpdMetrics m = gpd_metrics("add.ll",
+ "define i32 @add(i32 %a, i32 %b) {\n"
+ "entry:\n"
+ " %r = add i32 %a, %b\n"
+ " ret i32 %r\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: LLVM IR function definition must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* LLVM IR: two function definitions → 2 Function nodes. */
+TEST(probe_llvmir_two_functions) {
+ GpdMetrics m = gpd_metrics("math.ll",
+ "define i32 @square(i32 %n) {\n"
+ "entry:\n"
+ " %r = mul i32 %n, %n\n"
+ " ret i32 %r\n"
+ "}\n"
+ "\n"
+ "define i32 @negate(i32 %n) {\n"
+ "entry:\n"
+ " %r = sub i32 0, %n\n"
+ " ret i32 %r\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both function definitions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* LLVM IR: no OOP — no type-like nodes expected. */
+TEST(probe_llvmir_no_type_nodes) {
+ GpdMetrics m = gpd_metrics("noop.ll",
+ "define void @noop() {\n"
+ "entry:\n"
+ " ret void\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: LLVM IR produces 0 type-like nodes. */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 12 — Magma (.mag)
+ *
+ * Magma label histogram: Function:2, Module:1 (from grammar_labels).
+ * Spec: magma_func_types = {"function_definition","procedure_definition",
+ * "intrinsic_definition","anonymous_function"},
+ * magma_import_types = {"load_statement","require","require_statement"}.
+ * Extension: .mag → CBM_LANG_MAGMA.
+ * Note: .m also resolves to Magma if content has end function/procedure markers
+ * (via cbm_disambiguate_m), but .mag is unambiguous.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Magma: function definition → Function node. */
+TEST(probe_magma_function) {
+ GpdMetrics m = gpd_metrics("arith.mag",
+ "function Square(n)\n"
+ " return n * n;\n"
+ "end function;\n"
+ "\n"
+ "function Cube(n)\n"
+ " return n * Square(n);\n"
+ "end function;\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both function definitions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 2);
+ PASS();
+}
+
+/* Magma: procedure definition → Function node (procedures are in func_types). */
+TEST(probe_magma_procedure) {
+ GpdMetrics m = gpd_metrics("proc.mag",
+ "procedure PrintVal(n)\n"
+ " print n;\n"
+ "end procedure;\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: procedure must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Magma: no OOP types — Magma is functional/mathematical. */
+TEST(probe_magma_no_type_nodes) {
+ GpdMetrics m = gpd_metrics("simple.mag",
+ "function Id(x)\n"
+ " return x;\n"
+ "end function;\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Magma produces 0 type-like nodes. */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 13 — Move (.move)
+ *
+ * Move label histogram: Function:1, Module:1.
+ * Spec: move_func_types = {"function_item"}, no class types (grammar comment:
+ * struct/enum exist only as anonymous keyword tokens, never as parent nodes),
+ * move_import_types = {"use_declaration"}.
+ * Extension: .move → CBM_LANG_MOVE.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Move: function inside module → Function node. */
+TEST(probe_move_function) {
+ GpdMetrics m = gpd_metrics("math.move",
+ "module 0x1::math {\n"
+ " public fun double(n: u64): u64 {\n"
+ " n * 2\n"
+ " }\n"
+ "\n"
+ " public fun square(n: u64): u64 {\n"
+ " n * n\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both function_item nodes must reach the graph. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Move: `use` declaration in two-file fixture → IMPORTS edge.
+ * RED: grammar-only Move has no use-declaration resolver in the pipeline. */
+TEST(probe_move_imports_edge) {
+ static const GpdFile files[] = {
+ {"utils.move",
+ "module 0x1::utils {\n"
+ " public fun double(n: u64): u64 { n * 2 }\n"
+ "}\n"},
+ {"main.move",
+ "module 0x1::main {\n"
+ " use 0x1::utils;\n"
+ "\n"
+ " public fun run(n: u64): u64 {\n"
+ " utils::double(n)\n"
+ " }\n"
+ "}\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Move `use` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* Move: struct definition — grammar models struct only as anonymous token, not
+ * as a named parent node. Verify no spurious type nodes are emitted. */
+TEST(probe_move_struct_not_extracted) {
+ GpdMetrics m = gpd_metrics("types.move",
+ "module 0x1::types {\n"
+ " struct Point has copy, drop {\n"
+ " x: u64,\n"
+ " y: u64,\n"
+ " }\n"
+ "\n"
+ " public fun origin(): Point {\n"
+ " Point { x: 0, y: 0 }\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Move grammar produces 0 type nodes (struct is anonymous token). */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 14 — NASM (.nasm)
+ *
+ * NASM label histogram: Function:1, Module:1.
+ * Spec: nasm_func_types = {"label","preproc_def","preproc_multiline_macro"},
+ * nasm_class_types = {"struc_declaration"},
+ * nasm_import_types = {"preproc_include"}.
+ * Extension: .nasm → CBM_LANG_NASM.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* NASM: label → Function node. */
+TEST(probe_nasm_label_function) {
+ GpdMetrics m = gpd_metrics("add.nasm",
+ "global add\n"
+ "add:\n"
+ " mov eax, edi\n"
+ " add eax, esi\n"
+ " ret\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: label must be extracted as Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* NASM: struc declaration → type-like node.
+ * RED: histogram shows Function:1/Module:1 only; struc_declaration not
+ * extracted as a type node despite nasm_class_types spec. */
+TEST(probe_nasm_struc_node) {
+ GpdMetrics m = gpd_metrics("point.nasm",
+ "struc Point\n"
+ " .x: resd 1\n"
+ " .y: resd 1\n"
+ "endstruc\n"
+ "\n"
+ "global get_x\n"
+ "get_x:\n"
+ " mov eax, [edi + Point.x]\n"
+ " ret\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: NASM struc_declaration not extracted as type-like node. */
+ ASSERT_TRUE(m.types >= 1); /* expected RED */
+ PASS();
+}
+
+/* NASM: %include in two-file fixture → IMPORTS edge.
+ * RED: grammar-only NASM has no include-resolver in the pipeline. */
+TEST(probe_nasm_include_edge) {
+ static const GpdFile files[] = {
+ {"utils.nasm",
+ "global double\n"
+ "double:\n"
+ " shl edi, 1\n"
+ " mov eax, edi\n"
+ " ret\n"},
+ {"main.nasm",
+ "%include \"utils.nasm\"\n"
+ "\n"
+ "global run\n"
+ "run:\n"
+ " call double\n"
+ " ret\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: NASM %include not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 15 — Objective-C (.m with ObjC markers)
+ *
+ * ObjC label histogram: Class:1, Function:2, Module:1 (from grammar_labels).
+ * Spec: objc_func_types = {"function_definition","method_definition","method_declaration"},
+ * objc_class_types = {"class_interface","class_implementation","protocol_declaration",...},
+ * objc_import_types = {"preproc_import","preproc_include"}.
+ * Extension: .m → disambiguated to CBM_LANG_OBJC when @interface/@implementation
+ * markers are present (via cbm_disambiguate_m).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* ObjC: @interface declaration → Class node. */
+TEST(probe_objc_class_node) {
+ GpdMetrics m = gpd_metrics("Animal.m",
+ "#import <Foundation/Foundation.h>\n"
+ "\n"
+ "@interface Animal : NSObject\n"
+ "- (NSString *)speak;\n"
+ "- (NSString *)name;\n"
+ "@end\n"
+ "\n"
+ "@implementation Animal\n"
+ "- (NSString *)speak { return @\"...\"; }\n"
+ "- (NSString *)name { return @\"Animal\"; }\n"
+ "@end\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: @interface must produce a Class/type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* ObjC: methods → Function/Method nodes. */
+TEST(probe_objc_method_nodes) {
+ GpdMetrics m = gpd_metrics("Calc.m",
+ "@interface Calc : NSObject\n"
+ "- (int)square:(int)n;\n"
+ "- (int)cube:(int)n;\n"
+ "@end\n"
+ "\n"
+ "@implementation Calc\n"
+ "- (int)square:(int)n { return n * n; }\n"
+ "- (int)cube:(int)n { return n * n * n; }\n"
+ "@end\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: ObjC method_definition is labelled "Method" (extract_defs.c
+ * sets def.label = "Method" for CBM_LANG_OBJC method_definition),
+ * not "Function" — matches grammar_labels histogram objc=Method:1.
+ * Fixture fix: assert Method, not Function. */
+ ASSERT_TRUE(m.methods >= 1);
+ PASS();
+}
+
+/* ObjC: subclass via @interface Child : Parent → INHERITS edge.
+ * RED: grammar-only ObjC has no base-class resolver in the pipeline. */
+TEST(probe_objc_inherits_edge) {
+ GpdMetrics m = gpd_metrics("Dog.m",
+ "@interface Animal : NSObject\n"
+ "- (NSString *)speak;\n"
+ "@end\n"
+ "\n"
+ "@interface Dog : Animal\n"
+ "- (void)bark;\n"
+ "@end\n"
+ "\n"
+ "@implementation Dog\n"
+ "- (NSString *)speak { return @\"Woof\"; }\n"
+ "- (void)bark { NSLog(@\"Woof!\"); }\n"
+ "@end\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: ObjC @interface inheritance not yet resolved into INHERITS edges. */
+ ASSERT_TRUE(m.inherits >= 1); /* expected RED */
+ PASS();
+}
+
+/* ObjC: #import in two-file fixture → IMPORTS edge.
+ * RED: grammar-only ObjC has no #import resolver in the pipeline. */
+TEST(probe_objc_import_edge) {
+ static const GpdFile files[] = {
+ {"Utils.m",
+ "@interface Utils : NSObject\n"
+ "+ (int)double:(int)n;\n"
+ "@end\n"
+ "@implementation Utils\n"
+ "+ (int)double:(int)n { return n * 2; }\n"
+ "@end\n"},
+ {"Main.m",
+ "#import \"Utils.m\"\n"
+ "\n"
+ "@interface Main : NSObject\n"
+ "+ (int)run:(int)n;\n"
+ "@end\n"
+ "@implementation Main\n"
+ "+ (int)run:(int)n { return [Utils double:n]; }\n"
+ "@end\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: ObjC #import not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 16 — Pony (.pony)
+ *
+ * Pony label histogram: Class:1, Function:1, Module:1 (from grammar_labels).
+ * Spec: pony_func_types = {"method","constructor","ffi_method","lambda_expression"},
+ * pony_class_types = {"actor_definition","class_definition","struct_definition",
+ * "trait_definition","interface_definition","primitive_definition",
+ * "type_alias"},
+ * pony_import_types = {"use_statement"}.
+ * Extension: .pony → CBM_LANG_PONY.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Pony: class definition → Class node. */
+TEST(probe_pony_class_node) {
+ GpdMetrics m = gpd_metrics("Animal.pony",
+ "class Animal\n"
+ " let _name: String\n"
+ "\n"
+ " new create(name: String) =>\n"
+ " _name = name\n"
+ "\n"
+ " fun name(): String =>\n"
+ " _name\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: class_definition must produce a type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Pony: actor definition → type-like node. */
+TEST(probe_pony_actor_node) {
+ GpdMetrics m = gpd_metrics("Counter.pony",
+ "actor Counter\n"
+ " var _count: U64 = 0\n"
+ "\n"
+ " be increment() =>\n"
+ " _count = _count + 1\n"
+ "\n"
+ " be reset() =>\n"
+ " _count = 0\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: actor_definition must produce a type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Pony: methods (fun/be/new) → Function nodes. */
+TEST(probe_pony_method_nodes) {
+ GpdMetrics m = gpd_metrics("Math.pony",
+ "primitive Math\n"
+ " fun square(n: U64): U64 =>\n"
+ " n * n\n"
+ "\n"
+ " fun cube(n: U64): U64 =>\n"
+ " n * square(n)\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: fun methods must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Pony: trait with interface → type-like node. */
+TEST(probe_pony_trait_node) {
+ GpdMetrics m = gpd_metrics("Speakable.pony",
+ "trait Speakable\n"
+ " fun speak(): String\n"
+ "\n"
+ "class Dog is Speakable\n"
+ " fun speak(): String =>\n"
+ " \"Woof!\"\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both trait and class must produce type-like nodes. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Pony: `use` in two-file fixture → IMPORTS edge.
+ * RED: grammar-only Pony has no use-statement resolver in the pipeline. */
+TEST(probe_pony_imports_edge) {
+ static const GpdFile files[] = {
+ {"util.pony",
+ "primitive MathUtil\n"
+ " fun double(n: U64): U64 =>\n"
+ " n * 2\n"},
+ {"main.pony",
+ "use \"./util\"\n"
+ "\n"
+ "actor Main\n"
+ " new create(env: Env) =>\n"
+ " let r = MathUtil.double(21)\n"
+ " env.out.print(r.string())\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Pony `use` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 17 — PureScript (.purs)
+ *
+ * PureScript label histogram: Class:1, Function:1, Module:1 (from grammar_labels).
+ * Spec: purescript_func_types = {"function"},
+ * purescript_class_types = {"class_declaration","data","newtype","type_alias"},
+ * purescript_import_types = {"import","import_item","instance"}.
+ * Extension: .purs → CBM_LANG_PURESCRIPT.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* PureScript: function definition → Function node. */
+TEST(probe_purescript_function) {
+ GpdMetrics m = gpd_metrics("Math.purs",
+ "module Math where\n"
+ "\n"
+ "double :: Int -> Int\n"
+ "double n = n * 2\n"
+ "\n"
+ "square :: Int -> Int\n"
+ "square n = n * n\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: function definitions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* PureScript: data/type declaration → type-like node. */
+TEST(probe_purescript_data_type) {
+ GpdMetrics m = gpd_metrics("Types.purs",
+ "module Types where\n"
+ "\n"
+ "data Shape\n"
+ " = Circle Number\n"
+ " | Rectangle Number Number\n"
+ "\n"
+ "type Alias = Shape\n"
+ "\n"
+ "area :: Shape -> Number\n"
+ "area (Circle r) = 3.14159 * r * r\n"
+ "area (Rectangle w h) = w * h\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: data declaration must produce a type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* PureScript: `import` in two-file fixture → IMPORTS edge.
+ * RED: grammar-only PureScript has no import-resolver in the pipeline. */
+TEST(probe_purescript_imports_edge) {
+ static const GpdFile files[] = {
+ {"Utils.purs",
+ "module Utils where\n"
+ "\n"
+ "double :: Int -> Int\n"
+ "double n = n * 2\n"},
+ {"Main.purs",
+ "module Main where\n"
+ "\n"
+ "import Utils (double)\n"
+ "\n"
+ "quad :: Int -> Int\n"
+ "quad n = double (double n)\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: PureScript `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 18 — Pine Script (.pine)
+ *
+ * Pine label histogram: Function:1, Module:1 (from grammar_labels).
+ * Spec: pine_func_types = {"function_declaration_statement"},
+ * pine_class_types = {"type_definition_statement"}.
+ * Extension: .pine → CBM_LANG_PINE.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Pine Script: function declaration → Function node. */
+TEST(probe_pine_function) {
+ GpdMetrics m = gpd_metrics("indicator.pine",
+ "//@version=5\n"
+ "indicator('My Indicator')\n"
+ "\n"
+ "double(n) =>\n"
+ " n * 2\n"
+ "\n"
+ "square(n) =>\n"
+ " n * n\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: function_declaration_statement must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Pine Script: type definition → type-like node.
+ * RED: histogram shows Function/Module only; type_definition_statement not
+ * extracted as type-like node despite pine_class_types spec. */
+TEST(probe_pine_type_node) {
+ GpdMetrics m = gpd_metrics("types.pine",
+ "//@version=5\n"
+ "indicator('Types')\n"
+ "\n"
+ "type Point\n"
+ " float x = 0\n"
+ " float y = 0\n"
+ "\n"
+ "makePoint(x, y) =>\n"
+ " Point.new(x, y)\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: Pine Script type_definition_statement not extracted as type-like node. */
+ ASSERT_TRUE(m.types >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 19 — QML (.qml)
+ *
+ * QML label histogram: Class:1, Function:2, Module:1 (from grammar_labels).
+ * Spec: qml_class_types = {"class_declaration","class","abstract_class_declaration",
+ * "enum_declaration","interface_declaration","ui_inline_component"},
+ * qml_import_types = {"import_statement","import","ui_import"}.
+ * Function types reuse js_func_types (QMLJS is a TS/JS superset).
+ * Extension: .qml → CBM_LANG_QML.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* QML: JavaScript function inside a component → Function node. */
+TEST(probe_qml_function) {
+ GpdMetrics m = gpd_metrics("Button.qml",
+ "import QtQuick 2.15\n"
+ "\n"
+ "Rectangle {\n"
+ " id: root\n"
+ " width: 100; height: 40\n"
+ "\n"
+ " function greet(name) {\n"
+ " return \"Hello, \" + name\n"
+ " }\n"
+ "\n"
+ " function dismiss() {\n"
+ " visible = false\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: JavaScript functions inside QML must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* QML: `import` → IMPORTS edge.
+ * RED: grammar-only QML has no import-resolver in the pipeline. */
+TEST(probe_qml_imports_edge) {
+ static const GpdFile files[] = {
+ {"Utils.qml",
+ "import QtQuick 2.15\n"
+ "\n"
+ "Rectangle {\n"
+ " function double(n) { return n * 2 }\n"
+ "}\n"},
+ {"Main.qml",
+ "import QtQuick 2.15\n"
+ "import \"./Utils.qml\"\n"
+ "\n"
+ "Rectangle {\n"
+ " function run(n) { return n * 4 }\n"
+ "}\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: QML `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 20 — Smali (.smali)
+ *
+ * Smali label histogram: Class:1, Function:1, Module:1.
+ * Spec: smali_func_types = {"method_definition"},
+ * smali_class_types = {"class_definition"},
+ * smali_import_types = {"super_directive","implements_directive"}.
+ * Extension: .smali → CBM_LANG_SMALI.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Smali: class definition → Class node. */
+TEST(probe_smali_class_node) {
+ GpdMetrics m = gpd_metrics("A.smali",
+ ".class public LA;\n"
+ ".super Ljava/lang/Object;\n"
+ "\n"
+ ".method public constructor <init>()V\n"
+ " .registers 1\n"
+ " return-void\n"
+ ".end method\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: class_definition must produce a type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Smali: method definition → Function node. */
+TEST(probe_smali_method_node) {
+ GpdMetrics m = gpd_metrics("Math.smali",
+ ".class public LMath;\n"
+ ".super Ljava/lang/Object;\n"
+ "\n"
+ ".method public static square(I)I\n"
+ " .registers 2\n"
+ " mul-int v0, p0, p0\n"
+ " return v0\n"
+ ".end method\n"
+ "\n"
+ ".method public static cube(I)I\n"
+ " .registers 2\n"
+ " mul-int v0, p0, p0\n"
+ " mul-int v0, v0, p0\n"
+ " return v0\n"
+ ".end method\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: method definitions must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Smali: .super and .implements directives → IMPORTS edges.
+ * RED: Smali super/implements directives not resolved into IMPORTS edges. */
+TEST(probe_smali_super_import) {
+ static const GpdFile files[] = {
+ {"Base.smali",
+ ".class public LBase;\n"
+ ".super Ljava/lang/Object;\n"
+ "\n"
+ ".method public doBase()V\n"
+ " return-void\n"
+ ".end method\n"},
+ {"Child.smali",
+ ".class public LChild;\n"
+ ".super LBase;\n"
+ "\n"
+ ".method public doChild()V\n"
+ " return-void\n"
+ ".end method\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Smali .super directive not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 21 — TableGen (.td)
+ *
+ * TableGen label histogram: Function:1, Module:1.
+ * Spec: tablegen_func_types = {"def","multiclass","defm"},
+ * tablegen_class_types = {"class"},
+ * tablegen_import_types = {"include","include_directive"}.
+ * Extension: .td → CBM_LANG_TABLEGEN.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* TableGen: `def` record → Function node (def is in func_types). */
+TEST(probe_tablegen_def_node) {
+ GpdMetrics m = gpd_metrics("regs.td",
+ "def R0 { int num = 0; }\n"
+ "def R1 { int num = 1; }\n"
+ "def R2 { int num = 2; }\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: def records must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* TableGen: `class` definition → type-like node.
+ * RED: histogram shows Function:1/Module:1 only; class not extracted as
+ * type-like node despite tablegen_class_types spec. */
+TEST(probe_tablegen_class_node) {
+ GpdMetrics m = gpd_metrics("instrs.td",
+ "class Instruction {\n"
+ " string mnemonic = \"\";\n"
+ " int opcode = 0;\n"
+ "}\n"
+ "\n"
+ "def ADD : Instruction {\n"
+ " let mnemonic = \"add\";\n"
+ " let opcode = 1;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: TableGen class not extracted as type-like node. */
+ ASSERT_TRUE(m.types >= 1); /* expected RED */
+ PASS();
+}
+
+/* TableGen: `include` in two-file fixture → IMPORTS edge.
+ * RED: grammar-only TableGen has no include-resolver in the pipeline. */
+TEST(probe_tablegen_include_edge) {
+ static const GpdFile files[] = {
+ {"base.td",
+ "class BaseInstr {\n"
+ " int opcode = 0;\n"
+ "}\n"},
+ {"derived.td",
+ "include \"base.td\"\n"
+ "\n"
+ "def ADD : BaseInstr {\n"
+ " let opcode = 1;\n"
+ "}\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: TableGen `include` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 22 — TLA+ (.tla)
+ *
+ * TLA+ label histogram: Function:1, Module:1.
+ * Spec: tlaplus_func_types = {"operator_definition","function_definition"},
+ * tlaplus_import_types = {"extends","instance"}.
+ * Extension: .tla → CBM_LANG_TLAPLUS.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* TLA+: operator definition → Function node. */
+TEST(probe_tlaplus_operator) {
+ GpdMetrics m = gpd_metrics("counter.tla",
+ "---- MODULE counter ----\n"
+ "VARIABLE count\n"
+ "\n"
+ "Init == count = 0\n"
+ "\n"
+ "Increment == count' = count + 1\n"
+ "====\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: operator definitions (Init, Increment) must produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* TLA+: EXTENDS in two-file fixture → IMPORTS edge.
+ * RED: grammar-only TLA+ has no EXTENDS resolver in the pipeline. */
+TEST(probe_tlaplus_extends_edge) {
+ static const GpdFile files[] = {
+ {"Naturals.tla",
+ "---- MODULE Naturals ----\n"
+ "Max(a, b) == IF a > b THEN a ELSE b\n"
+ "====\n"},
+ {"Counter.tla",
+ "---- MODULE Counter ----\n"
+ "EXTENDS Naturals\n"
+ "\n"
+ "VARIABLE count\n"
+ "\n"
+ "Init == count = 0\n"
+ "Next == count' = Max(count + 1, count)\n"
+ "====\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: TLA+ EXTENDS not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* TLA+: no OOP — no type-like nodes expected. */
+TEST(probe_tlaplus_no_type_nodes) {
+ GpdMetrics m = gpd_metrics("simple.tla",
+ "---- MODULE simple ----\n"
+ "VARIABLE x\n"
+ "Init == x = 0\n"
+ "====\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: TLA+ produces 0 type-like nodes. */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 23 — Verilog (.v)
+ *
+ * Verilog label histogram: Class:1, Module:1.
+ * Spec: verilog_func_types = {"function_declaration","task_declaration",...},
+ * verilog_class_types = {"module_declaration","class_declaration",...},
+ * verilog_import_types = {"extends","import","package_import_declaration"}.
+ * Extension: .v → CBM_LANG_VERILOG.
+ * Note: .sv also maps to CBM_LANG_VERILOG (not CBM_LANG_SYSTEMVERILOG).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Verilog: module declaration → type-like node. */
+TEST(probe_verilog_module_node) {
+ GpdMetrics m = gpd_metrics("counter.v",
+ "module counter(\n"
+ " input clk,\n"
+ " input rst,\n"
+ " output reg [7:0] count\n"
+ ");\n"
+ "\n"
+ "always @(posedge clk or posedge rst) begin\n"
+ " if (rst)\n"
+ " count <= 0;\n"
+ " else\n"
+ " count <= count + 1;\n"
+ "end\n"
+ "\n"
+ "endmodule\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: module_declaration must produce a type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Verilog: function declaration → Function node. */
+TEST(probe_verilog_function) {
+ GpdMetrics m = gpd_metrics("math.v",
+ "module math_funcs;\n"
+ "\n"
+ "function [7:0] double;\n"
+ " input [7:0] n;\n"
+ " begin\n"
+ " double = n << 1;\n"
+ " end\n"
+ "endfunction\n"
+ "\n"
+ "endmodule\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: function declaration must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Verilog: SystemVerilog-style file (.sv) — lands on CBM_LANG_VERILOG via EXT_TABLE.
+ * No separate CBM_LANG_SYSTEMVERILOG routing is available through file extension. */
+TEST(probe_verilog_sv_extension) {
+ GpdMetrics m = gpd_metrics("adder.sv",
+ "module adder(\n"
+ " input logic [7:0] a,\n"
+ " input logic [7:0] b,\n"
+ " output logic [7:0] sum\n"
+ ");\n"
+ " assign sum = a + b;\n"
+ "endmodule\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: .sv → CBM_LANG_VERILOG; module_declaration must produce type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 24 — VHDL (.vhd)
+ *
+ * VHDL label histogram: Class:1, Module:1.
+ * Spec: vhdl_func_types = {"subprogram_declaration","subprogram_definition"},
+ * vhdl_class_types = {"entity_declaration","architecture_definition",
+ * "component_declaration","interface_declaration",
+ * "package_declaration","protected_type_declaration",
+ * "record_type_definition","type_declaration"},
+ * vhdl_import_types = {"library_clause","use_clause"}.
+ * Extension: .vhd / .vhdl → CBM_LANG_VHDL.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* VHDL: entity declaration → type-like node. */
+TEST(probe_vhdl_entity_node) {
+ GpdMetrics m = gpd_metrics("counter.vhd",
+ "entity counter is\n"
+ " port (\n"
+ " clk : in bit;\n"
+ " rst : in bit;\n"
+ " count : out integer\n"
+ " );\n"
+ "end counter;\n"
+ "\n"
+ "architecture rtl of counter is\n"
+ "begin\n"
+ "end architecture;\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: entity_declaration must produce a type-like node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* VHDL: subprogram (function/procedure) definition → Function node. */
+TEST(probe_vhdl_subprogram) {
+ GpdMetrics m = gpd_metrics("funcs.vhd",
+ "package math_pkg is\n"
+ " function double(n : integer) return integer;\n"
+ "end package;\n"
+ "\n"
+ "package body math_pkg is\n"
+ " function double(n : integer) return integer is\n"
+ " begin\n"
+ " return n * 2;\n"
+ " end function;\n"
+ "end package body;\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: subprogram_definition must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* VHDL: library/use in two-file fixture → IMPORTS edge.
+ * RED: grammar-only VHDL has no library/use resolver in the pipeline. */
+TEST(probe_vhdl_use_imports_edge) {
+ static const GpdFile files[] = {
+ {"math_pkg.vhd",
+ "package math_pkg is\n"
+ " function double(n : integer) return integer;\n"
+ "end package;\n"
+ "\n"
+ "package body math_pkg is\n"
+ " function double(n : integer) return integer is\n"
+ " begin return n * 2; end function;\n"
+ "end package body;\n"},
+ {"top.vhd",
+ "library work;\n"
+ "use work.math_pkg.all;\n"
+ "\n"
+ "entity top is end;\n"
+ "architecture rtl of top is\n"
+ "begin\n"
+ "end architecture;\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: VHDL library/use not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 25 — Wolfram (.wl)
+ *
+ * Wolfram label histogram: Function:2, Module:1.
+ * Spec: wolfram_func_types = {"set_delayed_top","set_top","set_delayed","set"},
+ * wolfram_import_types = {"get_top"}.
+ * Extension: .wl / .wls → CBM_LANG_WOLFRAM.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Wolfram: SetDelayed function definition → Function node. */
+TEST(probe_wolfram_function) {
+ GpdMetrics m = gpd_metrics("math.wl",
+ "Square[n_] := n * n\n"
+ "\n"
+ "Cube[n_] := n * Square[n]\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (class 16 node-extraction incompleteness): two top-level
+ * `f[x_] := ...` SetDelayed defs in one file yield only 1 Function node,
+ * not 2. The grammar_labels histogram only guarantees Function:1 for a
+ * single-def fixture; a 2-def file under-extracts. Root cause likely in
+ * extract_defs.c wolfram walk (resolve_wolfram_func_name / top-level
+ * statement iteration capturing only the first set_delayed_top). RED. */
+ ASSERT_TRUE(m.functions >= 2); /* REAL BUG — multi-def under-extraction */
+ PASS();
+}
+
+/* Wolfram: Set (=) definition → Function node. */
+TEST(probe_wolfram_set_definition) {
+ GpdMetrics m = gpd_metrics("const.wl",
+ "Pi = 3.14159265\n"
+ "\n"
+ "E = 2.71828182\n"
+ "\n"
+ "Double[n_] := n * 2\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (class 16 node-extraction incompleteness): a file whose first
+ * top-level statements are plain `Pi = 3.14` / `E = 2.71` (set_top with a
+ * non-`apply` LHS → resolve_wolfram_func_name returns null) followed by a
+ * real `Double[n_] := n*2` def yields 0 Function nodes — the trailing
+ * apply-LHS SetDelayed def is NOT extracted. A lone `f[x_] := ...`
+ * extracts fine (grammar_labels wolfram=Function:1), so the leading
+ * non-def set_top statements suppress later extraction. Root cause:
+ * extract_defs.c wolfram top-level walk. RED. */
+ ASSERT_TRUE(m.functions >= 1); /* REAL BUG — set_top prefix suppresses later def */
+ PASS();
+}
+
+/* Wolfram: << (Get) import in two-file fixture → IMPORTS edge.
+ * RED: grammar-only Wolfram has no << resolver in the pipeline. */
+TEST(probe_wolfram_get_import) {
+ static const GpdFile files[] = {
+ {"utils.wl",
+ "Double[n_] := n * 2\n"
+ "Triple[n_] := n * 3\n"},
+ {"main.wls",
+ "<< \"utils.wl\"\n"
+ "\n"
+ "Quad[n_] := Double[Double[n]]\n"}
+ };
+ GpdMetrics m = gpd_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Wolfram << (get_top) not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED */
+ PASS();
+}
+
+/* Wolfram: no OOP types — Wolfram is functional/symbolic. */
+TEST(probe_wolfram_no_type_nodes) {
+ GpdMetrics m = gpd_metrics("simple.wl",
+ "Id[x_] := x\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Wolfram produces 0 type-like nodes. */
+ ASSERT_TRUE(m.types == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * SUITE wiring
+ * ══════════════════════════════════════════════════════════════════ */
+
+SUITE(grammar_probe_d) {
+ /* Agda (.agda) */
+ RUN_TEST(probe_agda_function);
+ RUN_TEST(probe_agda_data_type);
+ RUN_TEST(probe_agda_imports_edge);
+
+ /* Assembly (.s) */
+ RUN_TEST(probe_assembly_label_function);
+ RUN_TEST(probe_assembly_multiple_labels);
+ RUN_TEST(probe_assembly_no_type_nodes);
+
+ /* Bicep (.bicep) */
+ RUN_TEST(probe_bicep_function);
+ RUN_TEST(probe_bicep_resource_node);
+ RUN_TEST(probe_bicep_module_import);
+
+ /* CFML (.cfm) */
+ RUN_TEST(probe_cfml_function_tag);
+ RUN_TEST(probe_cfml_two_functions);
+ RUN_TEST(probe_cfml_no_type_nodes);
+
+ /* CFScript (.cfc) */
+ RUN_TEST(probe_cfscript_functions);
+ RUN_TEST(probe_cfscript_no_import_edges);
+
+ /* COBOL (.cob) */
+ RUN_TEST(probe_cobol_program_node);
+ RUN_TEST(probe_cobol_no_crash);
+
+ /* Elm (.elm) */
+ RUN_TEST(probe_elm_function);
+ RUN_TEST(probe_elm_type_alias);
+ RUN_TEST(probe_elm_imports_edge);
+
+ /* FunC (.fc) */
+ RUN_TEST(probe_func_function);
+ RUN_TEST(probe_func_imports_edge);
+ RUN_TEST(probe_func_no_type_nodes);
+
+ /* Janet (.janet) */
+ RUN_TEST(probe_janet_no_crash);
+ RUN_TEST(probe_janet_function_extraction_gap);
+
+ /* Lean (.lean) */
+ RUN_TEST(probe_lean_def_functions);
+ RUN_TEST(probe_lean_theorem);
+ RUN_TEST(probe_lean_structure_type);
+ RUN_TEST(probe_lean_imports_edge);
+
+ /* LLVM IR (.ll) */
+ RUN_TEST(probe_llvmir_function);
+ RUN_TEST(probe_llvmir_two_functions);
+ RUN_TEST(probe_llvmir_no_type_nodes);
+
+ /* Magma (.mag) */
+ RUN_TEST(probe_magma_function);
+ RUN_TEST(probe_magma_procedure);
+ RUN_TEST(probe_magma_no_type_nodes);
+
+ /* Move (.move) */
+ RUN_TEST(probe_move_function);
+ RUN_TEST(probe_move_imports_edge);
+ RUN_TEST(probe_move_struct_not_extracted);
+
+ /* NASM (.nasm) */
+ RUN_TEST(probe_nasm_label_function);
+ RUN_TEST(probe_nasm_struc_node);
+ RUN_TEST(probe_nasm_include_edge);
+
+ /* Objective-C (.m with ObjC markers) */
+ RUN_TEST(probe_objc_class_node);
+ RUN_TEST(probe_objc_method_nodes);
+ RUN_TEST(probe_objc_inherits_edge);
+ RUN_TEST(probe_objc_import_edge);
+
+ /* Pony (.pony) */
+ RUN_TEST(probe_pony_class_node);
+ RUN_TEST(probe_pony_actor_node);
+ RUN_TEST(probe_pony_method_nodes);
+ RUN_TEST(probe_pony_trait_node);
+ RUN_TEST(probe_pony_imports_edge);
+
+ /* PureScript (.purs) */
+ RUN_TEST(probe_purescript_function);
+ RUN_TEST(probe_purescript_data_type);
+ RUN_TEST(probe_purescript_imports_edge);
+
+ /* Pine Script (.pine) */
+ RUN_TEST(probe_pine_function);
+ RUN_TEST(probe_pine_type_node);
+
+ /* QML (.qml) */
+ RUN_TEST(probe_qml_function);
+ RUN_TEST(probe_qml_imports_edge);
+
+ /* Smali (.smali) */
+ RUN_TEST(probe_smali_class_node);
+ RUN_TEST(probe_smali_method_node);
+ RUN_TEST(probe_smali_super_import);
+
+ /* TableGen (.td) */
+ RUN_TEST(probe_tablegen_def_node);
+ RUN_TEST(probe_tablegen_class_node);
+ RUN_TEST(probe_tablegen_include_edge);
+
+ /* TLA+ (.tla) */
+ RUN_TEST(probe_tlaplus_operator);
+ RUN_TEST(probe_tlaplus_extends_edge);
+ RUN_TEST(probe_tlaplus_no_type_nodes);
+
+ /* Verilog (.v — also covers .sv routed as CBM_LANG_VERILOG) */
+ RUN_TEST(probe_verilog_module_node);
+ RUN_TEST(probe_verilog_function);
+ RUN_TEST(probe_verilog_sv_extension);
+
+ /* VHDL (.vhd) */
+ RUN_TEST(probe_vhdl_entity_node);
+ RUN_TEST(probe_vhdl_subprogram);
+ RUN_TEST(probe_vhdl_use_imports_edge);
+
+ /* Wolfram (.wl) */
+ RUN_TEST(probe_wolfram_function);
+ RUN_TEST(probe_wolfram_set_definition);
+ RUN_TEST(probe_wolfram_get_import);
+ RUN_TEST(probe_wolfram_no_type_nodes);
+}
diff --git a/tests/test_grammar_probe_e.c b/tests/test_grammar_probe_e.c
new file mode 100644
index 000000000..9a8c45769
--- /dev/null
+++ b/tests/test_grammar_probe_e.c
@@ -0,0 +1,1520 @@
+/*
+ * test_grammar_probe_e.c — IDL/template node/import probe.
+ *
+ * SCOPE
+ * ─────
+ * IDL / schema languages:
+ * protobuf (.proto), thrift (.thrift), capnp (.capnp), wit (.wit),
+ * smithy (.smithy), prisma (.prisma), graphql (.graphql / .gql)
+ *
+ * Template / component languages:
+ * vue (.vue), svelte (.svelte), astro (.astro),
+ * blade (.blade.php), liquid (.liquid), jinja2 (.j2 / .jinja2),
+ * gotemplate (.gotmpl / .tmpl), mermaid (.mmd / .mermaid), jsdoc (.jsdoc)
+ *
+ * WHAT IS PROBED
+ * ──────────────
+ * • NODE creation — type-like nodes (Class/Struct/Interface/Enum) for IDL
+ * languages; Module-only for template/markup grammars.
+ * • IMPORTS edges — cross-file import/include/use where the grammar
+ * supports it. Two-file fixtures are used where
+ * applicable. Template grammars without a file-level
+ * import mechanism are tested for no-crash instead.
+ *
+ * COLOUR LEGEND
+ * ─────────────
+ * GREEN = guard: the pipeline already produces the correct result; a
+ * failure here is a real regression.
+ * RED = bug reproduction: the pipeline does NOT yet produce the expected
+ * node/edge. Brief inline comments identify the root-cause class.
+ *
+ * CALLS coverage is intentionally omitted (IDL/template languages have no
+ * in-language function calls to resolve; templates are covered by P5 breadth
+ * where applicable).
+ *
+ * Do NOT register this suite in test_main.c — a sibling agent owns that file.
+ *
+ * SUITE(grammar_probe_e)
+ */
+
+#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 — mirrors test_grammar_probe_a.c exactly.
+ * Prefix "gpe_" to avoid symbol collisions with sibling probe files.
+ * ══════════════════════════════════════════════════════════════════ */
+
+typedef struct {
+ char tmpdir[256];
+ char dbpath[512];
+ char *project;
+ cbm_mcp_server_t *srv;
+} GpeProj;
+
+typedef struct {
+ const char *name; /* relative filename, may include '/' for subdirs */
+ const char *content;
+} GpeFile;
+
+static void gpe_to_fwd_slashes(char *p) {
+ for (; *p; p++) {
+ if (*p == '\\') *p = '/';
+ }
+}
+
+static cbm_store_t *gpe_open_indexed(GpeProj *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 *gpe_index_files(GpeProj *lp, const GpeFile *files, int nfiles) {
+ memset(lp, 0, sizeof(*lp));
+ snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_gpe_XXXXXX");
+ if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
+ gpe_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 gpe_open_indexed(lp);
+}
+
+static void gpe_cleanup(GpeProj *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);
+}
+
+/* ── Node-count helpers ─────────────────────────────────────────── */
+
+static int gpe_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 of all type-like labels. */
+static int gpe_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 = gpe_count_label(store, project, labels[i]);
+ if (n > 0) total += n;
+ }
+ return total;
+}
+
+/* Metrics bundled per index pass. */
+typedef struct {
+ int ok;
+ int total_nodes;
+ int functions;
+ int methods;
+ int types; /* type-like sum */
+ int imports; /* IMPORTS edges */
+ int inherits; /* INHERITS edges */
+} GpeMetrics;
+
+static GpeMetrics gpe_metrics_files(const GpeFile *files, int nfiles) {
+ GpeProj lp;
+ cbm_store_t *store = gpe_index_files(&lp, files, nfiles);
+ GpeMetrics m = {0};
+ if (store) {
+ m.ok = 1;
+ m.total_nodes = cbm_store_count_nodes(store, lp.project);
+ m.functions = gpe_count_label(store, lp.project, "Function");
+ m.methods = gpe_count_label(store, lp.project, "Method");
+ m.types = gpe_type_nodes(store, lp.project);
+ m.imports = cbm_store_count_edges_by_type(store, lp.project, "IMPORTS");
+ m.inherits = cbm_store_count_edges_by_type(store, lp.project, "INHERITS");
+ }
+ gpe_cleanup(&lp, store);
+ return m;
+}
+
+static GpeMetrics gpe_metrics(const char *filename, const char *content) {
+ GpeFile f = {filename, content};
+ return gpe_metrics_files(&f, 1);
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 1 — Protobuf (.proto)
+ *
+ * Label histogram (test_grammar_labels.c): Class:1, Module:1
+ * A `message` definition → Class node.
+ * `enum` — whether it also produces a Class node is not confirmed; the
+ * histogram shows Class:1 for a single-message fixture, so a second Class
+ * for an enum would require a fixture with both message + enum.
+ * `service` — the label histogram does not show a Function node for a
+ * service method in the single-message fixture; service methods are
+ * extractable as Class/Function depending on extractor policy.
+ * `import` — Protobuf `import "other.proto"` is not resolved into IMPORTS
+ * graph edges; single-pass grammar-only extractor has no proto import
+ * resolver.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Protobuf: single message definition → at least 1 Class node. */
+TEST(probe_proto_message_node) {
+ GpeMetrics m = gpe_metrics("user.proto",
+ "syntax = \"proto3\";\n"
+ "package user;\n"
+ "\n"
+ "message User {\n"
+ " int64 id = 1;\n"
+ " string name = 2;\n"
+ " string email = 3;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: the `message` definition must produce a Class node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Protobuf: service definition — whether the service itself or its RPC
+ * methods produce extractable nodes. */
+TEST(probe_proto_service_node) {
+ GpeMetrics m = gpe_metrics("svc.proto",
+ "syntax = \"proto3\";\n"
+ "package svc;\n"
+ "\n"
+ "message Req { string query = 1; }\n"
+ "message Resp { string result = 1; }\n"
+ "\n"
+ "service SearchService {\n"
+ " rpc Search(Req) returns (Resp);\n"
+ " rpc Suggest(Req) returns (Resp);\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least the two message defs must produce Class nodes. */
+ ASSERT_TRUE(m.types >= 2);
+ PASS();
+}
+
+/* Protobuf: enum definition — confirm enum maps to a Class-like node. */
+TEST(probe_proto_enum_node) {
+ GpeMetrics m = gpe_metrics("status.proto",
+ "syntax = \"proto3\";\n"
+ "\n"
+ "enum Status {\n"
+ " STATUS_UNKNOWN = 0;\n"
+ " STATUS_ACTIVE = 1;\n"
+ " STATUS_INACTIVE = 2;\n"
+ "}\n"
+ "\n"
+ "message Item {\n"
+ " int64 id = 1;\n"
+ " Status status = 2;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at minimum the message must produce a Class node; enum may add
+ * another — total >= 1 is the safe floor. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Protobuf: two-file `import` → IMPORTS edge.
+ * RED: grammar-only protobuf has no import-resolver pass in the pipeline;
+ * `import "other.proto"` statements are not turned into IMPORTS edges. */
+TEST(probe_proto_import_edge) {
+ static const GpeFile files[] = {
+ {"common.proto",
+ "syntax = \"proto3\";\n"
+ "package common;\n"
+ "message Timestamp { int64 seconds = 1; }\n"},
+ {"event.proto",
+ "syntax = \"proto3\";\n"
+ "package event;\n"
+ "import \"common.proto\";\n"
+ "message Event {\n"
+ " string id = 1;\n"
+ " common.Timestamp created_at = 2;\n"
+ "}\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: protobuf `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no proto import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 2 — Thrift (.thrift)
+ *
+ * Label histogram: Function:1, Module:1
+ * `service Foo { void ping() }` → Function node (the method).
+ * `struct` — the histogram shows no Struct/Class node for a service-only
+ * fixture; struct extraction may not be implemented.
+ * `include` — Thrift uses `include "other.thrift"` for imports; not
+ * resolved by the grammar-only pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Thrift: service method → at least 1 Function node. */
+TEST(probe_thrift_service_function) {
+ GpeMetrics m = gpe_metrics("calc.thrift",
+ "namespace go calc\n"
+ "\n"
+ "service Calculator {\n"
+ " i32 add(1: i32 a, 2: i32 b)\n"
+ " i32 subtract(1: i32 a, 2: i32 b)\n"
+ " i32 multiply(1: i32 a, 2: i32 b)\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least one service method must appear as a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Thrift: struct definition — does the extractor produce a type-like node?
+ * RED: histogram shows Function:1/Module:1 for service-only fixtures; struct
+ * extraction is not confirmed and may not be implemented in the grammar
+ * extractor. */
+TEST(probe_thrift_struct_node) {
+ GpeMetrics m = gpe_metrics("types.thrift",
+ "namespace go types\n"
+ "\n"
+ "struct User {\n"
+ " 1: required i64 id\n"
+ " 2: required string name\n"
+ " 3: optional string email\n"
+ "}\n"
+ "\n"
+ "struct Address {\n"
+ " 1: required string street\n"
+ " 2: required string city\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1); /* GREEN: at minimum Module node */
+ /* RED: Thrift struct not yet extracted as a Struct/Class node. */
+ ASSERT_TRUE(m.types >= 1); /* expected RED — no Thrift struct extractor */
+ PASS();
+}
+
+/* Thrift: exception definition — a special struct-like type. */
+TEST(probe_thrift_exception_node) {
+ GpeMetrics m = gpe_metrics("errors.thrift",
+ "namespace go errors\n"
+ "\n"
+ "exception NotFound {\n"
+ " 1: required string message\n"
+ "}\n"
+ "\n"
+ "exception Unauthorized {\n"
+ " 1: required string reason\n"
+ "}\n"
+ "\n"
+ "service Auth {\n"
+ " void login(1: string user, 2: string pass)\n"
+ " throws (1: Unauthorized e)\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least the service method must appear as a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* Thrift: two-file `include` → IMPORTS edge.
+ * RED: grammar-only Thrift has no include-resolver in the pipeline. */
+TEST(probe_thrift_include_edge) {
+ static const GpeFile files[] = {
+ {"common.thrift",
+ "namespace go common\n"
+ "struct Timestamp { 1: required i64 seconds }\n"},
+ {"service.thrift",
+ "namespace go service\n"
+ "include \"common.thrift\"\n"
+ "struct Event {\n"
+ " 1: required string id\n"
+ " 2: required common.Timestamp created_at\n"
+ "}\n"
+ "service EventService {\n"
+ " Event getEvent(1: string id)\n"
+ "}\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Thrift `include` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Thrift include resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 3 — Cap'n Proto (.capnp)
+ *
+ * Label histogram: Class:1, Module:1
+ * `struct` → Class node.
+ * `interface` — may also produce a Class node (or Interface node).
+ * `import` with `@0x...` annotation — Capnp uses `using Import = import
+ * "other.capnp";`; not resolved by the grammar-only pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Cap'n Proto: struct definition → at least 1 Class node. */
+TEST(probe_capnp_struct_node) {
+ GpeMetrics m = gpe_metrics("schema.capnp",
+ "@0xdbb9ad1f14bf0b36;\n"
+ "\n"
+ "struct Person {\n"
+ " id @0 :UInt32;\n"
+ " name @1 :Text;\n"
+ " email @2 :Text;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: the struct must produce a Class node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Cap'n Proto: interface definition → Class (or Interface) node. */
+TEST(probe_capnp_interface_node) {
+ GpeMetrics m = gpe_metrics("service.capnp",
+ "@0xabc123def456789a;\n"
+ "\n"
+ "struct Request { query @0 :Text; }\n"
+ "struct Response { result @0 :Text; }\n"
+ "\n"
+ "interface SearchService {\n"
+ " search @0 (req :Request) -> (resp :Response);\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at minimum the two struct definitions must produce Class nodes. */
+ ASSERT_TRUE(m.types >= 2);
+ PASS();
+}
+
+/* Cap'n Proto: enum definition. */
+TEST(probe_capnp_enum_node) {
+ GpeMetrics m = gpe_metrics("enums.capnp",
+ "@0x1234567890abcdef;\n"
+ "\n"
+ "enum Color {\n"
+ " red @0;\n"
+ " green @1;\n"
+ " blue @2;\n"
+ "}\n"
+ "\n"
+ "struct Widget {\n"
+ " color @0 :Color;\n"
+ " label @1 :Text;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: the struct must produce a Class node; enum may add another. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Cap'n Proto: two-file import → IMPORTS edge.
+ * RED: grammar-only Cap'n Proto has no import-resolver pass in the pipeline. */
+TEST(probe_capnp_import_edge) {
+ static const GpeFile files[] = {
+ {"common.capnp",
+ "@0xaabbccddeeff0011;\n"
+ "struct Timestamp { seconds @0 :Int64; }\n"},
+ {"event.capnp",
+ "@0x1122334455667788;\n"
+ "using Common = import \"common.capnp\";\n"
+ "struct Event {\n"
+ " id @0 :Text;\n"
+ " createdAt @1 :Common.Timestamp;\n"
+ "}\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Cap'n Proto `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no capnp import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 4 — WIT (.wit)
+ *
+ * Label histogram: Class:2, Function:1, Module:1
+ * `record` → Class node; `enum` → Class node; `func` → Function node.
+ * `world` and `interface` container constructs; the histogram's Class:2
+ * comes from record + enum inside an interface block.
+ * `use` — WIT uses `use pkg:component/iface.{Type}` for imports;
+ * not resolved by the grammar-only pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* WIT: record and enum inside an interface → 2 Class nodes + 1 Function. */
+TEST(probe_wit_record_enum_function) {
+ GpeMetrics m = gpe_metrics("types.wit",
+ "interface geometry {\n"
+ " record point { x: u32, y: u32 }\n"
+ " enum color { red, green, blue }\n"
+ " area: func() -> u32;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: record → Class, enum → Class, func → Function.
+ * Histogram confirms Class:2, Function:1 for this pattern. */
+ ASSERT_TRUE(m.types >= 2);
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* WIT: world definition as a top-level construct. */
+TEST(probe_wit_world_node) {
+ GpeMetrics m = gpe_metrics("world.wit",
+ "world calculator {\n"
+ " export add: func(a: u32, b: u32) -> u32;\n"
+ " export subtract: func(a: u32, b: u32) -> u32;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (class 16 node-extraction incompleteness): `func`s declared
+ * inside a WIT `world { export X: func ... }` block are NOT extracted as
+ * Function nodes, whereas `interface`-scoped funcs ARE (see passing
+ * probe_wit_record_enum_function and grammar_labels wit=Function:1).
+ * The extractor's WIT func handling covers interface members but not
+ * world exports. Root cause: extract_defs.c WIT walk / lang_specs.c
+ * wit func_node_types scope. RED. */
+ ASSERT_TRUE(m.functions >= 1); /* REAL BUG — world-scoped funcs not extracted */
+ PASS();
+}
+
+/* WIT: type alias definition. */
+TEST(probe_wit_type_alias) {
+ GpeMetrics m = gpe_metrics("alias.wit",
+ "interface types {\n"
+ " type error-code = u32;\n"
+ " record error { code: error-code, msg: string }\n"
+ " get-error: func(code: error-code) -> error;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: the record → Class, func → Function. */
+ ASSERT_TRUE(m.types >= 1);
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* WIT: variant definition (tagged union). */
+TEST(probe_wit_variant_node) {
+ GpeMetrics m = gpe_metrics("result.wit",
+ "interface result-types {\n"
+ " variant result {\n"
+ " ok(u32),\n"
+ " err(string),\n"
+ " }\n"
+ " unwrap: func(r: result) -> u32;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at minimum the function must appear; variant may add a Class. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* WIT: two-file `use` → IMPORTS edge.
+ * RED: grammar-only WIT has no use-resolver in the pipeline. */
+TEST(probe_wit_use_edge) {
+ static const GpeFile files[] = {
+ {"types.wit",
+ "interface types {\n"
+ " record point { x: u32, y: u32 }\n"
+ "}\n"},
+ {"geometry.wit",
+ "interface geometry {\n"
+ " use types.{point};\n"
+ " distance: func(a: point, b: point) -> u32;\n"
+ "}\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: WIT `use` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no WIT use resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 5 — Smithy (.smithy)
+ *
+ * Label histogram: Class:1, Module:1
+ * `structure` → Class node (confirmed by grammar_regression: Foo → Class).
+ * `service` and `operation` — may produce additional Class nodes.
+ * `use` — Smithy uses `use com.example#Shape` for cross-namespace imports;
+ * not resolved by the grammar-only pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Smithy: structure definition → at least 1 Class node. */
+TEST(probe_smithy_structure_node) {
+ /* Fixture fix: valid Smithy ordering is control section ($version) FIRST,
+ * then namespace, then shapes. The original fixture had `namespace`
+ * before `$version`, which is invalid Smithy and failed to parse → 0
+ * nodes. Mirrors the working test_grammar_regression.c smithy fixture
+ * (namespace, then structure) which yields Class:1. */
+ GpeMetrics m = gpe_metrics("model.smithy",
+ "$version: \"2\"\n"
+ "\n"
+ "namespace com.example\n"
+ "\n"
+ "structure User {\n"
+ " @required\n"
+ " id: String\n"
+ " name: String\n"
+ " email: String\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: structure → Class node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Smithy: service + operation definitions. */
+TEST(probe_smithy_service_node) {
+ GpeMetrics m = gpe_metrics("service.smithy",
+ "namespace com.example\n"
+ "\n"
+ "service UserService {\n"
+ " version: \"2024-01-01\"\n"
+ " operations: [GetUser, CreateUser]\n"
+ "}\n"
+ "\n"
+ "operation GetUser {\n"
+ " input: GetUserInput\n"
+ " output: GetUserOutput\n"
+ "}\n"
+ "\n"
+ "operation CreateUser {\n"
+ " input: CreateUserInput\n"
+ "}\n"
+ "\n"
+ "structure GetUserInput { @required id: String }\n"
+ "structure GetUserOutput { id: String, name: String }\n"
+ "structure CreateUserInput { @required name: String }\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at minimum the structure definitions must produce Class nodes. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Smithy: enum definition. */
+TEST(probe_smithy_enum_node) {
+ GpeMetrics m = gpe_metrics("enum.smithy",
+ "namespace com.example\n"
+ "\n"
+ "enum Status {\n"
+ " ACTIVE = \"active\"\n"
+ " INACTIVE = \"inactive\"\n"
+ " PENDING = \"pending\"\n"
+ "}\n"
+ "\n"
+ "structure Item {\n"
+ " id: String\n"
+ " status: Status\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: structure → Class; enum may produce another type node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Smithy: two-file `use` → IMPORTS edge.
+ * RED: grammar-only Smithy has no use-resolver in the pipeline. */
+TEST(probe_smithy_use_edge) {
+ static const GpeFile files[] = {
+ {"common.smithy",
+ "namespace com.example.common\n"
+ "structure Timestamp { seconds: Long }\n"},
+ {"events.smithy",
+ "namespace com.example.events\n"
+ "use com.example.common#Timestamp\n"
+ "structure Event {\n"
+ " id: String\n"
+ " createdAt: Timestamp\n"
+ "}\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Smithy `use` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Smithy use resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 6 — Prisma (.prisma)
+ *
+ * Label histogram: Class:1, Module:1
+ * `model` → Class node.
+ * `enum` — may produce a second Class node.
+ * Prisma schema files are single-file; there is no cross-file import
+ * mechanism in the Prisma schema language itself (all models live in
+ * one schema.prisma or are merged via --schema flag, not `import`).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Prisma: model definition → at least 1 Class node. */
+TEST(probe_prisma_model_node) {
+ GpeMetrics m = gpe_metrics("schema.prisma",
+ "generator client {\n"
+ " provider = \"prisma-client-js\"\n"
+ "}\n"
+ "\n"
+ "datasource db {\n"
+ " provider = \"postgresql\"\n"
+ " url = env(\"DATABASE_URL\")\n"
+ "}\n"
+ "\n"
+ "model User {\n"
+ " id Int @id @default(autoincrement())\n"
+ " name String\n"
+ " email String @unique\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: `model User` must produce a Class node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Prisma: multiple model definitions → multiple Class nodes. */
+TEST(probe_prisma_multiple_models) {
+ GpeMetrics m = gpe_metrics("blog.prisma",
+ "model User {\n"
+ " id Int @id @default(autoincrement())\n"
+ " name String\n"
+ " posts Post[]\n"
+ "}\n"
+ "\n"
+ "model Post {\n"
+ " id Int @id @default(autoincrement())\n"
+ " title String\n"
+ " content String\n"
+ " authorId Int\n"
+ " author User @relation(fields: [authorId], references: [id])\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: two model definitions → at least 2 Class nodes. */
+ ASSERT_TRUE(m.types >= 2);
+ PASS();
+}
+
+/* Prisma: enum definition — does it yield an additional type node? */
+TEST(probe_prisma_enum_node) {
+ GpeMetrics m = gpe_metrics("status.prisma",
+ "enum Role {\n"
+ " USER\n"
+ " ADMIN\n"
+ " MODERATOR\n"
+ "}\n"
+ "\n"
+ "model Account {\n"
+ " id Int @id @default(autoincrement())\n"
+ " role Role @default(USER)\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: model → Class; enum may add another — floor is >= 1. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* Prisma: no-crash for a datasource-only schema (no models). */
+TEST(probe_prisma_datasource_only) {
+ GpeMetrics m = gpe_metrics("config.prisma",
+ "generator client {\n"
+ " provider = \"prisma-client-js\"\n"
+ "}\n"
+ "\n"
+ "datasource db {\n"
+ " provider = \"sqlite\"\n"
+ " url = \"file:./dev.db\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash on a schema with no models. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 7 — GraphQL (.graphql / .gql)
+ *
+ * Label histogram: Class:1, Module:1
+ * `type` definition → Class node.
+ * `input` and `interface` types — may also produce Class nodes.
+ * GraphQL schema files are typically standalone; cross-file imports are
+ * not part of the SDL (Schema Definition Language); no IMPORTS edges
+ * are expected from the grammar-only pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* GraphQL: type definition → at least 1 Class node. */
+TEST(probe_graphql_type_node) {
+ GpeMetrics m = gpe_metrics("schema.graphql",
+ "type User {\n"
+ " id: ID!\n"
+ " name: String!\n"
+ " email: String!\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: `type User` must produce a Class node. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* GraphQL: multiple type definitions → multiple Class nodes. */
+TEST(probe_graphql_multiple_types) {
+ GpeMetrics m = gpe_metrics("schema.gql",
+ "type Query {\n"
+ " user(id: ID!): User\n"
+ " users: [User!]!\n"
+ "}\n"
+ "\n"
+ "type User {\n"
+ " id: ID!\n"
+ " name: String!\n"
+ " posts: [Post!]!\n"
+ "}\n"
+ "\n"
+ "type Post {\n"
+ " id: ID!\n"
+ " title: String!\n"
+ " content: String!\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: 3 type definitions → at least 2 Class nodes. */
+ ASSERT_TRUE(m.types >= 2);
+ PASS();
+}
+
+/* GraphQL: interface definition → type-like node. */
+TEST(probe_graphql_interface_node) {
+ GpeMetrics m = gpe_metrics("iface.graphql",
+ "interface Node {\n"
+ " id: ID!\n"
+ "}\n"
+ "\n"
+ "type User implements Node {\n"
+ " id: ID!\n"
+ " name: String!\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at minimum `type User` → Class; `interface Node` may add one. */
+ ASSERT_TRUE(m.types >= 1);
+ PASS();
+}
+
+/* GraphQL: input type definition. */
+TEST(probe_graphql_input_type) {
+ GpeMetrics m = gpe_metrics("mutations.graphql",
+ "input CreateUserInput {\n"
+ " name: String!\n"
+ " email: String!\n"
+ "}\n"
+ "\n"
+ "type Mutation {\n"
+ " createUser(input: CreateUserInput!): User!\n"
+ "}\n"
+ "\n"
+ "type User {\n"
+ " id: ID!\n"
+ " name: String!\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least two type-like nodes expected (input + type + type). */
+ ASSERT_TRUE(m.types >= 2);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 8 — Vue (.vue)
+ *
+ * Label histogram: Module:1 only — no Class or Function nodes from the
+ * Vue component itself at the graph level.
+ * IMPORTS: `import` statements inside <script> blocks ARE extracted at the
+ * extraction level (test_grammar_imports confirms 2 imports for a vue
+ * fixture with 2 import statements). Whether these become IMPORTS graph
+ * edges in a two-file cross-component fixture depends on whether the
+ * JS/TS resolver handles .vue paths.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Vue: single-file component indexes without crash. */
+TEST(probe_vue_no_crash) {
+ GpeMetrics m = gpe_metrics("App.vue",
+ "<template>\n"
+ " <div>{{ message }}</div>\n"
+ "</template>\n"
+ "\n"
+ "<script setup>\n"
+ "import { ref } from 'vue'\n"
+ "const message = ref('Hello World')\n"
+ "</script>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash and must produce at least 1 node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Vue: <script setup> with two imports — extraction-level import count. */
+TEST(probe_vue_script_imports) {
+ GpeMetrics m = gpe_metrics("Counter.vue",
+ "<script setup>\n"
+ "import { ref, computed } from 'vue'\n"
+ "import BaseButton from './BaseButton.vue'\n"
+ "\n"
+ "const count = ref(0)\n"
+ "const doubled = computed(() => count.value * 2)\n"
+ "</script>\n"
+ "\n"
+ "<template>\n"
+ " <BaseButton @click=\"count++\">{{ doubled }}</BaseButton>\n"
+ "</template>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline indexes without crash. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Vue: two-file cross-component import → IMPORTS graph edge.
+ * The JS/TS resolver handles .vue imports via the same path-resolution
+ * logic used for TypeScript. With matching files on disk the resolver
+ * should produce an IMPORTS edge.
+ * RED: .vue extension may not be handled by the JS/TS import resolver. */
+TEST(probe_vue_cross_component_import) {
+ static const GpeFile files[] = {
+ {"BaseButton.vue",
+ "<template><button><slot /></button></template>\n"
+ "<script setup>\n"
+ "defineProps({ label: String })\n"
+ "</script>\n"},
+ {"App.vue",
+ "<script setup>\n"
+ "import BaseButton from './BaseButton.vue'\n"
+ "</script>\n"
+ "<template><BaseButton label=\"Click\" /></template>\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: .vue cross-component IMPORTS edge not confirmed by the pipeline. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — .vue paths not in JS resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 9 — Svelte (.svelte)
+ *
+ * Label histogram: Module:1 only.
+ * IMPORTS: <script> imports ARE extracted at the extraction level
+ * (test_grammar_imports confirms 2 imports for a svelte fixture).
+ * Cross-component IMPORTS edges share the same question as Vue.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Svelte: single-file component indexes without crash. */
+TEST(probe_svelte_no_crash) {
+ GpeMetrics m = gpe_metrics("App.svelte",
+ "<script>\n"
+ " let name = 'World';\n"
+ " function greet() { return `Hello ${name}`; }\n"
+ "</script>\n"
+ "<h1>{greet()}</h1>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash and must produce at least 1 node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Svelte: <script> with imports — extraction-level behavior. */
+TEST(probe_svelte_script_imports) {
+ GpeMetrics m = gpe_metrics("Counter.svelte",
+ "<script>\n"
+ " import { onMount } from 'svelte';\n"
+ " import Button from './Button.svelte';\n"
+ "\n"
+ " let count = 0;\n"
+ " onMount(() => { count = 1; });\n"
+ "</script>\n"
+ "<Button on:click={() => count++}>{count}</Button>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline indexes without crash. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Svelte: two-file cross-component import → IMPORTS graph edge.
+ * RED: .svelte extension may not be handled by the JS/TS import resolver. */
+TEST(probe_svelte_cross_component_import) {
+ static const GpeFile files[] = {
+ {"Button.svelte",
+ "<script>\n"
+ " export let label = 'Click';\n"
+ "</script>\n"
+ "<button>{label}</button>\n"},
+ {"App.svelte",
+ "<script>\n"
+ " import Button from './Button.svelte';\n"
+ "</script>\n"
+ "<Button label=\"Go\" />\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: .svelte cross-component IMPORTS edge not confirmed by the pipeline. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — .svelte paths not in JS resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 10 — Astro (.astro)
+ *
+ * Label histogram: Module:1 only.
+ * IMPORTS: frontmatter imports ARE extracted at the extraction level
+ * (test_grammar_imports confirms 2 imports for an astro fixture).
+ * Cross-component IMPORTS edges share the same question as Vue/Svelte.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Astro: single-file component indexes without crash. */
+TEST(probe_astro_no_crash) {
+ GpeMetrics m = gpe_metrics("index.astro",
+ "---\n"
+ "const greeting = 'Hello World';\n"
+ "---\n"
+ "<html>\n"
+ " <body><h1>{greeting}</h1></body>\n"
+ "</html>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash and must produce at least 1 node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Astro: frontmatter with imports. */
+TEST(probe_astro_frontmatter_imports) {
+ GpeMetrics m = gpe_metrics("Page.astro",
+ "---\n"
+ "import confetti from 'canvas-confetti';\n"
+ "import dayjs from 'dayjs';\n"
+ "\n"
+ "confetti();\n"
+ "const now = dayjs().format();\n"
+ "---\n"
+ "<div>{now}</div>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline indexes without crash. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Astro: two-file cross-component import → IMPORTS graph edge.
+ * RED: .astro extension may not be handled by the JS/TS import resolver. */
+TEST(probe_astro_cross_component_import) {
+ static const GpeFile files[] = {
+ {"Card.astro",
+ "---\n"
+ "const { title } = Astro.props;\n"
+ "---\n"
+ "<div class=\"card\"><h2>{title}</h2></div>\n"},
+ {"index.astro",
+ "---\n"
+ "import Card from './Card.astro';\n"
+ "---\n"
+ "<Card title=\"Hello\" />\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: .astro cross-component IMPORTS edge not confirmed by the pipeline. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — .astro paths not in JS resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 11 — Blade (.blade.php)
+ *
+ * Label histogram: Module:1 only.
+ * Blade templates use @extends / @include directives but these are not
+ * modeled as graph IMPORTS edges by the grammar-only pipeline.
+ * The .blade.php compound extension is registered via the compound
+ * extension table (language.c line 882).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Blade: basic template indexes without crash. */
+TEST(probe_blade_no_crash) {
+ GpeMetrics m = gpe_metrics("welcome.blade.php",
+ "@extends('layouts.app')\n"
+ "\n"
+ "@section('content')\n"
+ "<h1>Welcome</h1>\n"
+ "@endsection\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash and must produce at least 1 node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Blade: @include directive — not modeled as IMPORTS. */
+TEST(probe_blade_include_no_imports_edge) {
+ static const GpeFile files[] = {
+ {"partials/header.blade.php",
+ "<header><nav>Menu</nav></header>\n"},
+ {"home.blade.php",
+ "@extends('layouts.app')\n"
+ "@section('content')\n"
+ "@include('partials.header')\n"
+ "<main>Home</main>\n"
+ "@endsection\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ /* GREEN: Blade @include is not modeled as a graph IMPORTS edge. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* Blade: conditional and loop directives — pipeline stability. */
+TEST(probe_blade_directives_no_crash) {
+ GpeMetrics m = gpe_metrics("list.blade.php",
+ "@extends('layouts.app')\n"
+ "@section('content')\n"
+ "@if($items->count() > 0)\n"
+ " @foreach($items as $item)\n"
+ " <div>{{ $item->name }}</div>\n"
+ " @endforeach\n"
+ "@else\n"
+ " <p>No items found.</p>\n"
+ "@endif\n"
+ "@endsection\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: complex directives must not crash the pipeline. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 12 — Liquid (.liquid)
+ *
+ * Label histogram: Module:1 only.
+ * Liquid uses `{% render 'snippet' %}` / `{% include 'snippet' %}` but
+ * these are not modeled as graph IMPORTS edges.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Liquid: basic template indexes without crash. */
+TEST(probe_liquid_no_crash) {
+ GpeMetrics m = gpe_metrics("index.liquid",
+ "{% if customer %}\n"
+ " <p>Welcome, {{ customer.name }}!</p>\n"
+ "{% else %}\n"
+ " <p>Hello, visitor!</p>\n"
+ "{% endif %}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash and must produce at least 1 node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Liquid: for-loop + filters — pipeline stability. */
+TEST(probe_liquid_loop_and_filters) {
+ GpeMetrics m = gpe_metrics("products.liquid",
+ "{% for product in collection.products %}\n"
+ " <div class=\"product\">\n"
+ " <h2>{{ product.title | upcase }}</h2>\n"
+ " <p>{{ product.price | money }}</p>\n"
+ " </div>\n"
+ "{% endfor %}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: for-loop with filters must not crash. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Liquid: render/include — not modeled as IMPORTS. */
+TEST(probe_liquid_render_no_imports_edge) {
+ static const GpeFile files[] = {
+ {"snippets/card.liquid",
+ "<div class=\"card\">{{ card.title }}</div>\n"},
+ {"sections/featured.liquid",
+ "<section>\n"
+ " {% render 'snippets/card', card: featured_product %}\n"
+ "</section>\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ /* GREEN: Liquid `render` is not modeled as a graph IMPORTS edge. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 13 — Jinja2 (.j2 / .jinja2)
+ *
+ * Label histogram: Module:1 only.
+ * Jinja2 uses `{% extends "base.html" %}` / `{% include "header.html" %}`
+ * but these are not modeled as graph IMPORTS edges.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Jinja2: basic template indexes without crash (.j2 extension). */
+TEST(probe_jinja2_no_crash_j2) {
+ GpeMetrics m = gpe_metrics("config.j2",
+ "{% if env == 'production' %}\n"
+ "database_url: {{ db_url }}\n"
+ "{% else %}\n"
+ "database_url: sqlite:///dev.db\n"
+ "{% endif %}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash on a .j2 file. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Jinja2: extends and block directives (.jinja2 extension). */
+TEST(probe_jinja2_extends_no_imports_edge) {
+ static const GpeFile files[] = {
+ {"base.html.jinja2",
+ "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<head>{% block head %}{% endblock %}</head>\n"
+ "<body>{% block body %}{% endblock %}</body>\n"
+ "</html>\n"},
+ {"page.html.jinja2",
+ "{% extends \"base.html.jinja2\" %}\n"
+ "{% block head %}<title>Page</title>{% endblock %}\n"
+ "{% block body %}<h1>Hello</h1>{% endblock %}\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ /* GREEN: Jinja2 `extends` is not modeled as a graph IMPORTS edge. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* Jinja2: macro definition — does the extractor produce a node? */
+TEST(probe_jinja2_macro_no_crash) {
+ GpeMetrics m = gpe_metrics("macros.jinja",
+ "{% macro render_field(field, label='') %}\n"
+ " <div class=\"field\">\n"
+ " {% if label %}<label>{{ label }}</label>{% endif %}\n"
+ " {{ field }}\n"
+ " </div>\n"
+ "{% endmacro %}\n"
+ "\n"
+ "{% macro render_errors(field) %}\n"
+ " {% for error in field.errors %}\n"
+ " <span class=\"error\">{{ error }}</span>\n"
+ " {% endfor %}\n"
+ "{% endmacro %}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: macro-heavy template must not crash the pipeline. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 14 — Go Template (.gotmpl / .tmpl / .tpl)
+ *
+ * Label histogram: Module:1 only.
+ * Go templates use `{{ template "name" . }}` for includes but these are
+ * not modeled as graph IMPORTS edges.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Go Template: basic template indexes without crash (.gotmpl). */
+TEST(probe_gotemplate_no_crash_gotmpl) {
+ GpeMetrics m = gpe_metrics("page.gotmpl",
+ "{{ define \"page\" }}\n"
+ "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<body>\n"
+ " <h1>{{ .Title }}</h1>\n"
+ " {{ if .Items }}\n"
+ " <ul>\n"
+ " {{ range .Items }}<li>{{ . }}</li>{{ end }}\n"
+ " </ul>\n"
+ " {{ end }}\n"
+ "</body>\n"
+ "</html>\n"
+ "{{ end }}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash on a .gotmpl file. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Go Template: Helm-style .tpl with named template definitions. */
+TEST(probe_gotemplate_helm_tpl) {
+ GpeMetrics m = gpe_metrics("_helpers.tpl",
+ "{{/*\n"
+ "Expand the name of the chart.\n"
+ "*/}}\n"
+ "{{- define \"myapp.name\" -}}\n"
+ "{{- .Chart.Name | trunc 63 | trimSuffix \"-\" }}\n"
+ "{{- end }}\n"
+ "\n"
+ "{{- define \"myapp.labels\" -}}\n"
+ "helm.sh/chart: {{ include \"myapp.name\" . }}\n"
+ "{{- end }}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Helm helper template must not crash. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Go Template: `template` call — not modeled as IMPORTS. */
+TEST(probe_gotemplate_template_call_no_imports) {
+ static const GpeFile files[] = {
+ {"layout.tmpl",
+ "{{ define \"layout\" }}\n"
+ "<html><body>{{ template \"content\" . }}</body></html>\n"
+ "{{ end }}\n"},
+ {"page.tmpl",
+ "{{ define \"content\" }}\n"
+ "<h1>{{ .Title }}</h1>\n"
+ "{{ end }}\n"
+ "{{ template \"layout\" . }}\n"}
+ };
+ GpeMetrics m = gpe_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ /* GREEN: Go template `template` calls are not modeled as IMPORTS edges. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 15 — Mermaid (.mmd / .mermaid)
+ *
+ * Label histogram: Module:1 only.
+ * Mermaid diagrams describe graph/flow/sequence diagrams — no function or
+ * type definitions; no cross-file imports.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Mermaid: flowchart diagram indexes without crash (.mmd). */
+TEST(probe_mermaid_flowchart_no_crash) {
+ GpeMetrics m = gpe_metrics("flow.mmd",
+ "graph TD\n"
+ " A[Start] --> B{Is it?}\n"
+ " B -- Yes --> C[OK]\n"
+ " B -- No --> D[End]\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash on a .mmd file. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Mermaid: sequence diagram (.mermaid extension). */
+TEST(probe_mermaid_sequence_no_crash) {
+ GpeMetrics m = gpe_metrics("auth.mermaid",
+ "sequenceDiagram\n"
+ " participant Client\n"
+ " participant Server\n"
+ " Client->>Server: POST /login\n"
+ " Server-->>Client: 200 OK + token\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: sequence diagram must not crash. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Mermaid: entity-relationship diagram. */
+TEST(probe_mermaid_er_diagram_no_crash) {
+ GpeMetrics m = gpe_metrics("schema.mmd",
+ "erDiagram\n"
+ " USER {\n"
+ " int id PK\n"
+ " string name\n"
+ " string email\n"
+ " }\n"
+ " POST {\n"
+ " int id PK\n"
+ " int authorId FK\n"
+ " string title\n"
+ " }\n"
+ " USER ||--o{ POST : \"writes\"\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: ER diagram must not crash the pipeline. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 16 — JSDoc (.jsdoc)
+ *
+ * Label histogram: Module:1 only.
+ * JSDoc files contain documentation comment blocks — `@param`, `@returns`,
+ * `@module`, `@typedef` etc. No executable code; no cross-file imports.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* JSDoc: basic parameter documentation indexes without crash. */
+TEST(probe_jsdoc_params_no_crash) {
+ GpeMetrics m = gpe_metrics("api.jsdoc",
+ "/**\n"
+ " * @param {number} x - First operand\n"
+ " * @param {number} y - Second operand\n"
+ " * @returns {number} The sum\n"
+ " */\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pipeline must not crash on a .jsdoc file. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* JSDoc: @module and @typedef annotations. */
+TEST(probe_jsdoc_module_typedef_no_crash) {
+ GpeMetrics m = gpe_metrics("types.jsdoc",
+ "/**\n"
+ " * @module utils\n"
+ " */\n"
+ "\n"
+ "/**\n"
+ " * @typedef {Object} User\n"
+ " * @property {number} id - User identifier\n"
+ " * @property {string} name - User full name\n"
+ " * @property {string} email - User email address\n"
+ " */\n"
+ "\n"
+ "/**\n"
+ " * @callback Predicate\n"
+ " * @param {User} user\n"
+ " * @returns {boolean}\n"
+ " */\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: module + typedef annotations must not crash the pipeline. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* JSDoc: no function or type nodes expected — markup-only label set. */
+TEST(probe_jsdoc_no_function_or_type_nodes) {
+ GpeMetrics m = gpe_metrics("helpers.jsdoc",
+ "/**\n"
+ " * @function formatDate\n"
+ " * @param {Date} date\n"
+ " * @returns {string}\n"
+ " */\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: JSDoc produces only Module:1 — no Function or Class nodes. */
+ ASSERT_TRUE(m.types == 0);
+ ASSERT_TRUE(m.functions == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * SUITE wiring
+ * ══════════════════════════════════════════════════════════════════ */
+
+SUITE(grammar_probe_e) {
+ /* Protobuf (4 cases) */
+ RUN_TEST(probe_proto_message_node);
+ RUN_TEST(probe_proto_service_node);
+ RUN_TEST(probe_proto_enum_node);
+ RUN_TEST(probe_proto_import_edge);
+
+ /* Thrift (4 cases) */
+ RUN_TEST(probe_thrift_service_function);
+ RUN_TEST(probe_thrift_struct_node);
+ RUN_TEST(probe_thrift_exception_node);
+ RUN_TEST(probe_thrift_include_edge);
+
+ /* Cap'n Proto (4 cases) */
+ RUN_TEST(probe_capnp_struct_node);
+ RUN_TEST(probe_capnp_interface_node);
+ RUN_TEST(probe_capnp_enum_node);
+ RUN_TEST(probe_capnp_import_edge);
+
+ /* WIT (5 cases) */
+ RUN_TEST(probe_wit_record_enum_function);
+ RUN_TEST(probe_wit_world_node);
+ RUN_TEST(probe_wit_type_alias);
+ RUN_TEST(probe_wit_variant_node);
+ RUN_TEST(probe_wit_use_edge);
+
+ /* Smithy (4 cases) */
+ RUN_TEST(probe_smithy_structure_node);
+ RUN_TEST(probe_smithy_service_node);
+ RUN_TEST(probe_smithy_enum_node);
+ RUN_TEST(probe_smithy_use_edge);
+
+ /* Prisma (4 cases) */
+ RUN_TEST(probe_prisma_model_node);
+ RUN_TEST(probe_prisma_multiple_models);
+ RUN_TEST(probe_prisma_enum_node);
+ RUN_TEST(probe_prisma_datasource_only);
+
+ /* GraphQL (4 cases) */
+ RUN_TEST(probe_graphql_type_node);
+ RUN_TEST(probe_graphql_multiple_types);
+ RUN_TEST(probe_graphql_interface_node);
+ RUN_TEST(probe_graphql_input_type);
+
+ /* Vue (3 cases) */
+ RUN_TEST(probe_vue_no_crash);
+ RUN_TEST(probe_vue_script_imports);
+ RUN_TEST(probe_vue_cross_component_import);
+
+ /* Svelte (3 cases) */
+ RUN_TEST(probe_svelte_no_crash);
+ RUN_TEST(probe_svelte_script_imports);
+ RUN_TEST(probe_svelte_cross_component_import);
+
+ /* Astro (3 cases) */
+ RUN_TEST(probe_astro_no_crash);
+ RUN_TEST(probe_astro_frontmatter_imports);
+ RUN_TEST(probe_astro_cross_component_import);
+
+ /* Blade (3 cases) */
+ RUN_TEST(probe_blade_no_crash);
+ RUN_TEST(probe_blade_include_no_imports_edge);
+ RUN_TEST(probe_blade_directives_no_crash);
+
+ /* Liquid (3 cases) */
+ RUN_TEST(probe_liquid_no_crash);
+ RUN_TEST(probe_liquid_loop_and_filters);
+ RUN_TEST(probe_liquid_render_no_imports_edge);
+
+ /* Jinja2 (3 cases) */
+ RUN_TEST(probe_jinja2_no_crash_j2);
+ RUN_TEST(probe_jinja2_extends_no_imports_edge);
+ RUN_TEST(probe_jinja2_macro_no_crash);
+
+ /* Go Template (3 cases) */
+ RUN_TEST(probe_gotemplate_no_crash_gotmpl);
+ RUN_TEST(probe_gotemplate_helm_tpl);
+ RUN_TEST(probe_gotemplate_template_call_no_imports);
+
+ /* Mermaid (3 cases) */
+ RUN_TEST(probe_mermaid_flowchart_no_crash);
+ RUN_TEST(probe_mermaid_sequence_no_crash);
+ RUN_TEST(probe_mermaid_er_diagram_no_crash);
+
+ /* JSDoc (3 cases) */
+ RUN_TEST(probe_jsdoc_params_no_crash);
+ RUN_TEST(probe_jsdoc_module_typedef_no_crash);
+ RUN_TEST(probe_jsdoc_no_function_or_type_nodes);
+}
diff --git a/tests/test_grammar_probe_f.c b/tests/test_grammar_probe_f.c
new file mode 100644
index 000000000..ed734f052
--- /dev/null
+++ b/tests/test_grammar_probe_f.c
@@ -0,0 +1,1652 @@
+/*
+ * test_grammar_probe_f.c — IaC/build node/edge probe.
+ *
+ * SCOPE
+ * ─────
+ * Probes 19 IaC/config-as-code and build grammars:
+ * IaC/config: hcl, k8s, kustomize, nix, nickel, pkl, ron, jsonnet, kdl,
+ * hyprlang, devicetree
+ * Build: cmake, makefile, meson, gn, just, bitbake, kconfig, gomod
+ *
+ * DIMENSIONS PER GRAMMAR
+ * ──────────────────────
+ * • NODE creation — resource/target/recipe/config-entry blocks reach the graph
+ * • IMPORTS edges — include/import/`use` where the pipeline models it
+ * • INFRA_MAPS — HCL module.source → Route edge (parallel path only; probed
+ * in the single-path here as an expected RED)
+ * • DEPENDS_ON — gomod require → dependency node
+ *
+ * COLOUR LEGEND
+ * ─────────────
+ * green = guard: the pipeline already produces the result; a failure is a regression.
+ * red = bug reproduction: pipeline does NOT yet produce the expected node/edge;
+ * the test FAILS until fixed. Brief inline comment names the root cause.
+ *
+ * Not registered in test_main.c — sibling agent owns that file.
+ *
+ * SUITE(grammar_probe_f)
+ */
+
+#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 — mirrors test_grammar_probe_a.c (prefix "gpf_").
+ * ══════════════════════════════════════════════════════════════════ */
+
+typedef struct {
+ char tmpdir[256];
+ char dbpath[512];
+ char *project;
+ cbm_mcp_server_t *srv;
+} GpfProj;
+
+typedef struct {
+ const char *name;
+ const char *content;
+} GpfFile;
+
+static void gpf_to_fwd_slashes(char *p) {
+ for (; *p; p++) {
+ if (*p == '\\') *p = '/';
+ }
+}
+
+static cbm_store_t *gpf_open_indexed(GpfProj *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 *gpf_index_files(GpfProj *lp, const GpfFile *files, int nfiles) {
+ memset(lp, 0, sizeof(*lp));
+ snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_gpf_XXXXXX");
+ if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
+ gpf_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 gpf_open_indexed(lp);
+}
+
+static void gpf_cleanup(GpfProj *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);
+}
+
+/* ── Node-count helpers ──────────────────────────────────────────── */
+
+static int gpf_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;
+}
+
+/* Metrics bundled per index pass. */
+typedef struct {
+ int ok;
+ int total_nodes;
+ int functions; /* Function label */
+ int modules; /* Module label */
+ int classes; /* Class label */
+ int resources; /* Resource label (k8s) */
+ int imports; /* IMPORTS edges */
+ int depends_on; /* DEPENDS_ON edges */
+ int infra_maps; /* INFRA_MAPS edges */
+} GpfMetrics;
+
+static GpfMetrics gpf_metrics_files(const GpfFile *files, int nfiles) {
+ GpfProj lp;
+ cbm_store_t *store = gpf_index_files(&lp, files, nfiles);
+ GpfMetrics m = {0};
+ if (store) {
+ m.ok = 1;
+ m.total_nodes = cbm_store_count_nodes(store, lp.project);
+ m.functions = gpf_count_label(store, lp.project, "Function");
+ m.modules = gpf_count_label(store, lp.project, "Module");
+ m.classes = gpf_count_label(store, lp.project, "Class");
+ m.resources = gpf_count_label(store, lp.project, "Resource");
+ m.imports = cbm_store_count_edges_by_type(store, lp.project, "IMPORTS");
+ m.depends_on = cbm_store_count_edges_by_type(store, lp.project, "DEPENDS_ON");
+ m.infra_maps = cbm_store_count_edges_by_type(store, lp.project, "INFRA_MAPS");
+ }
+ gpf_cleanup(&lp, store);
+ return m;
+}
+
+static GpfMetrics gpf_metrics(const char *filename, const char *content) {
+ GpfFile f = {filename, content};
+ return gpf_metrics_files(&f, 1);
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 1 — HCL / Terraform (.hcl, .tf)
+ *
+ * Labels histogram: Class:1, Module:1
+ * The extractor models HCL as a single Module node plus a Class node for
+ * the file-level scope. Individual `resource` / `module` blocks are NOT
+ * yet extracted as separate nodes (grammar-only path).
+ * INFRA_MAPS is produced only by the parallel-path pipeline (>50 files);
+ * single-file fixture tests it as RED.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* HCL: minimal resource block → at least 1 node (Module) and 1 Class node. */
+TEST(probe_hcl_resource_nodes) {
+ GpfMetrics m = gpf_metrics("main.tf",
+ "resource \"aws_s3_bucket\" \"my_bucket\" {\n"
+ " bucket = \"my-tf-test-bucket\"\n"
+ " acl = \"private\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at minimum a Module node is created for an HCL file. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* HCL: Class node present alongside Module (label histogram: Class:1,Module:1). */
+TEST(probe_hcl_class_node) {
+ GpfMetrics m = gpf_metrics("infra.hcl",
+ "resource \"aws_instance\" \"web\" {\n"
+ " ami = \"ami-0c55b159cbfafe1f0\"\n"
+ " instance_type = \"t2.micro\"\n"
+ "}\n"
+ "\n"
+ "resource \"aws_instance\" \"db\" {\n"
+ " ami = \"ami-0c55b159cbfafe1f0\"\n"
+ " instance_type = \"t2.small\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: histogram confirms Class:1,Module:1 for any non-empty HCL file. */
+ ASSERT_TRUE(m.classes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* HCL: module block with `source` → separate resource-like node.
+ * RED: grammar-only HCL extractor produces only Class+Module (one per file);
+ * individual resource/module blocks are not broken out as distinct nodes. */
+TEST(probe_hcl_module_block_node) {
+ GpfMetrics m = gpf_metrics("modules.tf",
+ "module \"vpc\" {\n"
+ " source = \"terraform-aws-modules/vpc/aws\"\n"
+ " version = \"3.14.0\"\n"
+ " cidr = \"10.0.0.0/16\"\n"
+ "}\n"
+ "\n"
+ "module \"eks\" {\n"
+ " source = \"terraform-aws-modules/eks/aws\"\n"
+ " version = \"18.26.6\"\n"
+ " cluster_name = \"my-eks-cluster\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: individual module blocks not extracted as separate Resource/Module nodes;
+ * only the file-level Class+Module pair is produced. */
+ ASSERT_TRUE(m.total_nodes >= 3); /* expected RED — no per-block node extraction */
+ PASS();
+}
+
+/* HCL: INFRA_MAPS edge (module.source URL → Route node).
+ * RED: INFRA_MAPS is produced only by the parallel-path pipeline (>50 files);
+ * single-file fixture never crosses the threshold. */
+TEST(probe_hcl_infra_maps_edge) {
+ GpfMetrics m = gpf_metrics("sched.tf",
+ "resource \"google_cloud_scheduler_job\" \"cron\" {\n"
+ " name = \"cron-job\"\n"
+ " schedule = \"0 * * * *\"\n"
+ " http_target {\n"
+ " uri = \"https://my-service.example.com/run\"\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: INFRA_MAPS requires parallel-path (>50 files) — not triggered here. */
+ ASSERT_TRUE(m.infra_maps >= 1); /* expected RED — parallel path only */
+ PASS();
+}
+
+/* HCL: two-file fixture (.tf + .hcl) → still no cross-file IMPORTS edge
+ * because HCL/Terraform uses a directory-level evaluation model, not imports. */
+TEST(probe_hcl_no_spurious_imports) {
+ static const GpfFile files[] = {
+ {"vars.hcl",
+ "variable \"region\" {\n"
+ " default = \"us-east-1\"\n"
+ "}\n"},
+ {"main.tf",
+ "resource \"aws_s3_bucket\" \"b\" {\n"
+ " bucket = \"test\"\n"
+ "}\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* GREEN: HCL has no import syntax — pipeline should emit 0 IMPORTS edges. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 2 — Kubernetes manifests (.yaml with apiVersion:)
+ *
+ * Labels histogram: Module:1 (generic YAML pass); Resource node is emitted
+ * by pass_k8s.c (handle_k8s_manifest → cbm_extract_file CBM_LANG_K8S).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* K8s: Pod manifest → Resource node (kind=Pod, name=nginx-pod). */
+TEST(probe_k8s_pod_resource_node) {
+ GpfMetrics m = gpf_metrics("pod.yaml",
+ "apiVersion: v1\n"
+ "kind: Pod\n"
+ "metadata:\n"
+ " name: nginx-pod\n"
+ " namespace: default\n"
+ "spec:\n"
+ " containers:\n"
+ " - name: nginx\n"
+ " image: nginx:1.21\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: pass_k8s emits a Resource node for any k8s manifest with apiVersion. */
+ ASSERT_TRUE(m.resources >= 1);
+ PASS();
+}
+
+/* K8s: Deployment manifest → Resource node. */
+TEST(probe_k8s_deployment_resource_node) {
+ GpfMetrics m = gpf_metrics("deploy.yaml",
+ "apiVersion: apps/v1\n"
+ "kind: Deployment\n"
+ "metadata:\n"
+ " name: my-app\n"
+ "spec:\n"
+ " replicas: 3\n"
+ " selector:\n"
+ " matchLabels:\n"
+ " app: my-app\n"
+ " template:\n"
+ " metadata:\n"
+ " labels:\n"
+ " app: my-app\n"
+ " spec:\n"
+ " containers:\n"
+ " - name: app\n"
+ " image: my-app:latest\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Deployment kind → Resource node via pass_k8s. */
+ ASSERT_TRUE(m.resources >= 1);
+ PASS();
+}
+
+/* K8s: two manifests in one directory → 2 Resource nodes (one per file). */
+TEST(probe_k8s_two_manifests) {
+ static const GpfFile files[] = {
+ {"service.yaml",
+ "apiVersion: v1\n"
+ "kind: Service\n"
+ "metadata:\n"
+ " name: my-svc\n"
+ "spec:\n"
+ " selector:\n"
+ " app: my-app\n"
+ " ports:\n"
+ " - port: 80\n"},
+ {"configmap.yaml",
+ "apiVersion: v1\n"
+ "kind: ConfigMap\n"
+ "metadata:\n"
+ " name: app-config\n"
+ "data:\n"
+ " key: value\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* GREEN: each manifest file produces its own Resource node. */
+ ASSERT_TRUE(m.resources >= 2);
+ PASS();
+}
+
+/* K8s: cross-manifest reference via INFRA_MAPS.
+ * RED: the single-path pipeline does not emit INFRA_MAPS edges for k8s refs;
+ * pass_k8s only emits Resource nodes (no ref-resolution between manifests). */
+TEST(probe_k8s_infra_maps_edge) {
+ static const GpfFile files[] = {
+ {"deploy.yaml",
+ "apiVersion: apps/v1\n"
+ "kind: Deployment\n"
+ "metadata:\n"
+ " name: frontend\n"
+ "spec:\n"
+ " template:\n"
+ " spec:\n"
+ " containers:\n"
+ " - name: frontend\n"
+ " image: frontend:latest\n"},
+ {"service.yaml",
+ "apiVersion: v1\n"
+ "kind: Service\n"
+ "metadata:\n"
+ " name: frontend-svc\n"
+ "spec:\n"
+ " selector:\n"
+ " app: frontend\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: inter-manifest INFRA_MAPS edges not modeled by the current k8s pass. */
+ ASSERT_TRUE(m.infra_maps >= 1); /* expected RED — no k8s selector → INFRA_MAPS */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 3 — Kustomize (kustomization.yaml)
+ *
+ * Labels histogram: Module:1
+ * pass_k8s.c handle_kustomize: emits a Module node + IMPORTS edges for each
+ * resources/bases/patches entry that resolves to an existing graph node.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Kustomize: overlay file → Module node. */
+TEST(probe_kustomize_module_node) {
+ GpfMetrics m = gpf_metrics("kustomization.yaml",
+ "apiVersion: kustomize.config.k8s.io/v1beta1\n"
+ "kind: Kustomization\n"
+ "resources:\n"
+ " - deploy.yaml\n"
+ " - service.yaml\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: handle_kustomize always emits a Module node for the overlay file. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Kustomize: overlay + two resource manifests → IMPORTS edges.
+ * The resolver looks for nodes whose QN matches the resource paths.
+ * Each resolved entry produces an IMPORTS edge (Module → Resource node).
+ * RED: resources are YAML files that pass_k8s processes as k8s manifests only
+ * when apiVersion is present; without it they are plain YAML with no node
+ * in the graph, so the IMPORTS edge can't be created. */
+TEST(probe_kustomize_imports_edges) {
+ static const GpfFile files[] = {
+ {"kustomization.yaml",
+ "apiVersion: kustomize.config.k8s.io/v1beta1\n"
+ "kind: Kustomization\n"
+ "resources:\n"
+ " - deploy.yaml\n"
+ " - service.yaml\n"},
+ {"deploy.yaml",
+ "apiVersion: apps/v1\n"
+ "kind: Deployment\n"
+ "metadata:\n"
+ " name: myapp\n"
+ "spec:\n"
+ " replicas: 1\n"
+ " template:\n"
+ " spec:\n"
+ " containers:\n"
+ " - name: app\n"
+ " image: myapp:v1\n"},
+ {"service.yaml",
+ "apiVersion: v1\n"
+ "kind: Service\n"
+ "metadata:\n"
+ " name: myapp-svc\n"
+ "spec:\n"
+ " selector:\n"
+ " app: myapp\n"
+ " ports:\n"
+ " - port: 80\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 3);
+ ASSERT_TRUE(m.ok);
+ /* Kustomize Module node is always emitted. */
+ ASSERT_TRUE(m.modules >= 1);
+ /* RED: IMPORTS edge from kustomize Module → Resource nodes requires the
+ * resource file to already be in the graph as a QN-matched node;
+ * the ordering of pipeline passes may leave resource nodes absent
+ * when the kustomize pass runs, preventing edge creation. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — resource QN resolution fails */
+ PASS();
+}
+
+/* Kustomize: base overlay with patches entry → Module node (no crash). */
+TEST(probe_kustomize_with_patches) {
+ GpfMetrics m = gpf_metrics("kustomization.yaml",
+ "apiVersion: kustomize.config.k8s.io/v1beta1\n"
+ "kind: Kustomization\n"
+ "bases:\n"
+ " - ../base\n"
+ "patches:\n"
+ " - path: replica-patch.yaml\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: handle_kustomize emits Module node regardless of patches content. */
+ ASSERT_TRUE(m.modules >= 1);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 4 — Nix (.nix)
+ *
+ * Labels histogram: Module:1
+ * Nix is a purely functional language; the grammar-only extractor produces
+ * a single Module node per file. Nix `import` expressions (e.g.
+ * `import ./other.nix`) are textual — the pipeline does not yet resolve
+ * them into IMPORTS graph edges.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Nix: attribute set with derivation-like attrs → at least 1 node. */
+TEST(probe_nix_attrset_node) {
+ GpfMetrics m = gpf_metrics("default.nix",
+ "{ pkgs ? import <nixpkgs> {} }:\n"
+ "\n"
+ "pkgs.stdenv.mkDerivation {\n"
+ " pname = \"mypackage\";\n"
+ " version = \"1.0.0\";\n"
+ " src = ./src;\n"
+ " buildInputs = [ pkgs.gcc pkgs.make ];\n"
+ " buildPhase = \"make\";\n"
+ " installPhase = \"make install\";\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty Nix file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Nix: let-binding expression — multiple top-level attrs. */
+TEST(probe_nix_let_binding) {
+ GpfMetrics m = gpf_metrics("lib.nix",
+ "let\n"
+ " double = x: x * 2;\n"
+ " square = x: x * x;\n"
+ " cube = x: x * x * x;\n"
+ "in {\n"
+ " inherit double square cube;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: file-level Module node created. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Nix: `import` in two-file fixture → IMPORTS edge.
+ * RED: Nix import expressions are not resolved into IMPORTS graph edges. */
+TEST(probe_nix_import_edge) {
+ static const GpfFile files[] = {
+ {"utils.nix",
+ "{ double = x: x * 2; }\n"},
+ {"default.nix",
+ "let utils = import ./utils.nix;\n"
+ "in { result = utils.double 21; }\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Nix `import` not resolved into IMPORTS edges by the grammar-only pipeline. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Nix import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 5 — Nickel (.ncl)
+ *
+ * Labels histogram: Module:1
+ * Nickel is a configuration language; the extractor produces a single Module
+ * node per file. Import with `import "path"` is syntactically supported but
+ * not yet resolved into IMPORTS edges.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Nickel: record literal → Module node (no crash). */
+TEST(probe_nickel_record_node) {
+ GpfMetrics m = gpf_metrics("config.ncl",
+ "{\n"
+ " server = {\n"
+ " host = \"localhost\",\n"
+ " port = 8080,\n"
+ " },\n"
+ " database = {\n"
+ " name = \"mydb\",\n"
+ " max_connections = 10,\n"
+ " },\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty Nickel file produces a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Nickel: let-binding with function value. */
+TEST(probe_nickel_let_fn) {
+ GpfMetrics m = gpf_metrics("lib.ncl",
+ "let double = fun x => x * 2 in\n"
+ "let square = fun x => x * x in\n"
+ "{ double, square }\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: file-level Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Nickel: `import` in two-file fixture → IMPORTS edge.
+ * RED: Nickel import expressions not resolved by the pipeline. */
+TEST(probe_nickel_import_edge) {
+ static const GpfFile files[] = {
+ {"utils.ncl", "{ double = fun x => x * 2 }\n"},
+ {"main.ncl",
+ "let utils = import \"utils.ncl\" in\n"
+ "{ result = utils.double 21 }\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Nickel `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Nickel import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 6 — Pkl (.pkl)
+ *
+ * Labels histogram: Module:1
+ * Pkl is Apple's configuration language. `amends`/`import` for cross-file
+ * references — not yet resolved by the pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Pkl: property assignments → Module node. */
+TEST(probe_pkl_properties_node) {
+ GpfMetrics m = gpf_metrics("config.pkl",
+ "host = \"localhost\"\n"
+ "port = 8080\n"
+ "debug = false\n"
+ "maxConnections = 10\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty Pkl file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Pkl: class-like object definition. */
+TEST(probe_pkl_object_block) {
+ GpfMetrics m = gpf_metrics("server.pkl",
+ "server {\n"
+ " host = \"0.0.0.0\"\n"
+ " port = 443\n"
+ " tls {\n"
+ " enabled = true\n"
+ " cert = \"/etc/ssl/cert.pem\"\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Pkl: `import` in two-file fixture → IMPORTS edge.
+ * RED: Pkl import/amends not resolved into IMPORTS edges. */
+TEST(probe_pkl_import_edge) {
+ static const GpfFile files[] = {
+ {"base.pkl",
+ "host = \"localhost\"\n"
+ "port = 8080\n"},
+ {"prod.pkl",
+ "amends \"base.pkl\"\n"
+ "\n"
+ "port = 443\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Pkl `amends`/`import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Pkl import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 7 — RON (.ron)
+ *
+ * Labels histogram: Module:1
+ * RON (Rusty Object Notation) is a data serialization format; the extractor
+ * produces a Module node per file. No import mechanism exists in RON.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* RON: struct-like record → Module node. */
+TEST(probe_ron_record_node) {
+ GpfMetrics m = gpf_metrics("config.ron",
+ "(\n"
+ " host: \"localhost\",\n"
+ " port: 8080,\n"
+ " debug: false,\n"
+ " tags: [\"api\", \"v2\"],\n"
+ ")\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: RON file produces at least 1 node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* RON: named struct. */
+TEST(probe_ron_named_struct) {
+ GpfMetrics m = gpf_metrics("scene.ron",
+ "Scene(\n"
+ " entities: [\n"
+ " Entity(id: 1, name: \"player\"),\n"
+ " Entity(id: 2, name: \"enemy\"),\n"
+ " ],\n"
+ ")\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node for the RON file. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* RON: no import mechanism → 0 IMPORTS edges expected. */
+TEST(probe_ron_no_imports) {
+ GpfMetrics m = gpf_metrics("data.ron",
+ "[\n"
+ " (key: \"a\", value: 1),\n"
+ " (key: \"b\", value: 2),\n"
+ "]\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: RON has no import syntax; pipeline emits 0 IMPORTS edges. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 8 — Jsonnet (.jsonnet, .libsonnet)
+ *
+ * Labels histogram: Module:1
+ * Jsonnet is a data templating language. `import`/`importstr` for cross-file
+ * references — not yet resolved by the pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Jsonnet: object literal → Module node. */
+TEST(probe_jsonnet_object_node) {
+ GpfMetrics m = gpf_metrics("config.jsonnet",
+ "{\n"
+ " local env = \"prod\",\n"
+ " host: \"api.example.com\",\n"
+ " port: 443,\n"
+ " debug: env == \"dev\",\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty Jsonnet file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Jsonnet: function definition in object. */
+TEST(probe_jsonnet_function_in_object) {
+ GpfMetrics m = gpf_metrics("lib.jsonnet",
+ "{\n"
+ " double(x):: x * 2,\n"
+ " square(x):: x * x,\n"
+ " greet(name):: \"Hello, \" + name,\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Jsonnet: `import` in two-file fixture → IMPORTS edge.
+ * RED: Jsonnet import not resolved into IMPORTS edges. */
+TEST(probe_jsonnet_import_edge) {
+ static const GpfFile files[] = {
+ {"utils.libsonnet",
+ "{\n"
+ " double(x):: x * 2,\n"
+ "}\n"},
+ {"main.jsonnet",
+ "local utils = import 'utils.libsonnet';\n"
+ "{\n"
+ " result: utils.double(21),\n"
+ "}\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Jsonnet `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Jsonnet import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 9 — KDL (.kdl)
+ *
+ * Labels histogram: Module:1
+ * KDL is a document language. No import mechanism; single Module per file.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* KDL: node with children → Module node. */
+TEST(probe_kdl_node_block) {
+ GpfMetrics m = gpf_metrics("config.kdl",
+ "server {\n"
+ " host \"localhost\"\n"
+ " port 8080\n"
+ "}\n"
+ "\n"
+ "database {\n"
+ " host \"db.internal\"\n"
+ " port 5432\n"
+ " name \"mydb\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: KDL file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* KDL: flat node list (key-value style). */
+TEST(probe_kdl_flat_nodes) {
+ GpfMetrics m = gpf_metrics("manifest.kdl",
+ "package \"my-package\" version=\"1.0.0\"\n"
+ "description \"A test package\"\n"
+ "author \"Test Author\" email=\"[email protected]\"\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* KDL: no import mechanism → 0 IMPORTS edges. */
+TEST(probe_kdl_no_imports) {
+ GpfMetrics m = gpf_metrics("data.kdl",
+ "items {\n"
+ " item id=1 name=\"alpha\"\n"
+ " item id=2 name=\"beta\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: KDL has no import syntax; 0 IMPORTS edges expected. */
+ ASSERT_TRUE(m.imports == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 10 — Hyprlang (.conf, .hl, hyprland.conf)
+ *
+ * Labels histogram: Module:1
+ * Hyprlang is the Hyprland compositor config language. `source` directive
+ * for including other files — not resolved by the pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Hyprlang: section block → Module node. */
+TEST(probe_hyprlang_section_node) {
+ GpfMetrics m = gpf_metrics("hyprland.conf",
+ "general {\n"
+ " gaps_in = 5\n"
+ " gaps_out = 10\n"
+ " border_size = 2\n"
+ " col.active_border = rgba(33ccffee)\n"
+ "}\n"
+ "\n"
+ "decoration {\n"
+ " rounding = 10\n"
+ " blur {\n"
+ " enabled = true\n"
+ " size = 3\n"
+ " }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty Hyprlang file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Hyprlang: keybind and monitor directives. */
+TEST(probe_hyprlang_directives) {
+ GpfMetrics m = gpf_metrics("binds.hl",
+ "bind = $mainMod, Q, killactive\n"
+ "bind = $mainMod, M, exit\n"
+ "bind = $mainMod, F, fullscreen\n"
+ "monitor = DP-1, 1920x1080@144, 0x0, 1\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node for any non-empty .hl file. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Hyprlang: `source` in two-file fixture → IMPORTS edge.
+ * RED: Hyprlang `source` directive not resolved into IMPORTS edges. */
+TEST(probe_hyprlang_source_import_edge) {
+ static const GpfFile files[] = {
+ {"colors.conf",
+ "col.active_border = rgba(33ccffee)\n"
+ "col.inactive_border = rgba(595959aa)\n"},
+ {"hyprland.conf",
+ "source = ~/.config/hypr/colors.conf\n"
+ "\n"
+ "general {\n"
+ " gaps_in = 5\n"
+ "}\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Hyprlang `source` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Hyprlang source resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 11 — DeviceTree (.dts, .dtsi, .overlay)
+ *
+ * Labels histogram: Module:1
+ * DeviceTree Source describes hardware topology; node blocks like `/ { ... }`
+ * or named nodes like `cpu@0 { ... }`. `#include` is preprocessor-level;
+ * not modeled as IMPORTS in the pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* DeviceTree: minimal DTS with root node → Module node. */
+TEST(probe_devicetree_root_node) {
+ GpfMetrics m = gpf_metrics("board.dts",
+ "/dts-v1/;\n"
+ "\n"
+ "/ {\n"
+ " compatible = \"vendor,board\";\n"
+ " model = \"Vendor Board v1\";\n"
+ " #address-cells = <1>;\n"
+ " #size-cells = <1>;\n"
+ "};\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty DTS file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* DeviceTree: named child nodes (cpu, memory). */
+TEST(probe_devicetree_child_nodes) {
+ GpfMetrics m = gpf_metrics("soc.dts",
+ "/dts-v1/;\n"
+ "\n"
+ "/ {\n"
+ " cpus {\n"
+ " #address-cells = <1>;\n"
+ " #size-cells = <0>;\n"
+ " cpu@0 {\n"
+ " compatible = \"arm,cortex-a53\";\n"
+ " reg = <0>;\n"
+ " };\n"
+ " cpu@1 {\n"
+ " compatible = \"arm,cortex-a53\";\n"
+ " reg = <1>;\n"
+ " };\n"
+ " };\n"
+ " memory@80000000 {\n"
+ " reg = <0x80000000 0x40000000>;\n"
+ " };\n"
+ "};\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node (child nodes not individually extracted in grammar-only path). */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* DeviceTree: .dtsi include fragment → IMPORTS edge.
+ * RED: DeviceTree `#include` is handled at preprocessor level, not by the pipeline
+ * as an IMPORTS graph edge. */
+TEST(probe_devicetree_include_edge) {
+ static const GpfFile files[] = {
+ {"soc.dtsi",
+ "/dts-v1/;\n"
+ "/ {\n"
+ " soc: soc {\n"
+ " compatible = \"simple-bus\";\n"
+ " };\n"
+ "};\n"},
+ {"board.dts",
+ "/dts-v1/;\n"
+ "#include \"soc.dtsi\"\n"
+ "\n"
+ "/ {\n"
+ " model = \"My Board\";\n"
+ "};\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: DTS `#include` not resolved into IMPORTS edges (preprocessor-level). */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no DTS include resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 12 — CMake (CMakeLists.txt, .cmake)
+ *
+ * Labels histogram: Function:1, Module:1
+ * CMake's grammar extractor produces a Function node per defined function/macro
+ * plus a Module for the file. `include()` and `add_subdirectory()` are
+ * candidates for IMPORTS edges but not yet resolved.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* CMake: function definition → Function node. */
+TEST(probe_cmake_function_node) {
+ GpfMetrics m = gpf_metrics("CMakeLists.txt",
+ "cmake_minimum_required(VERSION 3.16)\n"
+ "project(MyProject)\n"
+ "\n"
+ "function(add_test_target name)\n"
+ " add_executable(${name} ${name}.cpp)\n"
+ " target_link_libraries(${name} PRIVATE gtest)\n"
+ "endfunction()\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: CMake function() definition must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* CMake: macro definition → Function node (macros map to Function label). */
+TEST(probe_cmake_macro_node) {
+ GpfMetrics m = gpf_metrics("helpers.cmake",
+ "macro(print_var varname)\n"
+ " message(STATUS \"${varname} = ${${varname}}\")\n"
+ "endmacro()\n"
+ "\n"
+ "function(setup_target name)\n"
+ " add_library(${name} STATIC)\n"
+ "endfunction()\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: both function() and macro() produce Function nodes. */
+ ASSERT_TRUE(m.functions >= 1);
+ PASS();
+}
+
+/* CMake: `include()` in two-file fixture → IMPORTS edge.
+ * RED: CMake include() not resolved into IMPORTS edges. */
+TEST(probe_cmake_include_edge) {
+ static const GpfFile files[] = {
+ {"helpers.cmake",
+ "function(check_compiler)\n"
+ " message(STATUS \"Compiler: ${CMAKE_CXX_COMPILER_ID}\")\n"
+ "endfunction()\n"},
+ {"CMakeLists.txt",
+ "cmake_minimum_required(VERSION 3.16)\n"
+ "project(Foo)\n"
+ "include(helpers.cmake)\n"
+ "check_compiler()\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: CMake `include()` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no CMake include resolver */
+ PASS();
+}
+
+/* CMake: add_subdirectory → child CMakeLists.txt; IMPORTS edge expected.
+ * RED: add_subdirectory not resolved into IMPORTS edges. */
+TEST(probe_cmake_subdirectory_edge) {
+ static const GpfFile files[] = {
+ {"CMakeLists.txt",
+ "cmake_minimum_required(VERSION 3.16)\n"
+ "project(Root)\n"
+ "add_subdirectory(lib)\n"},
+ {"lib/CMakeLists.txt",
+ "add_library(mylib STATIC mylib.cpp)\n"
+ "\n"
+ "function(mylib_configure target)\n"
+ " target_link_libraries(${target} PRIVATE mylib)\n"
+ "endfunction()\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: CMake add_subdirectory() not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no add_subdirectory resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 13 — Makefile (Makefile, .mk, GNUmakefile)
+ *
+ * Labels histogram: Function:1, Module:1
+ * The Makefile extractor produces a Function node for targets and a Module for
+ * the file. `include` directive is a candidate for IMPORTS but not resolved.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Makefile: phony targets → Function nodes. */
+TEST(probe_makefile_target_nodes) {
+ GpfMetrics m = gpf_metrics("Makefile",
+ ".PHONY: all build test clean\n"
+ "\n"
+ "all: build\n"
+ "\n"
+ "build:\n"
+ "\tgcc -o myapp main.c utils.c\n"
+ "\n"
+ "test:\n"
+ "\t./run_tests.sh\n"
+ "\n"
+ "clean:\n"
+ "\trm -f myapp *.o\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least the first target must produce a Function node. */
+ ASSERT_TRUE(m.functions >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Makefile: pattern rules and variables. */
+TEST(probe_makefile_pattern_rule) {
+ GpfMetrics m = gpf_metrics("rules.mk",
+ "CC = gcc\n"
+ "CFLAGS = -Wall -Wextra -O2\n"
+ "\n"
+ "%.o: %.c\n"
+ "\t$(CC) $(CFLAGS) -c $< -o $@\n"
+ "\n"
+ "install:\n"
+ "\tcp myapp /usr/local/bin/\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node for any non-empty Makefile. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* Makefile: `include` in two-file fixture → IMPORTS edge.
+ * RED: Makefile `include` directive not resolved into IMPORTS edges. */
+TEST(probe_makefile_include_edge) {
+ static const GpfFile files[] = {
+ {"common.mk",
+ "CC = gcc\n"
+ "CFLAGS = -Wall -O2\n"
+ "\n"
+ "clean:\n"
+ "\trm -f *.o\n"},
+ {"Makefile",
+ "include common.mk\n"
+ "\n"
+ "all:\n"
+ "\t$(CC) $(CFLAGS) -o myapp main.c\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Makefile `include` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Makefile include resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 14 — Meson (meson.build, meson.options)
+ *
+ * Labels histogram: Module:1
+ * Meson's grammar-only extractor produces a Module node per file. Individual
+ * build targets (executable(), library()) are not extracted as distinct nodes.
+ * `subdir()` maps to IMPORTS conceptually but is not resolved.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Meson: project + executable → Module node. */
+TEST(probe_meson_project_node) {
+ GpfMetrics m = gpf_metrics("meson.build",
+ "project('myapp', 'c',\n"
+ " version: '1.0.0',\n"
+ " default_options: ['warning_level=2'])\n"
+ "\n"
+ "executable('myapp',\n"
+ " sources: ['main.c', 'utils.c'],\n"
+ " install: true)\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty meson.build produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Meson: options file → Module node. */
+TEST(probe_meson_options_node) {
+ GpfMetrics m = gpf_metrics("meson.options",
+ "option('enable_tests', type: 'boolean', value: true,\n"
+ " description: 'Build and run tests')\n"
+ "option('build_type', type: 'combo', choices: ['debug', 'release'],\n"
+ " value: 'release')\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: meson.options also produces a Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Meson: subdir() across two files → IMPORTS edge.
+ * RED: Meson subdir() not resolved into IMPORTS edges. */
+TEST(probe_meson_subdir_edge) {
+ static const GpfFile files[] = {
+ {"meson.build",
+ "project('root', 'c')\n"
+ "subdir('lib')\n"},
+ {"lib/meson.build",
+ "static_library('mylib', 'mylib.c')\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Meson subdir() not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Meson subdir resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 15 — GN (.gn, .gni)
+ *
+ * Labels histogram: Module:1
+ * GN (Generate Ninja) build system for Chromium-like projects. The extractor
+ * produces a Module node per file. `import()` for shared .gni files is a
+ * candidate for IMPORTS but not yet resolved.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* GN: executable target → Module node (individual targets not extracted). */
+TEST(probe_gn_executable_node) {
+ GpfMetrics m = gpf_metrics("BUILD.gn",
+ "executable(\"myapp\") {\n"
+ " sources = [\n"
+ " \"main.cc\",\n"
+ " \"utils.cc\",\n"
+ " ]\n"
+ " deps = [ \"//third_party/base\" ]\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty .gn file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* GN: shared_library and static_library targets. */
+TEST(probe_gn_library_targets) {
+ GpfMetrics m = gpf_metrics("lib.gn",
+ "static_library(\"crypto\") {\n"
+ " sources = [ \"crypto.cc\", \"sha256.cc\" ]\n"
+ "}\n"
+ "\n"
+ "shared_library(\"net\") {\n"
+ " sources = [ \"net.cc\", \"socket.cc\" ]\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* GN: import() of a .gni file → IMPORTS edge.
+ * RED: GN import() not resolved into IMPORTS edges. */
+TEST(probe_gn_import_edge) {
+ static const GpfFile files[] = {
+ {"//build/common.gni",
+ "template(\"cc_binary\") {\n"
+ " executable(target_name) {\n"
+ " forward_variables_from(invoker, \"*\")\n"
+ " }\n"
+ "}\n"},
+ {"BUILD.gn",
+ "import(\"//build/common.gni\")\n"
+ "\n"
+ "cc_binary(\"myapp\") {\n"
+ " sources = [ \"main.cc\" ]\n"
+ "}\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: GN import() not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no GN import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 16 — Just (justfile, Justfile, .justfile)
+ *
+ * Labels histogram: Module:1
+ * Just is a command runner. Recipes are the build units; the grammar-only
+ * extractor currently produces only a Module node per file (recipes not
+ * individually extracted as Function nodes per the histogram).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Just: recipe definitions → at least Module node. */
+TEST(probe_just_recipe_nodes) {
+ GpfMetrics m = gpf_metrics("justfile",
+ "build:\n"
+ " cargo build --release\n"
+ "\n"
+ "test:\n"
+ " cargo test\n"
+ "\n"
+ "clean:\n"
+ " cargo clean\n"
+ "\n"
+ "fmt:\n"
+ " cargo fmt\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty justfile produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Just: recipe nodes as Function nodes.
+ * RED: histogram shows Module:1 only — individual recipes are not extracted
+ * as Function nodes by the grammar-only Just extractor. */
+TEST(probe_just_recipe_function_nodes) {
+ GpfMetrics m = gpf_metrics("Justfile",
+ "deploy env:\n"
+ " ./scripts/deploy.sh {{env}}\n"
+ "\n"
+ "lint:\n"
+ " golangci-lint run ./...\n"
+ "\n"
+ "generate:\n"
+ " go generate ./...\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: Just recipes not extracted as Function nodes (only Module:1 in histogram). */
+ ASSERT_TRUE(m.functions >= 1); /* expected RED — no Just recipe → Function extraction */
+ PASS();
+}
+
+/* Just: `import` directive (Just >=1.5) → IMPORTS edge.
+ * RED: Just `import` not resolved into IMPORTS edges. */
+TEST(probe_just_import_edge) {
+ static const GpfFile files[] = {
+ {"common.just",
+ "fmt:\n"
+ " cargo fmt\n"
+ "\n"
+ "lint:\n"
+ " cargo clippy\n"},
+ {"justfile",
+ "import 'common.just'\n"
+ "\n"
+ "build:\n"
+ " cargo build\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Just `import` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Just import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 17 — BitBake (.bb, .bbappend, .bbclass)
+ *
+ * Labels histogram: Module:1
+ * BitBake is the build system used by Yocto/OpenEmbedded. Recipes define
+ * tasks (do_compile, do_install, etc.) and variables. The extractor produces
+ * a Module node per file; individual tasks not extracted as Function nodes.
+ * `inherit` and `require`/`include` are cross-file mechanisms.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* BitBake: recipe with task and variable → Module node. */
+TEST(probe_bitbake_recipe_node) {
+ GpfMetrics m = gpf_metrics("mypackage_1.0.bb",
+ "DESCRIPTION = \"A simple test package\"\n"
+ "HOMEPAGE = \"https://example.com\"\n"
+ "LICENSE = \"MIT\"\n"
+ "LIC_FILES_CHKSUM = \"file://COPYING;md5=abc123\"\n"
+ "\n"
+ "SRC_URI = \"https://example.com/mypackage-1.0.tar.gz\"\n"
+ "\n"
+ "do_compile() {\n"
+ " make\n"
+ "}\n"
+ "\n"
+ "do_install() {\n"
+ " install -d ${D}${bindir}\n"
+ " install -m 0755 myapp ${D}${bindir}/\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: any non-empty .bb file produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* BitBake: bbclass file → Module node. */
+TEST(probe_bitbake_bbclass_node) {
+ GpfMetrics m = gpf_metrics("cmake.bbclass",
+ "# CMake class for BitBake\n"
+ "EXTRA_OECMAKE ?= \"\"\n"
+ "\n"
+ "cmake_do_configure() {\n"
+ " cmake -DCMAKE_INSTALL_PREFIX=${prefix} ${EXTRA_OECMAKE} ${S}\n"
+ "}\n"
+ "\n"
+ "cmake_do_compile() {\n"
+ " make ${EXTRA_OEMAKE}\n"
+ "}\n"
+ "\n"
+ "EXPORT_FUNCTIONS do_configure do_compile\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: .bbclass produces a Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* BitBake: `require` in two-file fixture → IMPORTS edge.
+ * RED: BitBake require/include not resolved into IMPORTS edges. */
+TEST(probe_bitbake_require_edge) {
+ static const GpfFile files[] = {
+ {"mypackage.inc",
+ "DESCRIPTION = \"Shared package metadata\"\n"
+ "LICENSE = \"MIT\"\n"
+ "SRC_URI = \"https://example.com/pkg-${PV}.tar.gz\"\n"},
+ {"mypackage_1.0.bb",
+ "require mypackage.inc\n"
+ "\n"
+ "PV = \"1.0\"\n"
+ "\n"
+ "do_compile() {\n"
+ " make\n"
+ "}\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: BitBake `require` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no BitBake require resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 18 — Kconfig (Kconfig)
+ *
+ * Labels histogram: Class:1, Module:1
+ * Kconfig describes Linux kernel configuration options. The extractor
+ * produces a Module + a Class node (one per Kconfig file, matching histogram).
+ * `source` directive includes other Kconfig files — not resolved as IMPORTS.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Kconfig: config entries → Module and Class nodes. */
+TEST(probe_kconfig_config_entries) {
+ GpfMetrics m = gpf_metrics("Kconfig",
+ "config MYDRV\n"
+ " tristate \"My Driver\"\n"
+ " depends on PCI\n"
+ " help\n"
+ " Enable this driver for My Device.\n"
+ "\n"
+ "config MYDRV_DEBUG\n"
+ " bool \"Enable debug output\"\n"
+ " depends on MYDRV\n"
+ " default n\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: histogram confirms Class:1,Module:1 for any Kconfig file. */
+ ASSERT_TRUE(m.modules >= 1);
+ ASSERT_TRUE(m.classes >= 1);
+ PASS();
+}
+
+/* Kconfig: menu block with multiple entries. */
+TEST(probe_kconfig_menu_block) {
+ GpfMetrics m = gpf_metrics("Kconfig",
+ "menu \"Network Support\"\n"
+ "\n"
+ "config NET\n"
+ " bool \"Networking support\"\n"
+ "\n"
+ "config INET\n"
+ " bool \"TCP/IP networking\"\n"
+ " depends on NET\n"
+ "\n"
+ "endmenu\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Module + Class nodes for the file. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Kconfig: `source` in two-file fixture → IMPORTS edge.
+ * RED: Kconfig `source` directive not resolved into IMPORTS edges. */
+TEST(probe_kconfig_source_edge) {
+ static const GpfFile files[] = {
+ {"drivers/Kconfig",
+ "config DRV_USB\n"
+ " tristate \"USB Driver\"\n"
+ " depends on USB\n"},
+ {"Kconfig",
+ "mainmenu \"Linux Kernel Configuration\"\n"
+ "\n"
+ "source \"drivers/Kconfig\"\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: Kconfig `source` not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no Kconfig source resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 19 — Go Mod (go.mod)
+ *
+ * Labels histogram: Module:1
+ * go.mod is parsed by pass_pkgmap.c which extracts the module path as a
+ * pkgmap entry used for import resolution, not for producing a DEPENDS_ON
+ * edge per `require` directive. A Module node is created per file.
+ * DEPENDS_ON edges are produced for Helm chart dependencies (pass_k8s.c),
+ * not for go.mod `require` blocks in the grammar-only pipeline.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Go mod: module directive → Module node. */
+TEST(probe_gomod_module_node) {
+ GpfMetrics m = gpf_metrics("go.mod",
+ "module example.com/myapp\n"
+ "\n"
+ "go 1.21\n"
+ "\n"
+ "require (\n"
+ " github.com/gin-gonic/gin v1.9.1\n"
+ " github.com/stretchr/testify v1.8.4\n"
+ ")\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: go.mod produces at least a Module node. */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Go mod: simple module with go directive only. */
+TEST(probe_gomod_simple) {
+ GpfMetrics m = gpf_metrics("go.mod",
+ "module example.com/simple\n"
+ "\n"
+ "go 1.21\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: even a minimal go.mod with no requires produces a Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Go mod: `require` blocks → DEPENDS_ON edges per dependency.
+ * RED: go.mod `require` directives are not resolved into DEPENDS_ON edges;
+ * pass_pkgmap only uses go.mod for intra-repo module path mapping. */
+TEST(probe_gomod_depends_on_edges) {
+ GpfMetrics m = gpf_metrics("go.mod",
+ "module example.com/server\n"
+ "\n"
+ "go 1.21\n"
+ "\n"
+ "require (\n"
+ " github.com/gorilla/mux v1.8.1\n"
+ " github.com/sirupsen/logrus v1.9.3\n"
+ " github.com/prometheus/client_golang v1.17.0\n"
+ ")\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: go.mod require → DEPENDS_ON not implemented (pkgmap handles path mapping only). */
+ ASSERT_TRUE(m.depends_on >= 1); /* expected RED — no go.mod DEPENDS_ON producer */
+ PASS();
+}
+
+/* Go mod: go.mod used in a multi-file project to enable cross-package IMPORTS.
+ * GREEN: the presence of go.mod enables the pkgmap resolver to link
+ * cross-package imports in Go source files. */
+TEST(probe_gomod_enables_go_imports) {
+ static const GpfFile files[] = {
+ {"go.mod",
+ "module example.com/demo\n"
+ "\n"
+ "go 1.21\n"},
+ {"pkg/calc/calc.go",
+ "package calc\n"
+ "\n"
+ "func Add(a, b int) int { return a + b }\n"},
+ {"main.go",
+ "package main\n"
+ "\n"
+ "import \"example.com/demo/pkg/calc\"\n"
+ "\n"
+ "func main() { _ = calc.Add(1, 2) }\n"}
+ };
+ GpfMetrics m = gpf_metrics_files(files, 3);
+ ASSERT_TRUE(m.ok);
+ /* GREEN: go.mod enables the pkgmap resolver; main.go → calc IMPORTS edge. */
+ ASSERT_TRUE(m.imports >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * SUITE wiring
+ * ══════════════════════════════════════════════════════════════════ */
+
+SUITE(grammar_probe_f) {
+ /* HCL / Terraform */
+ RUN_TEST(probe_hcl_resource_nodes);
+ RUN_TEST(probe_hcl_class_node);
+ RUN_TEST(probe_hcl_module_block_node);
+ RUN_TEST(probe_hcl_infra_maps_edge);
+ RUN_TEST(probe_hcl_no_spurious_imports);
+
+ /* Kubernetes manifests */
+ RUN_TEST(probe_k8s_pod_resource_node);
+ RUN_TEST(probe_k8s_deployment_resource_node);
+ RUN_TEST(probe_k8s_two_manifests);
+ RUN_TEST(probe_k8s_infra_maps_edge);
+
+ /* Kustomize */
+ RUN_TEST(probe_kustomize_module_node);
+ RUN_TEST(probe_kustomize_imports_edges);
+ RUN_TEST(probe_kustomize_with_patches);
+
+ /* Nix */
+ RUN_TEST(probe_nix_attrset_node);
+ RUN_TEST(probe_nix_let_binding);
+ RUN_TEST(probe_nix_import_edge);
+
+ /* Nickel */
+ RUN_TEST(probe_nickel_record_node);
+ RUN_TEST(probe_nickel_let_fn);
+ RUN_TEST(probe_nickel_import_edge);
+
+ /* Pkl */
+ RUN_TEST(probe_pkl_properties_node);
+ RUN_TEST(probe_pkl_object_block);
+ RUN_TEST(probe_pkl_import_edge);
+
+ /* RON */
+ RUN_TEST(probe_ron_record_node);
+ RUN_TEST(probe_ron_named_struct);
+ RUN_TEST(probe_ron_no_imports);
+
+ /* Jsonnet */
+ RUN_TEST(probe_jsonnet_object_node);
+ RUN_TEST(probe_jsonnet_function_in_object);
+ RUN_TEST(probe_jsonnet_import_edge);
+
+ /* KDL */
+ RUN_TEST(probe_kdl_node_block);
+ RUN_TEST(probe_kdl_flat_nodes);
+ RUN_TEST(probe_kdl_no_imports);
+
+ /* Hyprlang */
+ RUN_TEST(probe_hyprlang_section_node);
+ RUN_TEST(probe_hyprlang_directives);
+ RUN_TEST(probe_hyprlang_source_import_edge);
+
+ /* DeviceTree */
+ RUN_TEST(probe_devicetree_root_node);
+ RUN_TEST(probe_devicetree_child_nodes);
+ RUN_TEST(probe_devicetree_include_edge);
+
+ /* CMake */
+ RUN_TEST(probe_cmake_function_node);
+ RUN_TEST(probe_cmake_macro_node);
+ RUN_TEST(probe_cmake_include_edge);
+ RUN_TEST(probe_cmake_subdirectory_edge);
+
+ /* Makefile */
+ RUN_TEST(probe_makefile_target_nodes);
+ RUN_TEST(probe_makefile_pattern_rule);
+ RUN_TEST(probe_makefile_include_edge);
+
+ /* Meson */
+ RUN_TEST(probe_meson_project_node);
+ RUN_TEST(probe_meson_options_node);
+ RUN_TEST(probe_meson_subdir_edge);
+
+ /* GN */
+ RUN_TEST(probe_gn_executable_node);
+ RUN_TEST(probe_gn_library_targets);
+ RUN_TEST(probe_gn_import_edge);
+
+ /* Just */
+ RUN_TEST(probe_just_recipe_nodes);
+ RUN_TEST(probe_just_recipe_function_nodes);
+ RUN_TEST(probe_just_import_edge);
+
+ /* BitBake */
+ RUN_TEST(probe_bitbake_recipe_node);
+ RUN_TEST(probe_bitbake_bbclass_node);
+ RUN_TEST(probe_bitbake_require_edge);
+
+ /* Kconfig */
+ RUN_TEST(probe_kconfig_config_entries);
+ RUN_TEST(probe_kconfig_menu_block);
+ RUN_TEST(probe_kconfig_source_edge);
+
+ /* Go Mod */
+ RUN_TEST(probe_gomod_module_node);
+ RUN_TEST(probe_gomod_simple);
+ RUN_TEST(probe_gomod_depends_on_edges);
+ RUN_TEST(probe_gomod_enables_go_imports);
+}
diff --git a/tests/test_grammar_probe_g.c b/tests/test_grammar_probe_g.c
new file mode 100644
index 000000000..60c20e66f
--- /dev/null
+++ b/tests/test_grammar_probe_g.c
@@ -0,0 +1,1173 @@
+/*
+ * test_grammar_probe_g.c — Markup / data / config grammar node-creation + edge probe.
+ *
+ * SCOPE
+ * ─────
+ * Probes 27 grammars that have little or no code surface:
+ * html, xml, css, scss, markdown, rst, json, json5, yaml, toml, ini,
+ * csv, sql, soql, sosl, dotenv, gitignore, gitattributes, properties,
+ * requirements, diff, po, regex, sshconfig, bibtex, form, linkerscript
+ *
+ * STRUCTURAL-NODE-BEARING (produce nodes beyond Module):
+ * xml — Class:2 per fixture (element nodes)
+ * toml — Class:1 + Variable:1 (table + key)
+ * ini — Class:1 + Variable:1 (section + key)
+ * json — Variable:2 (top-level keys)
+ * yaml — Variable:2 (top-level keys)
+ * scss — Variable:1 (one def extracted)
+ * sql — Variable:1 (table reference node)
+ * markdown — Section:1 (heading node)
+ * form — Variable:1 (one variable def)
+ *
+ * PURE-DATA Module-only (only a Module node is created):
+ * html, css, rst, json5, soql, sosl, dotenv, gitignore, gitattributes,
+ * properties, requirements, diff, po, regex, sshconfig, bibtex, linkerscript, csv
+ *
+ * COLOUR LEGEND
+ * ─────────────
+ * GREEN = guard: pipeline already produces the result; failure = regression.
+ * RED = bug reproduction: pipeline does NOT yet produce the expected
+ * node/edge; the test FAILS until the bug is fixed. Brief inline
+ * comment documents the root-cause class.
+ *
+ * CALLS/inheritance dimensions are not applicable to these data/markup grammars.
+ * Do NOT register this suite in test_main.c — a sibling agent owns that file.
+ *
+ * SUITE(grammar_probe_g)
+ */
+
+#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 — mirrors test_grammar_probe_a.c exactly.
+ * Prefix "gpg_" to avoid symbol collisions with sibling probe files.
+ * ══════════════════════════════════════════════════════════════════ */
+
+typedef struct {
+ char tmpdir[256];
+ char dbpath[512];
+ char *project;
+ cbm_mcp_server_t *srv;
+} GpgProj;
+
+typedef struct {
+ const char *name; /* relative filename, may include '/' for subdirs */
+ const char *content;
+} GpgFile;
+
+static void gpg_to_fwd_slashes(char *p) {
+ for (; *p; p++) {
+ if (*p == '\\') *p = '/';
+ }
+}
+
+static cbm_store_t *gpg_open_indexed(GpgProj *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 *gpg_index_files(GpgProj *lp, const GpgFile *files, int nfiles) {
+ memset(lp, 0, sizeof(*lp));
+ snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_gpg_XXXXXX");
+ if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
+ gpg_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 gpg_open_indexed(lp);
+}
+
+static void gpg_cleanup(GpgProj *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);
+}
+
+/* ── Node-count helpers ─────────────────────────────────────────── */
+
+static int gpg_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;
+}
+
+typedef struct {
+ int ok;
+ int total_nodes;
+ int modules;
+ int classes;
+ int variables;
+ int sections;
+ int imports; /* IMPORTS edges */
+ int depends; /* DEPENDS_ON edges */
+} GpgMetrics;
+
+static GpgMetrics gpg_metrics_files(const GpgFile *files, int nfiles) {
+ GpgProj lp;
+ cbm_store_t *store = gpg_index_files(&lp, files, nfiles);
+ GpgMetrics m = {0};
+ if (store) {
+ m.ok = 1;
+ m.total_nodes = cbm_store_count_nodes(store, lp.project);
+ m.modules = gpg_count_label(store, lp.project, "Module");
+ m.classes = gpg_count_label(store, lp.project, "Class");
+ m.variables = gpg_count_label(store, lp.project, "Variable");
+ m.sections = gpg_count_label(store, lp.project, "Section");
+ m.imports = cbm_store_count_edges_by_type(store, lp.project, "IMPORTS");
+ m.depends = cbm_store_count_edges_by_type(store, lp.project, "DEPENDS_ON");
+ }
+ gpg_cleanup(&lp, store);
+ return m;
+}
+
+static GpgMetrics gpg_metrics(const char *filename, const char *content) {
+ GpgFile f = {filename, content};
+ return gpg_metrics_files(&f, 1);
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 1 — HTML (.html)
+ *
+ * HTML golden histogram: Module:1 (pure-data — no element nodes extracted).
+ * <script src="..."> and <link href="..."> are the only edges the pipeline
+ * could model, but no HTML IMPORTS resolver exists in the pipeline today.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* HTML: minimal page → at least 1 Module node, no crash. */
+TEST(probe_html_minimal_page) {
+ GpgMetrics m = gpg_metrics("index.html",
+ "<!DOCTYPE html>\n"
+ "<html><head><title>Test</title></head>\n"
+ "<body><h1>Hello</h1></body></html>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: HTML always produces at least a Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* HTML: file with <script src> and <link rel=stylesheet> → IMPORTS edges.
+ * RED: no HTML import resolver; script/link attributes are not walked into
+ * IMPORTS edges by the pipeline. */
+TEST(probe_html_script_imports) {
+ static const GpgFile files[] = {
+ {"app.js",
+ "function init() { console.log('ready'); }\n"},
+ {"index.html",
+ "<!DOCTYPE html><html><head>\n"
+ "<link rel=\"stylesheet\" href=\"style.css\">\n"
+ "<script src=\"app.js\"></script>\n"
+ "</head><body></body></html>\n"}
+ };
+ GpgMetrics m = gpg_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: HTML <script src> / <link href> not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no HTML import resolver */
+ PASS();
+}
+
+/* HTML: pure-data — no Class/Variable/Section nodes expected. */
+TEST(probe_html_no_structural_nodes) {
+ GpgMetrics m = gpg_metrics("page.html",
+ "<html><body><p>text</p></body></html>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: HTML produces zero Class/Variable/Section nodes (pure-data). */
+ ASSERT_TRUE(m.classes == 0);
+ ASSERT_TRUE(m.variables == 0);
+ ASSERT_TRUE(m.sections == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 2 — XML (.xml)
+ *
+ * XML golden histogram: Class:2, Module:1
+ * The XML extractor produces Class nodes for element definitions
+ * (e.g., root element + nested element type nodes).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* XML: minimal document → Module node + at least 2 Class nodes. */
+TEST(probe_xml_element_nodes) {
+ GpgMetrics m = gpg_metrics("config.xml",
+ "<?xml version=\"1.0\"?>\n"
+ "<config>\n"
+ " <server host=\"localhost\" port=\"8080\"/>\n"
+ " <database name=\"mydb\"/>\n"
+ "</config>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: XML extractor produces Class nodes for elements. */
+ ASSERT_TRUE(m.classes >= 2);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* XML: more elements → more Class nodes (≥ 2). */
+TEST(probe_xml_multiple_elements) {
+ GpgMetrics m = gpg_metrics("pom.xml",
+ "<project>\n"
+ " <groupId>com.example</groupId>\n"
+ " <artifactId>demo</artifactId>\n"
+ " <version>1.0</version>\n"
+ "</project>\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: multiple element types must produce Class nodes. */
+ ASSERT_TRUE(m.classes >= 2);
+ PASS();
+}
+
+/* XML: no-crash guard for empty document. */
+TEST(probe_xml_no_crash) {
+ GpgMetrics m = gpg_metrics("empty.xml",
+ "<?xml version=\"1.0\"?><root/>\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 3 — CSS (.css)
+ *
+ * CSS golden histogram: Module:1 (pure-data).
+ * CSS selectors/rules are not extracted as graph nodes; only a Module
+ * node is emitted per file.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* CSS: rules file → only a Module node. */
+TEST(probe_css_module_only) {
+ GpgMetrics m = gpg_metrics("styles.css",
+ "body {\n"
+ " margin: 0;\n"
+ " font-family: sans-serif;\n"
+ "}\n"
+ ".container { max-width: 1200px; }\n"
+ "#header { background: #fff; }\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: CSS produces exactly 1 Module node; no Class/Variable/Section. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.classes == 0);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* CSS: @import in two-file fixture → IMPORTS edge.
+ * RED: no CSS import resolver in the pipeline. */
+TEST(probe_css_at_import) {
+ static const GpgFile files[] = {
+ {"base.css",
+ "* { box-sizing: border-box; }\n"},
+ {"main.css",
+ "@import \"base.css\";\n"
+ "body { margin: 0; }\n"}
+ };
+ GpgMetrics m = gpg_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: CSS @import not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no CSS import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 4 — SCSS (.scss)
+ *
+ * SCSS golden histogram: Module:1, Variable:1
+ * The extractor pulls at least one Variable node (e.g. a CSS custom property
+ * or SCSS variable). No selector/rule Class nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* SCSS: variables + rules → at least 1 Variable node. */
+TEST(probe_scss_variable_node) {
+ GpgMetrics m = gpg_metrics("theme.scss",
+ "$primary: #3498db;\n"
+ "$secondary: #2ecc71;\n"
+ "\n"
+ ".button {\n"
+ " background: $primary;\n"
+ " color: white;\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: SCSS extracts at least 1 Variable node (histogram: Variable:1). */
+ ASSERT_TRUE(m.variables >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* SCSS: @import / @use in two-file fixture → IMPORTS edge.
+ * RED: no SCSS import resolver in the pipeline. */
+TEST(probe_scss_at_use_imports) {
+ static const GpgFile files[] = {
+ {"_vars.scss",
+ "$brand: #e74c3c;\n"},
+ {"main.scss",
+ "@use 'vars';\n"
+ ".hero { color: vars.$brand; }\n"}
+ };
+ GpgMetrics m = gpg_metrics_files(files, 2);
+ ASSERT_TRUE(m.ok);
+ /* RED: SCSS @use / @import not resolved into IMPORTS edges. */
+ ASSERT_TRUE(m.imports >= 1); /* expected RED — no SCSS import resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 5 — Markdown (.md)
+ *
+ * Markdown golden histogram: Module:1, Section:1
+ * Headings become Section nodes. Links are NOT resolved to IMPORTS edges.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Markdown: document with headings → at least 1 Section node. */
+TEST(probe_markdown_section_node) {
+ GpgMetrics m = gpg_metrics("README.md",
+ "# Project Title\n"
+ "\n"
+ "Description text.\n"
+ "\n"
+ "## Getting Started\n"
+ "\n"
+ "Install with `npm install`.\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Markdown headings produce Section nodes. */
+ ASSERT_TRUE(m.sections >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* Markdown: multiple headings → at least 1 Section (histogram baseline: Section:1).
+ * The histogram fixture has 1 section; additional headings may or may not add more. */
+TEST(probe_markdown_multi_heading) {
+ GpgMetrics m = gpg_metrics("docs.md",
+ "# Title\n"
+ "## Setup\n"
+ "### Install\n"
+ "## Usage\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at minimum 1 Section node. */
+ ASSERT_TRUE(m.sections >= 1);
+ PASS();
+}
+
+/* Markdown: no Class/Variable nodes (pure-data beyond Section). */
+TEST(probe_markdown_no_class_variable) {
+ GpgMetrics m = gpg_metrics("notes.md",
+ "# Notes\n\nSome content.\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: Markdown does not produce Class or Variable nodes. */
+ ASSERT_TRUE(m.classes == 0);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 6 — RST (.rst)
+ *
+ * RST golden histogram: Module:1 (pure-data).
+ * reStructuredText headings are NOT extracted as Section nodes (unlike Markdown).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* RST: document with sections → Module:1, no Section nodes. */
+TEST(probe_rst_module_only) {
+ GpgMetrics m = gpg_metrics("docs.rst",
+ "Project Title\n"
+ "=============\n"
+ "\n"
+ "Description text.\n"
+ "\n"
+ "Installation\n"
+ "------------\n"
+ "\n"
+ "Run ``pip install mypackage``.\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: RST produces only a Module node (no Section nodes extracted). */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.sections == 0);
+ PASS();
+}
+
+/* RST: no-crash guard. */
+TEST(probe_rst_no_crash) {
+ GpgMetrics m = gpg_metrics("api.rst",
+ ".. automodule:: mypackage.api\n"
+ " :members:\n");
+ ASSERT_TRUE(m.ok);
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 7 — JSON (.json)
+ *
+ * JSON golden histogram: Module:1, Variable:2
+ * Top-level keys become Variable nodes (2 in the fixture).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* JSON: object with two top-level keys → 2 Variable nodes. */
+TEST(probe_json_variable_nodes) {
+ GpgMetrics m = gpg_metrics("config.json",
+ "{\n"
+ " \"name\": \"myproject\",\n"
+ " \"version\": \"1.0.0\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: JSON top-level keys become Variable nodes. */
+ ASSERT_TRUE(m.variables >= 2);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* JSON: three top-level keys → ≥ 2 Variable nodes (floor from histogram). */
+TEST(probe_json_more_variables) {
+ /* Fixture fix: "package.json" is in discover.c IGNORED_JSON_FILES, so
+ * detect_file_language() returns CBM_LANG_COUNT and the file is never
+ * indexed (0 nodes). Use a generic .json filename so the JSON grammar
+ * actually runs (grammar_labels json=Variable:2). */
+ GpgMetrics m = gpg_metrics("data.json",
+ "{\n"
+ " \"name\": \"demo\",\n"
+ " \"version\": \"0.1.0\",\n"
+ " \"description\": \"A demo project\"\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least 2 Variable nodes (histogram baseline). */
+ ASSERT_TRUE(m.variables >= 2);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 8 — JSON5 (.json5)
+ *
+ * JSON5 golden histogram: Module:1 (pure-data).
+ * Despite being a superset of JSON, the JSON5 extractor produces only Module.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* JSON5: file with keys → only Module node. */
+TEST(probe_json5_module_only) {
+ GpgMetrics m = gpg_metrics("config.json5",
+ "{\n"
+ " // comments allowed\n"
+ " name: 'myproject',\n"
+ " version: '1.0',\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: JSON5 produces only a Module node (no Variable nodes unlike JSON). */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 9 — YAML (.yaml)
+ *
+ * YAML golden histogram: Module:1, Variable:2
+ * Top-level keys become Variable nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* YAML: document with two top-level keys → 2 Variable nodes. */
+TEST(probe_yaml_variable_nodes) {
+ GpgMetrics m = gpg_metrics("config.yaml",
+ "name: myproject\n"
+ "version: 1.0.0\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: YAML top-level keys become Variable nodes. */
+ ASSERT_TRUE(m.variables >= 2);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* YAML: three top-level keys → still ≥ 2 Variable nodes (baseline). */
+TEST(probe_yaml_three_keys) {
+ GpgMetrics m = gpg_metrics("app.yaml",
+ "host: localhost\n"
+ "port: 8080\n"
+ "debug: true\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least 2 Variable nodes. */
+ ASSERT_TRUE(m.variables >= 2);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 10 — TOML (.toml)
+ *
+ * TOML golden histogram: Class:1, Module:1, Variable:1
+ * Table headers produce Class nodes; top-level keys produce Variable nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* TOML: file with table + key → Class:1 + Variable:1. */
+TEST(probe_toml_table_and_key) {
+ GpgMetrics m = gpg_metrics("Cargo.toml",
+ "[package]\n"
+ "name = \"mylib\"\n"
+ "version = \"0.1.0\"\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: TOML table [package] becomes a Class node. */
+ ASSERT_TRUE(m.classes >= 1);
+ /* GREEN: key becomes a Variable node. */
+ ASSERT_TRUE(m.variables >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* TOML: multiple tables → ≥ 1 Class node (may be exactly 1 per fixture). */
+TEST(probe_toml_multiple_tables) {
+ GpgMetrics m = gpg_metrics("pyproject.toml",
+ "[tool.poetry]\n"
+ "name = \"demo\"\n"
+ "\n"
+ "[tool.poetry.dependencies]\n"
+ "python = \"^3.9\"\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least one Class node for tables. */
+ ASSERT_TRUE(m.classes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 11 — INI (.ini)
+ *
+ * INI golden histogram: Class:1, Module:1, Variable:1
+ * Sections produce Class nodes; key-value pairs produce Variable nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* INI: file with a section and a key → Class + Variable. */
+TEST(probe_ini_section_and_key) {
+ GpgMetrics m = gpg_metrics("app.ini",
+ "[database]\n"
+ "host = localhost\n"
+ "port = 5432\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: [database] section becomes a Class node. */
+ ASSERT_TRUE(m.classes >= 1);
+ /* GREEN: key becomes a Variable node. */
+ ASSERT_TRUE(m.variables >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* INI: .conf extension also maps to CBM_LANG_INI; must produce same structure. */
+TEST(probe_ini_conf_extension) {
+ GpgMetrics m = gpg_metrics("server.conf",
+ "[server]\n"
+ "listen = 0.0.0.0\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: .conf files index as INI and produce Class + Variable nodes. */
+ ASSERT_TRUE(m.classes >= 1);
+ ASSERT_TRUE(m.variables >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 12 — CSV (.csv)
+ *
+ * CSV golden histogram: Module:1 (pure-data).
+ * Tabular data — no structural nodes beyond Module.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* CSV: file with header + rows → only Module node. */
+TEST(probe_csv_module_only) {
+ GpgMetrics m = gpg_metrics("data.csv",
+ "id,name,score\n"
+ "1,Alice,95\n"
+ "2,Bob,87\n"
+ "3,Carol,92\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: CSV produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.classes == 0);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 13 — SQL (.sql)
+ *
+ * SQL golden histogram: Module:1, Variable:1
+ * Table references (e.g. CREATE TABLE / SELECT FROM) produce Variable nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* SQL: CREATE TABLE + SELECT → at least 1 Variable node. */
+TEST(probe_sql_variable_node) {
+ GpgMetrics m = gpg_metrics("schema.sql",
+ "CREATE TABLE users (\n"
+ " id INTEGER PRIMARY KEY,\n"
+ " name TEXT NOT NULL\n"
+ ");\n"
+ "\n"
+ "SELECT id, name FROM users WHERE id = 1;\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: SQL table reference produces at least 1 Variable node. */
+ ASSERT_TRUE(m.variables >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* SQL: multiple statements → still at least 1 Variable. */
+TEST(probe_sql_insert_select) {
+ GpgMetrics m = gpg_metrics("queries.sql",
+ "INSERT INTO orders (user_id, total) VALUES (1, 99.99);\n"
+ "SELECT o.id, u.name FROM orders o JOIN users u ON o.user_id = u.id;\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN (fixture fix): SQL Variable nodes come ONLY from DDL
+ * create_table/create_view (lang_specs.c sql_var_types), NOT from
+ * DML table *references* in INSERT/SELECT. A DML-only file correctly
+ * yields 0 Variable nodes; the original `>= 1` asserted a non-feature.
+ * Assert the true contract: no table definitions → 0 Variables. */
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 14 — SOQL (.soql)
+ *
+ * SOQL golden histogram: Module:1 (pure-data).
+ * Salesforce Object Query Language — no structural nodes extracted.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* SOQL: SELECT query → only Module node. */
+TEST(probe_soql_module_only) {
+ GpgMetrics m = gpg_metrics("query.soql",
+ "SELECT Id, Name, Email\n"
+ "FROM Contact\n"
+ "WHERE AccountId = :accountId\n"
+ "ORDER BY Name\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: SOQL produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 15 — SOSL (.sosl)
+ *
+ * SOSL golden histogram: Module:1 (pure-data).
+ * Salesforce Object Search Language — no structural nodes extracted.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* SOSL: FIND query → only Module node. */
+TEST(probe_sosl_module_only) {
+ GpgMetrics m = gpg_metrics("search.sosl",
+ "FIND {Acme} IN ALL FIELDS\n"
+ "RETURNING Account(Id, Name), Contact(Id, Name)\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: SOSL produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 16 — DotEnv (.env)
+ *
+ * DotEnv golden histogram: Module:1 (pure-data).
+ * Environment variable files are pure-data; keys are NOT extracted as nodes.
+ * Extension: .env suffix detected by pass_envscan; filename ".env" also works.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* DotEnv: .env file → only Module node. */
+TEST(probe_dotenv_module_only) {
+ GpgMetrics m = gpg_metrics(".env",
+ "DATABASE_URL=postgres://localhost/mydb\n"
+ "SECRET_KEY=supersecret\n"
+ "DEBUG=true\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (NEW class — file-index routing gap): the DotEnv grammar +
+ * histogram (grammar_labels dotenv=Module:1) exist and work via DIRECT
+ * extraction, but ".env" has no FILENAME_TABLE / EXT_TABLE entry in
+ * language.c, so file-based index_repository's cbm_language_for_filename
+ * returns CBM_LANG_COUNT and the file is never indexed → 0 Module nodes.
+ * Routing/registration gap, distinct from extraction classes 2/16. RED. */
+ ASSERT_TRUE(m.modules == 1); /* REAL BUG — .env not routed by file index */
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* DotEnv: .env.local suffix variant → indexed as DotEnv. */
+TEST(probe_dotenv_local_suffix) {
+ GpgMetrics m = gpg_metrics(".env.local",
+ "API_KEY=local-test-key\n"
+ "PORT=3001\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (NEW class — file-index routing gap): ".env.local" has no
+ * FILENAME_TABLE/EXT_TABLE entry, so file-based index_repository never
+ * routes it to CBM_LANG_DOTENV → 0 Module nodes. Same routing gap as
+ * probe_dotenv_module_only. RED. */
+ ASSERT_TRUE(m.modules >= 1); /* REAL BUG — .env.local not routed by file index */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 17 — gitignore (.gitignore)
+ *
+ * gitignore golden histogram: Module:1 (pure-data).
+ * Pattern files — no structural graph nodes.
+ * Extension: cbm_path_ext(".gitignore") → "gitignore" (strips the leading dot).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* gitignore: pattern file → only Module node. */
+TEST(probe_gitignore_module_only) {
+ GpgMetrics m = gpg_metrics(".gitignore",
+ "*.o\n"
+ "*.a\n"
+ "build/\n"
+ "dist/\n"
+ ".DS_Store\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (NEW class — file-index routing gap): the gitignore grammar +
+ * histogram (grammar_labels gitignore=Module:1) work via DIRECT
+ * extraction, but ".gitignore" has no FILENAME_TABLE/EXT_TABLE entry
+ * (cbm_language_for_filename(".gitignore") → ext ".gitignore" → not in
+ * EXT_TABLE → CBM_LANG_COUNT), so file-based index_repository never
+ * routes it → 0 Module nodes. Routing/registration gap. RED. */
+ ASSERT_TRUE(m.modules == 1); /* REAL BUG — .gitignore not routed by file index */
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 18 — gitattributes (.gitattributes)
+ *
+ * gitattributes golden histogram: Module:1 (pure-data).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* gitattributes: attribute file → only Module node. */
+TEST(probe_gitattributes_module_only) {
+ GpgMetrics m = gpg_metrics(".gitattributes",
+ "*.c text eol=lf\n"
+ "*.h text eol=lf\n"
+ "*.png binary\n"
+ "*.jpg binary\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (NEW class — file-index routing gap): gitattributes grammar +
+ * histogram (Module:1) work via DIRECT extraction, but ".gitattributes"
+ * has no FILENAME_TABLE/EXT_TABLE entry → file-based index_repository
+ * never routes it → 0 Module nodes. Same routing gap as .gitignore. */
+ ASSERT_TRUE(m.modules == 1); /* REAL BUG — .gitattributes not routed by file index */
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 19 — Properties (.properties)
+ *
+ * Properties golden histogram: Module:1 (pure-data).
+ * Java-style key=value files — keys NOT extracted as Variable nodes
+ * (unlike INI which does produce Class/Variable nodes).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Properties: key=value file → only Module node. */
+TEST(probe_properties_module_only) {
+ GpgMetrics m = gpg_metrics("app.properties",
+ "server.host=localhost\n"
+ "server.port=8080\n"
+ "log.level=INFO\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: .properties produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 20 — Requirements (.txt via FILENAME_TABLE)
+ *
+ * Requirements golden histogram: Module:1 (pure-data).
+ * Python dependency specs — deps NOT extracted as DEPENDS_ON edges by
+ * the grammar-only pipeline (no requirements resolver).
+ * Extension: recognized only for "requirements.txt", "requirements-dev.txt",
+ * "requirements-test.txt" (FILENAME_TABLE exact match).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Requirements: dep file → only Module node. */
+TEST(probe_requirements_module_only) {
+ GpgMetrics m = gpg_metrics("requirements.txt",
+ "flask==2.3.0\n"
+ "requests>=2.28.0\n"
+ "sqlalchemy~=2.0\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: requirements.txt produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ PASS();
+}
+
+/* Requirements: DEPENDS_ON edges for package entries.
+ * RED: grammar-only requirements has no dependency-edge resolver. */
+TEST(probe_requirements_depends_on_edge) {
+ GpgMetrics m = gpg_metrics("requirements.txt",
+ "numpy==1.24.0\n"
+ "pandas>=1.5.0\n"
+ "scipy>=1.10.0\n");
+ ASSERT_TRUE(m.ok);
+ /* RED: requirements deps not resolved into DEPENDS_ON edges. */
+ ASSERT_TRUE(m.depends >= 1); /* expected RED — no requirements edge resolver */
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 21 — Diff (.diff / .patch)
+ *
+ * Diff golden histogram: Module:1 (pure-data).
+ * Patch files are structural metadata, not code.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Diff: unified diff → only Module node. */
+TEST(probe_diff_module_only) {
+ GpgMetrics m = gpg_metrics("changes.diff",
+ "--- a/main.c\n"
+ "+++ b/main.c\n"
+ "@@ -1,5 +1,6 @@\n"
+ " #include <stdio.h>\n"
+ "+#include <stdlib.h>\n"
+ " \n"
+ " int main(void) {\n"
+ "- printf(\"hello\\n\");\n"
+ "+ printf(\"hello world\\n\");\n"
+ " return 0;\n"
+ " }\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: diff produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 22 — PO (.po)
+ *
+ * PO golden histogram: Module:1 (pure-data).
+ * GNU gettext translation catalogs — no structural nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* PO: translation file → only Module node. */
+TEST(probe_po_module_only) {
+ GpgMetrics m = gpg_metrics("messages.po",
+ "# Translation file\n"
+ "msgid \"\"\n"
+ "msgstr \"\"\n"
+ "\"Content-Type: text/plain; charset=UTF-8\\n\"\n"
+ "\n"
+ "msgid \"Hello\"\n"
+ "msgstr \"Bonjour\"\n"
+ "\n"
+ "msgid \"Goodbye\"\n"
+ "msgstr \"Au revoir\"\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: PO produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 23 — Regex (.re)
+ *
+ * Regex golden histogram: Module:1 (pure-data).
+ * Extension: ".re" maps to CBM_LANG_REGEX in grammar_cases.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Regex: pattern file → only Module node. */
+TEST(probe_regex_module_only) {
+ GpgMetrics m = gpg_metrics("patterns.re",
+ "(foo|bar)+\n"
+ "^[a-zA-Z_][a-zA-Z0-9_]*$\n"
+ "\\d{4}-\\d{2}-\\d{2}\n");
+ ASSERT_TRUE(m.ok);
+ /* REAL BUG (NEW class — file-index routing gap): the Regex grammar +
+ * histogram (grammar_labels regex=Module:1) work via DIRECT extraction
+ * (a.re), but the ".re" extension has no EXT_TABLE entry in language.c,
+ * so file-based index_repository never routes it → 0 Module nodes.
+ * Routing/registration gap, distinct from extraction classes 2/16. RED. */
+ ASSERT_TRUE(m.modules == 1); /* REAL BUG — .re not routed by file index */
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 24 — SSH Config (ssh_config / sshd_config / config)
+ *
+ * SSH Config golden histogram: Module:1 (pure-data).
+ * Special filenames: "ssh_config", "sshd_config", ".ssh/config" (FILENAME_TABLE).
+ * Also matches "config" basename in certain contexts (grammar_regression uses "config").
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* SSH Config: host file via ssh_config filename → only Module node. */
+TEST(probe_sshconfig_module_only) {
+ GpgMetrics m = gpg_metrics("ssh_config",
+ "Host bastion\n"
+ " HostName 10.0.0.1\n"
+ " User ubuntu\n"
+ " IdentityFile ~/.ssh/id_rsa\n"
+ "\n"
+ "Host dev\n"
+ " HostName dev.example.com\n"
+ " User deploy\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: SSH config produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 25 — BibTeX (.bib)
+ *
+ * BibTeX golden histogram: Module:1 (pure-data).
+ * Bibliography entries are NOT extracted as structural nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* BibTeX: bibliography file → only Module node. */
+TEST(probe_bibtex_module_only) {
+ GpgMetrics m = gpg_metrics("refs.bib",
+ "@article{smith2023,\n"
+ " author = {Smith, John},\n"
+ " title = {A Study of Something},\n"
+ " year = {2023},\n"
+ " journal = {J. Examples}\n"
+ "}\n"
+ "\n"
+ "@book{jones2020,\n"
+ " author = {Jones, Alice},\n"
+ " title = {Reference Book},\n"
+ " year = {2020}\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: BibTeX produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 26 — FORM (.frm)
+ *
+ * FORM golden histogram: Module:1, Variable:1
+ * The FORM language (symbolic algebra) produces a Variable node for
+ * one definition. Extension: .frm (CBM_LANG_FORM in EXT_TABLE).
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* FORM: file with a variable declaration → at least 1 Variable node. */
+TEST(probe_form_variable_node) {
+ GpgMetrics m = gpg_metrics("calc.frm",
+ "Symbol x, y, z;\n"
+ "Local F = x^2 + y^2 + z^2;\n"
+ "Print;\n"
+ ".end\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: FORM produces at least 1 Variable node (histogram: Variable:1). */
+ ASSERT_TRUE(m.variables >= 1);
+ ASSERT_TRUE(m.modules >= 1);
+ PASS();
+}
+
+/* FORM: no-crash guard with procedure definition. */
+TEST(probe_form_procedure) {
+ GpgMetrics m = gpg_metrics("proc.frm",
+ "#procedure Square(x)\n"
+ " id `x'^2 = `x'^2;\n"
+ "#endprocedure\n"
+ "\n"
+ "Symbol a;\n"
+ "Local expr = a^2;\n"
+ ".end\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: at least 1 node (Module). */
+ ASSERT_TRUE(m.total_nodes >= 1);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * GROUP 27 — Linker Script (.ld / .lds)
+ *
+ * Linker Script golden histogram: Module:1 (pure-data).
+ * SECTIONS / MEMORY directives are not extracted as structural nodes.
+ * ══════════════════════════════════════════════════════════════════ */
+
+/* Linker script: SECTIONS directive → only Module node. */
+TEST(probe_linkerscript_module_only) {
+ GpgMetrics m = gpg_metrics("link.ld",
+ "SECTIONS\n"
+ "{\n"
+ " . = 0x10000;\n"
+ " .text : { *(.text) }\n"
+ " .data : { *(.data) }\n"
+ " .bss : { *(.bss) }\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: linker script produces only a Module node. */
+ ASSERT_TRUE(m.modules == 1);
+ ASSERT_TRUE(m.variables == 0);
+ PASS();
+}
+
+/* Linker script: MEMORY + SECTIONS → still only Module node. */
+TEST(probe_linkerscript_memory_sections) {
+ GpgMetrics m = gpg_metrics("stm32.ld",
+ "MEMORY\n"
+ "{\n"
+ " FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K\n"
+ " RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K\n"
+ "}\n"
+ "SECTIONS\n"
+ "{\n"
+ " .isr_vector : { *(.isr_vector) } > FLASH\n"
+ " .text : { *(.text*) } > FLASH\n"
+ " .bss : { *(.bss*) } > RAM\n"
+ "}\n");
+ ASSERT_TRUE(m.ok);
+ /* GREEN: linker script produces only a Module node. */
+ ASSERT_TRUE(m.modules >= 1);
+ ASSERT_TRUE(m.classes == 0);
+ PASS();
+}
+
+/* ══════════════════════════════════════════════════════════════════
+ * SUITE wiring
+ * ══════════════════════════════════════════════════════════════════ */
+
+SUITE(grammar_probe_g) {
+ /* HTML */
+ RUN_TEST(probe_html_minimal_page);
+ RUN_TEST(probe_html_script_imports);
+ RUN_TEST(probe_html_no_structural_nodes);
+
+ /* XML */
+ RUN_TEST(probe_xml_element_nodes);
+ RUN_TEST(probe_xml_multiple_elements);
+ RUN_TEST(probe_xml_no_crash);
+
+ /* CSS */
+ RUN_TEST(probe_css_module_only);
+ RUN_TEST(probe_css_at_import);
+
+ /* SCSS */
+ RUN_TEST(probe_scss_variable_node);
+ RUN_TEST(probe_scss_at_use_imports);
+
+ /* Markdown */
+ RUN_TEST(probe_markdown_section_node);
+ RUN_TEST(probe_markdown_multi_heading);
+ RUN_TEST(probe_markdown_no_class_variable);
+
+ /* RST */
+ RUN_TEST(probe_rst_module_only);
+ RUN_TEST(probe_rst_no_crash);
+
+ /* JSON */
+ RUN_TEST(probe_json_variable_nodes);
+ RUN_TEST(probe_json_more_variables);
+
+ /* JSON5 */
+ RUN_TEST(probe_json5_module_only);
+
+ /* YAML */
+ RUN_TEST(probe_yaml_variable_nodes);
+ RUN_TEST(probe_yaml_three_keys);
+
+ /* TOML */
+ RUN_TEST(probe_toml_table_and_key);
+ RUN_TEST(probe_toml_multiple_tables);
+
+ /* INI */
+ RUN_TEST(probe_ini_section_and_key);
+ RUN_TEST(probe_ini_conf_extension);
+
+ /* CSV */
+ RUN_TEST(probe_csv_module_only);
+
+ /* SQL */
+ RUN_TEST(probe_sql_variable_node);
+ RUN_TEST(probe_sql_insert_select);
+
+ /* SOQL */
+ RUN_TEST(probe_soql_module_only);
+
+ /* SOSL */
+ RUN_TEST(probe_sosl_module_only);
+
+ /* DotEnv */
+ RUN_TEST(probe_dotenv_module_only);
+ RUN_TEST(probe_dotenv_local_suffix);
+
+ /* gitignore */
+ RUN_TEST(probe_gitignore_module_only);
+
+ /* gitattributes */
+ RUN_TEST(probe_gitattributes_module_only);
+
+ /* Properties */
+ RUN_TEST(probe_properties_module_only);
+
+ /* Requirements */
+ RUN_TEST(probe_requirements_module_only);
+ RUN_TEST(probe_requirements_depends_on_edge);
+
+ /* Diff */
+ RUN_TEST(probe_diff_module_only);
+
+ /* PO */
+ RUN_TEST(probe_po_module_only);
+
+ /* Regex */
+ RUN_TEST(probe_regex_module_only);
+
+ /* SSH Config */
+ RUN_TEST(probe_sshconfig_module_only);
+
+ /* BibTeX */
+ RUN_TEST(probe_bibtex_module_only);
+
+ /* FORM */
+ RUN_TEST(probe_form_variable_node);
+ RUN_TEST(probe_form_procedure);
+
+ /* Linker Script */
+ RUN_TEST(probe_linkerscript_module_only);
+ RUN_TEST(probe_linkerscript_memory_sections);
+}
diff --git a/tests/test_main.c b/tests/test_main.c
index 0a953f332..543ddd14e 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -89,6 +89,10 @@ extern void suite_matrix_new_constructs(void);
extern void suite_grammar_probe_a(void);
extern void suite_grammar_probe_b(void);
extern void suite_grammar_probe_c(void);
+extern void suite_grammar_probe_d(void);
+extern void suite_grammar_probe_e(void);
+extern void suite_grammar_probe_f(void);
+extern void suite_grammar_probe_g(void);
extern void suite_incremental(void);
extern void suite_simhash(void);
extern void suite_stack_overflow(void);
@@ -235,6 +239,10 @@ int main(void) {
RUN_SUITE(grammar_probe_a);
RUN_SUITE(grammar_probe_b);
RUN_SUITE(grammar_probe_c);
+ RUN_SUITE(grammar_probe_d);
+ RUN_SUITE(grammar_probe_e);
+ RUN_SUITE(grammar_probe_f);
+ RUN_SUITE(grammar_probe_g);
RUN_SUITE(incremental);