mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 14:05:49 +00:00
test(evidence): consolidate bundle comparison proof at the MCP boundary (#12813)
* test(evidence): verify bundle source retention through MCP * test(evidence): verify retention without explicit record pairs
This commit is contained in:
1 parent
86acb2a964
commit
adb8e2ea35
2 files changed
+13
-52
No files matched your search
@@ -1,43 +0,0 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { AnalysisInputError } from "../../domain/analysisErrorCore.js";
|
||||
import { createEvidence } from "../../domain/evidence.js";
|
||||
import { createEvidenceBundle } from "../../domain/evidenceBundle.js";
|
||||
import { unknownTarget } from "../../domain/targetIdentity.js";
|
||||
import { bundleComparisonExecution } from "./BundleComparisonEvidence.js";
|
||||
|
||||
const PROVIDER = { id: "fixture", name: "Fixture", version: "1" } as const;
|
||||
const evidence = (label: string) =>
|
||||
createEvidence(unknownTarget("not-observed"), PROVIDER, {
|
||||
operation: "observe",
|
||||
parameters: { label },
|
||||
result: { label },
|
||||
confidence: "derived",
|
||||
authority: "analyst-inference",
|
||||
});
|
||||
|
||||
it("returns a missing record pair as a typed input failure", () => {
|
||||
const leftRecord = evidence("left");
|
||||
const rightRecord = evidence("right");
|
||||
const left = createEvidenceBundle([leftRecord]);
|
||||
const right = createEvidenceBundle([rightRecord]);
|
||||
const failed = bundleComparisonExecution({
|
||||
left,
|
||||
right,
|
||||
recordPairs: [
|
||||
{
|
||||
left_evidence_id: evidence("missing").evidence_id,
|
||||
right_evidence_id: rightRecord.evidence_id,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(failed.ok).toBe(false);
|
||||
if (failed.ok) throw new Error("Expected a failure");
|
||||
expect(failed.error).toBeInstanceOf(AnalysisInputError);
|
||||
const compared = bundleComparisonExecution({ left, right, recordPairs: [] });
|
||||
if (!compared.ok) throw compared.error;
|
||||
expect(compared.value.sources).toEqual([leftRecord, rightRecord]);
|
||||
expect(compared.value.evidence.evidence_links).toEqual(
|
||||
expect.arrayContaining([leftRecord.evidence_id, rightRecord.evidence_id]),
|
||||
);
|
||||
});
|
||||
@@ -227,7 +227,7 @@ it("requires absolute bundle paths without changing server-cwd semantics", async
|
||||
});
|
||||
|
||||
describe("bundle comparison MCP integration", () => {
|
||||
it("reads caller-selected bundle files and returns complete Evidence", async () => {
|
||||
it("retains both sources from caller-selected bundles without explicit pairs", async () => {
|
||||
const root = await createTestTempDirectory("rea-bundle-mcp-");
|
||||
const leftPath = join(root, "left.json");
|
||||
const rightPath = join(root, "right.json");
|
||||
@@ -250,19 +250,23 @@ describe("bundle comparison MCP integration", () => {
|
||||
arguments: {
|
||||
left_bundle_path: leftPath,
|
||||
right_bundle_path: rightPath,
|
||||
record_pairs: [
|
||||
{
|
||||
left_evidence_id: leftRecord.evidence_id,
|
||||
right_evidence_id: rightRecord.evidence_id,
|
||||
},
|
||||
],
|
||||
record_pairs: [],
|
||||
},
|
||||
});
|
||||
expect(result.isError).not.toBe(true);
|
||||
expect(result.structuredContent).toMatchObject({
|
||||
normalized_result: { status: "changed" },
|
||||
const evidence = toolContract("compare_bundles").outputSchema.parse(
|
||||
result.structuredContent,
|
||||
);
|
||||
expect(evidence).toMatchObject({
|
||||
normalized_result: { status: "unknown", summary: { unresolved: 2 } },
|
||||
evidence_links: [leftRecord.evidence_id, rightRecord.evidence_id],
|
||||
evidence_id: expect.stringMatching(/^ev_[a-f0-9]{64}$/u),
|
||||
});
|
||||
const retained = connected.session.exportEvidenceBundle().records;
|
||||
expect(retained).toHaveLength(3);
|
||||
expect(retained).toEqual(
|
||||
expect.arrayContaining([leftRecord, rightRecord, evidence]),
|
||||
);
|
||||
} finally {
|
||||
await connected.close();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user