fix(javascript): preserve execution and invocation provenance
Keep direct empty bridge objects observed, reject unexecuted initializers, invalidate modified bootstrap tables and Electron identities, and retain selection predicates through symbolic values and wrapper paths. Track lexical binding identity and completed activation boundaries without leaking analysis order into earlier reads. Separate wrapper invocation provenance from the underlying IPC source range so repeated registrations remain ambiguous through transfer and graph joins. Use the same offered transfer budget for module preflight and final writing. Index static literal properties once instead of rescanning every member. Keep the original 10,001-member capacity fixture; Flameox confirmed the repeated lookup cost and the optimized fixture completes in under one second locally. Prune the stale compact-schema tool inventory assertion and update the public call-graph registration expectation to its declared result envelope. Validation: build, check, docs:check, 83 focused tests, 10 Electron identity acceptance cases, 2 full-scale finding-capacity cases, and 7 compact-schema transport tests. No real Electron runtime execution is claimed.
This commit is contained in:
@@ -129,6 +129,7 @@ for (const surface of ["CLI", "stdio MCP"] as const) {
|
||||
const root = await createTestTempDirectory("rea-electron-branch-paths-");
|
||||
await writeFixtureFiles(root, {
|
||||
"preload.js": `const e=require("electron");
|
||||
e.contextBridge.exposeInMainWorld("empty", {});
|
||||
function choose(){
|
||||
if(flag)return ()=>e.ipcRenderer.send("test:copy");
|
||||
else return ()=>e.ipcRenderer.send("test:cut");
|
||||
@@ -150,6 +151,19 @@ for (const surface of ["CLI", "stdio MCP"] as const) {
|
||||
register("test:fallback",event=>{false ?? event.sender.copy()});`,
|
||||
});
|
||||
const { graph } = await analyzeJavaScriptDirectory(surface, cli, root);
|
||||
const empty = graph.nodes
|
||||
.filter((node) => node.kind === "context-bridge-api")
|
||||
.flatMap((node) => node.observations)
|
||||
.find((observation) => observation.properties.api_key === "empty");
|
||||
expect(empty).toMatchObject({
|
||||
properties: {
|
||||
api_status: "object-literal",
|
||||
members: [],
|
||||
unknown_members: 0,
|
||||
resolution_basis: "direct-syntax",
|
||||
},
|
||||
evidence: { state: "observed" },
|
||||
});
|
||||
const joins = graph.edges.filter(
|
||||
(edge) =>
|
||||
edge.evidence.extractor.operation === "join-electron-wrapper-paths",
|
||||
@@ -172,6 +186,17 @@ for (const surface of ["CLI", "stdio MCP"] as const) {
|
||||
),
|
||||
].sort(),
|
||||
).toEqual(["test:copy", "test:cut"]);
|
||||
for (const [channel, expression] of [
|
||||
["test:copy", "flag"],
|
||||
["test:cut", "!(flag)"],
|
||||
])
|
||||
expect(
|
||||
steps.find(
|
||||
(step) =>
|
||||
step.properties.entry === "desktop.choose" &&
|
||||
step.properties.channel === channel,
|
||||
)?.properties.conditions,
|
||||
).toEqual([expect.objectContaining({ expression })]);
|
||||
expect(
|
||||
steps.some(
|
||||
(step) =>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { completeJavaScriptAnalysisSteps } from "../../../src/application/javasc
|
||||
import { projectJavaScriptSemanticFileSteps } from "../../../src/application/javascript/JavaScriptSemanticGraphBuilder.js";
|
||||
import {
|
||||
javaScriptTransferByteBudget,
|
||||
measureJavaScriptModuleTransfer,
|
||||
writeJavaScriptAnalysisTransfer,
|
||||
readJavaScriptAnalysisTransfer,
|
||||
} from "../../../src/javascript/analysis/JavaScriptAnalysisTransfer.js";
|
||||
@@ -44,6 +45,27 @@ it("enforces the offered complete-file byte budget while preserving authenticate
|
||||
module,
|
||||
projection,
|
||||
);
|
||||
const measured = measureJavaScriptModuleTransfer(module);
|
||||
expect(measured).toMatchObject({
|
||||
bytes: observed.module_bytes,
|
||||
records: observed.module_records,
|
||||
});
|
||||
expect(measureJavaScriptModuleTransfer(module, measured.bytes)).toEqual(
|
||||
measured,
|
||||
);
|
||||
expect(() =>
|
||||
measureJavaScriptModuleTransfer(module, measured.bytes - 1),
|
||||
).toThrowError(
|
||||
expect.objectContaining({
|
||||
resource: "transport",
|
||||
reportedLimits: expect.objectContaining({
|
||||
transfer_file_bytes: measured.bytes - 1,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(() =>
|
||||
measureJavaScriptModuleTransfer(module, 2 ** 31 + 1),
|
||||
).toThrowError(RangeError);
|
||||
const exactPath = join(root, "exact");
|
||||
const exact = await writeJavaScriptAnalysisTransfer(
|
||||
exactPath,
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Ajv2020 } from "ajv/dist/2020.js";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
||||
import { compactAdvertisedInputSchema } from "../../../src/contracts/compactInputSchema.js";
|
||||
import {
|
||||
COMPACT_INPUT_SCHEMA_BUDGET_BYTES,
|
||||
parseMcpInputSchemaProfile,
|
||||
@@ -121,29 +120,6 @@ describe("MCP compact input schema profile", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("reduces at most the structurally oversized tools", async () => {
|
||||
const full = fullServer();
|
||||
registerCatalog(full);
|
||||
const tools = await listToolsThroughTransport(full);
|
||||
const reduced: string[] = [];
|
||||
for (const tool of tools) {
|
||||
const { presentation } = compactAdvertisedInputSchema(
|
||||
tool.inputSchema,
|
||||
COMPACT_INPUT_SCHEMA_BUDGET_BYTES,
|
||||
);
|
||||
if (presentation === "reduced") reduced.push(tool.name);
|
||||
}
|
||||
expect(reduced.sort()).toEqual([
|
||||
"build_reconstruction_obligation_ledger",
|
||||
"capture_browser_scenario",
|
||||
"compare_application_versions",
|
||||
"compare_web_captures",
|
||||
"evaluate_reconstruction_coverage",
|
||||
"project_managed_application_graph",
|
||||
]);
|
||||
expect(tools.length).toBe(TOOL_CONTRACTS.length);
|
||||
});
|
||||
|
||||
it("retains parameter types and avoids client-side reference expansion", async () => {
|
||||
const server = compactServer();
|
||||
registerCatalog(server);
|
||||
|
||||
@@ -288,37 +288,43 @@ describe("enhanced MCP tools", () => {
|
||||
failed: 0,
|
||||
});
|
||||
expect(results[3]).toEqual({
|
||||
"0": [
|
||||
{
|
||||
address: "0x1",
|
||||
status: "ok",
|
||||
calls: ["0x2", "0x3"],
|
||||
relationship_coverage: {
|
||||
status: "unknown",
|
||||
reason: "Provider did not report relationship coverage.",
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
address: "0x1",
|
||||
status: "ok",
|
||||
calls: ["0x2", "0x3"],
|
||||
limitations: ["Provider did not report relationship coverage."],
|
||||
relationship_coverage: {
|
||||
status: "unknown",
|
||||
reason: "Provider did not report relationship coverage.",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
address: "0x2",
|
||||
status: "ok",
|
||||
calls: ["0x1"],
|
||||
relationship_coverage: {
|
||||
status: "unknown",
|
||||
reason: "Provider did not report relationship coverage.",
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
address: "0x2",
|
||||
status: "ok",
|
||||
calls: ["0x1"],
|
||||
limitations: ["Provider did not report relationship coverage."],
|
||||
relationship_coverage: {
|
||||
status: "unknown",
|
||||
reason: "Provider did not report relationship coverage.",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
address: "0x3",
|
||||
status: "ok",
|
||||
calls: [],
|
||||
relationship_coverage: {
|
||||
status: "unknown",
|
||||
reason: "Provider did not report relationship coverage.",
|
||||
{
|
||||
address: "0x3",
|
||||
status: "ok",
|
||||
calls: [],
|
||||
limitations: ["Provider did not report relationship coverage."],
|
||||
relationship_coverage: {
|
||||
status: "unknown",
|
||||
reason: "Provider did not report relationship coverage.",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
limitations: [],
|
||||
});
|
||||
expect(results[4]).toMatchObject({
|
||||
total: 1,
|
||||
|
||||
Reference in New Issue
Block a user