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.
This commit is contained in:
2SinceJuly committed 2026-11-13 03:54:11 +08:00
1 parent 332c3afedd
commit b6e40dc914
2 files changed
+30 -11

No files matched your search

@@ -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({
@@ -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(