refactor(mcp): make analysis states unrepresentable (#468)
* refactor(config): parse capability settings into exact states * refactor(runtime): encode replay and process outcomes exactly * refactor: make analysis states unrepresentable * refactor(mcp): register canonical schemas with SDK * fix: preserve capability and catalog invariants * fix(build): remove stale compiled modules * fix(replay): update real verifier policy dependency * fix(package): verify the complete MCP catalog * fix(test): supply complete replay reload policy * refactor(contracts): centralize output schema lookup * refactor(mcp): delegate protocol boundaries to SDK * fix(browser): approve real source capture * fix(mcp): preserve catalog guidance
This commit is contained in:
@@ -11,6 +11,7 @@ import { analyzeJavaScriptApplication } from "../../../src/application/JavaScrip
|
||||
import { reconcileJavaScriptRuntime } from "../../../src/domain/javascriptRuntimeReconciliation.js";
|
||||
import { javascriptRuntimeReconciliationResultSchema } from "../../../src/domain/javascriptRuntimeReconciliationSchemas.js";
|
||||
import { electronActiveObservationInputSchema } from "../../../src/domain/electronActiveObservation.js";
|
||||
import { inspectElectronPageInputSchema } from "../../../src/domain/electronObservation.js";
|
||||
import { createWebTextArtifact } from "../../../src/domain/webContentArtifact.js";
|
||||
import { permissionAuthorityForRoot } from "../../fixtures/permissionAuthority.js";
|
||||
import { createElectronActiveObservationFixtureResult } from "../../fixtures/electronActiveObservationResult.js";
|
||||
@@ -337,7 +338,7 @@ const electronRuntimeEvidence = (
|
||||
const includeWorker = options.includeWorker ?? true;
|
||||
const targetId = options.targetId ?? "target-main";
|
||||
const sourceCaptureApproved = options.sourceCaptureApproved ?? true;
|
||||
const input = {
|
||||
const input = inspectElectronPageInputSchema.parse({
|
||||
cdp_endpoint: "http://127.0.0.1:9223",
|
||||
allowed_file_roots: [root],
|
||||
target_id: targetId,
|
||||
@@ -354,7 +355,7 @@ const electronRuntimeEvidence = (
|
||||
max_script_source_bytes: 1_048_576,
|
||||
max_total_script_source_bytes: 4_194_304,
|
||||
},
|
||||
};
|
||||
});
|
||||
return createElectronEvidence(
|
||||
"inspect_electron_page",
|
||||
input,
|
||||
|
||||
@@ -7,6 +7,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import {
|
||||
MANAGED_RUNTIME_DISABLED,
|
||||
planManagedRuntimeCorrelationEvidence,
|
||||
type ManagedRuntimePolicy,
|
||||
} from "../../../src/application/ManagedRuntimeCorrelationService.js";
|
||||
@@ -43,7 +44,7 @@ describe("managed runtime correlation planning", () => {
|
||||
const fixture = inspect(buildManagedPeFixture(), "/tmp/disabled.dll");
|
||||
const result = await planManagedRuntimeCorrelationEvidence(
|
||||
{
|
||||
policy: disabledPolicy,
|
||||
policy: () => MANAGED_RUNTIME_DISABLED,
|
||||
authority: undefined,
|
||||
},
|
||||
inputFor(fixture.evidence, fixture.method),
|
||||
@@ -64,7 +65,7 @@ describe("managed runtime correlation planning", () => {
|
||||
const authority = await authorityFor(directory, executablePath, false);
|
||||
const result = await planManagedRuntimeCorrelationEvidence(
|
||||
{
|
||||
policy: { enabled: true, roots: [directory], executablePath },
|
||||
policy: () => enabledPolicy(directory, executablePath),
|
||||
authority,
|
||||
},
|
||||
inputFor(fixture.evidence, fixture.method),
|
||||
@@ -82,10 +83,10 @@ describe("managed runtime correlation planning", () => {
|
||||
await writeFile(artifactPath, buildManagedPeFixture());
|
||||
await writeFile(executablePath, "#!/bin/sh\n");
|
||||
const fixture = inspect(buildManagedPeFixture(), artifactPath);
|
||||
const policy = { enabled: true, roots: [directory], executablePath };
|
||||
const policy = enabledPolicy(directory, executablePath);
|
||||
const authority = await authorityFor(directory, executablePath, true);
|
||||
const result = await planManagedRuntimeCorrelationEvidence(
|
||||
{ policy, authority },
|
||||
{ policy: () => policy, authority },
|
||||
inputFor(fixture.evidence, fixture.method),
|
||||
);
|
||||
|
||||
@@ -131,7 +132,7 @@ describe("managed runtime correlation planning", () => {
|
||||
const authority = await authorityFor(directory, executablePath, true);
|
||||
const result = await planManagedRuntimeCorrelationEvidence(
|
||||
{
|
||||
policy: { enabled: true, roots: [directory], executablePath },
|
||||
policy: () => enabledPolicy(directory, executablePath),
|
||||
authority,
|
||||
},
|
||||
{
|
||||
@@ -162,7 +163,7 @@ describe("managed runtime correlation planning", () => {
|
||||
const authority = await authorityFor(directory, executablePath, true);
|
||||
const result = await planManagedRuntimeCorrelationEvidence(
|
||||
{
|
||||
policy: { enabled: true, roots: [directory], executablePath },
|
||||
policy: () => enabledPolicy(directory, executablePath),
|
||||
authority,
|
||||
},
|
||||
inputFor(fixture.evidence, fixture.method),
|
||||
@@ -178,11 +179,14 @@ describe("managed runtime correlation planning", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const disabledPolicy: ManagedRuntimePolicy = {
|
||||
enabled: false,
|
||||
roots: [],
|
||||
executablePath: "/usr/bin/dotnet",
|
||||
};
|
||||
const enabledPolicy = (
|
||||
root: string,
|
||||
executablePath: string,
|
||||
): ManagedRuntimePolicy => ({
|
||||
status: "enabled",
|
||||
roots: [root],
|
||||
executablePath,
|
||||
});
|
||||
|
||||
const authorityFor = async (
|
||||
root: string,
|
||||
@@ -251,6 +255,9 @@ const inspect = (
|
||||
kind: "executable",
|
||||
format: "pe",
|
||||
architecture: "x86",
|
||||
availableArchitectures: ["x86"],
|
||||
executableRole: "application",
|
||||
managed: true,
|
||||
};
|
||||
const result = inspectManagedMembersBytes(bytes, target, limits);
|
||||
const method = result.methods.items[0];
|
||||
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
prepareNodeCharacterization,
|
||||
} from "../../../src/application/NodeRuntimeCharacterizationService.js";
|
||||
import type {
|
||||
EnabledJavaScriptReplayPolicy,
|
||||
JavaScriptReplayHost,
|
||||
JavaScriptReplayPolicy,
|
||||
JavaScriptReplayRunner,
|
||||
} from "../../../src/application/JavaScriptReplayPlanning.js";
|
||||
import { PermissionAuthority } from "../../../src/application/PermissionAuthority.js";
|
||||
@@ -68,6 +68,12 @@ describe("Node runtime characterization", () => {
|
||||
},
|
||||
replay: { phase: "plan" },
|
||||
});
|
||||
expect(() =>
|
||||
nodeCharacterizationPreparationOutputSchema.parse({
|
||||
...output,
|
||||
plan: { ...output.plan, expected_effect: "bounded-effects" },
|
||||
}),
|
||||
).toThrow();
|
||||
|
||||
const stale = await executeNodeCharacterization(dependencies, {
|
||||
execution_approved: true,
|
||||
@@ -192,13 +198,12 @@ const preparationInput = (
|
||||
entry_export: "selected",
|
||||
},
|
||||
cases: [{ case_id: "trim", arguments: [" value "] }],
|
||||
approved: false,
|
||||
},
|
||||
});
|
||||
|
||||
const dependenciesFor = (root: string, onExecute: () => void) => {
|
||||
const policy: JavaScriptReplayPolicy = {
|
||||
enabled: true,
|
||||
const policy: EnabledJavaScriptReplayPolicy = {
|
||||
status: "enabled",
|
||||
roots: [root],
|
||||
nodePath: process.execPath,
|
||||
bubblewrapPath: process.execPath,
|
||||
@@ -287,5 +292,5 @@ const dependenciesFor = (root: string, onExecute: () => void) => {
|
||||
],
|
||||
),
|
||||
);
|
||||
return { policy, host, runner, authority };
|
||||
return { policy: () => policy, host, runner, authority };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user