fix(javascript): report version-comparison coverage unknown when a source graph cannot tell (#11206)

* fix(javascript): report version-comparison coverage unknown when a source graph cannot tell

* refactor(javascript): name the unavailable-graph coverage mapping once

* fix(javascript): give the version change graph and its edges the same unknown coverage

* fix(javascript): report export-shape comparison coverage unknown when a source graph cannot tell (#11218)

* fix(javascript): report export-shape comparison coverage unknown when a source graph cannot tell

* test(javascript): keep unknown export-shape coverage beside a truncated projection

* fix(javascript): read runtime-reconciliation input coverage once and report unknown when a static graph cannot tell (#11230)

* fix(javascript): read runtime-reconciliation input coverage once and report unknown when a static graph cannot tell

* fix(javascript): keep a known input truncation beside unknown reconciliation coverage

* fix(javascript): report export-shape source omission counts unknown when a side has no projection (#11261)

compare_export_shapes reported left/right_omitted_fields and omitted_property_coverage as 0 for a side whose export selection recovered no return-shape projection (missing, ambiguous or unavailable), while the sibling source_omitted_variants already reported null. Add Known<T> (src/domain/known.ts) and read each side's source coverage once through it; the counts are now null (unknown) with a limitation naming why. The runtime-reconciliation graph's omission sum and its parallel 'omissions known' flag become one Known<number> via sumKnownCounts (no output change).
This commit is contained in:
morluto authored and GitHub committed 2026-11-15 23:59:23 +08:00
1 parent 8b7829e385
commit 90ce8bae4a
15 files changed
+665 -169

No files matched your search

@@ -439,3 +439,90 @@ describe("application version comparison graph ownership", () => {
).toThrow("Comparison coverage must match source graph completeness");
});
});
describe("version comparison coverage", () => {
const withCoverage = (
graph: JavaScriptApplicationGraph,
coverage: JavaScriptApplicationGraph["coverage"],
): JavaScriptApplicationGraph => {
const { graph_id: _graphId, ...input } = graph;
return createJavaScriptApplicationGraph({
...input,
coverage,
limitations: ["Fixture graph coverage is incomplete."],
});
};
const compareWith = (
left: JavaScriptApplicationGraph["coverage"],
right: JavaScriptApplicationGraph["coverage"],
) =>
compareJavaScriptApplicationVersions({
left: {
evidenceId: `ev_${"1".repeat(64)}`,
rootArtifactSha256: LEFT_SHA,
graph: withCoverage(buildGraph(LEFT_SHA, 1), left),
},
right: {
evidenceId: `ev_${"2".repeat(64)}`,
rootArtifactSha256: RIGHT_SHA,
graph: withCoverage(buildGraph(RIGHT_SHA, 2), right),
},
leftNativeEvidence: [],
rightNativeEvidence: [],
});
type Coverage = JavaScriptApplicationGraph["coverage"];
const unknown = (status: "unknown" | "unavailable"): Coverage => ({
status,
truncated: false,
omitted_count: null,
limits: [],
});
const truncated: Coverage = {
status: "partial",
truncated: true,
omitted_count: 3,
limits: [{ name: "modules", value: 3, unit: "items" }],
};
it.each(["unknown", "unavailable"] as const)(
"reports unknown, not a known gap, when a source graph is %s",
(status) => {
const result = compareWith(completeCoverage, unknown(status));
expect(result.coverage).toMatchObject({
right_graph_status: status,
status: "unknown",
});
// The change graph and each changed_from edge make the same claim.
expect(result.graph.coverage).toMatchObject({
status: "unknown",
omitted_count: null,
});
const changed = result.graph.edges.filter(
({ relation }) => relation === "changed_from",
);
expect(changed.length).toBeGreaterThan(0);
for (const edge of changed)
expect(edge.evidence.coverage.status).toBe("unknown");
// Unknown wins over a known truncation on the other side.
expect(compareWith(truncated, unknown(status)).coverage.status).toBe(
"unknown",
);
},
);
it("keeps a known truncation when both graphs report their coverage", () => {
expect(compareWith(truncated, completeCoverage).coverage.status).toBe(
"truncated",
);
});
it("refuses an unknown status that the source graphs do not support", () => {
const result = compare();
expect(() =>
ownedApplicationVersionComparisonResultSchema.parse({
...result,
coverage: { ...result.coverage, status: "unknown" },
}),
).toThrow(/unknown exactly when/u);
});
});