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
+3 -139
View File
@@ -10,23 +10,12 @@ import {
traceApplicationFeatureRequestSchema,
traceJavaScriptSemanticsRequestSchema,
} from "./applicationWorkflowInputContracts.js";
import {
controlledReplayInputSchema,
controlledReplayOutputSchema,
} from "../domain/javascriptReplay.js";
import {
nodeCharacterizationExecutionInputSchema,
nodeCharacterizationExecutionOutputSchema,
nodeCharacterizationPreparationInputSchema,
nodeCharacterizationPreparationOutputSchema,
} from "../domain/nodeRuntimeCharacterization.js";
import { reconstructionCoverageEvaluationInputSchema } from "../application/ReconstructionCoverageService.js";
import { reconstructionClosureResultSchema } from "../domain/reconstructionCoverage.js";
import {
reconstructionObligationLedgerInputSchema,
reconstructionObligationLedgerSchema,
} from "../domain/reconstructionObligationLedgerSchemas.js";
import { jsonObjectSchema } from "../domain/jsonValue.js";
import type { ToolContract } from "./toolContracts.js";
import { toolContractMetadata } from "./toolEffects.js";
import { evidenceResultOf } from "./toolOutputSchemas.js";
@@ -54,37 +43,6 @@ const reconstructionObligationLedgerOutputSchema = evidenceResultOf(
reconstructionObligationLedgerSchema,
);
const HASH = "0".repeat(64);
const NODE_PREPARATION_EXAMPLE = jsonObjectSchema.parse({
selected_alias: "bundle",
expected_effect: "pure",
instrumentation: {
artifact_path: "/tmp/example/bundle.js",
artifact_sha256: HASH,
selection: {
byte_start: 100,
byte_end: 120,
selected_sha256: HASH,
export_name: "selected",
},
},
replay: {
mode: "plan",
left: {
modules: [
{
alias: "bundle",
path: "/tmp/example/bundle.js",
format: "commonjs-factory",
role: "module",
dependencies: {},
},
],
entry_alias: "bundle",
entry_export: "selected",
},
cases: [{ case_id: "empty", arguments: [""] }],
},
});
/** Provider-neutral graph workflow contracts shared by MCP and CLI adapters. */
export const APPLICATION_TOOL_CONTRACTS = [
@@ -159,7 +117,7 @@ export const APPLICATION_TOOL_CONTRACTS = [
name: "compare_javascript_export_shapes",
...toolContractMetadata("compare_javascript_export_shapes"),
description:
"Compare static return shapes for one exact module/export selector on each authenticated JavaScript Application Graph supplied as inline Evidence. Variants pair only by reciprocal unique literal discriminants; dynamic values, incomplete properties, and ambiguous variants remain unknown. Reports JSON Pointer changes and recommends controlled replay separately without executing JavaScript.",
"Compare static return shapes for one exact module/export selector on each authenticated JavaScript Application Graph supplied as inline Evidence. Variants pair only by reciprocal unique literal discriminants; dynamic values, incomplete properties, and ambiguous variants remain unknown. Reports JSON Pointer changes without executing JavaScript; runtime behavior requires a separate agent-run probe.",
kind: "application",
inputSchema: compareJavaScriptExportShapesRequestSchema,
outputSchema: exportShapeComparisonOutputSchema,
@@ -170,91 +128,6 @@ export const APPLICATION_TOOL_CONTRACTS = [
},
],
},
{
name: "run_controlled_replay",
...toolContractMetadata("run_controlled_replay"),
description:
"Plan or execute a content-bound extracted-module JavaScript replay inside the Linux Bubblewrap, seccomp, and cgroup boundary. Execution requires the exact plan digest. Supports deterministic boundary cases and optional left/right differential comparison; observations have controlled-replay authority and do not claim real application runtime behavior.",
kind: "application",
inputSchema: controlledReplayInputSchema,
outputSchema: controlledReplayOutputSchema,
examples: [
{
title: "Plan one extracted ESM parser replay",
input: {
mode: "plan",
left: {
modules: [
{
alias: "parser",
path: "/tmp/example/parser.mjs",
format: "esm",
role: "module",
dependencies: {},
},
],
entry_alias: "parser",
entry_export: "default",
},
cases: [{ case_id: "empty", arguments: [""] }],
determinism: {
clock_iso: "2000-01-01T00:00:00.000Z",
random_seed: 0,
locale: "en-US",
timezone: "UTC",
platform: "linux",
},
limits: {
wall_time_ms: 3000,
memory_bytes: 134217728,
tasks: 8,
cpu_quota_percent: 50,
tmpfs_bytes: 16777216,
module_bytes: 4194304,
input_bytes: 262144,
protocol_bytes: 16777216,
output_bytes: 524288,
stderr_bytes: 32768,
result_depth: 16,
result_nodes: 10000,
},
},
},
],
},
{
name: "prepare_node_characterization",
...toolContractMetadata("prepare_node_characterization"),
description:
"Prepare a hash-bound Node/JavaScript characterization plan and deterministic reversible export transformation without executing target code. The exact source, selected byte range, runtime closure, sandbox profile, cases, and limits are committed for later execution.",
kind: "application",
inputSchema: nodeCharacterizationPreparationInputSchema,
outputSchema: nodeCharacterizationPreparationOutputSchema,
examples: [
{
title: "Prepare one exact bundled callable characterization",
input: NODE_PREPARATION_EXAMPLE,
},
],
},
{
name: "execute_node_characterization",
...toolContractMetadata("execute_node_characterization"),
description:
"Recompute and execute one exact Node characterization plan in the owned controlled-replay boundary. The supplied plan_sha256 is checked against the freshly computed plan_sha256 as content identity; a mismatch fails before execution. Returns transformation, replay, cleanup, and provider-neutral characterization Evidence.",
kind: "application",
inputSchema: nodeCharacterizationExecutionInputSchema,
outputSchema: nodeCharacterizationExecutionOutputSchema,
examples: [
{
title: "Execute one exact characterization plan",
input: {
plan_sha256: HASH,
preparation: NODE_PREPARATION_EXAMPLE,
},
},
],
},
{
name: "build_reconstruction_obligation_ledger",
...toolContractMetadata("build_reconstruction_obligation_ledger"),
@@ -355,20 +228,11 @@ export function applicationToolContract(
name: "compare_javascript_export_shapes",
): (typeof APPLICATION_TOOL_CONTRACTS)[4];
export function applicationToolContract(
name: "run_controlled_replay",
name: "build_reconstruction_obligation_ledger",
): (typeof APPLICATION_TOOL_CONTRACTS)[5];
export function applicationToolContract(
name: "prepare_node_characterization",
): (typeof APPLICATION_TOOL_CONTRACTS)[6];
export function applicationToolContract(
name: "execute_node_characterization",
): (typeof APPLICATION_TOOL_CONTRACTS)[7];
export function applicationToolContract(
name: "build_reconstruction_obligation_ledger",
): (typeof APPLICATION_TOOL_CONTRACTS)[8];
export function applicationToolContract(
name: "evaluate_reconstruction_coverage",
): (typeof APPLICATION_TOOL_CONTRACTS)[9];
): (typeof APPLICATION_TOOL_CONTRACTS)[6];
export function applicationToolContract(
name: (typeof APPLICATION_TOOL_CONTRACTS)[number]["name"],
): (typeof APPLICATION_TOOL_CONTRACTS)[number] {
@@ -26,7 +26,7 @@ export const BROWSER_SCENARIO_TOOL_CONTRACTS = [
name: "capture_browser_scenario",
...toolContractMetadata("capture_browser_scenario"),
description:
"Run a controlled browser scenario when passive observation cannot exercise the application. Launch the selected executable or connect to a loopback CDP target, provide a start URL and actions, and optionally declare additional origins for navigation, storage, or request replay. By default, only the start URL origin is in scope. Environment, empty storage, disabled request replay, redaction, and a URL-only final capture are defaults; provide secrets, initial storage, request replay, or additional artifacts when needed. Actions run until completion or cancellation unless timeout_ms is set. Results are returned inline.",
"Run a controlled browser scenario when passive observation cannot exercise the application. Launch the selected executable or connect to a loopback CDP target, provide a start URL and actions, and select storage or artifacts when needed. Environment, empty storage, and a URL-only final capture are defaults; provide initial storage or additional artifacts when needed. Agents can run their own local fixture servers to control application responses. Actions run until completion or cancellation unless timeout_ms is set. Results are returned inline.",
kind: "browser-provider",
inputSchema: browserScenarioInputSchema,
outputSchema: evidenceResultOf(browserScenarioCaptureSchema),
-1
View File
@@ -74,7 +74,6 @@ const exampleScenarioCapture = () => ({
},
scenario: {
start_origin: origin,
allowed_origins: [origin],
action_count: 1,
secret_references: [],
},
-1
View File
@@ -43,7 +43,6 @@ export const enhancedInputSchemas = {
procedure: z.string().describe("A procedure name or address"),
}),
trace_feature: traceLiteralInputSchema,
find_code_for_string: traceLiteralInputSchema,
trace_call_path: z.strictObject({
start: z.string().describe("A provider-normalized procedure address"),
goal: z
-1
View File
@@ -58,7 +58,6 @@ export const analysisErrorProjectionSchema = z.discriminatedUnion("code", [
generic("configuration_invalid"),
generic("target_unavailable"),
generic("execution_failure"),
generic("plan_stale"),
]);
/** JSON Schema document used by generated API documentation and clients. */
-23
View File
@@ -307,26 +307,3 @@ export const MANAGED_NATIVE_VERIFICATION_EXAMPLE = {
managed_boundaries: boundaryEvidence(),
native_observations: [nativeExportEvidence()],
};
/** Minimal valid managed runtime-correlation planning request. */
export const MANAGED_RUNTIME_CORRELATION_EXAMPLE = {
static_members: runtimeExampleEvidence,
method: {
token: "0x06000001",
signature_sha256: "3".repeat(64),
normalized_il_sha256: "5".repeat(64),
},
requested_effect: "attach",
host: {
os: "linux",
clr_family: "dotnet",
architecture: "x86_64",
},
bounds: {
timeout_ms: 5_000,
max_threads: 32,
max_output_bytes: 65_536,
allow_network: false,
allow_ui: false,
},
};
@@ -2,7 +2,6 @@ import { z } from "zod";
import { evidenceSchema } from "../domain/evidence.js";
import { managedReconstructionImportInputSchema } from "../domain/managedReconstruction.js";
import { managedRuntimeCorrelationInputSchema } from "../domain/managedRuntimeCorrelation.js";
import type { ToolContract } from "./toolContracts.js";
import { managedWorkflowOutputSchemas } from "./toolOutputSchemas.js";
import {
@@ -10,7 +9,6 @@ import {
MANAGED_NATIVE_VERIFICATION_EXAMPLE,
MANAGED_APPLICATION_GRAPH_EXAMPLE,
MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE,
MANAGED_RUNTIME_CORRELATION_EXAMPLE,
} from "./managedWorkflowExamples.js";
import { toolContractMetadata } from "./toolEffects.js";
import { requireOutputSchema } from "./toolOutputSchemaPrimitives.js";
@@ -30,12 +28,6 @@ export const compareManagedMembersReferenceInputSchema = z
});
});
/** MCP reference for planning from one session-owned managed observation. */
export const managedRuntimeCorrelationReferenceInputSchema =
managedRuntimeCorrelationInputSchema.extend({
static_members: evidenceSchema,
});
/** Inline Evidence input for importing reconstruction. */
export const managedReconstructionReferenceInputSchema =
managedReconstructionImportInputSchema.extend({
@@ -115,10 +107,6 @@ const comparisonOutputSchema = requireOutputSchema(
managedWorkflowOutputSchemas,
"compare_managed_members",
);
const runtimeOutputSchema = requireOutputSchema(
managedWorkflowOutputSchemas,
"plan_managed_runtime_correlation",
);
const reconstructionOutputSchema = requireOutputSchema(
managedWorkflowOutputSchemas,
"import_managed_reconstruction",
@@ -192,28 +180,6 @@ export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
},
],
},
{
name: "plan_managed_runtime_correlation",
...toolContractMetadata("plan_managed_runtime_correlation"),
description:
"Prepare a non-executing managed runtime-correlation plan from authenticated inspect_managed_members Evidence. Planning does not probe or launch a runtime; it records the configured executable or the default command name, locks the exact artifact SHA-256, MVID, method signature, and decoded-IL hash, and describes requested effects and bounds without claiming execution or confinement.",
kind: "application",
inputSchema: managedRuntimeCorrelationReferenceInputSchema,
outputSchema: runtimeOutputSchema,
examples: [
{
title: "Plan an exact-build managed runtime correlation",
input: {
static_members: MANAGED_RUNTIME_CORRELATION_EXAMPLE.static_members,
method: MANAGED_RUNTIME_CORRELATION_EXAMPLE.method,
requested_effect:
MANAGED_RUNTIME_CORRELATION_EXAMPLE.requested_effect,
host: MANAGED_RUNTIME_CORRELATION_EXAMPLE.host,
bounds: MANAGED_RUNTIME_CORRELATION_EXAMPLE.bounds,
},
},
],
},
{
name: "project_managed_application_graph",
...toolContractMetadata("project_managed_application_graph"),
-38
View File
@@ -1,38 +0,0 @@
import { jsonObjectSchema } from "../domain/jsonValue.js";
/** Minimal login callback accepted by the direct replay-machine contract. */
export const REPLAY_MACHINE_RUN_EXAMPLE = jsonObjectSchema.parse({
machine: {
initial_state: "waiting",
states: [{ name: "waiting" }, { name: "complete", terminal: true }],
transitions: [
{
id: "accept_callback",
from: "waiting",
to: "complete",
trigger: { protocol: "http", method: "POST", path: "/callback" },
captures: [
{
variable: "token",
value: { source: "request_json", path: ["token"] },
sensitive: true,
},
],
actions: [{ type: "http_response", status: 204, body: "" }],
max_uses: 1,
},
],
max_transitions: 1,
},
events: [
{
protocol: "http",
connection: "not_applicable",
at_ms: 0,
method: "POST",
path: "/callback",
headers: {},
body: '{"token":"opaque"}',
},
],
});
-2
View File
@@ -10,7 +10,6 @@ import { processScenarioSchema } from "../domain/processCapture.js";
import { processTraceSpecificationSchema } from "../domain/processTraceComparison.js";
import { recordUnknownInputSchema } from "../domain/residualUnknown.js";
import { reconstructionVerificationInputSchema } from "../domain/reconstructionVerification.js";
import { replayMachineRunInputSchema } from "../domain/replayMachineRun.js";
import { staticRuntimeCorrelationInputSchema } from "../domain/staticRuntimeCorrelation.js";
import { evidenceSchema } from "../domain/evidence.js";
import { updateUnknownInputSchema } from "../domain/residualUnknown.js";
@@ -75,7 +74,6 @@ export {
processScenarioSchema,
reconstructionVerificationInputSchema,
recordUnknownInputSchema,
replayMachineRunInputSchema,
staticRuntimeCorrelationInputSchema,
updateUnknownInputSchema,
};
-3
View File
@@ -7,7 +7,6 @@ import {
PROCESS_CAPTURE_REFERENCE,
PROCESS_CAPTURE_RECONSTRUCTION,
} from "./investigationExamples.js";
import { REPLAY_MACHINE_RUN_EXAMPLE } from "./replayMachineExample.js";
/** Canonical examples for contracts whose required inputs have no defaults. */
export const TOOL_EXAMPLE_OVERRIDES: Readonly<
@@ -46,7 +45,6 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
analyze_swift_types: { category: "classes", pattern: "Account" },
inspect_native_api: { procedure: "main" },
trace_feature: { query: "license" },
find_code_for_string: { query: "authorization failed" },
trace_call_path: { start: "0x1000", goal: "0x1100" },
trace_native_ui_action: { action: "buildTapped:" },
open_binary: { path: "/tmp/fixture" },
@@ -57,7 +55,6 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
executable: "/usr/bin/true",
working_directory: "/tmp",
},
run_replay_machine: REPLAY_MACHINE_RUN_EXAMPLE,
compare_process_captures: {
left: PROCESS_CAPTURE_REFERENCE,
right: PROCESS_CAPTURE_RECONSTRUCTION,
-6
View File
@@ -74,11 +74,9 @@ const PUBLISHED_TOOL_NAME_FLOOR = [
"demangle_swift",
"discover_webmcp_tools",
"evaluate_reconstruction_coverage",
"execute_node_characterization",
"export_evidence_bundle",
"extract_artifact",
"find_changed_behavior",
"find_code_for_string",
"find_xrefs_to_name",
"get_call_graph",
"get_evidence_bundle",
@@ -117,8 +115,6 @@ const PUBLISHED_TOOL_NAME_FLOOR = [
"observe_javascript_runtime",
"observe_web_session",
"open_binary",
"plan_managed_runtime_correlation",
"prepare_node_characterization",
"prev_address",
"procedure_address",
"procedure_assembly",
@@ -133,8 +129,6 @@ const PUBLISHED_TOOL_NAME_FLOOR = [
"reconcile_javascript_runtime",
"record_unknown",
"resolve_containing_procedure",
"run_controlled_replay",
"run_replay_machine",
"search_procedures",
"search_strings",
"set_address_name",
+18 -11
View File
@@ -31,7 +31,6 @@ import {
processScenarioSchema,
reconstructionVerificationInputSchema,
recordUnknownInputSchema,
replayMachineRunInputSchema,
getEvidenceBundleInputSchema,
staticRuntimeCorrelationInputSchema,
updateUnknownInputSchema,
@@ -358,11 +357,6 @@ export const ENHANCED_TOOL_CONTRACTS = [
"Trace a literal feature query through every matching string and procedure, their xrefs, and truthful containing-procedure resolution. Returns observations, operation count, and residual unknowns without inferring reference kinds.",
enhancedInputSchemas.trace_feature,
),
enhanced(
"find_code_for_string",
"Resolve one literal string query across analyzed string entries, xrefs, and truthful containing-procedure candidates. Returns observations, operation count, and residual unknowns; it never infers reference kinds or runtime reachability.",
enhancedInputSchemas.find_code_for_string,
),
enhanced(
"trace_call_path",
"Trace direct callers or callees from one exact procedure address until the graph is exhausted or the optional goal is reached. Returns visited nodes, direct-call edges, a shortest traversal path, provider failures, and residual unknowns; unresolved indirect calls remain unknown.",
@@ -478,11 +472,6 @@ export const SESSION_TOOL_CONTRACTS = [
"Revalidate the current residual-unknown head against live bundled evidence, exact authority/confidence/environment requirements, and revision integrity. Withdrawn and out-of-scope dispositions are not truth claims.",
verifyUnknownResolutionInputSchema,
),
session(
"run_replay_machine",
"Evaluate ordered HTTP and WebSocket events directly against one validated finite replay machine without opening sockets or launching a target. Returns every decision, a capture-value-free transition journal, one redacted action table entry per used transition, captured aliases, final state, and exact configured and consumed limits.",
replayMachineRunInputSchema,
),
session(
"get_evidence_bundle",
"Return every Evidence record and residual unknown currently retained by this session as one inline bundle for direct inspection or follow-up workflows.",
@@ -514,3 +503,21 @@ export const TOOL_CONTRACTS = [
...APPLICATION_TOOL_CONTRACTS,
...SESSION_TOOL_CONTRACTS,
] as const;
/** Resolve a public contract by name while retaining its exact schema types. */
export const toolContract = <
Name extends (typeof TOOL_CONTRACTS)[number]["name"],
>(
name: Name,
): Extract<(typeof TOOL_CONTRACTS)[number], { readonly name: Name }> => {
const contract = TOOL_CONTRACTS.find(
(
candidate,
): candidate is Extract<
(typeof TOOL_CONTRACTS)[number],
{ readonly name: Name }
> => candidate.name === name,
);
if (contract === undefined) throw new Error(`Missing tool contract: ${name}`);
return contract;
};
-17
View File
@@ -96,7 +96,6 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
analyze_function: evidence,
inspect_native_api: effects({ mutatesSession: true, idempotent: false }),
trace_feature: effects({ mutatesSession: true, idempotent: false }),
find_code_for_string: effects({ mutatesSession: true, idempotent: false }),
trace_call_path: effects({ mutatesSession: true, idempotent: false }),
observe_native_ui: effects({
mutatesSession: true,
@@ -129,7 +128,6 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
compare_managed_members: sessionEvidence,
verify_managed_native_boundaries: sessionEvidence,
import_managed_reconstruction: sessionEvidence,
plan_managed_runtime_correlation: sessionEvidence,
project_managed_application_graph: sessionEvidence,
list_browser_targets: browserEvidence,
inspect_web_page: browserEvidence,
@@ -171,21 +169,6 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
compare_source_to_bundle: evidence,
compare_javascript_export_shapes: evidence,
build_reconstruction_obligation_ledger: evidence,
run_replay_machine: effects(),
run_controlled_replay: effects({
mutatesSession: true,
writesFilesystem: true,
launchesProcess: true,
}),
prepare_node_characterization: effects({
mutatesSession: true,
launchesProcess: true,
}),
execute_node_characterization: effects({
mutatesSession: true,
writesFilesystem: true,
launchesProcess: true,
}),
evaluate_reconstruction_coverage: effects(),
open_binary: effects({ mutatesSession: true, launchesProcess: true }),
close_binary: effects({
-7
View File
@@ -39,7 +39,6 @@ import {
import { managedMemberComparisonResultSchema } from "../domain/managedMemberComparison.js";
import { managedNativeVerificationResultSchema } from "../domain/managedNativeVerification.js";
import { managedReconstructionImportResultSchema } from "../domain/managedReconstruction.js";
import { managedRuntimeCorrelationResultSchema } from "../domain/managedRuntimeCorrelation.js";
import { managedApplicationGraphResultSchema } from "../domain/managedApplicationGraph.js";
import { artifactComparisonResultSchema } from "../domain/artifactComparison.js";
import { functionComparisonResultSchema } from "../domain/functionComparison.js";
@@ -48,7 +47,6 @@ import { changedBehaviorResultSchema } from "../domain/changedBehavior.js";
import { callPathResultSchema } from "../domain/callPath.js";
import { staticRuntimeCorrelationResultSchema } from "../domain/staticRuntimeCorrelation.js";
import { reconstructionVerificationResultSchema } from "../domain/reconstructionVerification.js";
import { replayMachineRunOutputSchema } from "../domain/replayMachineRun.js";
import { analysisErrorProjectionSchema } from "./errorSchemas.js";
import { nativeDispatchMetadataResultSchema } from "../domain/objcSwiftMetadata.js";
import { nativeInvestigationTraceSchema } from "../domain/nativeInvestigationGraph.js";
@@ -313,7 +311,6 @@ export const enhancedOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
analyze_function: functionDossierOutput,
inspect_native_api: resultOf(nativeApiInspectionResultSchema),
trace_feature: literalTraceOutput,
find_code_for_string: literalTraceOutput,
trace_call_path: callPathTraceOutput,
};
@@ -357,9 +354,6 @@ export const managedWorkflowOutputSchemas: Readonly<
import_managed_reconstruction: resultOf(
managedReconstructionImportResultSchema,
),
plan_managed_runtime_correlation: resultOf(
managedRuntimeCorrelationResultSchema,
),
project_managed_application_graph: resultOf(
managedApplicationGraphResultSchema,
),
@@ -462,5 +456,4 @@ export const sessionOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
unknown: residualUnknownSchema,
}),
),
run_replay_machine: lifecycleResultOf(replayMachineRunOutputSchema),
};