perf(javascript): validate the version change graph once (#1370)

compareJavaScriptApplicationVersions built the change graph with
createJavaScriptApplicationGraph, which validates it and re-derives
every node, observation, edge and graph ID, then parsed the result
with a schema that embeds the full graph schema, repeating all of
that work. Seal the change graph with the owned immutable factory and
accept that exact sealed graph in the result parse, as owned analysis
results already do. Items, coverage and the public result schema are
unchanged; output is byte-identical.
This commit is contained in:
keemsisi
2026-10-09 23:34:21 +01:00
committed by GitHub
parent 810107a2ad
commit 037709a52c
4 changed files with 160 additions and 6 deletions
@@ -1,6 +1,6 @@
import {
createJavaScriptApplicationEdge,
createJavaScriptApplicationGraph,
createImmutableJavaScriptApplicationGraphSteps,
createJavaScriptApplicationNode,
type JavaScriptApplicationGraph,
} from "./javascriptApplicationGraph.js";
@@ -59,7 +59,7 @@ export const buildJavaScriptApplicationChangeGraph = (
const candidateEdges = uniqueEdges([...sourceEdges, ...comparisonEdges]);
const rootNodeIds = preferredRoots.filter((nodeId) => retained.has(nodeId));
const fallbackRoot = mergedNodes[0]?.node_id;
const graph = createJavaScriptApplicationGraph({
const steps = createImmutableJavaScriptApplicationGraphSteps({
schema: "JavaScriptApplicationGraph",
root_node_ids:
rootNodeIds.length > 0
@@ -77,7 +77,9 @@ export const buildJavaScriptApplicationChangeGraph = (
"The change graph contains compared entities and their retained relationships; it is not an executable application.",
]),
});
return { graph };
let next = steps.next();
while (!next.done) next = steps.next();
return { graph: next.value };
};
const nodeCandidates = (