From b6e40dc9141e2b3deaaa58096747bcbf0b1384d2 Mon Sep 17 00:00:00 2001 From: 2SinceJuly <202121119+2SinceJuly@users.noreply.github.com> Date: Fri, 13 Nov 2026 03:54:11 +0800 Subject: [PATCH] fix(artifacts): compare Evidence by identity across a replay session The composed-workflow test opened a second fixture, which writes its own temp artifact, so a replay record's subject path and the session-attributed provider selection no longer matched the snapshot copy. Both are display metadata outside the Evidence id; the provider call is what establishes the binding here, so compare the content the id commits to and assert the ids separately, which the test already does. Also apply the formatter to BinarySessionInvestigation.test.ts, which fails format:check on its own. --- .../binary/BinarySessionInvestigation.test.ts | 14 +++++----- .../composedWorkflowEvidenceLinks.test.ts | 27 +++++++++++++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/application/binary/BinarySessionInvestigation.test.ts b/src/application/binary/BinarySessionInvestigation.test.ts index edd33d42f39..d952adf386b 100644 --- a/src/application/binary/BinarySessionInvestigation.test.ts +++ b/src/application/binary/BinarySessionInvestigation.test.ts @@ -280,12 +280,14 @@ it("adopts a later recording's selection without erasing retained display metada // selected path; adopting the bundle's later selection must keep that path. const foreign = createEvidenceBundle([observation("provider_run")]); expect(session.importEvidenceBundle(foreign).ok).toBe(true); - expect(session.recordEvidence( - withEvidenceCallerInputPath( - observation("provider_run"), - "/selected/app.bin", - ), - ).ok).toBe(true); + expect( + session.recordEvidence( + withEvidenceCallerInputPath( + observation("provider_run"), + "/selected/app.bin", + ), + ).ok, + ).toBe(true); const [record] = session.exportEvidenceBundle().records; expect(record?.caller_input_path).toBe("/selected/app.bin"); expect(record?.provider_selection).toMatchObject({ diff --git a/tests/boundary/filesystem/composedWorkflowEvidenceLinks.test.ts b/tests/boundary/filesystem/composedWorkflowEvidenceLinks.test.ts index 2fc5678cdde..e8bc8fbb611 100644 --- a/tests/boundary/filesystem/composedWorkflowEvidenceLinks.test.ts +++ b/tests/boundary/filesystem/composedWorkflowEvidenceLinks.test.ts @@ -5,7 +5,11 @@ import { ok } from "../../../src/domain/result.js"; import { createDeferred } from "../../fixtures/binarySession.js"; import { expect, it } from "vitest"; import { runDirectAnalysis } from "../../../src/application/DirectAnalysis.js"; -import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js"; +import { + createEvidence, + evidenceSemanticContent, + parseEvidence, +} from "../../../src/domain/evidence.js"; import { composedWorkflowFixture } from "../../fixtures/composedWorkflowEvidence.js"; import { readFile, writeFile } from "node:fs/promises"; import { dirname, join } from "node:path"; @@ -403,11 +407,24 @@ it("reruns an ambiguous snapshot binding before selecting composed Evidence link const originalRecord = snapshot.value.evidence_bundle.records.find( ({ evidence_id }) => evidence_id === initial.value.evidenceId, ); - expect(replay.session.evidenceById(after.value.evidenceId)).toEqual( - originalRecord, + if (originalRecord === undefined) + throw new Error("Snapshot did not carry the initial record"); + const replayedRecord = replay.session.evidenceById(after.value.evidenceId); + if (replayedRecord === undefined) + throw new Error("Replay did not commit the reproduced record"); + // The replay session opens a different temp copy of the artifact, so the + // subject's display path and the session-attributed provider selection are + // presentation metadata, not part of the id. Compare what the id commits to. + expect(evidenceSemanticContent(replayedRecord)).toEqual( + evidenceSemanticContent(originalRecord), ); - expect(replay.session.evidenceById(alternative.evidence_id)).toEqual( - alternative, + const replayedAlternative = replay.session.evidenceById( + alternative.evidence_id, + ); + if (replayedAlternative === undefined) + throw new Error("Replay did not carry the alternative record"); + expect(evidenceSemanticContent(replayedAlternative)).toEqual( + evidenceSemanticContent(alternative), ); const composed = await executeComposedWorkflow(