refactor(tools): remove redundant limits and acknowledgements

This commit is contained in:
morluto
2026-09-29 10:53:45 +08:00
parent 7ba3580c86
commit bd0e341572
158 changed files with 599 additions and 1527 deletions
@@ -156,7 +156,6 @@ async function executeReplayScenario(
arguments: {
...input,
mode: "execute",
approved: true,
plan_digest: digest,
},
});
@@ -180,7 +179,6 @@ async function createCharacterizationInput(root: string) {
const factoryBytes = await readFile(factoryPath);
const factorySha256 = createHash("sha256").update(factoryBytes).digest("hex");
return {
preparation_approved: true,
selected_alias: "bundle",
expected_effect: "pure",
instrumentation: {
@@ -230,7 +228,6 @@ async function executeCharacterizationScenario(
const characterized = await client.callTool({
name: "execute_node_characterization",
arguments: {
execution_approved: true,
approved_plan_sha256: approvedPlan.plan_sha256,
preparation: input,
},
@@ -8,7 +8,6 @@ import { afterEach, describe, expect, it } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import {
JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE,
JAVASCRIPT_FEATURE_TRACE_FULL_EVIDENCE_EXAMPLE,
JAVASCRIPT_FEATURE_TRACE_EXAMPLE,
JAVASCRIPT_VERSION_COMPARISON_FULL_EVIDENCE_EXAMPLE,
@@ -160,7 +159,6 @@ describe("application workflow CLI Evidence resolution", () => {
[
"compare-application-versions",
JSON.stringify({
...JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE,
left_evidence_id:
JAVASCRIPT_VERSION_COMPARISON_FULL_EVIDENCE_EXAMPLE.left
.evidence_id,
@@ -4,6 +4,7 @@ import { afterEach, describe, expect, it } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { compareApplicationVersionsRequestSchema } from "../../../src/contracts/applicationWorkflowInputContracts.js";
import { analyzeJavaScriptApplication } from "../../../src/application/JavaScriptApplicationService.js";
import { compareApplicationVersionsEvidence } from "../../../src/application/JavaScriptApplicationWorkflowService.js";
import { createEvidence } from "../../../src/domain/evidence.js";
@@ -132,6 +133,41 @@ describe("JavaScript application workflows", () => {
});
describe("JavaScript application comparison workflows", () => {
it("accepts complete native evidence arrays and rejects comparison limit bags", () => {
const native = Array.from({ length: 65 }, (_, index) =>
createEvidence(
{
path: `/tmp/native-${index}.node`,
sha256: index.toString(16).padStart(64, "0"),
format: "elf",
architecture: "x86_64",
},
{ id: "ghidra", name: "Ghidra", version: "fixture" },
{
operation: "analyze_function",
parameters: { address: `0x${index.toString(16)}` },
result: { address: `0x${index.toString(16)}` },
},
),
);
const input = {
left: `ev_${"a".repeat(64)}`,
right: `ev_${"b".repeat(64)}`,
left_native_observations: native,
};
expect(
compareApplicationVersionsRequestSchema.safeParse(input).success,
).toBe(true);
expect(
compareApplicationVersionsRequestSchema.safeParse({
...input,
limits: { max_comparison_items: 1 },
}).success,
).toBe(false);
});
});
describe("complete comparison projections", () => {
it("matches rechunked modules by exact source and minified modules by structural fingerprint", async () => {
const root = await createTestTempDirectory("rea-application-versions-");
temporary.push(root);
@@ -145,6 +181,7 @@ describe("JavaScript application comparison workflows", () => {
const result = applicationVersionComparisonResultSchema.parse(
compared.value.normalized_result,
);
expectFullComparisonResultSchema(result);
const modules = result.items.filter(
({ node_kind: kind }) => kind === "javascript-module",
);
@@ -174,6 +211,9 @@ describe("JavaScript application comparison workflows", () => {
);
expect(result.summary.added).toBeGreaterThan(0);
expect(result.summary.removed).toBeGreaterThan(0);
expect(result.coverage).not.toHaveProperty("omitted_graph_nodes");
expect(result.coverage).not.toHaveProperty("omitted_graph_edges");
expect(result.coverage).not.toHaveProperty("omitted_graph_observations");
expect(result.graph.edges).toEqual(
expect.arrayContaining([
expect.objectContaining({
@@ -216,7 +256,7 @@ describe("JavaScript application comparison workflows", () => {
);
});
it("keeps incomplete one-sided absence unknown and reports output truncation", () => {
it("keeps incomplete one-sided absence unknown and reports source omissions", () => {
const complete = buildSyntheticJavaScriptApplicationGraph();
const rootNode = complete.nodes.find(({ node_id: id }) =>
complete.root_node_ids.includes(id),
@@ -248,12 +288,6 @@ describe("JavaScript application comparison workflows", () => {
},
leftNativeEvidence: [],
rightNativeEvidence: [],
limits: {
max_comparison_items: 1,
max_candidate_nodes: 1,
max_graph_nodes: 20,
max_graph_edges: 20,
},
};
const first = compareJavaScriptApplicationVersions(input);
@@ -262,8 +296,8 @@ describe("JavaScript application comparison workflows", () => {
expect(first.coverage).toMatchObject({
status: "truncated",
right_graph_status: "partial",
right_graph_omitted_count: complete.nodes.length - 1,
});
expect(first.coverage.omitted_comparison_items).toBeGreaterThan(0);
expect(first.summary.removed).toBe(0);
expect(first.summary.unknown).toBeGreaterThan(0);
});
@@ -310,8 +344,40 @@ const expectComparisonItemAlgebra = (
coverage: {
...result.coverage,
status: "complete-within-inputs",
omitted_comparison_items: 1,
left_graph_status: "partial",
},
}).success,
).toBe(false);
};
const expectFullComparisonResultSchema = (
result: ApplicationVersionComparisonResult,
): void => {
const candidateNodeIds = Array.from(
{ length: 1_001 },
(_, index) => `jag_node_${index.toString(16).padStart(64, "0")}`,
);
const expanded = {
...result,
evidence_links: Array.from(
{ length: 131 },
(_, index) => `ev_${index.toString(16).padStart(64, "0")}`,
),
items: result.items.map((item) =>
item.match.status === "ambiguous"
? {
...item,
match: {
...item.match,
...(item.match.candidate_left_node_ids.length === 0
? { candidate_right_node_ids: candidateNodeIds }
: { candidate_left_node_ids: candidateNodeIds }),
},
}
: item,
),
};
expect(
applicationVersionComparisonResultSchema.safeParse(expanded).success,
).toBe(true);
};
@@ -16,7 +16,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 1", () => {
listBrowserTargetsInputSchema.parse({
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
approved: true,
}),
);
if (!listed.ok) throw listed.error;
@@ -33,7 +32,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 1", () => {
listBrowserTargetsInputSchema.parse({
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
approved: true,
}),
);
@@ -68,7 +66,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 1", () => {
const input = {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
approved: true as const,
target_id: "allowed-page",
};
const expected = `${prefix}${browser.allowedOrigin}/app?startup=%5BREDACTED%5D`;
@@ -102,7 +99,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 1", () => {
listBrowserTargetsInputSchema.parse({
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
approved: true,
}),
);
if (!listed.ok) throw listed.error;
@@ -119,7 +115,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -132,7 +127,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page-with-socket",
approved: true,
observation_ms: 0,
}),
);
@@ -156,7 +150,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -179,7 +172,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: targetId,
approved: true,
observation_ms: 0,
}),
);
@@ -201,7 +193,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 2", () => {
listBrowserTargetsInputSchema.parse({
cdp_endpoint: malformed.endpoint,
allowed_origins: [malformed.allowedOrigin],
approved: true,
}),
);
expect(malformedResult).toMatchObject({
@@ -221,7 +212,6 @@ describeBrowser("CdpBrowserProvider: discovery authorization 2", () => {
cdp_endpoint: disconnecting.endpoint,
allowed_origins: [disconnecting.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -17,7 +17,6 @@ describeBrowser("CdpBrowserProvider: document script 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_accessibility_text: true,
limits: {
@@ -50,10 +49,8 @@ describeBrowser("CdpBrowserProvider: document script 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_script_sources: true,
source_capture_approved: true,
}),
);
@@ -89,11 +86,8 @@ describeBrowser("CdpBrowserProvider: document script 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
source_capture_approved: true,
observation_ms: 0,
fetch_source_maps: true,
source_map_fetch_approved: true,
}),
);
@@ -133,7 +127,6 @@ describeBrowser("CdpBrowserProvider: document script 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -188,7 +181,6 @@ describeBrowser("CdpBrowserProvider: document script 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -212,7 +204,6 @@ describeBrowser("CdpBrowserProvider: document script 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -241,7 +232,6 @@ describeBrowser("CdpBrowserProvider: document script 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
max_tools: 1,
}),
@@ -272,7 +262,6 @@ describeBrowser("CdpBrowserProvider: document script 3", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -301,8 +290,6 @@ describeBrowser("CdpBrowserProvider: document script 3", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
screenshot_approved: true,
}),
);
@@ -330,8 +317,6 @@ describeBrowser("CdpBrowserProvider: document script 3", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
screenshot_approved: true,
}),
);
@@ -353,10 +338,8 @@ describeBrowser("CdpBrowserProvider: document script 3", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_script_sources: true,
source_capture_approved: true,
limits: {
max_frames: 1,
max_dom_nodes: 1,
@@ -399,7 +382,6 @@ describeBrowser("CdpBrowserProvider: document script 4", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_storage_keys: true,
limits: {
@@ -26,7 +26,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 1_000,
}),
{
@@ -66,8 +65,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
source_capture_approved: true,
observation_ms: 1_000,
}),
{
@@ -100,7 +97,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 20,
}),
);
@@ -147,7 +143,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 1_000,
}),
);
@@ -172,7 +167,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 1_000,
}),
);
@@ -199,7 +193,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 1_000,
}),
);
@@ -235,7 +228,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 1,
}),
);
@@ -262,7 +254,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 3", () => {
cdp_endpoint: optional.endpoint,
allowed_origins: [optional.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -288,7 +279,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 3", () => {
listBrowserTargetsInputSchema.parse({
cdp_endpoint: failed.endpoint,
allowed_origins: [failed.allowedOrigin],
approved: true,
}),
);
expect(result.ok).toBe(false);
@@ -308,7 +298,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 3", () => {
cdp_endpoint: malformed.endpoint,
allowed_origins: [malformed.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -326,7 +315,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 3", () => {
cdp_endpoint: malformedEvent.endpoint,
allowed_origins: [malformedEvent.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -344,7 +332,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 3", () => {
cdp_endpoint: malformedEventShape.endpoint,
allowed_origins: [malformedEventShape.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -363,7 +350,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 3", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 1_000,
}),
{ signal: controller.signal },
@@ -398,7 +384,6 @@ describeBrowser("CdpBrowserProvider: lifecycle failures 4", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
});
const committed = await new CdpBrowserProvider().inspectPage(
@@ -16,7 +16,6 @@ describeBrowser("CdpBrowserProvider: network 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -25,7 +25,6 @@ describeBrowser("CdpBrowserProvider: sensitive data 1", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_storage_keys: true,
include_storage_fingerprints: true,
@@ -171,14 +170,10 @@ describeBrowser("CdpBrowserProvider: sensitive data 2", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_console_text: true,
console_text_approved: true,
include_json_body_shapes: true,
json_body_schema_approved: true,
include_websocket_shapes: true,
websocket_shape_approved: true,
}),
);
@@ -261,14 +256,10 @@ describeBrowser("CdpBrowserProvider: sensitive data 3", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_console_text: true,
console_text_approved: true,
include_json_body_shapes: true,
json_body_schema_approved: true,
include_websocket_shapes: true,
websocket_shape_approved: true,
limits: {
max_console_text_field_bytes: 5,
max_total_console_text_bytes: 5,
@@ -316,12 +307,9 @@ describeBrowser("CdpBrowserProvider: sensitive data 3", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_json_body_shapes: true,
json_body_schema_approved: true,
include_websocket_shapes: true,
websocket_shape_approved: true,
}),
);
@@ -41,7 +41,6 @@ describe("CdpElectronProvider target access", () => {
listElectronTargetsInputSchema.parse({
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
approved: true,
}),
);
if (!listed.ok) throw listed.error;
@@ -63,7 +62,6 @@ describe("CdpElectronProvider target access", () => {
listElectronTargetsInputSchema.parse({
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
approved: true,
}),
);
if (!listed.ok) throw listed.error;
@@ -84,7 +82,6 @@ describe("CdpElectronProvider target access", () => {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
target_id: "electron-page",
approved: true,
observation_ms: 0,
}),
);
@@ -120,7 +117,6 @@ describe("CdpElectronProvider target access", () => {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
target_id: "missing",
approved: true,
observation_ms: 0,
}),
);
@@ -148,7 +144,6 @@ describe("CdpElectronProvider target access", () => {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
target_id: "electron-page",
approved: true,
observation_ms: 0,
}),
);
@@ -170,7 +165,6 @@ describe("CdpElectronProvider target access", () => {
listElectronTargetsInputSchema.parse({
cdp_endpoint: "http://127.0.0.1:9222",
allowed_file_roots: [root],
approved: true,
}),
{ signal: controller.signal },
);
@@ -197,10 +191,8 @@ describe("CdpElectronProvider capture", () => {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
target_id: "electron-page",
approved: true,
observation_ms: 0,
include_script_sources: true,
source_capture_approved: true,
}),
);
if (!result.ok) throw result.error;
@@ -225,7 +217,6 @@ describe("CdpElectronProvider capture", () => {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
target_id: "electron-page",
approved: true,
observation_ms: 0,
}),
);
@@ -257,7 +248,6 @@ describe("CdpElectronProvider capture", () => {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
target_id: "electron-page",
approved: true,
observation_ms: 0,
}),
);
@@ -38,7 +38,6 @@ describe("passive V8 Inspector provider", () => {
inspector_endpoint: fake.endpoint,
allowed_file_roots: [fixture.root],
allowed_origins: [],
approved: true,
});
expect(listed.ok).toBe(true);
if (!listed.ok) return;
@@ -61,7 +60,6 @@ describe("passive V8 Inspector provider", () => {
inspector_endpoint: fake.endpoint,
allowed_file_roots: [fixture.root],
allowed_origins: [],
approved: true,
});
expect(result.ok).toBe(true);
if (!result.ok) return;
@@ -125,7 +123,6 @@ describe("passive V8 Inspector provider", () => {
inspector_endpoint: fake.endpoint,
allowed_file_roots: [fixture.root],
allowed_origins: [],
approved: true,
});
expect(listed.ok).toBe(true);
if (!listed.ok) return;
@@ -269,7 +266,6 @@ describe("passive V8 Inspector evidence", () => {
inspector_endpoint: fake.endpoint,
allowed_file_roots: [fixture.root],
allowed_origins: [],
approved: true,
},
);
expect(listed.ok).toBe(true);
@@ -292,7 +288,6 @@ describe("passive V8 Inspector evidence", () => {
allowed_origins: [],
target_id: "example-v8-target",
runtime_kind: "electron-main",
approved: true,
observation_ms: 100,
limits: {
max_events: 10_000,
@@ -345,7 +340,6 @@ const observeInput = (
allowed_origins: [],
target_id: targetId,
runtime_kind: runtimeKind,
approved: true,
observation_ms: 10,
limits: {
max_events: 10_000,
@@ -30,7 +30,6 @@ describe("web capture diff", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -97,7 +96,6 @@ describe("web capture diff", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -124,7 +122,6 @@ describe("web capture diff", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
}),
);
@@ -164,7 +161,6 @@ describe("web capture diff semantics and fingerprints", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_accessibility_text: true,
include_storage_keys: true,
@@ -240,7 +236,6 @@ describe("web capture diff completeness", () => {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_accessibility_text: true,
include_storage_keys: true,
@@ -245,17 +245,12 @@ describe("web source-map aggregate limits", () => {
});
});
it("rejects a per-map byte limit larger than the aggregate limit", () => {
it("does not accept caller overrides for provider source-map limits", () => {
const parsed = analyzeWebBundleInputSchema.safeParse({
cdp_endpoint: "http://127.0.0.1:9222",
allowed_origins: [origin],
target_id: "page-1",
approved: true,
source_capture_approved: true,
analysis_limits: {
max_source_map_bytes: 2,
max_total_source_map_bytes: 1,
},
analysis_limits: { max_source_maps: 0 },
});
expect(parsed.success).toBe(false);
@@ -274,14 +269,22 @@ const validMapResponse = () =>
{ status: 200 },
);
const input = (overrides: Record<string, unknown> = {}) =>
analyzeWebBundleInputSchema.parse({
const input = (overrides: Record<string, unknown> = {}) => {
const { analysis_limits: internalLimitOverrides, ...callerOverrides } =
overrides;
const parsed = analyzeWebBundleInputSchema.parse({
cdp_endpoint: "http://127.0.0.1:9222",
allowed_origins: [origin],
target_id: "page-1",
approved: true,
source_capture_approved: true,
fetch_source_maps: true,
source_map_fetch_approved: true,
...overrides,
...callerOverrides,
});
const limits = {
...parsed.analysis_limits,
...(internalLimitOverrides as Record<string, number> | undefined),
};
return {
...parsed,
analysis_limits: limits,
};
};
+8 -23
View File
@@ -35,7 +35,7 @@ describe("browser CLI parity", () => {
]),
};
const listed = await runCli(
["list-browser-targets", browser.endpoint, "--approved", "--json"],
["list-browser-targets", browser.endpoint, "--json"],
environment,
);
expect(listed).toMatchObject({
@@ -50,15 +50,11 @@ describe("browser CLI parity", () => {
"inspect-web-page",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"0",
"--include-console-text",
"--console-text-approved",
"--include-json-body-shapes",
"--json-body-schema-approved",
"--include-websocket-shapes",
"--websocket-shape-approved",
"--json",
],
environment,
@@ -145,8 +141,6 @@ describe("browser CLI capture parity", () => {
"analyze-web-bundle",
browser.endpoint,
"allowed-page",
"--approved",
"--source-capture-approved",
"--observation-ms",
"0",
"--json",
@@ -165,7 +159,6 @@ describe("browser CLI capture parity", () => {
"observe-web-session",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"5",
"--json",
@@ -186,7 +179,6 @@ describe("browser CLI capture parity", () => {
"discover-webmcp-tools",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"0",
"--json",
@@ -202,14 +194,7 @@ describe("browser CLI capture parity", () => {
},
});
const screenshot = await runCli(
[
"capture-web-screenshot",
browser.endpoint,
"allowed-page",
"--approved",
"--screenshot-approved",
"--json",
],
["capture-web-screenshot", browser.endpoint, "allowed-page", "--json"],
environment,
);
const artifact = screenshotArtifact(screenshot);
@@ -251,9 +236,9 @@ describe("browser CLI capture parity", () => {
);
});
describe("browser CLI approval", () => {
describe("browser CLI configured access", () => {
it(
"requires explicit approval before opening the CDP endpoint",
"uses the configured endpoint without a redundant request approval flag",
async () => {
const browser = await startFakeCdpBrowser();
browsers.push(browser);
@@ -269,11 +254,11 @@ describe("browser CLI approval", () => {
},
);
expect(result).toMatchObject({
error: "Browser observation failed",
code: "invalid_request",
category: "invalid_input",
operation: "list_browser_targets",
normalized_result: {
targets: [{ target_id: "allowed-page" }],
},
});
expect(browser.commands).toHaveLength(0);
},
INTEGRATION_TEST_TIMEOUT_MS,
);
+1 -2
View File
@@ -51,7 +51,7 @@ describe("Electron CLI parity", () => {
REA_ELECTRON_FILE_ROOTS_JSON: JSON.stringify([root]),
};
const listed = await runCli(
["list-electron-targets", browser.endpoint, "--approved", "--json"],
["list-electron-targets", browser.endpoint, "--json"],
environment,
);
expect(listed).toMatchObject({
@@ -65,7 +65,6 @@ describe("Electron CLI parity", () => {
"inspect-electron-page",
browser.endpoint,
"electron-page",
"--approved",
"--observation-ms",
"0",
"--json",
@@ -48,12 +48,7 @@ describe("JavaScript runtime observation CLI parity", () => {
};
const listed = await runCli(
[
"list-javascript-runtime-targets",
inspector.endpoint,
"--approved",
"--json",
],
["list-javascript-runtime-targets", inspector.endpoint, "--json"],
environment,
);
expect(listed).toMatchObject({
@@ -71,7 +66,6 @@ describe("JavaScript runtime observation CLI parity", () => {
inspector.targetId,
"--runtime-kind",
"node",
"--approved",
"--observation-ms",
"10",
"--json",
@@ -105,7 +99,6 @@ describe("JavaScript runtime observation CLI parity", () => {
allowed_origins: [],
target_id: inspector.targetId,
runtime_kind: "node",
approved: true,
observation_ms: 10,
limits: {
max_events: 10_000,
-1
View File
@@ -98,7 +98,6 @@ describe("process CLI errors", () => {
await writeFile(
scenario,
JSON.stringify({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
}),
@@ -31,67 +31,7 @@ it("reads local source maps as part of static artifact analysis", async () => {
);
});
it("reports text and AST limits as truncation instead of absence", async () => {
const root = await fixtureDirectory();
const result = await reconstructJavaScriptArtifact({
input_path: root,
limits: {
max_text_file_bytes: 128,
max_total_text_bytes: 1_024,
max_ast_nodes: 50,
},
});
expect(result.statistics.limit_omitted_text_files).toBeGreaterThan(0);
expect(result.graph.coverage).toMatchObject({
status: "partial",
truncated: true,
});
expect(result.graph.coverage.omitted_count).toBeGreaterThan(0);
expect(result.graph.nodes.some(({ kind }) => kind === "unknown")).toBe(true);
expect(result.graph.limitations.join(" ")).toMatch(/incomplete|bound/iu);
});
it("uses an unknown omission count when AST traversal reaches its bound", async () => {
const root = await createTestTempDirectory("rea-javascript-ast-limit-");
await writeFile(
join(root, "large.js"),
[
'import "./unobserved.js";',
...Array.from(
{ length: 100 },
(_, index) => `export const value${String(index)} = ${String(index)};`,
),
].join("\n"),
);
const result = await reconstructJavaScriptArtifact({
input_path: root,
limits: { max_ast_nodes: 50 },
});
expect(result.statistics.limit_omitted_text_files).toBe(0);
expect(result.statistics.truncated_scopes).toBe(1);
expect(result.graph.coverage).toMatchObject({
status: "partial",
truncated: true,
omitted_count: null,
});
const derivedImport = result.graph.edges.find(
({ relation, properties }) =>
relation === "imports" && properties.specifier === "./unobserved.js",
);
expect(derivedImport?.evidence.coverage).toEqual({
status: "partial",
truncated: true,
omitted_count: null,
limits: expect.arrayContaining([
{ name: "max-ast-nodes", value: 50, unit: "items" },
]),
});
});
it("does not follow symlinks or read oversized JavaScript text", async () => {
it("does not follow symlinks or exceed the internal text-file safety boundary", async () => {
const root = await fixtureDirectory();
const outside = await createTestTempDirectory("rea-javascript-outside-");
const outsideFile = join(outside, "secret.js");
@@ -102,13 +42,10 @@ it("does not follow symlinks or read oversized JavaScript text", async () => {
await symlink(outsideFile, join(root, "escape.js"));
await writeFile(
join(root, "oversized.js"),
`const oversizedSecret = "${"private-marker-".repeat(256)}";`,
`const oversizedSecret = "${"private-marker-".repeat(600_000)}";`,
);
const result = await reconstructJavaScriptArtifact({
input_path: root,
limits: { max_text_file_bytes: 512 },
});
const result = await reconstructJavaScriptArtifact({ input_path: root });
const encoded = JSON.stringify(result);
expect(result.statistics.limit_omitted_text_files).toBeGreaterThan(0);
@@ -153,7 +90,7 @@ it("keeps malformed JavaScript, package metadata, and source maps as explicit un
);
});
it("applies one source-map source budget across every local map", async () => {
it("retains every source declared by every included local source map", async () => {
const root = await createTestTempDirectory("rea-javascript-source-maps-");
await Promise.all([
writeFile(
@@ -178,22 +115,19 @@ it("applies one source-map source budget across every local map", async () => {
),
]);
const result = await reconstructJavaScriptArtifact({
input_path: root,
limits: { max_source_map_sources: 3 },
});
const result = await reconstructJavaScriptArtifact({ input_path: root });
expect(
result.graph.nodes.filter(({ kind }) => kind === "source-module"),
).toHaveLength(3);
).toHaveLength(4);
expect(result.graph.coverage).toMatchObject({
status: "partial",
truncated: true,
omitted_count: null,
status: "complete",
truncated: false,
omitted_count: 0,
});
});
it("bounds repeated content observations while retaining every containment path", async () => {
it("retains every repeated content observation and containment path", async () => {
const root = await createTestTempDirectory("rea-javascript-observations-");
await Promise.all(
Array.from({ length: 70 }, (_, index) =>
@@ -218,26 +152,23 @@ it("bounds repeated content observations while retaining every containment path"
String(properties.path).startsWith("duplicate-"),
);
expect(duplicateNode?.observations).toHaveLength(64);
expect(duplicateNode?.observations).toHaveLength(70);
expect(duplicateEdges).toHaveLength(70);
expect(result.graph.coverage).toMatchObject({
status: "partial",
truncated: true,
omitted_count: 6,
status: "complete",
truncated: false,
omitted_count: 0,
});
}, 15_000);
it("rejects traversal from a production reader seam and malformed ASAR containers", async () => {
const root = await fixtureDirectory();
const input = javascriptArtifactReconstructionInputSchema.parse({
input_path: root,
});
const snapshot = await scanArtifactInventory(
root,
artifactLimitsForReconstruction(input),
artifactLimitsForReconstruction(),
);
await expect(
readJavaScriptArtifactFiles(new TraversalReader(), snapshot, input),
readJavaScriptArtifactFiles(new TraversalReader(), snapshot),
).rejects.toMatchObject({ reason: "path" });
const malformed = join(root, "malformed.asar");
@@ -264,11 +195,11 @@ it("preserves cancellation and explicit format diagnostics", async () => {
message: expect.stringContaining(root),
});
expect(
javascriptArtifactReconstructionInputSchema.parse({
javascriptArtifactReconstructionInputSchema.safeParse({
input_path: root,
limits: { max_entries: 100_000 },
}).limits.max_entries,
).toBe(100_000);
}).success,
).toBe(false);
});
class TraversalReader implements ArtifactReader {
@@ -46,10 +46,7 @@ describe("Node runtime characterization", () => {
plan: {
preparation_sha256: expect.stringMatching(/^[a-f0-9]{64}$/u),
runtime: { family: "ecmascript", provider_id: "node-javascript" },
authority: {
preparation_approved: true,
execution_approved: false,
},
authority: {},
},
transformation: {
original_sha256: fixture.sha256,
@@ -69,7 +66,6 @@ describe("Node runtime characterization", () => {
).toThrow();
const stale = await executeNodeCharacterization(dependencies, {
execution_approved: true,
approved_plan_sha256: "0".repeat(64),
preparation: input,
});
@@ -78,7 +74,6 @@ describe("Node runtime characterization", () => {
expect(executions).toBe(0);
const executed = await executeNodeCharacterization(dependencies, {
execution_approved: true,
approved_plan_sha256: output.plan.plan_sha256,
preparation: input,
});
@@ -161,7 +156,6 @@ const createFixture = async () => {
const preparationInput = (
fixture: Awaited<ReturnType<typeof createFixture>>,
) => ({
preparation_approved: true,
selected_alias: "bundle",
expected_effect: "pure" as const,
instrumentation: {
-24
View File
@@ -71,7 +71,6 @@ it(
arguments: {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
approved: true,
},
});
expect(listed.isError).not.toBe(true);
@@ -80,33 +79,17 @@ it(
targets: [{ target_id: "allowed-page" }],
},
});
const unapprovedSourceCapture = await connected.client.callTool({
name: "inspect_web_page",
arguments: {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
include_script_sources: true,
},
});
expect(unapprovedSourceCapture.isError).toBe(true);
const inspected = await connected.client.callTool({
name: "inspect_web_page",
arguments: {
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
include_console_text: true,
console_text_approved: true,
include_json_body_shapes: true,
json_body_schema_approved: true,
include_websocket_shapes: true,
websocket_shape_approved: true,
include_script_sources: true,
source_capture_approved: true,
},
});
expect(inspected.isError).not.toBe(true);
@@ -146,8 +129,6 @@ it(
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
source_capture_approved: true,
observation_ms: 0,
},
});
@@ -174,7 +155,6 @@ const verifySessionAndComparisonTools = async (
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 5,
},
});
@@ -193,7 +173,6 @@ const verifySessionAndComparisonTools = async (
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
},
});
@@ -228,8 +207,6 @@ const verifySessionAndComparisonTools = async (
cdp_endpoint: browser.endpoint,
allowed_origins: [browser.allowedOrigin],
target_id: "allowed-page",
approved: true,
screenshot_approved: true,
},
});
expect(screenshot.isError).not.toBe(true);
@@ -262,7 +239,6 @@ it("denies origins outside the administrator ceiling before CDP attach", async (
cdp_endpoint: browser.endpoint,
allowed_origins: ["https://unapproved.example.test"],
target_id: "allowed-page",
approved: true,
observation_ms: 0,
},
});
@@ -163,7 +163,6 @@ const scenario = (origin = "https://app.example.test") => ({
max_storage_entries: 100,
max_total_metadata_bytes: 1_048_576,
},
approved: true,
});
describe("browser scenario MCP tool", () => {
-5
View File
@@ -88,7 +88,6 @@ it("exposes root-confined Electron discovery and inspection as Evidence v2", asy
arguments: {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
approved: true,
},
});
expect(listed.isError).not.toBe(true);
@@ -103,10 +102,8 @@ it("exposes root-confined Electron discovery and inspection as Evidence v2", asy
cdp_endpoint: browser.endpoint,
allowed_file_roots: [root],
target_id: "electron-page",
approved: true,
observation_ms: 0,
include_script_sources: true,
source_capture_approved: true,
},
});
const analyzed = await client.callTool({
@@ -171,7 +168,6 @@ it("exposes root-confined Electron discovery and inspection as Evidence v2", asy
arguments: {
cdp_endpoint: browser.endpoint,
allowed_file_roots: [outside],
approved: true,
},
});
expect(denied.isError).toBe(true);
@@ -248,7 +244,6 @@ it("exposes active Electron scenarios through the separately granted MCP boundar
actions: [
{ step_id: "submit", kind: "click", selector: "#submit-secret" },
],
approved: true,
},
});
expect(captured.isError, JSON.stringify(captured)).not.toBe(true);
@@ -249,7 +249,6 @@ it("cannot omit a session-owned active unknown from reconstruction input", async
expect(session.recordEvidence(evidence).ok).toBe(true);
expect(
session.recordUnknown({
approved: true,
question: "Was terminal equivalence reproduced independently?",
severity: "high",
domain: "reconstruction-verification",
@@ -72,7 +72,6 @@ describe("JavaScript runtime observation MCP tools", () => {
inspector_endpoint: inspector.endpoint,
allowed_file_roots: [root],
allowed_origins: [],
approved: true,
},
});
expect(listed.isError).not.toBe(true);
@@ -90,7 +89,6 @@ describe("JavaScript runtime observation MCP tools", () => {
allowed_origins: [],
target_id: inspector.targetId,
runtime_kind: "node",
approved: true,
observation_ms: 10,
},
});
@@ -126,7 +124,6 @@ describe("JavaScript runtime observation MCP tools", () => {
allowed_origins: [],
target_id: inspector.targetId,
runtime_kind: "node",
approved: true,
observation_ms: 10,
limits: {
max_events: 10_000,
+25
View File
@@ -57,6 +57,31 @@ interface Invocation {
const resources: Array<{ close(): Promise<void> }> = [];
describe("read_bytes contract", () => {
it("accepts lengths above the former arbitrary ceiling and rejects zero", () => {
const contract = OFFICIAL_TOOL_CONTRACTS.find(
({ name }) => name === "read_bytes",
);
expect(contract).toBeDefined();
expect(
contract?.inputSchema.safeParse({ address: "0x1000", length: 4097 })
.success,
).toBe(true);
expect(
contract?.inputSchema.safeParse({ address: "0x1000", length: 0 }).success,
).toBe(false);
expect(
contract?.outputSchema.shape.result.safeParse({
address: "0x1000",
requested_bytes: 4097,
returned_bytes: 4097,
bytes_hex: "ff".repeat(4097),
complete: true,
}).success,
).toBe(true);
});
});
afterEach(async () => {
await Promise.all(
resources.splice(0).map(async (resource) => resource.close()),
@@ -90,7 +90,6 @@ describe("process-capture MCP elicitation handshake", () => {
const captured = await client.callTool({
name: "capture_process_scenario",
arguments: {
approved: true,
executable: process.execPath,
arguments: ["-e", "process.exit(0)"],
working_directory: root,
@@ -69,7 +69,6 @@ describe("process-capture MCP elicitation handshake", () => {
const call = {
name: "capture_process_scenario",
arguments: {
approved: true,
executable: process.execPath,
arguments: ["-e", "process.exit(0)"],
working_directory: root,
@@ -93,7 +93,6 @@ describe("guided prompt completion from investigation records", () => {
])
expect(session.recordEvidence(evidence).ok).toBe(true);
const unknown = session.recordUnknown({
approved: true,
question: "Which branch handles the fallback?",
severity: "medium",
domain: "control-flow",
@@ -122,7 +121,6 @@ describe("guided prompt completion from investigation records", () => {
]);
const resolved = session.updateUnknown({
approved: true,
unknown_id: unknown.value.unknown_id,
expected_revision: unknown.value.revision,
status: "resolved",
-2
View File
@@ -156,7 +156,6 @@ describe("target-free MCP workflow", () => {
const resolved = await mcp.callTool({
name: "update_unknown",
arguments: {
approved: true,
unknown_id: recordedUnknown.unknown_id,
expected_revision: 1,
status: "resolved",
@@ -253,7 +252,6 @@ describe("process residuals over MCP", () => {
const captured = await mcp.callTool({
name: "capture_process_scenario",
arguments: {
approved: true,
unknown_registry_approved: true,
executable: process.execPath,
arguments: [processFixture, "partial"],
-1
View File
@@ -133,7 +133,6 @@ export const snapshotAndRecordUnknown = async (
await mcp.callTool({
name: "record_unknown",
arguments: {
approved: true,
question: "Does the alternate branch execute?",
severity: "medium",
domain: "control-flow",
@@ -119,7 +119,7 @@ it("rejects runtime source bytes whose Evidence omits source-capture approval",
const staticEvidence = await analyzeFixture(fixture);
const contradictoryRuntime = electronRuntimeEvidence(fixture, SOURCE, {
includeWorker: false,
sourceCaptureApproved: false,
sourceIncluded: false,
});
expect(() =>
@@ -127,7 +127,7 @@ it("rejects runtime source bytes whose Evidence omits source-capture approval",
static_layers: [{ role: "application", analysis: staticEvidence }],
runtime_observations: [contradictoryRuntime],
}),
).toThrow(/source-capture approval/u);
).toThrow(/source-capture selection/u);
});
it("keeps graph omission counts unknown when a runtime section is unavailable", async () => {
@@ -219,22 +219,20 @@ const electronRuntimeEvidence = (
readonly scriptFile?: string;
readonly includeWorker?: boolean;
readonly targetId?: string;
readonly sourceCaptureApproved?: boolean;
readonly sourceIncluded?: boolean;
readonly workersUnavailable?: boolean;
} = {},
) => {
const scriptFile = options.scriptFile ?? "app.js";
const includeWorker = options.includeWorker ?? true;
const targetId = options.targetId ?? "target-main";
const sourceCaptureApproved = options.sourceCaptureApproved ?? true;
const sourceIncluded = options.sourceIncluded ?? true;
const input = inspectElectronPageInputSchema.parse({
cdp_endpoint: "http://127.0.0.1:9223",
allowed_file_roots: [root],
target_id: targetId,
approved: true as const,
observation_ms: 100,
include_script_sources: sourceCaptureApproved,
source_capture_approved: sourceCaptureApproved,
include_script_sources: sourceIncluded,
limits: {
max_frames: 200,
max_dom_nodes: 2_000,
@@ -29,7 +29,6 @@ it("does not follow or disclose symlink targets outside declared roots", async (
if (!capability.available) return;
const result = await captureProcessScenario(
parseProcessScenario({
approved: true,
executable: "/usr/bin/true",
working_directory: root,
filesystem_roots: [root],
@@ -60,7 +59,6 @@ it("does not follow or disclose symlink targets outside declared roots", async (
it("does not launch when policy denies capture", async () => {
const scenario = parseProcessScenario({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
});
@@ -84,7 +82,6 @@ it("distinguishes timeout from cancellation and cleans both runs", async () => {
};
const timedOut = await captureProcessScenario(
parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [processFixture, "hang"],
working_directory: dirname(processFixture),
@@ -105,7 +102,6 @@ it("distinguishes timeout from cancellation and cleans both runs", async () => {
setTimeout(() => controller.abort(), 50);
const cancelled = await captureProcessScenario(
parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [processFixture, "hang"],
working_directory: dirname(processFixture),
@@ -125,7 +121,6 @@ it("captures source-owned interactive, resize, Unicode, and signal behavior", as
if (!capability.available) return;
const result = await captureProcessScenario(
parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [processFixture, "interactive"],
working_directory: dirname(processFixture),
@@ -161,7 +156,6 @@ it("dispatches scheduled events before a silent PTY produces output", async () =
if (!capability.available) return;
const result = await captureProcessScenario(
parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [processFixture, "silent-interactive"],
working_directory: dirname(processFixture),
@@ -202,7 +196,6 @@ it("samples and cleans a source-owned child and grandchild process tree", async
if (!capability.available) return;
const result = await captureProcessScenario(
parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [processFixture, "tree"],
working_directory: dirname(processFixture),
@@ -118,7 +118,6 @@ function collectionTriggers() {
function createMultiSourceScenario(root: string, script: string) {
return parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [script, "codex"],
working_directory: root,
@@ -15,7 +15,6 @@ import { processCaptureIssues } from "../../../src/domain/processCapture.fixture
function createInteractiveScenario(root: string, script: string) {
return parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [script],
working_directory: root,
@@ -307,7 +306,6 @@ it("records target loss before post-exit settlement can win the deadline race",
const script = join(root, "exit.mjs");
await writeFile(script, 'process.stdout.write("exiting\\n");\n');
const scenario = parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [script],
working_directory: root,
@@ -37,7 +37,6 @@ it("runs a login and reconnect replay machine inside process capture", async ()
].join("\n"),
);
const scenario = parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [script],
working_directory: root,
@@ -179,7 +178,6 @@ it("captures PTY, filesystem, descendants, HTTP replay, and redacts environment"
networkAccess: "external",
};
const scenario = parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [script],
working_directory: root,
@@ -6,7 +6,6 @@ import { parseProcessScenario } from "../../../src/domain/processCapture.js";
it("serves bounded HTTP and WebSocket replay on loopback", async () => {
const scenario = parseProcessScenario({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
replay: {
@@ -38,7 +37,6 @@ it("serves bounded HTTP and WebSocket replay on loopback", async () => {
it("matches bounded HTTP scripts without persisting request secrets", async () => {
const scenario = parseProcessScenario({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
replay: {
@@ -95,7 +93,6 @@ it("matches bounded HTTP scripts without persisting request secrets", async () =
it("consumes ordered WebSocket reconnect scripts and reports exhaustion", async () => {
const scenario = parseProcessScenario({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
replay: {
@@ -134,7 +131,6 @@ it("consumes ordered WebSocket reconnect scripts and reports exhaustion", async
it("serializes WebSocket transition actions across rapid messages", async () => {
const scenario = parseProcessScenario({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
replay: {
@@ -213,7 +209,6 @@ it("serializes WebSocket transition actions across rapid messages", async () =>
it("drains queued machine work before exposing finalized snapshots", async () => {
const scenario = parseProcessScenario({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
replay: {
@@ -290,7 +285,6 @@ it("drains queued machine work before exposing finalized snapshots", async () =>
it("enforces replay duration before normalizing recorded timestamps", async () => {
const scenario = parseProcessScenario({
approved: true,
executable: "/bin/sh",
working_directory: "/tmp",
normalization: { time_bucket_ms: 60_000 },
@@ -11,7 +11,6 @@ import { parseProcessScenario } from "../../../src/domain/processCapture.js";
const buildTerminalScenario = (root: string, script: string) =>
parseProcessScenario({
approved: true,
executable: process.execPath,
arguments: [script],
working_directory: root,
@@ -128,7 +128,6 @@ const input = (
entry_export: "default",
},
cases: [{ case_id: "heading", arguments: ["# Title"] }],
...(mode === "execute" ? { approved: true as const } : {}),
});
const completedRunner = (): JavaScriptReplayRunner => ({
@@ -153,18 +152,16 @@ const completedRunner = (): JavaScriptReplayRunner => ({
});
describe("controlled JavaScript replay planning", () => {
it("parses planning and execution as disjoint legal states", () => {
it("requires an exact digest for execution and keeps plan input separate", () => {
expect(
controlledReplayInputSchema.safeParse({
...input("execute"),
approved: false,
plan_digest: "0".repeat(64),
}).success,
).toBe(false);
).toBe(true);
expect(
controlledReplayInputSchema.safeParse({
...input("execute"),
approved: true,
}).success,
).toBe(false);
expect(
@@ -176,20 +173,17 @@ describe("controlled JavaScript replay planning", () => {
expect(
controlledReplayInputSchema.safeParse({
...input("plan"),
approved: true,
}).success,
).toBe(false);
).toBe(true);
expect(
controlledReplayInputSchema.safeParse({
...input("execute"),
approved: true,
plan_digest: "0".repeat(64),
reproducer_export: {
path: "/tmp/reproducer",
approved: false,
},
}).success,
).toBe(false);
).toBe(true);
});
it("rejects relative paths and more than 128 combined cases", () => {
@@ -482,7 +476,6 @@ describe("controlled JavaScript replay cancellation and export", () => {
};
const export_ = {
path,
approved: true,
include_sources: false,
};
try {
@@ -10,7 +10,7 @@ import { analyzeJavaScriptApplicationInputSchema } from "../../../src/domain/jav
import { writeElectronBoundaryFixture } from "../../fixtures/electronBoundaryApplication.js";
describe("static Electron application analysis", () => {
it("accepts a caller path and caller-selected analysis bounds", () => {
it("accepts an absolute caller path without caller-selected analysis bounds", () => {
expect(
analyzeJavaScriptApplicationInputSchema.safeParse({
input_path: "relative/app.asar",
@@ -24,20 +24,14 @@ describe("static Electron application analysis", () => {
expect(
analyzeJavaScriptApplicationInputSchema.safeParse({
input_path: "/tmp/app.asar",
limits: {
max_entries: 100_000,
max_findings: 200_000,
},
limits: { max_findings: 200_000 },
}).success,
).toBe(true);
).toBe(false);
expect(
analyzeJavaScriptApplicationInputSchema.parse({
input_path: "/tmp/app.asar",
}),
).toMatchObject({
format: "auto",
limits: { max_findings: 8_000 },
});
).toEqual({ input_path: "/tmp/app.asar", format: "auto" });
});
it("maps windows, preload, contextBridge, IPC, validations, utility, and native boundaries without execution", async () => {
@@ -148,31 +148,40 @@ describe("CommonJS and ESM module relationships", () => {
});
});
describe("CommonJS and ESM relationship limits", () => {
it("retains exact semantic omissions when the relationship budget truncates", async () => {
const root = await createTestTempDirectory("rea-module-limit-");
await writeFile(
join(root, "exports.mjs"),
"export const first = 1; export const second = 2; export const third = 3;",
describe("complete static application projections", () => {
it("retains exports and JSON keys beyond the former projection prefix", async () => {
const root = await moduleFixture();
const exportNames = Array.from(
{ length: 140 },
(_, index) =>
`export const retained_${String(index).padStart(3, "0")} = ${index};`,
);
const result = await reconstructJavaScriptArtifact({
input_path: root,
limits: { max_findings: 1 },
});
const jsonKeys = Object.fromEntries(
Array.from({ length: 140 }, (_, index) => [`key_${index}`, index]),
);
await Promise.all([
writeFile(join(root, "many-exports.mjs"), exportNames.join("\n")),
writeFile(join(root, "many.json"), JSON.stringify(jsonKeys)),
]);
expect(result.statistics.truncated_scopes).toBeGreaterThan(0);
expect(
result.graph.nodes.filter((node) =>
node.observations.some(
({ properties }) => properties.semantic_role === "export-binding",
),
const { graph } = await reconstructJavaScriptArtifact({ input_path: root });
const module = sourceModule(graph, "many-exports.mjs");
const exportObservation = module?.observations.find(
({ properties }) => properties.semantic_role === "source-module",
);
const json = graph.nodes.find((node) =>
node.observations.some(
({ properties }) => properties.path === "many.json",
),
).toHaveLength(1);
expect(result.graph.coverage).toMatchObject({
status: "partial",
truncated: true,
omitted_count: 2,
});
);
const jsonObservation = json?.observations.find(
({ properties }) => properties.path === "many.json",
);
expect(exportObservation?.properties.export_names).toHaveLength(140);
expect(exportObservation?.properties.omitted_export_names).toBe(0);
expect(jsonObservation?.properties.json_top_level_keys).toHaveLength(140);
expect(jsonObservation?.properties.omitted_json_top_level_keys).toBe(0);
});
});
@@ -178,7 +178,6 @@ it("reconciles active Electron as a partial target-only runtime capture", async
application_path: applicationPath,
application_root: fixture,
actions: [],
approved: true,
});
const runtimeEvidence = createElectronActiveEvidence(
input,
@@ -220,7 +219,6 @@ it("hashes the retained Electron scenario projection, not raw selectors or secre
application_root: fixture,
args: ["--token", secret],
actions: [{ step_id: "click", kind: "click", selector }],
approved: true,
});
const provider = {
id: "rea-playwright-electron-active",
@@ -342,22 +340,20 @@ const electronRuntimeEvidence = (
readonly scriptFile?: string;
readonly includeWorker?: boolean;
readonly targetId?: string;
readonly sourceCaptureApproved?: boolean;
readonly sourceIncluded?: boolean;
readonly workersUnavailable?: boolean;
} = {},
) => {
const scriptFile = options.scriptFile ?? "app.js";
const includeWorker = options.includeWorker ?? true;
const targetId = options.targetId ?? "target-main";
const sourceCaptureApproved = options.sourceCaptureApproved ?? true;
const sourceIncluded = options.sourceIncluded ?? true;
const input = inspectElectronPageInputSchema.parse({
cdp_endpoint: "http://127.0.0.1:9223",
allowed_file_roots: [root],
target_id: targetId,
approved: true as const,
observation_ms: 100,
include_script_sources: sourceCaptureApproved,
source_capture_approved: sourceCaptureApproved,
include_script_sources: sourceIncluded,
limits: {
max_frames: 200,
max_dom_nodes: 2_000,