diff --git a/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts b/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts index 948670fb41..7834ee50a6 100644 --- a/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts +++ b/src/contracts/javascript/javascriptApplicationWorkflowExamples.ts @@ -1,4 +1,4 @@ -import { jsonObjectSchema } from "../../domain/jsonValue.js"; +import type { JsonValue } from "../../domain/jsonValue.js"; import { createEvidence } from "../../domain/evidence.js"; import { readRuntimeReconciliationInput, @@ -73,7 +73,7 @@ export const JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE = { }; /** Historical source inventory compared with inline application Evidence. */ -export const SOURCE_TO_BUNDLE_COMPARISON_EXAMPLE = jsonObjectSchema.parse({ +export const SOURCE_TO_BUNDLE_COMPARISON_EXAMPLE = { reference: createHistoricalSourceGraph({ schema: "HistoricalSourceGraph", authority: "historical-reference", @@ -112,4 +112,4 @@ export const SOURCE_TO_BUNDLE_COMPARISON_EXAMPLE = jsonObjectSchema.parse({ limitations: [], }), application: JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE, -}); +} satisfies Readonly>; diff --git a/src/domain/referenceSourceGraph.test.ts b/src/domain/referenceSourceGraph.test.ts index 7f0576763f..70cdfb8f69 100644 --- a/src/domain/referenceSourceGraph.test.ts +++ b/src/domain/referenceSourceGraph.test.ts @@ -131,6 +131,25 @@ describe("historical source graph", () => { ).toThrow(/Unicode code point/u); }); + it("omits absent local diagnostics and rejects explicitly undefined non-JSON metadata", () => { + const input = graphInput(); + const graph = createHistoricalSourceGraph(input); + expect( + graph.entries.every( + (entry) => !Object.hasOwn(entry, "local_diagnostics"), + ), + ).toBe(true); + expect(() => + createHistoricalSourceGraph({ + ...input, + entries: input.entries.map((entry) => ({ + ...entry, + local_diagnostics: undefined, + })), + }), + ).toThrow(); + }); + it("builds and verifies internal root and manifest commitments", () => { const graph = createHistoricalSourceGraph(graphInput()); const first = createHistoricalSourceManifest(graph); diff --git a/src/domain/referenceSourceGraph.ts b/src/domain/referenceSourceGraph.ts index 9ac3163ff3..80a1ce6dbb 100644 --- a/src/domain/referenceSourceGraph.ts +++ b/src/domain/referenceSourceGraph.ts @@ -41,7 +41,7 @@ const entryBaseShape = { classifications: z.array(classificationSchema).min(1), limitations: z.array(boundedTextSchema), // Host presentation is retained evidence, separate from relocatable semantics. - local_diagnostics: z.array(boundedTextSchema).optional(), + local_diagnostics: z.array(boundedTextSchema).exactOptional(), }; const sourceFileBaseShape = {