refactor(domain): remove provider-specific target and snapshot state

Move Hopper loader derivation and compatibility projection into the Hopper adapter so BinaryTarget carries only provider-neutral identity and format metadata.

Introduce bounded canonical analysis-profile commitments, exact provider/profile snapshot v2 bindings, legacy snapshot rejection guidance, and backward-compatible profiled Evidence v2 records. Partition cache and replay behavior by target, concrete provider build, and profile while preserving custom Hopper loader overrides.

Propagate profiles consistently through CLI, MCP, composed workflows, and session lifecycle; preserve the 78-tool contract and legacy loaderArgs response projection. Add migration documentation, generated API updates, property regressions, package verification, and real Hopper coverage.
This commit is contained in:
N0zoM1z0
2026-07-15 20:31:56 +09:00
committed by N0zoM1z0
parent 75f8696a57
commit 21da71ec6d
261 changed files with 3042 additions and 1231 deletions
+2
View File
@@ -125,6 +125,8 @@ export const createServer = (
registerEnhancedTools(server, analysis, {
logger: toolLogger,
activeTarget,
analysisProfile:
session === undefined ? undefined : () => session.analysisProfile(),
recordEvidence,
recordUnknown:
session === undefined
+19 -7
View File
@@ -17,21 +17,23 @@ import { jsonObjectSchema, type JsonValue } from "../domain/jsonValue.js";
import { enhancedInputSchemas } from "../contracts/enhancedInputs.js";
import { UnknownRegistryError } from "../domain/errors.js";
import { mcpProgressReporter } from "./mcpProgress.js";
import type { AnalysisProfileCommitment } from "../domain/analysisProfile.js";
import {
REA_WORKFLOW_PROVIDER,
workflowAnalysisProfile,
} from "../application/InvestigationProviders.js";
/** Optional session services used by enhanced tool registration. */
export interface EnhancedToolRegistration {
readonly logger: Logger;
readonly activeTarget: (() => BinaryTarget | undefined) | undefined;
readonly analysisProfile:
| (() => AnalysisProfileCommitment | undefined)
| undefined;
readonly recordEvidence: BinarySessionPort["recordEvidence"] | undefined;
readonly recordUnknown: BinarySessionPort["recordUnknown"] | undefined;
}
const WORKFLOW_PROVIDER = {
id: "rea-workflow",
name: "REA composed investigation workflow",
version: "1",
} as const;
/** Register composed workflows against the same port as direct bridge tools. */
export const registerEnhancedTools = (
server: McpServer,
@@ -43,6 +45,7 @@ export const registerEnhancedTools = (
registerEnhancedTool(server, services, contract, {
logger: options.logger,
activeTarget: options.activeTarget,
analysisProfile: options.analysisProfile,
recordEvidence: options.recordEvidence,
recordUnknown: options.recordUnknown,
});
@@ -56,6 +59,9 @@ const registerEnhancedTool = (
registration: {
readonly logger: Logger;
readonly activeTarget: (() => BinaryTarget | undefined) | undefined;
readonly analysisProfile:
| (() => AnalysisProfileCommitment | undefined)
| undefined;
readonly recordEvidence: BinarySessionPort["recordEvidence"] | undefined;
readonly recordUnknown: BinarySessionPort["recordUnknown"] | undefined;
},
@@ -92,13 +98,19 @@ const registerEnhancedTool = (
terminal: true,
});
if (result.ok) {
const upstreamProfile = registration.analysisProfile?.();
const evidence = createEvidence(
registration.activeTarget?.(),
WORKFLOW_PROVIDER,
REA_WORKFLOW_PROVIDER,
{
operation: name,
parameters,
result: result.value,
...(upstreamProfile === undefined
? {}
: {
analysisProfile: workflowAnalysisProfile(upstreamProfile),
}),
confidence: "derived",
limitations: [
"Derived by an REA workflow from one or more provider observations.",
+3
View File
@@ -95,6 +95,9 @@ const registerOfficialTool = (
operation: contract.name,
parameters: arguments_,
result: result.value.result,
...(result.value.analysisProfile === undefined
? {}
: { analysisProfile: result.value.analysisProfile }),
rawResult: result.value.rawResult,
limitations: result.value.limitations,
locations: result.value.locations,
+3 -1
View File
@@ -507,7 +507,9 @@ const registerLifecycleTools = ({
path: opened.value.path,
format: opened.value.format,
kind: opened.value.kind,
loaderArgs: [...opened.value.loaderArgs],
loaderArgs: z
.array(z.string())
.parse(session.openCompatibility().loaderArgs ?? []),
sha256: opened.value.sha256,
architecture: opened.value.architecture ?? null,
},