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
@@ -2,7 +2,11 @@ import { z } from "zod";
import { emptyArraySchema } from "../emptyArraySchema.js";
import { evidenceSchema } from "../evidence.js";
import { javascriptApplicationGraphSchema } from "./javascriptApplicationGraph.js";
import {
isValidatedImmutableJavaScriptApplicationGraph,
javascriptApplicationGraphSchema,
type JavaScriptApplicationGraph,
} from "./javascriptApplicationGraph.js";
import { JAVASCRIPT_APPLICATION_NODE_KINDS } from "./javascriptApplicationGraphSchemas.js";
import { prefixedDigestSchema } from "../digests.js";
@@ -234,6 +238,14 @@ export const applicationVersionComparisonResultSchema = z
});
});
/** Reuse the exact owned change graph while validating the rest of the result. */
export const ownedApplicationVersionComparisonResultSchema =
applicationVersionComparisonResultSchema.safeExtend({
graph: z.custom<JavaScriptApplicationGraph>(
isValidatedImmutableJavaScriptApplicationGraph,
),
});
export type ApplicationVersionComparisonItem = z.infer<
typeof comparisonItemSchema
>;