Files
reverse-engineering-anything/tests/support/mcp/artifactSession.ts
T
morluto 60149282fc test: strengthen integration oracles and verification (#8295)
* test: strengthen integration oracles and verification

* test: bound lifecycle gates and strengthen workflow checks

* test: verify complete paged and extracted results

* test: preserve bytecode and cancellation evidence

* test: strengthen retained evidence and fixture cleanup

* test: require cross-projection bridge identities

* test: retain fixture owners through cleanup failures

* test: verify graph examples and project selectors

* test: tighten provider and lifecycle regressions

* test: consolidate hex coverage and bound cutter cleanup

* test: bound subprocess output waits and strengthen graph checks

* test: check mcp recovery and preserve cleanup owners

* test: verify structured mcp argument failures

* test: preserve artifact cleanup and gdb limit evidence

* test: preserve evidence identities and bound provider gates

* test: retain browser and comparison cleanup owners

* test: bound startup and strengthen fixture oracles

* test: bound lifecycle gates and verify recovered evidence

* test: verify public outcomes and lifecycle ownership

* test: assert precise evidence and release lifecycle gates

* test: verify selected facts and bound cleanup waits

* test: check retained evidence and decoded records

* test: verify final reports and retain cleanup ownership

* test: bound reviewed startup gates and retain cleanup

* test: verify PE errors and preserve MCP cleanup

* test: preserve MCP fixture cleanup ownership

* test: release provider gates before late startup
2026-11-01 00:15:28 +08:00

51 lines
1.9 KiB
TypeScript

import type { Client } from "@modelcontextprotocol/client";
import { expect, type OnTestFinishedHandler } from "vitest";
import { createArtifactBinarySession } from "../../../src/composition/binary.js";
import { createServer } from "../../../src/server/createServer.js";
import type { TestMcp } from "./mcpFixture.js";
/** Register session teardown while retaining its owner for a failed-close retry. */
export const ownArtifactSession = (
session: Awaited<ReturnType<typeof createArtifactBinarySession>>,
onTestFinished: (handler: OnTestFinishedHandler) => void,
): void => {
onTestFinished(async () => {
const result = await session.close();
if (!result.ok) throw result.error;
});
};
const openSessionTarget = async (
mcp: TestMcp,
onTestFinished: (handler: OnTestFinishedHandler) => void,
operation: "open_binary" | "open_bundle_resources",
path: string,
): Promise<Client> => {
const session = await createArtifactBinarySession(process.env);
ownArtifactSession(session, onTestFinished);
const client = await mcp.connect(createServer({ kind: "session", session }));
const opened = await client.callTool({
name: operation,
arguments: { path },
});
expect(opened.isError, JSON.stringify(opened.content)).not.toBe(true);
return client;
};
/** Open a static artifact target in the production artifact-only MCP composition. */
export const openArtifactTarget = (
mcp: TestMcp,
onTestFinished: (handler: OnTestFinishedHandler) => void,
path: string,
): Promise<Client> =>
openSessionTarget(mcp, onTestFinished, "open_binary", path);
/** Open a caller-selected bundle resource root in the production MCP session. */
export const openBundleResourcesTarget = (
mcp: TestMcp,
onTestFinished: (handler: OnTestFinishedHandler) => void,
path: string,
): Promise<Client> =>
openSessionTarget(mcp, onTestFinished, "open_bundle_resources", path);