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:
@@ -6,18 +6,9 @@ import type { BrowserObservationPort } from "../application/BrowserObservationPo
|
||||
import type { BrowserScenarioCapturePort } from "../application/BrowserScenarioCapturePort.js";
|
||||
import type { ElectronActiveObservationPort } from "../application/ElectronActiveObservationPort.js";
|
||||
import type { ElectronObservationPort } from "../application/ElectronObservationPort.js";
|
||||
import type {
|
||||
JavaScriptReplayConfiguration,
|
||||
JavaScriptReplayHost,
|
||||
JavaScriptReplayRunner,
|
||||
} from "../application/JavaScriptReplayPlanning.js";
|
||||
import type { ManagedRuntimeConfiguration } from "../application/ManagedRuntimeCorrelationService.js";
|
||||
import type { JavaScriptRuntimeObservationPort } from "../application/JavaScriptRuntimeObservationPort.js";
|
||||
import { PRODUCT_IDENTITY } from "../identity.js";
|
||||
import { defaultJavaScriptReplayConfiguration } from "../config/runtimeConfiguration.js";
|
||||
import { silentLogger, type Logger } from "../logger.js";
|
||||
import { LinuxJavaScriptReplayRunner } from "../replay/LinuxJavaScriptReplayRunner.js";
|
||||
import { SystemJavaScriptReplayHost } from "../replay/SystemJavaScriptReplayHost.js";
|
||||
import { registerApplicationTools } from "./registerApplicationTools.js";
|
||||
import { registerArtifactTools } from "./registerArtifactTools.js";
|
||||
import { registerBrowserScenarioTool } from "./registerBrowserScenarioTool.js";
|
||||
@@ -47,10 +38,6 @@ export interface CreateServerOptions {
|
||||
readonly electronObservation?: ElectronObservationPort;
|
||||
readonly electronActiveObservation?: ElectronActiveObservationPort;
|
||||
readonly javascriptRuntimeObservation?: JavaScriptRuntimeObservationPort;
|
||||
readonly javascriptReplayConfiguration?: () => JavaScriptReplayConfiguration;
|
||||
readonly javascriptReplayHost?: JavaScriptReplayHost;
|
||||
readonly javascriptReplayRunner?: JavaScriptReplayRunner;
|
||||
readonly managedRuntimeConfiguration?: () => ManagedRuntimeConfiguration;
|
||||
readonly availabilityPolicy?: () => SessionAvailability;
|
||||
}
|
||||
|
||||
@@ -170,7 +157,6 @@ const registerBinaryAnalysisTools = ({
|
||||
server,
|
||||
analysis,
|
||||
session,
|
||||
options,
|
||||
logger,
|
||||
activeTarget,
|
||||
recordEvidence,
|
||||
@@ -208,11 +194,6 @@ const registerBinaryAnalysisTools = ({
|
||||
recordEvidence,
|
||||
recordEvidenceWithUnknown,
|
||||
session,
|
||||
runtime: {
|
||||
configuration:
|
||||
options.managedRuntimeConfiguration ??
|
||||
(() => ({ executablePath: undefined })),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -245,13 +226,5 @@ const registerObservationTools = ({
|
||||
logger,
|
||||
recordEvidence,
|
||||
recordEvidenceWithUnknown,
|
||||
replay: {
|
||||
configuration:
|
||||
options.javascriptReplayConfiguration ??
|
||||
defaultJavaScriptReplayConfiguration,
|
||||
host: options.javascriptReplayHost ?? new SystemJavaScriptReplayHost(),
|
||||
runner:
|
||||
options.javascriptReplayRunner ?? new LinuxJavaScriptReplayRunner(),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -5,8 +5,6 @@ import { registerTraceJavaScriptSemanticsTool } from "./registerApplicationTools
|
||||
import { registerCompareApplicationVersionsTool } from "./registerApplicationTools/compareVersions.js";
|
||||
import { registerCompareSourceToBundleTool } from "./registerApplicationTools/compareSourceToBundle.js";
|
||||
import { registerCompareJavaScriptExportShapesTool } from "./registerApplicationTools/compareExportShapes.js";
|
||||
import { registerControlledReplayTool } from "./registerApplicationTools/controlledReplay.js";
|
||||
import { registerCharacterizationTools } from "./registerApplicationTools/characterization.js";
|
||||
import { registerCoverageTools } from "./registerApplicationTools/coverage.js";
|
||||
import { registerReconstructionObligationLedgerTool } from "./registerApplicationTools/obligationLedger.js";
|
||||
import type { ApplicationToolRegistration } from "./registerApplicationTools/types.js";
|
||||
@@ -23,8 +21,6 @@ export const registerApplicationTools = (
|
||||
registerCompareApplicationVersionsTool(server, options);
|
||||
registerCompareSourceToBundleTool(server, options);
|
||||
registerCompareJavaScriptExportShapesTool(server, options);
|
||||
registerControlledReplayTool(server, options);
|
||||
registerCharacterizationTools(server, options);
|
||||
registerReconstructionObligationLedgerTool(server, options);
|
||||
registerCoverageTools(server, options);
|
||||
};
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
import { recordSessionEvidenceSources } from "../sessionEvidence.js";
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import {
|
||||
executeNodeCharacterization,
|
||||
prepareNodeCharacterization,
|
||||
} from "../../application/NodeRuntimeCharacterizationService.js";
|
||||
import { applicationToolContract } from "../../contracts/applicationToolContracts.js";
|
||||
import { parseEvidence } from "../../domain/evidence.js";
|
||||
import {
|
||||
nodeCharacterizationExecutionOutputSchema,
|
||||
nodeCharacterizationPreparationOutputSchema,
|
||||
} from "../../domain/nodeRuntimeCharacterization.js";
|
||||
import { mcpProgressReporter } from "../mcpProgress.js";
|
||||
import { logToolExecution } from "../toolLogging.js";
|
||||
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
||||
import { toCallToolResult } from "../toolResult.js";
|
||||
|
||||
import type { ApplicationToolRegistration } from "./types.js";
|
||||
|
||||
const prepareContract = applicationToolContract(
|
||||
"prepare_node_characterization",
|
||||
);
|
||||
const executeContract = applicationToolContract(
|
||||
"execute_node_characterization",
|
||||
);
|
||||
|
||||
/** Register node runtime characterization prepare and execute tools. */
|
||||
export const registerCharacterizationTools = (
|
||||
server: McpServer,
|
||||
options: ApplicationToolRegistration,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
prepareContract.name,
|
||||
toolRegistrationOptions(prepareContract),
|
||||
async (input, context) => {
|
||||
const result = await logToolExecution(
|
||||
options.logger,
|
||||
prepareContract.name,
|
||||
() =>
|
||||
prepareNodeCharacterization(options.replay, input, {
|
||||
signal: context.mcpReq.signal,
|
||||
progress: mcpProgressReporter(context),
|
||||
}),
|
||||
);
|
||||
if (!result.ok) return toCallToolResult(result, prepareContract);
|
||||
const output = nodeCharacterizationPreparationOutputSchema.parse(
|
||||
result.value,
|
||||
);
|
||||
const recorded = options.recordEvidence?.(
|
||||
parseEvidence(output.transformation_evidence),
|
||||
);
|
||||
if (recorded !== undefined && !recorded.ok)
|
||||
return toCallToolResult(recorded, prepareContract);
|
||||
return toCallToolResult(result, prepareContract);
|
||||
},
|
||||
);
|
||||
server.registerTool(
|
||||
executeContract.name,
|
||||
toolRegistrationOptions(executeContract),
|
||||
async (input, context) => {
|
||||
const result = await logToolExecution(
|
||||
options.logger,
|
||||
executeContract.name,
|
||||
() =>
|
||||
executeNodeCharacterization(options.replay, input, {
|
||||
signal: context.mcpReq.signal,
|
||||
progress: mcpProgressReporter(context),
|
||||
}),
|
||||
);
|
||||
if (!result.ok) return toCallToolResult(result, executeContract);
|
||||
const output = nodeCharacterizationExecutionOutputSchema.parse(
|
||||
result.value,
|
||||
);
|
||||
const sources = [
|
||||
output.transformation_evidence,
|
||||
...output.replay.source_evidence,
|
||||
output.replay.evidence,
|
||||
output.evidence,
|
||||
].map((item) => parseEvidence(item));
|
||||
const recorded = recordSessionEvidenceSources(
|
||||
options.recordEvidence,
|
||||
sources,
|
||||
);
|
||||
if (!recorded.ok) return toCallToolResult(recorded, executeContract);
|
||||
return toCallToolResult(result, executeContract);
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
import { recordSessionEvidenceSources } from "../sessionEvidence.js";
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import { runControlledReplayValidated } from "../../application/JavaScriptReplayService.js";
|
||||
import { applicationToolContract } from "../../contracts/applicationToolContracts.js";
|
||||
import { parseEvidence } from "../../domain/evidence.js";
|
||||
import { controlledReplayOutputSchema } from "../../domain/javascriptReplay.js";
|
||||
import { mcpProgressReporter } from "../mcpProgress.js";
|
||||
import { logToolExecution } from "../toolLogging.js";
|
||||
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
||||
import { toCallToolResult } from "../toolResult.js";
|
||||
|
||||
import type { ApplicationToolRegistration } from "./types.js";
|
||||
|
||||
const replayContract = applicationToolContract("run_controlled_replay");
|
||||
|
||||
/** Register the controlled JavaScript replay tool. */
|
||||
export const registerControlledReplayTool = (
|
||||
server: McpServer,
|
||||
options: ApplicationToolRegistration,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
replayContract.name,
|
||||
toolRegistrationOptions(replayContract),
|
||||
async (input, context) => {
|
||||
const result = await logToolExecution(
|
||||
options.logger,
|
||||
replayContract.name,
|
||||
() =>
|
||||
runControlledReplayValidated(options.replay, input, {
|
||||
signal: context.mcpReq.signal,
|
||||
progress: mcpProgressReporter(context),
|
||||
}),
|
||||
);
|
||||
if (!result.ok) return toCallToolResult(result, replayContract);
|
||||
const output = controlledReplayOutputSchema.parse(result.value);
|
||||
if (output.phase === "execute") {
|
||||
const sourcesRecorded = recordSessionEvidenceSources(
|
||||
options.recordEvidence,
|
||||
output.source_evidence.map((item) => parseEvidence(item)),
|
||||
);
|
||||
if (!sourcesRecorded.ok)
|
||||
return toCallToolResult(sourcesRecorded, replayContract);
|
||||
const recorded = options.recordEvidence?.(
|
||||
parseEvidence(output.evidence),
|
||||
);
|
||||
if (recorded !== undefined && !recorded.ok)
|
||||
return toCallToolResult(recorded, replayContract);
|
||||
}
|
||||
return toCallToolResult(result, replayContract);
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -55,18 +55,10 @@ const unknownRegistration = (
|
||||
{
|
||||
operation: "reconcile_javascript_runtime",
|
||||
rationale:
|
||||
"Add approved passive runtime Evidence without promoting it to static fact.",
|
||||
"Add passive runtime Evidence without promoting it to static fact.",
|
||||
},
|
||||
]
|
||||
: kind === "source-to-bundle-comparison"
|
||||
? []
|
||||
: [
|
||||
{
|
||||
operation: "run_controlled_replay",
|
||||
rationale:
|
||||
"Validate exact approved module behavior separately when runtime semantics are required.",
|
||||
},
|
||||
]),
|
||||
: []),
|
||||
],
|
||||
relationships: [],
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { BinarySessionPort } from "../../application/BinarySession.js";
|
||||
import type { JavaScriptReplayDependencies } from "../../application/JavaScriptReplayService.js";
|
||||
import type { Logger } from "../../logger.js";
|
||||
|
||||
/** Shared services for registering JavaScript application graph workflows. */
|
||||
@@ -9,5 +8,4 @@ export interface ApplicationToolRegistration {
|
||||
readonly recordEvidenceWithUnknown:
|
||||
| BinarySessionPort["recordEvidenceWithUnknown"]
|
||||
| undefined;
|
||||
readonly replay: JavaScriptReplayDependencies;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import { compareArtifacts } from "../domain/artifactComparison.js";
|
||||
import { createEvidence, parseEvidence } from "../domain/evidence.js";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
@@ -16,7 +16,7 @@ import { toCallToolResult } from "./toolResult.js";
|
||||
export const registerArtifactComparisonTool = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[7],
|
||||
contract: ReturnType<typeof toolContract<"compare_artifacts">>,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import { readEvidenceBundle } from "../application/EvidenceBundleFiles.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import { compareBundles } from "../domain/bundleComparison.js";
|
||||
import { createEvidence } from "../domain/evidence.js";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
@@ -16,7 +16,7 @@ import { toCallToolResult } from "./toolResult.js";
|
||||
export const registerBundleComparisonTool = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[9],
|
||||
contract: ReturnType<typeof toolContract<"compare_bundles">>,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
|
||||
@@ -15,7 +15,7 @@ export const registerCloseLifecycleTool = ({
|
||||
server,
|
||||
session,
|
||||
logger,
|
||||
contracts: [, closeContract],
|
||||
closeContract,
|
||||
}: LifecycleToolRegistration): void => {
|
||||
server.registerTool(
|
||||
closeContract.name,
|
||||
|
||||
@@ -14,10 +14,7 @@ import {
|
||||
REA_WORKFLOW_PROVIDER,
|
||||
workflowAnalysisProfile,
|
||||
} from "../application/InvestigationProviders.js";
|
||||
import {
|
||||
ENHANCED_TOOL_CONTRACTS,
|
||||
type ToolContract,
|
||||
} from "../contracts/toolContracts.js";
|
||||
import { toolContract, type ToolContract } from "../contracts/toolContracts.js";
|
||||
import type { AnalysisProfileCommitment } from "../domain/analysisProfile.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTarget.js";
|
||||
import { UnknownRegistryError } from "../domain/errors.js";
|
||||
@@ -47,23 +44,22 @@ export const registerEnhancedTools = (
|
||||
analysis: AnalysisOperationPort,
|
||||
options: EnhancedToolRegistration,
|
||||
): void => {
|
||||
const [
|
||||
nativeDispatchMetadata,
|
||||
objcClasses,
|
||||
objcProtocols,
|
||||
batchDecompile,
|
||||
callGraph,
|
||||
swiftTypes,
|
||||
xrefsToName,
|
||||
binaryOverview,
|
||||
analyzeFunction,
|
||||
inspectNativeApi,
|
||||
traceFeature,
|
||||
codeForString,
|
||||
traceCallPath,
|
||||
traceNativeUiAction,
|
||||
traceNativeValues,
|
||||
] = ENHANCED_TOOL_CONTRACTS;
|
||||
const nativeDispatchMetadata = toolContract(
|
||||
"inspect_native_dispatch_metadata",
|
||||
);
|
||||
const objcClasses = toolContract("get_objc_classes");
|
||||
const objcProtocols = toolContract("get_objc_protocols");
|
||||
const batchDecompile = toolContract("batch_decompile");
|
||||
const callGraph = toolContract("get_call_graph");
|
||||
const swiftTypes = toolContract("analyze_swift_types");
|
||||
const xrefsToName = toolContract("find_xrefs_to_name");
|
||||
const binaryOverview = toolContract("binary_overview");
|
||||
const analyzeFunction = toolContract("analyze_function");
|
||||
const inspectNativeApi = toolContract("inspect_native_api");
|
||||
const traceFeature = toolContract("trace_feature");
|
||||
const traceCallPath = toolContract("trace_call_path");
|
||||
const traceNativeUiAction = toolContract("trace_native_ui_action");
|
||||
const traceNativeValues = toolContract("trace_native_values");
|
||||
server.registerTool(
|
||||
traceNativeValues.name,
|
||||
toolRegistrationOptions(traceNativeValues),
|
||||
@@ -172,15 +168,6 @@ export const registerEnhancedTools = (
|
||||
context,
|
||||
}),
|
||||
);
|
||||
server.registerTool(
|
||||
codeForString.name,
|
||||
toolRegistrationOptions(codeForString),
|
||||
(input, context) =>
|
||||
executeEnhancedTool(analysis, options, codeForString, {
|
||||
validatedCall: { name: "find_code_for_string", input },
|
||||
context,
|
||||
}),
|
||||
);
|
||||
server.registerTool(
|
||||
traceCallPath.name,
|
||||
toolRegistrationOptions(traceCallPath),
|
||||
@@ -298,12 +285,9 @@ const recordWorkflowUnknowns = ({
|
||||
| ReturnType<BinarySessionPort["recordUnknown"]>
|
||||
| { readonly ok: true; readonly value: null } => {
|
||||
if (
|
||||
![
|
||||
"trace_feature",
|
||||
"find_code_for_string",
|
||||
"trace_call_path",
|
||||
"inspect_native_api",
|
||||
].includes(name) ||
|
||||
!["trace_feature", "trace_call_path", "inspect_native_api"].includes(
|
||||
name,
|
||||
) ||
|
||||
recordUnknown === undefined ||
|
||||
typeof result !== "object" ||
|
||||
result === null ||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import {
|
||||
createEvidence,
|
||||
parseEvidence,
|
||||
@@ -23,7 +23,7 @@ import { toCallToolResult } from "./toolResult.js";
|
||||
export const registerFunctionComparisonTool = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[8],
|
||||
contract: ReturnType<typeof toolContract<"compare_functions">>,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import { buildCallPath } from "../domain/callPath.js";
|
||||
import { findChangedBehavior } from "../domain/changedBehavior.js";
|
||||
import { createEvidence } from "../domain/evidence.js";
|
||||
@@ -29,23 +29,29 @@ import { toCallToolResult } from "./toolResult.js";
|
||||
export const registerInvestigationTools = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contracts: readonly [
|
||||
(typeof SESSION_TOOL_CONTRACTS)[10],
|
||||
(typeof SESSION_TOOL_CONTRACTS)[11],
|
||||
(typeof SESSION_TOOL_CONTRACTS)[12],
|
||||
(typeof SESSION_TOOL_CONTRACTS)[13],
|
||||
],
|
||||
): void => {
|
||||
registerChangedBehavior(server, session, contracts[0]);
|
||||
registerCallPath(server, session, contracts[1]);
|
||||
registerStaticRuntime(server, session, contracts[2]);
|
||||
registerReconstruction(server, session, contracts[3]);
|
||||
registerChangedBehavior(
|
||||
server,
|
||||
session,
|
||||
toolContract("find_changed_behavior"),
|
||||
);
|
||||
registerCallPath(server, session, toolContract("build_call_path"));
|
||||
registerStaticRuntime(
|
||||
server,
|
||||
session,
|
||||
toolContract("correlate_static_and_runtime"),
|
||||
);
|
||||
registerReconstruction(
|
||||
server,
|
||||
session,
|
||||
toolContract("verify_reconstruction"),
|
||||
);
|
||||
};
|
||||
|
||||
const registerChangedBehavior = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[10],
|
||||
contract: ReturnType<typeof toolContract<"find_changed_behavior">>,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
@@ -103,7 +109,7 @@ const registerChangedBehavior = (
|
||||
const registerCallPath = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[11],
|
||||
contract: ReturnType<typeof toolContract<"build_call_path">>,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
@@ -160,7 +166,7 @@ const registerCallPath = (
|
||||
const registerStaticRuntime = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[12],
|
||||
contract: ReturnType<typeof toolContract<"correlate_static_and_runtime">>,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
@@ -221,7 +227,7 @@ const registerStaticRuntime = (
|
||||
const registerReconstruction = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[13],
|
||||
contract: ReturnType<typeof toolContract<"verify_reconstruction">>,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
|
||||
@@ -3,7 +3,6 @@ import type { McpServer } from "@modelcontextprotocol/server";
|
||||
import { registerCompareManagedMembers } from "./registerManagedWorkflowTools/compareManagedMembers.js";
|
||||
import { registerVerifyManagedNativeBoundaries } from "./registerManagedWorkflowTools/verifyManagedNativeBoundaries.js";
|
||||
import { registerImportManagedReconstruction } from "./registerManagedWorkflowTools/importManagedReconstruction.js";
|
||||
import { registerPlanManagedRuntimeCorrelation } from "./registerManagedWorkflowTools/planManagedRuntimeCorrelation.js";
|
||||
import { registerProjectManagedApplicationGraph } from "./registerManagedWorkflowTools/projectManagedApplicationGraph.js";
|
||||
import type { ManagedWorkflowToolRegistration } from "./registerManagedWorkflowTools/types.js";
|
||||
|
||||
@@ -17,6 +16,5 @@ export const registerManagedWorkflowTools = (
|
||||
registerCompareManagedMembers(server, options);
|
||||
registerVerifyManagedNativeBoundaries(server, options);
|
||||
registerImportManagedReconstruction(server, options);
|
||||
registerPlanManagedRuntimeCorrelation(server, options);
|
||||
registerProjectManagedApplicationGraph(server, options);
|
||||
};
|
||||
|
||||
@@ -10,12 +10,9 @@ export function managedWorkflowContract(
|
||||
export function managedWorkflowContract(
|
||||
name: "import_managed_reconstruction",
|
||||
): (typeof MANAGED_WORKFLOW_TOOL_CONTRACTS)[2];
|
||||
export function managedWorkflowContract(
|
||||
name: "plan_managed_runtime_correlation",
|
||||
): (typeof MANAGED_WORKFLOW_TOOL_CONTRACTS)[3];
|
||||
export function managedWorkflowContract(
|
||||
name: "project_managed_application_graph",
|
||||
): (typeof MANAGED_WORKFLOW_TOOL_CONTRACTS)[4];
|
||||
): (typeof MANAGED_WORKFLOW_TOOL_CONTRACTS)[3];
|
||||
export function managedWorkflowContract(
|
||||
name: (typeof MANAGED_WORKFLOW_TOOL_CONTRACTS)[number]["name"],
|
||||
) {
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import { planManagedRuntimeCorrelationEvidenceValidated } from "../../application/ManagedRuntimeCorrelationService.js";
|
||||
import { logToolExecution } from "../toolLogging.js";
|
||||
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
||||
import { toCallToolResult } from "../toolResult.js";
|
||||
import { managedWorkflowContract } from "./contract.js";
|
||||
import { resolveManagedEvidence } from "./evidence.js";
|
||||
import type { ManagedWorkflowToolRegistration } from "./types.js";
|
||||
|
||||
const runtimeContract = managedWorkflowContract(
|
||||
"plan_managed_runtime_correlation",
|
||||
);
|
||||
|
||||
/** Register the managed runtime correlation planning workflow tool. */
|
||||
export const registerPlanManagedRuntimeCorrelation = (
|
||||
server: McpServer,
|
||||
options: ManagedWorkflowToolRegistration,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
runtimeContract.name,
|
||||
toolRegistrationOptions(runtimeContract),
|
||||
async (input) => {
|
||||
const resolved = resolveManagedEvidence(input.static_members);
|
||||
if (!resolved.ok) return toCallToolResult(resolved, runtimeContract);
|
||||
const staticMembers = resolved.value[0];
|
||||
if (staticMembers === undefined)
|
||||
throw new TypeError("Managed runtime Evidence resolution failed");
|
||||
const parsed = { ...input, static_members: staticMembers };
|
||||
const result = await logToolExecution(
|
||||
options.logger,
|
||||
runtimeContract.name,
|
||||
() =>
|
||||
Promise.resolve(
|
||||
planManagedRuntimeCorrelationEvidenceValidated(
|
||||
options.runtime,
|
||||
parsed,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!result.ok) return toCallToolResult(result, runtimeContract);
|
||||
const recordedSource = options.recordEvidence?.(parsed.static_members);
|
||||
if (recordedSource !== undefined && !recordedSource.ok)
|
||||
return toCallToolResult(recordedSource, runtimeContract);
|
||||
const recorded = options.recordEvidence?.(result.value);
|
||||
if (recorded !== undefined && !recorded.ok)
|
||||
return toCallToolResult(recorded, runtimeContract);
|
||||
return toCallToolResult(result, runtimeContract);
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { BinarySessionPort } from "../../application/BinarySession.js";
|
||||
import type { ManagedRuntimeCorrelationDependencies } from "../../application/ManagedRuntimeCorrelationService.js";
|
||||
import type { Logger } from "../../logger.js";
|
||||
|
||||
/** Shared services for registering managed-code workflow tools. */
|
||||
@@ -9,6 +8,5 @@ export interface ManagedWorkflowToolRegistration {
|
||||
readonly recordEvidenceWithUnknown:
|
||||
| BinarySessionPort["recordEvidenceWithUnknown"]
|
||||
| undefined;
|
||||
readonly runtime: ManagedRuntimeCorrelationDependencies;
|
||||
readonly session: BinarySessionPort;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import { EvidenceIntegrityError } from "../domain/errors.js";
|
||||
import {
|
||||
createEvidence,
|
||||
@@ -37,7 +37,7 @@ const sourceLocations = (
|
||||
export const registerProcessComparisonTool = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
contract: (typeof SESSION_TOOL_CONTRACTS)[6],
|
||||
contract: ReturnType<typeof toolContract<"compare_process_captures">>,
|
||||
now: () => number = Date.now,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
@@ -153,9 +153,7 @@ const comparisonUnknownInput = (
|
||||
["interaction", comparison.interaction],
|
||||
["exit", comparison.exit],
|
||||
["filesystem", comparison.filesystem],
|
||||
["protocol", comparison.protocol],
|
||||
["process", comparison.process],
|
||||
["shim", comparison.shim],
|
||||
]
|
||||
.filter(([, status]) => status !== "unchanged")
|
||||
.map(([scope]) => scope)
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { runReplayMachine } from "../domain/replayMachineRun.js";
|
||||
import { ok } from "../domain/result.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { logToolExecution } from "./toolLogging.js";
|
||||
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
||||
import { toCallToolResult } from "./toolResult.js";
|
||||
|
||||
const contract = SESSION_TOOL_CONTRACTS[18];
|
||||
|
||||
/** Register direct execution-free finite replay-machine evaluation. */
|
||||
export const registerReplayMachineTool = (
|
||||
server: McpServer,
|
||||
logger: Logger,
|
||||
): void => {
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
toolRegistrationOptions(contract),
|
||||
async (input) => {
|
||||
const result = await logToolExecution(logger, contract.name, () =>
|
||||
Promise.resolve(ok(runReplayMachine(input))),
|
||||
);
|
||||
return toCallToolResult(result, contract);
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
readEvidenceBundle,
|
||||
writeEvidenceBundle,
|
||||
} from "../application/EvidenceBundleFiles.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import type { EvidenceBundle } from "../domain/evidenceBundle.js";
|
||||
import { ok } from "../domain/result.js";
|
||||
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
||||
@@ -14,9 +14,15 @@ import { toCallToolResult } from "./toolResult.js";
|
||||
interface EvidenceToolRegistration {
|
||||
readonly server: McpServer;
|
||||
readonly session: BinarySessionPort;
|
||||
readonly exportContract: (typeof SESSION_TOOL_CONTRACTS)[3];
|
||||
readonly importContract: (typeof SESSION_TOOL_CONTRACTS)[4];
|
||||
readonly snapshotContract: (typeof SESSION_TOOL_CONTRACTS)[19];
|
||||
readonly exportContract: ReturnType<
|
||||
typeof toolContract<"export_evidence_bundle">
|
||||
>;
|
||||
readonly importContract: ReturnType<
|
||||
typeof toolContract<"import_evidence_bundle">
|
||||
>;
|
||||
readonly snapshotContract: ReturnType<
|
||||
typeof toolContract<"get_evidence_bundle">
|
||||
>;
|
||||
}
|
||||
|
||||
/** Register evidence bundle import and export tools. */
|
||||
@@ -113,16 +119,14 @@ const unknownRevisionKey = (
|
||||
interface UnknownToolRegistration {
|
||||
readonly server: McpServer;
|
||||
readonly session: BinarySessionPort;
|
||||
readonly contracts: typeof SESSION_TOOL_CONTRACTS;
|
||||
}
|
||||
|
||||
/** Register residual-unknown query and mutation tools. */
|
||||
const registerListUnknownsTool = ({
|
||||
server,
|
||||
session,
|
||||
contracts,
|
||||
}: UnknownToolRegistration): void => {
|
||||
const listContract = contracts[14];
|
||||
const listContract = toolContract("list_unknowns");
|
||||
server.registerTool(
|
||||
listContract.name,
|
||||
toolRegistrationOptions(listContract),
|
||||
@@ -149,9 +153,8 @@ const registerListUnknownsTool = ({
|
||||
const registerRecordUnknownTool = ({
|
||||
server,
|
||||
session,
|
||||
contracts,
|
||||
}: UnknownToolRegistration): void => {
|
||||
const recordContract = contracts[15];
|
||||
const recordContract = toolContract("record_unknown");
|
||||
server.registerTool(
|
||||
recordContract.name,
|
||||
toolRegistrationOptions(recordContract),
|
||||
@@ -165,9 +168,8 @@ const registerRecordUnknownTool = ({
|
||||
const registerUpdateUnknownTool = ({
|
||||
server,
|
||||
session,
|
||||
contracts,
|
||||
}: UnknownToolRegistration): void => {
|
||||
const updateContract = contracts[16];
|
||||
const updateContract = toolContract("update_unknown");
|
||||
server.registerTool(
|
||||
updateContract.name,
|
||||
toolRegistrationOptions(updateContract),
|
||||
@@ -181,9 +183,8 @@ const registerUpdateUnknownTool = ({
|
||||
const registerVerifyUnknownTool = ({
|
||||
server,
|
||||
session,
|
||||
contracts,
|
||||
}: UnknownToolRegistration): void => {
|
||||
const verifyContract = contracts[17];
|
||||
const verifyContract = toolContract("verify_unknown_resolution");
|
||||
server.registerTool(
|
||||
verifyContract.name,
|
||||
toolRegistrationOptions(verifyContract),
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import { buildCapabilityInventory } from "../application/CapabilityInventory.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import type { ClientFeatureAvailability } from "../contracts/toolOutputSchemaPrimitives.js";
|
||||
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
||||
import { createServerIdentity } from "../serverIdentity.js";
|
||||
@@ -17,7 +17,7 @@ type ToolAvailability = ReturnType<typeof buildCapabilityInventory>[number];
|
||||
export interface SessionStatusToolOptions {
|
||||
readonly server: McpServer;
|
||||
readonly session: BinarySessionPort;
|
||||
readonly contract: (typeof SESSION_TOOL_CONTRACTS)[2];
|
||||
readonly contract: ReturnType<typeof toolContract<"binary_session">>;
|
||||
readonly startedAt: string;
|
||||
readonly availabilityPolicy: () => SessionAvailability;
|
||||
}
|
||||
|
||||
@@ -9,14 +9,11 @@ import { readAnalysisSnapshot } from "../application/AnalysisSnapshotFiles.js";
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import { createProcessCaptureEvidence } from "../application/ProcessEvidence.js";
|
||||
import { captureProcessScenario } from "../application/ProcessHarness.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import { toolContract } from "../contracts/toolContracts.js";
|
||||
import type { AnalysisSnapshot } from "../domain/analysisSnapshot.js";
|
||||
import { UnknownRegistryError, type AnalysisError } from "../domain/errors.js";
|
||||
import type { Evidence } from "../domain/evidence.js";
|
||||
import type {
|
||||
ProcessCapture,
|
||||
ProcessScenario,
|
||||
} from "../domain/processCapture.js";
|
||||
import type { ProcessCapture } from "../domain/processCapture.js";
|
||||
import { ok, type Result } from "../domain/result.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { mcpProgressReporter } from "./mcpProgress.js";
|
||||
@@ -26,7 +23,6 @@ import { registerCloseLifecycleTool } from "./registerCloseLifecycleTool.js";
|
||||
import { registerFunctionComparisonTool } from "./registerFunctionComparisonTool.js";
|
||||
import { registerInvestigationTools } from "./registerInvestigationTools.js";
|
||||
import { registerProcessComparisonTool } from "./registerProcessComparisonTool.js";
|
||||
import { registerReplayMachineTool } from "./registerReplayMachineTool.js";
|
||||
import {
|
||||
registerEvidenceTools,
|
||||
registerUnknownTools,
|
||||
@@ -42,7 +38,6 @@ import { toCallToolResult } from "./toolResult.js";
|
||||
|
||||
const recordProcessResidualUnknowns = (
|
||||
session: BinarySessionPort,
|
||||
scenario: ProcessScenario,
|
||||
evidence: Evidence,
|
||||
residuals: ProcessCapture["residual_unknowns"],
|
||||
): Result<null, AnalysisError> => {
|
||||
@@ -81,7 +76,9 @@ interface ProcessToolRegistration {
|
||||
readonly server: McpServer;
|
||||
readonly session: BinarySessionPort;
|
||||
readonly logger: Logger;
|
||||
readonly captureContract: (typeof SESSION_TOOL_CONTRACTS)[5];
|
||||
readonly captureContract: ReturnType<
|
||||
typeof toolContract<"capture_process_scenario">
|
||||
>;
|
||||
}
|
||||
|
||||
const registerProcessTools = ({
|
||||
@@ -120,7 +117,6 @@ const registerProcessTools = ({
|
||||
if (!recorded.ok) return toCallToolResult(recorded, captureContract);
|
||||
const unknowns = recordProcessResidualUnknowns(
|
||||
session,
|
||||
scenario,
|
||||
evidence,
|
||||
captured.value.residual_unknowns,
|
||||
);
|
||||
@@ -134,11 +130,9 @@ export interface LifecycleToolRegistration {
|
||||
readonly server: McpServer;
|
||||
readonly session: BinarySessionPort;
|
||||
readonly logger: Logger;
|
||||
readonly contracts: readonly [
|
||||
(typeof SESSION_TOOL_CONTRACTS)[0],
|
||||
(typeof SESSION_TOOL_CONTRACTS)[1],
|
||||
(typeof SESSION_TOOL_CONTRACTS)[2],
|
||||
];
|
||||
readonly openContract: ReturnType<typeof toolContract<"open_binary">>;
|
||||
readonly closeContract: ReturnType<typeof toolContract<"close_binary">>;
|
||||
readonly statusContract: ReturnType<typeof toolContract<"binary_session">>;
|
||||
readonly startedAt: string;
|
||||
readonly availabilityPolicy: () => SessionAvailability;
|
||||
}
|
||||
@@ -146,14 +140,14 @@ export interface LifecycleToolRegistration {
|
||||
const registerLifecycleTools = (
|
||||
registration: LifecycleToolRegistration,
|
||||
): void => {
|
||||
const { server, session, contracts, startedAt, availabilityPolicy } =
|
||||
const { server, session, statusContract, startedAt, availabilityPolicy } =
|
||||
registration;
|
||||
registerOpenLifecycleTool(registration);
|
||||
registerCloseLifecycleTool(registration);
|
||||
registerSessionStatusTool({
|
||||
server,
|
||||
session,
|
||||
contract: contracts[2],
|
||||
contract: statusContract,
|
||||
startedAt,
|
||||
availabilityPolicy,
|
||||
});
|
||||
@@ -163,7 +157,7 @@ const registerOpenLifecycleTool = ({
|
||||
server,
|
||||
session,
|
||||
logger,
|
||||
contracts: [openContract],
|
||||
openContract,
|
||||
}: LifecycleToolRegistration): void => {
|
||||
server.registerTool(
|
||||
openContract.name,
|
||||
@@ -212,25 +206,12 @@ export interface SessionToolOptions {
|
||||
readonly availabilityPolicy?: () => SessionAvailability;
|
||||
}
|
||||
|
||||
const registerRecordAndReplayTools = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
logger: Logger,
|
||||
): void => {
|
||||
registerUnknownTools({
|
||||
server,
|
||||
session,
|
||||
contracts: SESSION_TOOL_CONTRACTS,
|
||||
});
|
||||
registerReplayMachineTool(server, logger);
|
||||
};
|
||||
|
||||
const registerContextTools = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
): void => {
|
||||
const navigationContract = SESSION_TOOL_CONTRACTS[20];
|
||||
const addressContract = SESSION_TOOL_CONTRACTS[21];
|
||||
const navigationContract = toolContract("get_navigation_context");
|
||||
const addressContract = toolContract("inspect_address_context");
|
||||
server.registerTool(
|
||||
navigationContract.name,
|
||||
toolRegistrationOptions(navigationContract),
|
||||
@@ -259,28 +240,24 @@ export const registerSessionTools = (
|
||||
logger: Logger,
|
||||
options: SessionToolOptions = {},
|
||||
): void => {
|
||||
const [
|
||||
openContract,
|
||||
closeContract,
|
||||
statusContract,
|
||||
exportContract,
|
||||
importContract,
|
||||
captureContract,
|
||||
compareContract,
|
||||
compareArtifactsContract,
|
||||
compareFunctionsContract,
|
||||
compareBundlesContract,
|
||||
changedBehaviorContract,
|
||||
callPathContract,
|
||||
staticRuntimeContract,
|
||||
reconstructionContract,
|
||||
] = SESSION_TOOL_CONTRACTS;
|
||||
const snapshotContract = SESSION_TOOL_CONTRACTS[19];
|
||||
const openContract = toolContract("open_binary");
|
||||
const closeContract = toolContract("close_binary");
|
||||
const statusContract = toolContract("binary_session");
|
||||
const exportContract = toolContract("export_evidence_bundle");
|
||||
const importContract = toolContract("import_evidence_bundle");
|
||||
const captureContract = toolContract("capture_process_scenario");
|
||||
const compareContract = toolContract("compare_process_captures");
|
||||
const compareArtifactsContract = toolContract("compare_artifacts");
|
||||
const compareFunctionsContract = toolContract("compare_functions");
|
||||
const compareBundlesContract = toolContract("compare_bundles");
|
||||
const snapshotContract = toolContract("get_evidence_bundle");
|
||||
registerLifecycleTools({
|
||||
server,
|
||||
session,
|
||||
logger,
|
||||
contracts: [openContract, closeContract, statusContract],
|
||||
openContract,
|
||||
closeContract,
|
||||
statusContract,
|
||||
startedAt: options.startedAt ?? new Date().toISOString(),
|
||||
availabilityPolicy: sessionAvailabilityPolicy(
|
||||
options.availabilityPolicy,
|
||||
@@ -304,13 +281,7 @@ export const registerSessionTools = (
|
||||
registerArtifactComparisonTool(server, session, compareArtifactsContract);
|
||||
registerFunctionComparisonTool(server, session, compareFunctionsContract);
|
||||
registerBundleComparisonTool(server, session, compareBundlesContract);
|
||||
const investigationContracts = [
|
||||
changedBehaviorContract,
|
||||
callPathContract,
|
||||
staticRuntimeContract,
|
||||
reconstructionContract,
|
||||
] as const;
|
||||
registerInvestigationTools(server, session, investigationContracts);
|
||||
registerRecordAndReplayTools(server, session, logger);
|
||||
registerInvestigationTools(server, session);
|
||||
registerUnknownTools({ server, session });
|
||||
registerContextTools(server, session);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { AvailabilityPolicy } from "../application/CapabilityInventory.js";
|
||||
import { arch, platform } from "node:process";
|
||||
import { isSupportedControlledReplayHost } from "../application/ControlledReplayHostSupport.js";
|
||||
import { platform } from "node:process";
|
||||
|
||||
export type SessionAvailability = AvailabilityPolicy;
|
||||
|
||||
@@ -23,7 +22,6 @@ export const sessionAvailabilityPolicy = (
|
||||
configured ??
|
||||
(() => ({
|
||||
processCaptureEnabled: platform !== "win32",
|
||||
controlledReplayEnabled: isSupportedControlledReplayHost(platform, arch),
|
||||
browserObservationEnabled:
|
||||
defaults.optionalFeatures?.browserObservationEnabled ?? false,
|
||||
browserScenarioEnabled:
|
||||
|
||||
Reference in New Issue
Block a user