Files
morluto 88fd8a9df0 test: drop detail requests the budget seed made redundant (#14615)
PR #14252 added explicit complete-detail requests across tests before the
vitest REA_AGENT_RESULT_BUDGET_BYTES seed and the complete-Evidence harness
existed. Restore the pre-#14252 form where the seed or the harness already
delivers complete Evidence.

Keep the requests that are load-bearing: delivery, summary and budget tests,
tools whose omitted detail is summary, and callers that neither the seed nor
the harness reaches (unwrapped SDK clients on servers with an explicit
environment, and in-process CLIs). Those were found by running the touched
files with the shipped budget lowered to its 4 KiB minimum.
2026-11-25 21:08:12 +00:00

77 lines
3.2 KiB
TypeScript

import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { createServer } from "../../src/server/createServer.js";
import { createTestBinarySession } from "../fixtures/binarySession.js";
import { realpath, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, expect } from "vitest";
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
import { cliTest } from "../support/cli/cliFixture.js";
import { ByteEntropyService } from "../../src/application/binaryDiagnostics/ByteEntropyService.js";
import { parseEvidence } from "../../src/domain/evidence.js";
import { createMcpSchemaValidation } from "../fixtures/mcpSchemaValidation.js";
describe.skipIf(process.platform !== "win32")(
"Windows selected-file spelling",
() => {
cliTest(
"shares entropy identity across service/MCP admission and CLI case spellings",
async ({ cli }) => {
const root = await realpath(
await createTestTempDirectory("rea-EntropyCase-"),
);
const path = join(root, "Sample.BIN");
await writeFile(path, Buffer.from([1, 2, 3, 4]));
const service = new ByteEntropyService();
const session = createTestBinarySession(() => {
throw new Error("No analysis provider should start");
});
const server = createServer({ kind: "session", session });
const client = new Client(
{ name: "entropy-case", version: "1" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
await client.connect(clientTransport);
try {
const ids = new Set<string>();
for (const spelling of [
path,
path.toUpperCase(),
path.toLowerCase(),
path.replaceAll("\\", "/"),
`${root}\\.\\Sample.BIN`,
]) {
const direct = await service.inspect({ path: spelling });
if (!direct.ok) throw direct.error;
const fromCli = await cli.run({
arguments: ["inspect-byte-entropy", spelling, "--json"],
});
expect(fromCli.exitCode, fromCli.stderr).toBe(0);
const evidence = parseEvidence(fromCli.json);
const response = await client.callTool({
name: "inspect_byte_entropy",
arguments: { path: spelling },
});
expect(response.isError).not.toBe(true);
const mcpEvidence = parseEvidence(response.structuredContent);
ids.add(mcpEvidence.evidence_id);
expect(mcpEvidence.caller_input_path).toBe(spelling);
ids.add(evidence.evidence_id);
ids.add(direct.value.evidence_id);
expect(direct.value.caller_input_path).toBe(spelling);
expect(evidence.caller_input_path).toBe(spelling);
}
expect(ids.size).toBe(1);
} finally {
await client.close();
await server.close();
await session.close();
await service.close();
}
},
);
},
);