From e8419acaf51eeeda942f7e721f633c14158b0dfb Mon Sep 17 00:00:00 2001 From: ShuaixinHuang <1836656514@qq.com> Date: Tue, 1 Dec 2026 02:51:17 +0800 Subject: [PATCH] fix(javascript): explain relation omissions at semantic node ceilings (#15295) --- .../javascript-artifact-reconstruction.md | 5 +- .../JavaScriptSemanticGraphBuilder.ts | 4 +- .../javascriptGraphQueryCoverage.test.ts | 64 +++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/docs/guides/javascript/javascript-artifact-reconstruction.md b/docs/guides/javascript/javascript-artifact-reconstruction.md index 0bb936c3e41..b449b31e1d8 100644 --- a/docs/guides/javascript/javascript-artifact-reconstruction.md +++ b/docs/guides/javascript/javascript-artifact-reconstruction.md @@ -1057,7 +1057,10 @@ also bounded by the remaining application capacity. Raising these controls does not bypass worker heap, execution deadline or parent result admission. Truncated coverage lists both effective ceilings, `max_semantic_nodes` and `max_semantic_nodes_per_file`. The limitation names only the ceiling that -stopped retention. Omitted relationships remain unknown. +stopped retention. A relation requires both endpoints to be retained. If the +node ceiling omits endpoints, even an empty relation list leaves relationship +coverage unknown. The graph reports `coverage.omitted_relations: null` when the +node ceiling stops retention. Unknown records have independent defaults of 100000 across the application and 20000 per source. Select `max_semantic_unknowns` and diff --git a/src/application/javascript/JavaScriptSemanticGraphBuilder.ts b/src/application/javascript/JavaScriptSemanticGraphBuilder.ts index ea1309953a3..19852d17b48 100644 --- a/src/application/javascript/JavaScriptSemanticGraphBuilder.ts +++ b/src/application/javascript/JavaScriptSemanticGraphBuilder.ts @@ -376,7 +376,9 @@ export const createJavaScriptSemanticGraphProjection = ( ]), ...(nodeCeilingCoverage === undefined ? [] - : [nodeCeilingCoverage.limitation]), + : [ + `${nodeCeilingCoverage.limitation} A relation requires both endpoints to be retained. The node ceiling can omit endpoints, so an empty relation list leaves relationship coverage unknown. The number of omitted relations is unknown.`, + ]), "The semantic graph contains static syntax observations and conservative relationship candidates; it does not claim runtime execution.", "Local data flow does not claim control-flow-sensitive reaching definitions or arbitrary dynamic property resolution.", "Promise ownership covers explicit unshadowed Promise construction, static factories, aggregation, chaining, and await syntax only.", diff --git a/tests/acceptance/applications/javascriptGraphQueryCoverage.test.ts b/tests/acceptance/applications/javascriptGraphQueryCoverage.test.ts index 32515f5bd1f..cda8febaf48 100644 --- a/tests/acceptance/applications/javascriptGraphQueryCoverage.test.ts +++ b/tests/acceptance/applications/javascriptGraphQueryCoverage.test.ts @@ -232,3 +232,67 @@ cliTest( } }, ); + +cliTest( + "explains missing relation endpoints when callable nodes fill the file ceiling", + async ({ cli }) => { + const root = await createTestTempDirectory("rea-graph-endpoint-ceiling-"); + await writeFile( + join(root, "main.js"), + "function helper() { return 1; }\n" + + Array.from( + { length: 5 }, + (_, index) => `function f${index}() { return helper() + ${index}; }`, + ).join("\n"), + ); + const analyze = async (ceiling: string) => { + const response = await cli.run({ + arguments: [ + "analyze-javascript-application", + root, + "--source-path", + "main.js", + "--max-semantic-nodes-per-file", + ceiling, + "--json", + ], + }); + expect(response.exitCode, response.stderr).toBe(0); + return javascriptApplicationAnalysisResultSchema.parse( + parseEvidence(response.json).normalized_result, + ).semantic_graph; + }; + + const truncated = await analyze("4"); + expect(truncated.nodes.map(({ kind }) => kind).sort()).toEqual([ + "function", + "function", + "function", + "module", + ]); + expect(truncated.relations).toEqual([]); + expect(truncated.coverage).toMatchObject({ + status: "partial", + truncated: true, + omitted_nodes: null, + omitted_relations: null, + }); + expect(truncated.limitations).toEqual( + expect.arrayContaining([ + expect.stringContaining("The node ceiling can omit endpoints"), + ]), + ); + + const complete = await analyze("100"); + expect(complete.relations.length).toBeGreaterThan(0); + expect(complete.coverage).toMatchObject({ + truncated: false, + omitted_relations: 0, + }); + expect(complete.limitations).not.toEqual( + expect.arrayContaining([ + expect.stringContaining("The node ceiling can omit endpoints"), + ]), + ); + }, +);