test(application): verify packaged MCP replay
This commit is contained in:
@@ -50,6 +50,20 @@ export async function verifyPackagedInvestigation(input) {
|
|||||||
persisted.runs?.[0]?.status !== "complete"
|
persisted.runs?.[0]?.status !== "complete"
|
||||||
)
|
)
|
||||||
throw new Error("packaged persistent investigation CLI failed");
|
throw new Error("packaged persistent investigation CLI failed");
|
||||||
|
return {
|
||||||
|
arguments: {
|
||||||
|
approved: true,
|
||||||
|
workspace_path: workspacePath,
|
||||||
|
workspace_name: "package-versions",
|
||||||
|
expected_workspace_revision: persisted.revision,
|
||||||
|
replay_run_id: runId,
|
||||||
|
left_path: input.artifactArchive,
|
||||||
|
right_path: artifactArchiveV2,
|
||||||
|
},
|
||||||
|
evidenceId: investigated.evidence_id,
|
||||||
|
workspacePath,
|
||||||
|
revision: persisted.revision,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runJson(command, args, environment) {
|
async function runJson(command, args, environment) {
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ try {
|
|||||||
)
|
)
|
||||||
throw new Error("packaged artifact inventory CLI failed");
|
throw new Error("packaged artifact inventory CLI failed");
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
await verifyPackagedInvestigation({ cli, workspace, evidenceRoot, artifactArchive, environment });
|
const investigationReplay = await verifyPackagedInvestigation({ cli, workspace, evidenceRoot, artifactArchive, environment });
|
||||||
const overview = json(
|
const overview = json(
|
||||||
await run(cli, ["analyze", process.execPath, "--json"], environment),
|
await run(cli, ["analyze", process.execPath, "--json"], environment),
|
||||||
);
|
);
|
||||||
@@ -448,7 +448,10 @@ try {
|
|||||||
const transport = new StdioClientTransport({
|
const transport = new StdioClientTransport({
|
||||||
command: cli,
|
command: cli,
|
||||||
args: ["mcp"],
|
args: ["mcp"],
|
||||||
env: environment,
|
env: {
|
||||||
|
...environment,
|
||||||
|
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([]),
|
||||||
|
},
|
||||||
stderr: "pipe",
|
stderr: "pipe",
|
||||||
});
|
});
|
||||||
let mcpStderr = "";
|
let mcpStderr = "";
|
||||||
@@ -466,6 +469,25 @@ try {
|
|||||||
throw new Error("packaged MCP tool inventory diverged from contracts");
|
throw new Error("packaged MCP tool inventory diverged from contracts");
|
||||||
await prompts.verifyPromptCatalog(client, mcpOptions, prompts.names);
|
await prompts.verifyPromptCatalog(client, mcpOptions, prompts.names);
|
||||||
await prompts.verifyPromptCompletion(client, mcpOptions, false);
|
await prompts.verifyPromptCompletion(client, mcpOptions, false);
|
||||||
|
const replay = await client.callTool(
|
||||||
|
{
|
||||||
|
name: "find_changed_behavior",
|
||||||
|
arguments: { investigation_run: investigationReplay.arguments },
|
||||||
|
},
|
||||||
|
mcpOptions,
|
||||||
|
);
|
||||||
|
const replayEvidence = json(prompts.mcpText(replay));
|
||||||
|
const replayWorkspace = json(
|
||||||
|
await readFile(investigationReplay.workspacePath, "utf8"),
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
replay.isError === true ||
|
||||||
|
replayEvidence.evidence_id !== investigationReplay.evidenceId ||
|
||||||
|
replayWorkspace.revision !== investigationReplay.revision
|
||||||
|
)
|
||||||
|
throw new Error(
|
||||||
|
"packaged MCP did not replay with workspace-only authority",
|
||||||
|
);
|
||||||
const result = await client.callTool(
|
const result = await client.callTool(
|
||||||
{ name: "current_document", arguments: {} },
|
{ name: "current_document", arguments: {} },
|
||||||
mcpOptions,
|
mcpOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user