chore: integrate canonical Evidence changes for MCP error delivery

This commit is contained in:
N0zoM1z0
2026-10-09 12:43:17 +00:00
643 changed files with 12727 additions and 10243 deletions
@@ -155,7 +155,7 @@ describe.skipIf(process.platform !== "darwin")(
});
expect(inspected.isError, JSON.stringify(inspected)).not.toBe(true);
expect(inspected.structuredContent).toMatchObject({
result: {
normalized_result: {
value: {
CFBundleExecutable: "App",
CFBundleIdentifier: "dev.rea.encoding",
@@ -154,8 +154,8 @@ const analyzeThroughStdioMcp = async (
expect.arrayContaining([expect.objectContaining({ type: "text" })]),
);
const result = z
.object({ result: javascriptApplicationAnalysisResultSchema })
.parse(response.structuredContent).result;
.object({ normalized_result: javascriptApplicationAnalysisResultSchema })
.parse(response.structuredContent).normalized_result;
expect(result).toMatchObject({
input_path: inputPath,
format: "directory",
@@ -140,10 +140,10 @@ describe("production stdio runtime", () => {
const observation = evidenceResultOf(z.literal("fixture")).parse(
result.structuredContent,
);
const evidence = parseEvidence(observation.evidence);
const evidence = parseEvidence(observation);
expect(evidence.operation).toBe("current_document");
expect(evidence.provider.id).toBe("hopper");
expect(evidence.normalized_result).toBe(observation.result);
expect(evidence.normalized_result).toBe(observation.normalized_result);
expect(records).toContainEqual(
expect.objectContaining({
application: "rea",
@@ -1,63 +0,0 @@
import { execFile } from "node:child_process";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { expect, it } from "vitest";
import { z } from "zod";
import { GENERATED_MCP_TOOL_CATALOG } from "../../src/generatedMcpToolCatalog.js";
const execute = promisify(execFile);
const fixture = fileURLToPath(
new URL("../fixtures/contractPresentation.mjs", import.meta.url),
);
const resultSchema = z.object({
catalog: z.array(
z.object({
name: z.string(),
inputSchema: z.record(z.string(), z.unknown()),
outputSchema: z.record(z.string(), z.unknown()),
}),
),
responses: z.array(
z.object({ name: z.string(), response: z.record(z.string(), z.unknown()) }),
),
});
it.each(["original", "reversed"])(
"preserves advertised schemas and handler meaning with %s presentation",
async (presentation) => {
const { stdout } = await execute(
process.execPath,
[fixture, presentation],
{
timeout: 20_000,
maxBuffer: 16 * 1024 * 1024,
},
);
const result = resultSchema.parse(JSON.parse(stdout));
expect(result.catalog).toHaveLength(GENERATED_MCP_TOOL_CATALOG.length);
expect(new Set(result.catalog.map(({ name }) => name))).toEqual(
new Set(GENERATED_MCP_TOOL_CATALOG.map(({ name }) => name)),
);
for (const advertised of result.catalog) {
const canonical = GENERATED_MCP_TOOL_CATALOG.find(
({ name }) => name === advertised.name,
);
expect(advertised.inputSchema).toEqual(canonical?.inputSchema);
expect(advertised.outputSchema).toEqual(canonical?.outputSchema);
}
for (const { name, response } of result.responses) {
if (name === "reconcile_javascript_runtime") {
expect(response.isError).not.toBe(true);
expect(response.structuredContent).toMatchObject({
evidence: { operation: name },
});
} else {
expect(response.isError, name).toBe(true);
expect(response.structuredContent, name).toMatchObject({
error: { details: { operation: name } },
});
}
}
},
);
@@ -103,7 +103,7 @@ it("reports real HAR heap exhaustion through CLI and MCP and preserves server us
});
expect(control.isError, JSON.stringify(control)).not.toBe(true);
expect(control.structuredContent).toMatchObject({
result: { total_records: 2 },
normalized_result: { total_records: 2 },
});
await truncate(path, WEB_NETWORK_CAPTURE_LIMITS.inputBytes + 1);
const oversized = await call("inspect_web_network_capture", {
@@ -39,7 +39,7 @@ it("observes a real Node Inspector and releases attachments after cancellation a
const targets = toolContract(
"list_javascript_runtime_targets",
).outputSchema.parse(discovery.structuredContent);
const id = targets.result.targets[0]?.target_id;
const id = targets.normalized_result.targets[0]?.target_id;
if (id === undefined) throw new Error("Node Inspector target was not listed");
const request = {
inspector_endpoint: endpoint,
@@ -50,7 +50,7 @@ it("observes a real Node Inspector and releases attachments after cancellation a
const observation = toolContract(
"observe_javascript_runtime",
).outputSchema.parse(observed.structuredContent);
expect(observation.result.scripts.items).toEqual(
expect(observation.normalized_result.scripts.items).toEqual(
expect.arrayContaining([
expect.objectContaining({
location: expect.objectContaining({ file_path: fixture }),
@@ -231,12 +231,12 @@ captureTest.each(["unknown", "truncated"] as const)(
const capture = toolContract("capture_process_scenario").outputSchema.parse(
captured.structuredContent,
);
const source = capture.evidence;
const source = capture;
if (status === "unknown")
expect(
capture.result.frames.map((frame) => frame.data).join(""),
capture.normalized_result.frames.map((frame) => frame.data).join(""),
).toContain("value ordinary-evidence caller-value");
else expect(capture.result.truncated).toBe(true);
else expect(capture.normalized_result.truncated).toBe(true);
const environment = await call("capture_process_scenario", {
executable: "/usr/bin/printenv",
arguments: ["1"],
@@ -245,15 +245,15 @@ captureTest.each(["unknown", "truncated"] as const)(
const environmentEnvelope = toolContract(
"capture_process_scenario",
).outputSchema.parse(environment.structuredContent);
const received = environmentEnvelope.result.frames
const received = environmentEnvelope.normalized_result.frames
.map((frame) => frame.data)
.join("");
expect(received).toBe("numbered\r\n");
expect(await readFile(join(root, "state"), "utf8")).toBe("selected");
expect(capture.result.filesystem_effects).toEqual(
expect(capture.normalized_result.filesystem_effects).toEqual(
expect.arrayContaining([expect.objectContaining({ status: "created" })]),
);
expect(capture.result.cleanup).toMatchObject({
expect(capture.normalized_result.cleanup).toMatchObject({
owned_process_group: "verified",
temporary_root: "removed",
});
@@ -265,7 +265,7 @@ captureTest.each(["unknown", "truncated"] as const)(
const comparison = toolContract(
"compare_process_captures",
).outputSchema.parse(compared.structuredContent);
expect(comparison.result.status).toBe(status);
expect(comparison.normalized_result.status).toBe(status);
const verification = await call("verify_reconstruction", {
specification: {
name: "Self comparison retains uncertainty",
@@ -282,7 +282,7 @@ captureTest.each(["unknown", "truncated"] as const)(
});
expect(verification.isError, JSON.stringify(verification)).not.toBe(true);
expect(verification.structuredContent).toMatchObject({
result: {
normalized_result: {
status: "unknown",
claims: {
items: [
@@ -299,11 +299,11 @@ captureTest.each(["unknown", "truncated"] as const)(
},
});
const behavior = await call("find_changed_behavior", {
comparisons: [comparison.evidence],
comparisons: [comparison],
});
expect(behavior.isError, JSON.stringify(behavior)).not.toBe(true);
expect(behavior.structuredContent).toMatchObject({
result: { behavior_status: status },
normalized_result: { behavior_status: status },
});
const unknowns = await call("list_unknowns", {
domain: "process-comparison",
@@ -336,9 +336,7 @@ captureTest.each(["unknown", "truncated"] as const)(
path,
"--json",
]);
expect(parseEvidence(JSON.parse(cliComparison.stdout))).toEqual(
comparison.evidence,
);
expect(parseEvidence(JSON.parse(cliComparison.stdout))).toEqual(comparison);
},
);
@@ -358,15 +356,15 @@ captureTest(
const capture = toolContract("capture_process_scenario").outputSchema.parse(
response.structuredContent,
);
expect(capture.result.frames.map((frame) => frame.data).join("")).toContain(
"stdin-byte:0",
);
expect(capture.result.manifest.scenario).toMatchObject({
expect(
capture.normalized_result.frames.map((frame) => frame.data).join(""),
).toContain("stdin-byte:0");
expect(capture.normalized_result.manifest.scenario).toMatchObject({
environment: {},
filesystem_observation_paths: [],
terminal: { columns: 80, rows: 24, scrollback: 1000 },
});
expect(capture.result.interaction_events).toEqual(
expect(capture.normalized_result.interaction_events).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: "input",
+1 -1
View File
@@ -67,6 +67,6 @@ cliTest(
});
expect(response.isError).not.toBe(true);
const expected = cliResponse.json;
expect(response.structuredContent).toMatchObject({ evidence: expected });
expect(response.structuredContent).toEqual(expected);
},
);
@@ -86,9 +86,7 @@ cliTest(
},
});
expect(mcpResponse.isError, JSON.stringify(mcpResponse)).not.toBe(true);
expect(mcpResponse.structuredContent).toMatchObject({
evidence: response.json,
});
expect(mcpResponse.structuredContent).toEqual(response.json);
const invalid = await cli.run({
arguments: [
"trace-web-source-location",