mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 14:05:49 +00:00
fix(mcp): retain partial Playwright trace Evidence on failed imports (#9543)
This commit is contained in:
2 files changed
+47
-1
No files matched your search
@@ -42,8 +42,13 @@ export const registerPlaywrightTraceTool = (
|
||||
contract.name,
|
||||
() => service.inspect(input, context.mcpReq.signal),
|
||||
);
|
||||
// A failed import can carry partial Evidence; retain it for views.
|
||||
if (!result.ok)
|
||||
return server.delivery.toCallToolResult(result, contract);
|
||||
return server.delivery.toPartialErrorToolResult(
|
||||
result.error,
|
||||
contract.returnsTargetContent,
|
||||
options.recordEvidence,
|
||||
);
|
||||
return deliverApplicationEvidence(
|
||||
server,
|
||||
options,
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
playwrightTracePathFixture,
|
||||
} from "../../fixtures/playwrightTrace.js";
|
||||
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
|
||||
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
|
||||
import { advertisedMcpToolSchemas } from "../../fixtures/advertisedMcpTool.js";
|
||||
import { parseEvidence, type Evidence } from "../../../src/domain/evidence.js";
|
||||
import { playwrightTraceSchema } from "../../../src/domain/playwrightTrace/playwrightTrace.js";
|
||||
@@ -431,3 +432,43 @@ cliTest(
|
||||
expect(requests).toBe(0);
|
||||
},
|
||||
);
|
||||
|
||||
cliTest(
|
||||
"retains partial MCP Evidence when a trace stream fails after earlier streams were read",
|
||||
async () => {
|
||||
const fixture = await playwrightTraceFixture({ level: 0 });
|
||||
const bytes = await readFile(fixture.path);
|
||||
// A stored network byte breaks only that member's ZIP CRC.
|
||||
const offset = bytes.indexOf(Buffer.from('"method":"GET"'));
|
||||
expect(offset).toBeGreaterThan(0);
|
||||
bytes[offset + 10] = 80;
|
||||
await writeFile(fixture.path, bytes);
|
||||
const { call } = await connectLocalToolsMcp({
|
||||
REA_MCP_TOOL_FAMILIES: "application,session",
|
||||
PLAYWRIGHT_BROWSERS_PATH: "/rea-no-browser-required",
|
||||
});
|
||||
const failed = parseMcpToolError(
|
||||
await call("inspect_playwright_trace", {
|
||||
path: fixture.path,
|
||||
detail: "complete",
|
||||
}),
|
||||
);
|
||||
const reference = failed.error.details?.partial_observation;
|
||||
expect(reference).toEqual({
|
||||
kind: "retained-evidence",
|
||||
evidence_id: expect.any(String),
|
||||
});
|
||||
const { evidence_id } = reference as { evidence_id: string };
|
||||
const page = await call("inspect_analysis_view", {
|
||||
source: { kind: "retained-evidence", evidence_id },
|
||||
view: { kind: "playwright-trace", collection: "events", fields: [] },
|
||||
});
|
||||
expect(page.isError, JSON.stringify(page.content)).not.toBe(true);
|
||||
expect(
|
||||
parseEvidence(page.structuredContent).normalized_result,
|
||||
).toMatchObject({
|
||||
coverage: { total: 20, exhausted: true },
|
||||
source_coverage: { interpretation: "partial" },
|
||||
});
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user