refactor!: simplify runtime tools and remove replay engines (#572)

* fix(hopper): report unavailable procedure body coverage

* refactor!: simplify runtime tools and remove replay engines

Keep direct inspection, capture, and comparison tools. Bind handlers to named contracts and let agents compose experiments with commands and local fixture servers.

BREAKING CHANGE: Remove controlled replay, Node characterization, finite replay-machine, managed runtime planning, and redundant string-tracing tools. Retire process replay, shims, reactive scenarios, custom checkpoints, and active browser replay and origin-scope inputs.
This commit is contained in:
morluto
2026-10-05 21:15:04 +08:00
committed by GitHub
parent c6d3bdf597
commit e07b81649e
258 changed files with 1193 additions and 22444 deletions
@@ -81,7 +81,6 @@ const captureFor = (scenario: BrowserScenario): BrowserScenarioCapture => {
},
scenario: {
start_origin: new URL(start).origin,
allowed_origins: scenario.allowed_origins,
action_count: scenario.actions.length,
secret_references: scenario.secrets.map(({ secret_id: id }) => id),
},
@@ -109,7 +108,6 @@ const minimalScenario = (origin = "https://app.example.test") => ({
executable_path: process.execPath,
},
start_url: { url: `${origin}/`, query: [] },
allowed_origins: [origin],
actions: [
{
step_id: "settle",
@@ -173,7 +171,6 @@ describe("browser scenario MCP tool", () => {
expect(provider.scenarios[0]).toMatchObject({
environment: { color_scheme: "light", service_workers: "block" },
storage: { cookies: [], local_storage: [], session_storage: [] },
request_replay: { mode: "disabled" },
capture: { after_each_step: [], at_end: ["url"], events: [] },
});
-1
View File
@@ -18,6 +18,5 @@ describe("MCP server composition", () => {
expect(client.getInstructions()).not.toContain("open_binary");
const names = (await client.listTools()).tools.map(({ name }) => name);
expect(names).not.toContain("compare_managed_members");
expect(names).not.toContain("plan_managed_runtime_correlation");
});
});
@@ -214,7 +214,6 @@ describe("enhanced MCP tools", () => {
["analyze_function", { procedure: "0x1" }],
["inspect_native_api", { procedure: "0x1" }],
["trace_feature", { query: "hello" }],
["find_code_for_string", { query: "hello" }],
["trace_call_path", { start: "0x1", goal: "0x2" }],
["trace_native_ui_action", { action: "missing-selector" }],
["inspect_native_dispatch_metadata", { max_records: 100 }],
@@ -294,11 +293,6 @@ describe("enhanced MCP tools", () => {
],
});
expect(results[10]).toMatchObject({
query: "hello",
matches: [{ type: "string", address: "0x30", value: "hello" }],
truncated: false,
});
expect(results[11]).toMatchObject({
start: "0x1",
goal: "0x2",
direction: "forward",
@@ -310,11 +304,11 @@ describe("enhanced MCP tools", () => {
],
truncated: false,
});
expect(results[12]).toMatchObject({
expect(results[11]).toMatchObject({
start: "missing-selector",
reason: "ui_action_or_object_not_found",
});
expect(results[13]).toMatchObject({
expect(results[12]).toMatchObject({
target_sha256: "a".repeat(64),
provider: {
id: "fixture",
@@ -327,7 +321,7 @@ describe("enhanced MCP tools", () => {
]),
},
});
expect(results[14]).toMatchObject({
expect(results[13]).toMatchObject({
target_sha256: "a".repeat(64),
decompilations: 1,
unknowns: [
+29 -56
View File
@@ -1,68 +1,42 @@
import { serveStdio } from "@modelcontextprotocol/server/stdio";
import { describe, expect, it } from "vitest";
import { run } from "../../../src/main.js";
import {
createServer,
type CreateServerOptions,
} from "../../../src/server/createServer.js";
type RuntimeDependencies = NonNullable<Parameters<typeof run>[0]>;
import { parseConfig } from "../../../src/config.js";
import { silentLogger } from "../../../src/logger.js";
import { registerConfigReload } from "../../../src/main/reload.js";
import type { RuntimeDependencies } from "../../../src/main/types.js";
import { createRuntimeState } from "../../../src/main/state.js";
describe("runtime configuration reload", () => {
it("updates runtime executable configuration for connected server factories", async () => {
const env: NodeJS.ProcessEnv = {
REA_JAVASCRIPT_REPLAY_NODE_PATH: "/first/node",
REA_MANAGED_RUNTIME_EXECUTABLE_PATH: "/first/dotnet",
};
const runtime = await startRuntime(env);
it("applies a valid configuration reload", () => {
const env: NodeJS.ProcessEnv = { REA_LOG_LEVEL: "info" };
const runtime = setupReload(env);
expect(runtime.options.javascriptReplayConfiguration?.()).toMatchObject({
nodePath: "/first/node",
});
expect(runtime.options.managedRuntimeConfiguration?.()).toEqual({
executablePath: "/first/dotnet",
});
env.REA_JAVASCRIPT_REPLAY_NODE_PATH = "/second/node";
env.REA_MANAGED_RUNTIME_EXECUTABLE_PATH = "/second/dotnet";
env.REA_LOG_LEVEL = "debug";
runtime.reload();
expect(runtime.options.javascriptReplayConfiguration?.()).toMatchObject({
nodePath: "/second/node",
});
expect(runtime.options.managedRuntimeConfiguration?.()).toEqual({
executablePath: "/second/dotnet",
});
expect(runtime.state.currentConfig.logLevel).toBe("debug");
});
it("retains the last valid runtime configuration after an invalid reload", async () => {
const env: NodeJS.ProcessEnv = {
REA_JAVASCRIPT_REPLAY_NODE_PATH: "/valid/node",
REA_MANAGED_RUNTIME_EXECUTABLE_PATH: "/valid/dotnet",
};
const runtime = await startRuntime(env);
it("retains the last valid configuration after an invalid reload", () => {
const env: NodeJS.ProcessEnv = { REA_LOG_LEVEL: "info" };
const runtime = setupReload(env);
env.REA_JAVASCRIPT_REPLAY_BWRAP_PATH = "relative/bwrap";
env.REA_LOG_LEVEL = "invalid";
runtime.reload();
expect(runtime.options.javascriptReplayConfiguration?.()).toMatchObject({
nodePath: "/valid/node",
});
expect(runtime.options.managedRuntimeConfiguration?.()).toEqual({
executablePath: "/valid/dotnet",
});
expect(runtime.state.currentConfig.logLevel).toBe("info");
});
});
const startRuntime = async (env: NodeJS.ProcessEnv) => {
const setupReload = (env: NodeJS.ProcessEnv) => {
const parsed = parseConfig(env);
if (!parsed.ok) throw parsed.error;
const state = createRuntimeState(parsed.value);
let reload: (() => void) | undefined;
let options: CreateServerOptions | undefined;
const dependencies: RuntimeDependencies = {
env,
serve: (factory) => {
void factory({ era: "legacy" });
return { close: () => Promise.resolve() };
},
serve: serveStdio,
writeStderr: () => undefined,
setExitCode: () => undefined,
registerShutdown: () => () => undefined,
@@ -70,14 +44,13 @@ const startRuntime = async (env: NodeJS.ProcessEnv) => {
reload = handler;
return () => undefined;
},
createServer: (analysis, session, received) => {
options = received;
return createServer(analysis, session, received);
},
};
expect(await run(dependencies)).toBe(0);
if (reload === undefined || options === undefined)
throw new Error("Runtime reload seam was not initialized");
return { reload, options };
registerConfigReload({
dependencies,
runtimeState: state,
serverLogger: silentLogger,
});
if (reload === undefined)
throw new Error("Reload handler was not registered");
return { reload, state };
};
-49
View File
@@ -29,13 +29,11 @@ it("opens a managed PE and executes the managed static provider through MCP", as
]),
);
const server = createServer(session, session, {
managedRuntimeConfiguration: () => ({ executablePath: process.execPath }),
availabilityPolicy: () => ({
processCaptureEnabled: false,
investigationInputRoots: 0,
browserObservationEnabled: false,
electronObservationEnabled: false,
javascriptReplayEnabled: false,
}),
});
const client = new Client({ name: "managed-mcp-test", version: "1.0.0" });
@@ -66,7 +64,6 @@ const verifyManagedCatalogAndNativeWorkflow = async (
"compare_managed_members",
"import_managed_reconstruction",
"verify_managed_native_boundaries",
"plan_managed_runtime_correlation",
]),
);
for (const evidence of [
@@ -221,7 +218,6 @@ const verifyManagedComparisonAndReconstruction = async (
expect(method).toBeDefined();
if (method === undefined) return;
await verifyImport(client, members, method);
await verifyRuntimePlan(client, members, method);
};
type ManagedMethod = NonNullable<ReturnType<typeof methodFrom>>;
@@ -278,51 +274,6 @@ const verifyImport = async (
});
};
const verifyRuntimePlan = async (
client: Client,
members: Record<string, unknown>,
method: ManagedMethod,
): Promise<void> => {
const planned = inlineEvidence(
structured(
await client.callTool({
name: "plan_managed_runtime_correlation",
arguments: {
static_members: members,
method: {
token: method.token,
signature_sha256: method.signature.raw_sha256,
normalized_il_sha256: method.body.normalized_il_sha256,
},
requested_effect: "attach",
host: {
os: "linux",
clr_family: "dotnet",
architecture: "x86_64",
},
bounds: {
timeout_ms: 5000,
max_threads: 32,
max_output_bytes: 65536,
allow_network: false,
allow_ui: false,
},
},
}),
),
);
expect(planned).toMatchObject({
operation: "plan_managed_runtime_correlation",
provider: { id: "rea-dotnet-workflows" },
confidence: "derived",
normalized_result: {
executed: false,
requested_runtime: { effect: "attach", network: "none" },
effect_taxonomy: { attaches_process: true },
},
});
};
const structured = (result: CallToolResult): Record<string, unknown> => {
if (
typeof result.structuredContent !== "object" ||
@@ -1,70 +0,0 @@
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { describe, expect, it } from "vitest";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import { REPLAY_MACHINE_RUN_EXAMPLE } from "../../../src/contracts/replayMachineExample.js";
import { createServer } from "../../../src/server/createServer.js";
import { observed } from "../../fixtures/analysisExecution.js";
describe("direct replay machine MCP parity", () => {
it("returns typed journal output and safe validation failures", async () => {
const session = createTestBinarySession(() => ({
execute: () => Promise.resolve(observed(null)),
close: () => Promise.resolve(),
}));
const server = createServer(session, session);
const client = new Client({ name: "replay-machine-test", version: "1" });
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
const example = REPLAY_MACHINE_RUN_EXAMPLE;
try {
await server.connect(serverTransport);
await client.connect(clientTransport);
const result = await client.callTool({
name: "run_replay_machine",
arguments: example,
});
expect(result).toMatchObject({
structuredContent: {
result: {
final_state: "complete",
terminal: true,
decisions: [{ outcome: "matched", transition_sequence: 0 }],
transition_journal: [
{
transition_id: "accept_callback",
captured_aliases: [{ name: "token", sensitive: true }],
},
],
},
},
});
expect(JSON.stringify(result)).not.toContain("opaque");
const invalid = await client.callTool({
name: "run_replay_machine",
arguments: {
...example,
events: [
{
protocol: "http",
connection: "not_applicable",
at_ms: 0,
method: null,
path: "/callback",
headers: {},
body: "private-request-body",
},
],
},
});
expect(invalid.isError).toBe(true);
expect(invalid.structuredContent).toBeUndefined();
expect(JSON.stringify(invalid)).not.toContain("private-request-body");
} finally {
await client.close();
await server.close();
await session.close();
}
});
});
+2 -13
View File
@@ -128,7 +128,7 @@ it("does not record capability unavailability without supporting Evidence", asyn
});
});
it("records approved capture disagreement as a contradicted unknown", async () => {
it("records capture disagreement as a contradicted unknown", async () => {
const session = createTestBinarySession(
() =>
({
@@ -149,17 +149,6 @@ it("records approved capture disagreement as a contradicted unknown", async () =
outcome: "dispatched",
},
],
shim_events: [
{
sequence: 0,
at_ms: 0,
command: "fixture",
route_index: null,
arguments: [],
working_directory: "/tmp",
outcome: "unmatched",
},
],
});
const captureEvidence = (capture: typeof left) =>
createEvidence(undefined, PROCESS_PROVIDER, {
@@ -213,7 +202,7 @@ it("records approved capture disagreement as a contradicted unknown", async () =
{
status: "contradicted",
domain: "process-comparison",
question: "Process captures disagree across: interaction, shim",
question: "Process captures disagree across: interaction",
contradicting_evidence_ids: [rightEvidence.evidence_id],
},
],
@@ -99,24 +99,6 @@ describe("MCP JSON Schema validity", () => {
const { tools } = await client.listTools();
const advertised = new Map(tools.map((tool) => [tool.name, tool]));
const ajv = new Ajv2020({ strict: false, validateFormats: false });
const replayContract = TOOL_CONTRACTS.find(
({ name }) => name === "run_controlled_replay",
);
const replayTool = advertised.get("run_controlled_replay");
if (replayContract === undefined || replayTool === undefined)
throw new Error("Controlled replay tool was not advertised");
const replayExample = replayContract.examples[0];
if (replayExample === undefined)
throw new Error("Controlled replay tool has no valid example");
const invalidReplay = {
...replayExample.input,
cases: [],
};
expect(replayContract.inputSchema.safeParse(invalidReplay).success).toBe(
false,
);
expect(ajv.compile(replayTool.inputSchema)(invalidReplay)).toBe(false);
const graphContract = TOOL_CONTRACTS.find(
({ name }) => name === "project_managed_application_graph",
);