refactor!: enforce canonical evidence and provider boundaries
Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership. Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers. BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
||||
import type { LazyAnalysisProvider } from "../application/binary/LazyAnalysisProvider.js";
|
||||
import {
|
||||
ARTIFACT_PROVIDER_IDENTITY,
|
||||
@@ -18,33 +19,37 @@ type AuxiliaryProviderDeclaration = ConstructorParameters<
|
||||
|
||||
/** Wire the three existing auxiliary AnalysisProvider implementations lazily. */
|
||||
export const auxiliaryAnalysisProviderDeclarations = (
|
||||
selectedEnvironment: Readonly<NodeJS.ProcessEnv>,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): readonly AuxiliaryProviderDeclaration[] => [
|
||||
{
|
||||
identity: ARTIFACT_PROVIDER_IDENTITY,
|
||||
capabilities: artifactCapabilities(platform),
|
||||
load: async () => {
|
||||
const { ArtifactProvider } =
|
||||
await import("../artifacts/ArtifactProvider.js");
|
||||
return new ArtifactProvider(platform);
|
||||
): readonly AuxiliaryProviderDeclaration[] => {
|
||||
const environment = snapshotEnvironment(selectedEnvironment, platform);
|
||||
return [
|
||||
{
|
||||
identity: ARTIFACT_PROVIDER_IDENTITY,
|
||||
capabilities: artifactCapabilities(platform),
|
||||
load: async () => {
|
||||
const { ArtifactProvider } =
|
||||
await import("../artifacts/ArtifactProvider.js");
|
||||
return new ArtifactProvider(environment, platform);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
identity: NATIVE_MACOS_PROVIDER_IDENTITY,
|
||||
capabilities: nativeMacOSCapabilities(platform),
|
||||
load: async () => {
|
||||
const { NativeMacOSProvider } =
|
||||
await import("../native/NativeMacOSProvider.js");
|
||||
return new NativeMacOSProvider(undefined, platform);
|
||||
{
|
||||
identity: NATIVE_MACOS_PROVIDER_IDENTITY,
|
||||
capabilities: nativeMacOSCapabilities(platform),
|
||||
load: async () => {
|
||||
const { NativeMacOSProvider } =
|
||||
await import("../native/NativeMacOSProvider.js");
|
||||
return new NativeMacOSProvider(environment, undefined, platform);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
identity: MANAGED_STATIC_PROVIDER_IDENTITY,
|
||||
capabilities: managedStaticCapabilities(),
|
||||
load: async () => {
|
||||
const { ManagedStaticProvider } =
|
||||
await import("../dotnet/ManagedStaticProvider.js");
|
||||
return new ManagedStaticProvider();
|
||||
{
|
||||
identity: MANAGED_STATIC_PROVIDER_IDENTITY,
|
||||
capabilities: managedStaticCapabilities(),
|
||||
load: async () => {
|
||||
const { ManagedStaticProvider } =
|
||||
await import("../dotnet/ManagedStaticProvider.js");
|
||||
return new ManagedStaticProvider();
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
];
|
||||
};
|
||||
|
||||
+12
-12
@@ -1,15 +1,15 @@
|
||||
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
||||
import type { AppConfig } from "../config.js";
|
||||
import type { BinarySession } from "../application/binary/BinarySession.js";
|
||||
import { HopperProvider } from "../hopper/HopperProvider.js";
|
||||
import { GhidraProvider } from "../ghidra/GhidraProvider.js";
|
||||
import { IdaProvider } from "../ida/IdaProvider.js";
|
||||
import { silentLogger, type Logger } from "../logger.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { auxiliaryAnalysisProviderDeclarations } from "./auxiliaryAnalysisProviders.js";
|
||||
import { AnalysisProviderRegistry } from "../application/binary/AnalysisProviderRegistry.js";
|
||||
import { composeBinarySession } from "../application/binary/BinarySessionComposition.js";
|
||||
import { LazyAnalysisProvider } from "../application/binary/LazyAnalysisProvider.js";
|
||||
import { ManagedStaticProvider } from "../dotnet/ManagedStaticProvider.js";
|
||||
import { SessionProviderRouter } from "../application/binary/SessionProviderRouter.js";
|
||||
|
||||
/**
|
||||
* Compose the target-switching runtime shared directly by CLI and MCP adapters.
|
||||
@@ -18,17 +18,19 @@ import { SessionProviderRouter } from "../application/binary/SessionProviderRout
|
||||
*/
|
||||
export const createBinarySession = (
|
||||
config: AppConfig,
|
||||
logger: Logger = silentLogger,
|
||||
logger: Logger,
|
||||
selectedEnvironment: Readonly<NodeJS.ProcessEnv>,
|
||||
): BinarySession => {
|
||||
const hopper = new HopperProvider(config, logger);
|
||||
const ghidra = new GhidraProvider(config, logger);
|
||||
const ida = new IdaProvider(config);
|
||||
const environment = snapshotEnvironment(selectedEnvironment);
|
||||
const hopper = new HopperProvider(config, logger, environment);
|
||||
const ghidra = new GhidraProvider(config, logger, environment);
|
||||
const ida = new IdaProvider(config, environment);
|
||||
return composeBinarySession(
|
||||
new AnalysisProviderRegistry(
|
||||
[hopper, ghidra, ida],
|
||||
config.analysisProvider,
|
||||
),
|
||||
auxiliaryAnalysisProviderDeclarations().map(
|
||||
auxiliaryAnalysisProviderDeclarations(environment).map(
|
||||
(declaration) => new LazyAnalysisProvider(declaration),
|
||||
),
|
||||
);
|
||||
@@ -36,8 +38,6 @@ export const createBinarySession = (
|
||||
|
||||
/** Compose an execution-free managed session without native provider selection. */
|
||||
export const createManagedBinarySession = (): BinarySession =>
|
||||
composeBinarySession(
|
||||
SessionProviderRouter.selectable(new AnalysisProviderRegistry([]), [
|
||||
new ManagedStaticProvider(),
|
||||
]),
|
||||
);
|
||||
composeBinarySession(new AnalysisProviderRegistry([]), [
|
||||
new ManagedStaticProvider(),
|
||||
]);
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import type { BrowserScenarioCapturePort } from "../application/BrowserScenarioCapturePort.js";
|
||||
import { PlaywrightBrowserScenarioProvider } from "../browser/PlaywrightBrowserScenarioProvider.js";
|
||||
import { PlaywrightScenarioSessionFactory } from "../browser/PlaywrightScenarioSession.js";
|
||||
|
||||
/** Construct a fresh provider without opening a target or acquiring an engine. */
|
||||
export const createBrowserScenarioProvider = (): BrowserScenarioCapturePort =>
|
||||
new PlaywrightBrowserScenarioProvider();
|
||||
export const createBrowserScenarioProvider = (
|
||||
environment: Readonly<Record<string, string | undefined>>,
|
||||
): BrowserScenarioCapturePort =>
|
||||
new PlaywrightBrowserScenarioProvider(
|
||||
new PlaywrightScenarioSessionFactory(environment),
|
||||
);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
||||
import { parseConfig } from "../config.js";
|
||||
import {
|
||||
runDirectAnalysis as executeDirectAnalysis,
|
||||
runProviderAnalysis as executeProviderAnalysis,
|
||||
@@ -10,37 +12,32 @@ import {
|
||||
import type { DirectAnalysisDependencies } from "../application/DirectAnalysisDependencies.js";
|
||||
import { createBinarySession, createManagedBinarySession } from "./binary.js";
|
||||
|
||||
const dependencies: DirectAnalysisDependencies = {
|
||||
createBinarySession,
|
||||
createManagedBinarySession,
|
||||
/** Bind one-shot analysis and status commands to one caller-selected environment. */
|
||||
export const createDirectAnalysis = (
|
||||
selectedEnvironment: Readonly<Record<string, string | undefined>>,
|
||||
) => {
|
||||
const environment = snapshotEnvironment(selectedEnvironment);
|
||||
const dependencies: DirectAnalysisDependencies = {
|
||||
readConfiguration: () => parseConfig(environment),
|
||||
createBinarySession: (config, logger) =>
|
||||
createBinarySession(config, logger, environment),
|
||||
createManagedBinarySession,
|
||||
};
|
||||
return {
|
||||
runDirectAnalysis: executeDirectAnalysis.bind(undefined, dependencies),
|
||||
runProviderAnalysis: executeProviderAnalysis.bind(undefined, dependencies),
|
||||
runProviderStatus: executeProviderStatus.bind(undefined, dependencies),
|
||||
runCapabilityStatus: executeCapabilityStatus.bind(undefined, dependencies),
|
||||
};
|
||||
};
|
||||
|
||||
/** Run one isolated binary operation through the production session factory. */
|
||||
export const runDirectAnalysis = executeDirectAnalysis.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
/** Bound operations used by CLI command registration. */
|
||||
export type DirectAnalysis = ReturnType<typeof createDirectAnalysis>;
|
||||
|
||||
/** Run one isolated native, artifact or managed operation. */
|
||||
export const runProviderAnalysis = executeProviderAnalysis.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
|
||||
/** Execute managed metadata without constructing native provider candidates. */
|
||||
/** Execute managed metadata without configuration or native provider candidates. */
|
||||
export const runManagedProviderExecution = executeManagedProvider.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
|
||||
/** Report production provider candidates without opening a target. */
|
||||
export const runProviderStatus = executeProviderStatus.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
|
||||
/** Report production session operations without opening a target. */
|
||||
export const runCapabilityStatus = executeCapabilityStatus.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
{
|
||||
createManagedBinarySession,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -2,5 +2,7 @@ import type { ElectronActiveObservationPort } from "../application/javascript/El
|
||||
import { PlaywrightElectronActiveProvider } from "../browser/PlaywrightElectronActiveProvider.js";
|
||||
|
||||
/** Construct a fresh provider without opening a target or acquiring an engine. */
|
||||
export const createElectronScenarioProvider =
|
||||
(): ElectronActiveObservationPort => new PlaywrightElectronActiveProvider();
|
||||
export const createElectronScenarioProvider = (
|
||||
environment: Readonly<Record<string, string | undefined>>,
|
||||
): ElectronActiveObservationPort =>
|
||||
new PlaywrightElectronActiveProvider(environment);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
||||
import type {
|
||||
OptionalObservationProviders,
|
||||
OptionalProviderLoadFailure,
|
||||
@@ -19,23 +20,33 @@ export type OptionalObservationFactories = {
|
||||
>;
|
||||
};
|
||||
|
||||
const productionFactories: OptionalObservationFactories = {
|
||||
browserObservation: async () =>
|
||||
(
|
||||
await import("./browserObservation.js")
|
||||
).createBrowserObservationProvider(),
|
||||
browserScenarioCapture: async () =>
|
||||
(await import("./browserScenario.js")).createBrowserScenarioProvider(),
|
||||
electronObservation: async () =>
|
||||
(
|
||||
await import("./electronObservation.js")
|
||||
).createElectronObservationProvider(),
|
||||
electronActiveObservation: async () =>
|
||||
(await import("./electronScenario.js")).createElectronScenarioProvider(),
|
||||
javascriptRuntimeObservation: async () =>
|
||||
(
|
||||
await import("./javascriptRuntimeObservation.js")
|
||||
).createJavaScriptRuntimeObservationProvider(),
|
||||
/** Bind optional provider construction to one caller-selected process environment. */
|
||||
export const createOptionalObservationFactories = (
|
||||
selectedEnvironment: Readonly<Record<string, string | undefined>>,
|
||||
): OptionalObservationFactories => {
|
||||
const environment = snapshotEnvironment(selectedEnvironment);
|
||||
return {
|
||||
browserObservation: async () =>
|
||||
(
|
||||
await import("./browserObservation.js")
|
||||
).createBrowserObservationProvider(),
|
||||
browserScenarioCapture: async () =>
|
||||
(await import("./browserScenario.js")).createBrowserScenarioProvider(
|
||||
environment,
|
||||
),
|
||||
electronObservation: async () =>
|
||||
(
|
||||
await import("./electronObservation.js")
|
||||
).createElectronObservationProvider(),
|
||||
electronActiveObservation: async () =>
|
||||
(await import("./electronScenario.js")).createElectronScenarioProvider(
|
||||
environment,
|
||||
),
|
||||
javascriptRuntimeObservation: async () =>
|
||||
(
|
||||
await import("./javascriptRuntimeObservation.js")
|
||||
).createJavaScriptRuntimeObservationProvider(),
|
||||
};
|
||||
};
|
||||
|
||||
const loadPort = async <Port>(
|
||||
@@ -54,7 +65,7 @@ const loadPort = async <Port>(
|
||||
|
||||
/** Load each adapter independently, retaining healthy peers and exact failures. */
|
||||
export const loadOptionalObservationProviders = async (
|
||||
factories: OptionalObservationFactories = productionFactories,
|
||||
factories: OptionalObservationFactories,
|
||||
): Promise<OptionalProviderLoadResult> => {
|
||||
const [browser, scenario, electron, electronActive, runtime] =
|
||||
await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user