From f1cc48558122a922365a1b71dbf4fb196b037825 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Wed, 22 Jul 2026 21:06:10 +0000 Subject: [PATCH] fix(process): preserve nonconforming differences --- src/domain/processComparison.ts | 1 + tests/processTraceAdapters.test.ts | 48 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/domain/processComparison.ts b/src/domain/processComparison.ts index 3f26d7271..066456a16 100644 --- a/src/domain/processComparison.ts +++ b/src/domain/processComparison.ts @@ -300,6 +300,7 @@ const applyTraceVerdict = ( ): ComparisonStatus => { const exact = dimensions[dimension]; if (!covered.has(dimension)) return exact; + if (trace.verdict === "nonconforming") return exact; if (trace.verdict === "different") return traceShowsDifference ? "changed" : exact; if ( diff --git a/tests/processTraceAdapters.test.ts b/tests/processTraceAdapters.test.ts index 37d1c8176..8607a24e9 100644 --- a/tests/processTraceAdapters.test.ts +++ b/tests/processTraceAdapters.test.ts @@ -294,6 +294,54 @@ describe("declared trace comparison adapters", () => { }); }); + it("does not mask distinct payloads when both traces are nonconforming", () => { + const withTerminal = (data: string) => + processCaptureSchema.parse({ + ...capture, + frames: [{ sequence: 0, at_ms: 1, data }], + event_journal: [ + { + capture_order: 0, + collection: "filesystem_checkpoints", + index: 0, + }, + { capture_order: 1, collection: "frames", index: 0 }, + { capture_order: 2, collection: "lifecycle", index: 0 }, + { capture_order: 3, collection: "lifecycle", index: 1 }, + { + capture_order: 4, + collection: "filesystem_checkpoints", + index: 1, + }, + ], + }); + const specification: ProcessTraceSpecification = { + version: 1, + events: [ + { + id: "expected", + source: "terminal_raw", + exact: { sequence: 0, at_ms: 1, data: "expected" }, + cardinality: { kind: "required" }, + }, + ], + language: { + kind: "finite_traces", + variants: [{ id: "expected", trace: ["expected"] }], + }, + }; + + expect( + compareProcessCaptures(withTerminal("left"), withTerminal("right"), { + traceSpecification: specification, + }), + ).toMatchObject({ + status: "changed", + terminal: "changed", + trace: { verdict: "nonconforming" }, + }); + }); + it("returns identical CLI and MCP results and derived Evidence identity", async () => { const left = captureEvidence("left"); const right = captureEvidence("right");