feat(wasm): compare retained core-module interfaces (#2464)

Squash merge of https://github.com/morluto/rea/pull/2464.

Co-authored-by: Thang Luu <76550342+thangldw@users.noreply.github.com>
This commit is contained in:
Thang Luu
2026-10-13 23:49:04 +08:00
committed by GitHub
co-authored by Thang Luu
parent 75e7965dc3
commit 911894d758
29 changed files with 1757 additions and 54 deletions
+36
View File
@@ -1,3 +1,7 @@
import { compareWasmInterfaces } from "../application/wasm/WasmInterfaceComparisonService.js";
import { COMPARE_WASM_INTERFACES_CONTRACT } from "../contracts/wasm/wasmComparisonContracts.js";
import { resolvePairedEvidenceRequest } from "../application/EvidenceInputResolver.js";
import { recordSessionEvidenceSources } from "./sessionEvidence.js";
import type { EvidenceMcpServer } from "./EvidenceMcpServer.js";
import type { WasmArtifactService } from "../application/wasm/WasmArtifactService.js";
@@ -21,6 +25,38 @@ export const registerWasmTools = (
withAdmittedAnalysis?: WithAdmittedAnalysis,
evidenceById?: EvidenceLookup,
): void => {
const comparison = COMPARE_WASM_INTERFACES_CONTRACT;
const compareHandler = createEvidenceToolHandler(
server,
async (rawInput, options) => {
const input = comparison.inputSchema.safeParse(rawInput);
if (!input.success)
return err(
analysisInputErrorFromIssues(
comparison.name,
input.error.issues,
rawInput,
),
);
const sources = resolvePairedEvidenceRequest(input.data, evidenceById);
if (!sources.ok) return sources;
const result = await compareWasmInterfaces(sources.value, options);
if (!result.ok) return result;
const recorded = recordSessionEvidenceSources(recordEvidence, [
sources.value.left,
sources.value.right,
]);
return recorded.ok ? result : recorded;
},
logger,
recordEvidence,
withAdmittedAnalysis,
);
server.registerTool(
comparison.name,
toolRegistrationOptions(comparison),
compareHandler(comparison),
);
const contract = wasmArtifactModule.contract;
const handler = createEvidenceToolHandler(
server,