Files
reverse-engineering-anything/tests/boundary/mcp/inlineEvidenceCompositionMcp.test.ts
N0zoM1z0 ea9c3dab6b fix(mcp): return complete inline Evidence records (#585)
Return complete canonical Evidence records inline, including normalized_result, and preserve direct comparison and retained bundle identity.

Verified full deterministic gate, real Linux Ghidra CLI/MCP and independently installed artifact, generic package acceptance, private local samples, and targeted updates after syncing main.

Closes #551

Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
2026-10-06 00:10:31 +08:00

50 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.evidence, right: analyzed.evidence },
});
expect(comparison.isError).not.toBe(true);
const inline = parseEvidence(analyzed.evidence);
expect(inline.normalized_result).toEqual(analyzed.result);
expect(session.evidenceById(inline.evidence_id)).toEqual(inline);
const compared = toolContract("compare_functions").outputSchema.parse(
comparison.structuredContent,
);
const comparisonEvidence = parseEvidence(compared.evidence);
expect(comparisonEvidence.evidence_links).toContain(inline.evidence_id);
expect(comparisonEvidence.normalized_result).toEqual(compared.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();
}
});
});