fix(tools)!: simplify direct invocation and harden boundary contracts (#555)

Remove REA permission grants, scope ceilings, approval confirmations, and inert settings. Preserve selected local evidence, accept caller-chosen commands and paths, and report actual runtime failures.

Harden provider results, schema serialization, snapshot evidence binding, archive paths, source maps, native screenshots, managed EH parsing, and cancellation cleanup. Regenerate tool metadata and document direct invocation.

BREAKING CHANGE: Removed permission configuration and policy commands, approval fields, filesystem scope inputs, and fixed confirmation options. Process capture inherits the host environment and accepts command names; callers must refresh tool schemas and migrate removed fields.
This commit is contained in:
morluto
2026-10-05 20:16:44 +08:00
committed by GitHub
parent 4f099a10f8
commit b5e98915c6
350 changed files with 5347 additions and 10599 deletions
@@ -18,8 +18,8 @@ import {
createTestBinarySession,
} from "../../fixtures/binarySession.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { copyFile, writeFile } from "node:fs/promises";
import { extname, join } from "node:path";
import { describe, expect, it } from "vitest";
const nonHopperProvider = (operations: string[]): AnalysisProvider => {
@@ -339,7 +339,88 @@ describe("replay of exact immutable calls", () => {
expect(activeImport.error.message).toContain("profile_mismatch");
await activeProfileMismatch.close();
});
});
describe("snapshot switch rollback", () => {
it("retains the previous cache when a target switch snapshot conflicts", async () => {
const [first] = await createBinarySessionTargets();
const directory = await createTestTempDirectory("rea-session-copy-");
const second = join(directory, `second${extname(first)}`);
await copyFile(first, second);
const calls: string[] = [];
const session = createTestBinarySession(createCacheProvider(calls));
expect((await session.open(first)).ok).toBe(true);
expect(
(
await session.execute("address_name", {
address: "0x1000",
document: "first",
})
).ok,
).toBe(true);
expect(
session.recordUnknown({
question: "Does this function reach the network?",
severity: "medium",
domain: "network",
supporting_evidence_ids: [],
contradicting_evidence_ids: [],
required_authority: "shipped-artifact",
required_confidence: "observed",
required_environment: null,
recommended_probes: [
{ operation: "analyze_function", rationale: "Inspect its callers." },
],
relationships: [],
}).ok,
).toBe(true);
const originalCache = session.exportAnalysisSnapshot();
expect(originalCache).toMatchObject({
ok: true,
value: { entries: [{ operation: "address_name" }] },
});
const conflicting = createTestBinarySession(createCacheProvider([]));
expect((await conflicting.open(second)).ok).toBe(true);
expect(
conflicting.recordUnknown({
question: "Does this function reach the network?",
severity: "high",
domain: "network",
supporting_evidence_ids: [],
contradicting_evidence_ids: [],
required_authority: "shipped-artifact",
required_confidence: "observed",
required_environment: null,
recommended_probes: [
{ operation: "analyze_function", rationale: "Inspect its callers." },
],
relationships: [],
}).ok,
).toBe(true);
const conflictingSnapshot = conflicting.exportAnalysisSnapshot();
expect(conflictingSnapshot.ok).toBe(true);
if (!conflictingSnapshot.ok || !originalCache.ok) return;
await conflicting.close();
expect(
await session.open(second, { snapshot: conflictingSnapshot.value }),
).toMatchObject({ ok: false });
expect(session.activeTarget()?.path).toBe(first);
expect(
(
await session.execute("address_name", {
address: "0x1000",
document: "first",
})
).ok,
).toBe(true);
expect(calls).toEqual(["health", "address_name", "health", "health"]);
await session.close();
});
});
describe("snapshot cache eligibility", () => {
it("does not snapshot reads that depend on the provider cursor", async () => {
const [first] = await createBinarySessionTargets();
const calls: string[] = [];
@@ -10,12 +10,12 @@ import { analyzeJavaScriptApplicationInputSchema } from "../../../src/domain/jav
import { writeElectronBoundaryFixture } from "../../fixtures/electronBoundaryApplication.js";
describe("static Electron application analysis", () => {
it("rejects relative paths and caller-selected analysis bounds", () => {
it("accepts relative paths and rejects caller-selected analysis bounds", () => {
expect(
analyzeJavaScriptApplicationInputSchema.safeParse({
input_path: "relative/app.asar",
}).success,
).toBe(false);
).toBe(true);
expect(
analyzeJavaScriptApplicationInputSchema.safeParse({
input_path: "/tmp/app.asar",
@@ -306,8 +306,7 @@ const assertSemanticLinks = (
const endpointJson = JSON.stringify(
graph.nodes.filter(({ kind }) => kind === "endpoint"),
);
expect(endpointJson).toContain("token=%5BREDACTED%5D");
expect(endpointJson).not.toContain("fixture-secret");
expect(endpointJson).toContain("token=fixture-secret");
};
const fixtureDirectory = async (): Promise<string> => {
@@ -162,12 +162,15 @@ it("reconciles active Electron as a partial target-only runtime capture", async
const fixture = await applicationFixture();
const staticEvidence = await analyzeFixture(fixture);
const applicationPath = join(fixture, "main.js");
const input = electronActiveObservationInputSchema.parse({
executable_path: process.execPath,
application_path: applicationPath,
const input = {
...electronActiveObservationInputSchema.parse({
executable_path: process.execPath,
application_path: applicationPath,
application_root: fixture,
actions: [],
}),
application_root: fixture,
actions: [],
});
};
const runtimeEvidence = createElectronActiveEvidence(
input,
createElectronActiveObservationFixtureResult(applicationPath),
@@ -198,17 +201,19 @@ it("reconciles active Electron as a partial target-only runtime capture", async
);
});
it("hashes the retained Electron scenario projection, not raw selectors or secrets", async () => {
it("keeps selected Electron arguments while omitting raw selectors", async () => {
const fixture = await applicationFixture();
const applicationPath = join(fixture, "main.js");
const makeInput = (secret: string, selector: string) =>
electronActiveObservationInputSchema.parse({
const makeInput = (secret: string, selector: string) => ({
...electronActiveObservationInputSchema.parse({
executable_path: process.execPath,
application_path: applicationPath,
application_root: fixture,
args: ["--token", secret],
actions: [{ step_id: "click", kind: "click", selector }],
});
}),
application_root: fixture,
});
const provider = {
id: "rea-playwright-electron-active",
name: "REA Playwright active Electron observation provider",
@@ -225,12 +230,12 @@ it("hashes the retained Electron scenario projection, not raw selectors or secre
provider,
);
expect(first.parameters.scenario_sha256).toBe(
expect(first.parameters.scenario_sha256).not.toBe(
second.parameters.scenario_sha256,
);
expect(JSON.stringify(first)).not.toContain("first-secret");
expect(JSON.stringify(first)).toContain("first-secret");
expect(JSON.stringify(first)).not.toContain("#first-secret");
expect(first.parameters.args).toEqual(["--token", "<redacted>"]);
expect(first.parameters.args).toEqual(["--token", "first-secret"]);
});
it("imports an operator-provided cache layer through an explicit file mapping", async () => {