From 5439c363de6b64fa3c468981fcf7707987ccff64 Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Sun, 14 Jun 2026 10:36:48 +0000 Subject: [PATCH] test(cfg): validate cfg/visitors literals + drop 3 dead TS node types Extend the grammar-literal CI gate (test/helpers/literal-collectors.ts) to scan cfg/visitors/*.ts, mapping each visitor file to its grammar via the existing basename rule (c-cpp -> C/C++, csharp -> C#, java -> Java, go -> Go, typescript -> TS). Closes the gap where the gate never validated CFG visitor node-type literals -- the prerequisite for adding C-family visitors safely (#2195 U1). The newly-scanned TS visitor surfaced 3 dead literals absent from every grammar it serves (typescript/javascript/tsx all = 0): for_of_statement (for-of parses as for_in_statement), async_function_declaration and async_arrow_function (async functions are function_declaration / arrow_function + an async child). Removed them; behavior-preserving -- the cases never matched, bench --check fingerprints unchanged, TS visitor unit tests green. Co-Authored-By: Claude Opus 4.8 (1M context) --- gitnexus/src/core/ingestion/cfg/visitors/typescript.ts | 5 ----- gitnexus/test/helpers/literal-collectors.ts | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gitnexus/src/core/ingestion/cfg/visitors/typescript.ts b/gitnexus/src/core/ingestion/cfg/visitors/typescript.ts index 1382fdb66..3423da03c 100644 --- a/gitnexus/src/core/ingestion/cfg/visitors/typescript.ts +++ b/gitnexus/src/core/ingestion/cfg/visitors/typescript.ts @@ -76,8 +76,6 @@ const TS_FUNCTION_TYPES = new Set([ 'method_definition', 'generator_function_declaration', 'generator_function', - 'async_function_declaration', - 'async_arrow_function', ]); /** Statement node types that break a basic block (everything else coalesces). */ @@ -87,7 +85,6 @@ const CONTROL_FLOW_TYPES = new Set([ 'do_statement', 'for_statement', 'for_in_statement', - 'for_of_statement', 'switch_statement', 'try_statement', 'return_statement', @@ -103,7 +100,6 @@ const LOOP_OR_SWITCH_TYPES = new Set([ 'do_statement', 'for_statement', 'for_in_statement', - 'for_of_statement', 'switch_statement', ]); @@ -206,7 +202,6 @@ class TsCfgWalk { case 'for_statement': return this.visitFor(stmt); case 'for_in_statement': - case 'for_of_statement': return this.visitForIn(stmt); case 'switch_statement': return this.visitSwitch(stmt); diff --git a/gitnexus/test/helpers/literal-collectors.ts b/gitnexus/test/helpers/literal-collectors.ts index e75a44e2d..6e34e5165 100644 --- a/gitnexus/test/helpers/literal-collectors.ts +++ b/gitnexus/test/helpers/literal-collectors.ts @@ -183,6 +183,14 @@ function mode2Files(): string[] { if (existsSync(cap)) files.push(cap); } } + // CFG visitors (cfg/visitors/.ts) hard-code tree-sitter node-type and + // field literals directly; include them so the gate validates per-language + // CFG literals against the right grammar (basename → grammar via + // `fileLanguages`: c-cpp → C+C++, csharp → C#, java → Java, go → Go, + // typescript[-harvest] → TS). Without this, the gate stays green on dead + // literals in a new visitor — the exact failure KTD5 warns about. + const cfgVisitorsDir = join(INGESTION_DIR, 'cfg', 'visitors'); + if (existsSync(cfgVisitorsDir)) walkTs(cfgVisitorsDir, files); const exportDetection = join(INGESTION_DIR, 'export-detection.ts'); if (existsSync(exportDetection)) files.push(exportDetection); return files;