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)
This commit is contained in:
N0zoM1z0
2026-10-06 00:10:31 +08:00
committed by GitHub
parent 205a977777
commit ea9c3dab6b
12 changed files with 253 additions and 31 deletions
@@ -0,0 +1,49 @@
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();
}
});
});