Files
rea/tests/boundary/mcp/inlineEvidenceCompositionMcp.test.ts
T
morluto 63bf91405c refactor!: enforce canonical evidence and provider boundaries
Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership.

Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers.

BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
2026-10-09 20:18:52 +08:00

52 lines
2.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { toolContract } from "../../../src/contracts/toolContracts.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
import { parseEvidenceBundle } from "../../../src/domain/evidenceBundle.js";
import { connectGhidraMcp } from "./ghidraMcpHarness.js";
describe("inline MCP Evidence composition", () => {
it("feeds returned function Evidence directly to comparison and matches the bundle", async () => {
const harness = await connectGhidraMcp("inline-function-evidence");
const { mcp, session } = harness;
try {
const response = await mcp.callTool({
name: "analyze_function",
arguments: { procedure: "fixture_main" },
});
expect(response.isError).not.toBe(true);
const analyzed = toolContract("analyze_function").outputSchema.parse(
response.structuredContent,
);
const comparison = await mcp.callTool({
name: "compare_functions",
arguments: { left: analyzed, right: analyzed },
});
expect(comparison.isError).not.toBe(true);
const inline = parseEvidence(analyzed);
expect(inline.normalized_result).toEqual(analyzed.normalized_result);
expect(session.evidenceById(inline.evidence_id)).toEqual(inline);
const compared = toolContract("compare_functions").outputSchema.parse(
comparison.structuredContent,
);
const comparisonEvidence = parseEvidence(compared);
expect(comparisonEvidence.evidence_links).toContain(inline.evidence_id);
expect(comparisonEvidence.normalized_result).toEqual(
compared.normalized_result,
);
const bundle = await mcp.callTool({
name: "get_evidence_bundle",
arguments: {},
});
const exported = toolContract("get_evidence_bundle").outputSchema.parse(
bundle.structuredContent,
);
const retained = parseEvidenceBundle(exported.result);
expect(retained.records).toContainEqual(inline);
expect(retained.records).toContainEqual(comparisonEvidence);
} finally {
await harness.close();
}
});
});