refactor(tools): remove arbitrary workflow ceilings

This commit is contained in:
morluto
2026-09-29 17:36:26 +08:00
parent 6c68ff565f
commit 5f73cb061b
28 changed files with 184 additions and 195 deletions
@@ -186,6 +186,10 @@ describe("canonical CLI catalog", () => {
expect(cliCommandOptionNames(cli, name)).toContain("provider");
}
});
it("does not impose a private result limit on feature tracing", () => {
expect(cliCommandOptionNames(createCli(), "trace")).not.toContain("limit");
});
});
describe("canonical product catalog drift", () => {
@@ -27,7 +27,7 @@ it("reads local source maps as part of static artifact analysis", async () => {
);
});
it("does not follow symlinks and analyzes text beyond the former file-size cap", async () => {
it("does not follow symlinks and analyzes each local source file", async () => {
const root = await fixtureDirectory();
const outside = await createTestTempDirectory("rea-javascript-outside-");
const outsideFile = join(outside, "secret.js");
@@ -37,22 +37,27 @@ it("does not follow symlinks and analyzes text beyond the former file-size cap",
);
await symlink(outsideFile, join(root, "escape.js"));
const baseline = await reconstructJavaScriptArtifact({ input_path: root });
const oversizedSource = `// ${"private-marker-".repeat(600_000)}\nfetch("https://inside.invalid");\n`;
await writeFile(join(root, "oversized.js"), oversizedSource);
const additionalSource = Array.from(
{ length: 1_000 },
(_value, index) => `export const value${String(index)} = ${String(index)};`,
).join("\n");
await writeFile(join(root, "additional.js"), additionalSource);
const result = await reconstructJavaScriptArtifact({ input_path: root });
const encoded = JSON.stringify(result);
expect(result.statistics.text_bytes_read).toBeGreaterThan(8 * 1024 * 1024);
expect(result.graph.coverage).toMatchObject({
status: "complete",
truncated: false,
});
expect(result.statistics.parsed_javascript_files).toBe(
baseline.statistics.parsed_javascript_files + 1,
);
expect(result.statistics.text_bytes_read).toBe(
baseline.statistics.text_bytes_read + Buffer.byteLength(additionalSource),
);
expect(encoded).not.toContain(outsideFile);
expect(encoded).not.toContain("outside-secret.invalid");
expect(result.statistics.visited_ast_nodes).toBeGreaterThan(
baseline.statistics.visited_ast_nodes,
);
});
it("keeps malformed JavaScript, package metadata, and source maps as explicit unknowns", async () => {
+3 -3
View File
@@ -18,9 +18,9 @@ describe("Ghidra MCP evidence parity", () => {
);
expect(listed).toMatchObject({
operation: "list_procedures",
provider: { id: "ghidra", name: "Ghidra", version: "12.1.2" },
provider: { id: "ghidra", name: "Ghidra", version: "12.1.4" },
analysis_profile: {
provider: { id: "ghidra", version: "12.1.2" },
provider: { id: "ghidra", version: "12.1.4" },
parameters: {
import_mode: "ephemeral-read-only",
analyzer_preset: "ghidra-default",
@@ -78,7 +78,7 @@ describe("Ghidra MCP evidence parity", () => {
);
expect(pseudocode).toMatchObject({
operation: "procedure_pseudo_code",
provider: { id: "ghidra", version: "12.1.2" },
provider: { id: "ghidra", version: "12.1.4" },
normalized_result: expect.stringContaining("return 42"),
limitations: expect.arrayContaining([
expect.stringContaining("not text-equivalent to Hopper"),
+3 -3
View File
@@ -22,7 +22,7 @@ import {
ghidraReferenceEdge,
} from "../../../src/domain/hopperValues.fixture.js";
const INSTALL = "/opt/ghidra_12.1.2_PUBLIC";
const INSTALL = "/opt/ghidra_12.1.4_PUBLIC";
export const connectGhidraMcp = async (name: string) => {
const calls: GhidraOperation[] = [];
@@ -98,7 +98,7 @@ export const sessionEvidence = (session: BinarySession, value: unknown) => {
const installationHost = (): GhidraInstallationHost => ({
platform: "linux",
architecture: "x64",
readText: () => "application.version=12.1.2\n",
readText: () => "application.version=12.1.4\n",
executable: () => true,
probeJava: () => ({
version: "21.0.11",
@@ -113,7 +113,7 @@ const sessionInfo = (profileDigest: string, targetSha256: string) => ({
name: "REA Ghidra bridge" as const,
run_id: "11111111-1111-4111-8111-111111111111",
profile_digest: profileDigest,
provider: { id: "ghidra" as const, version: "12.1.2" },
provider: { id: "ghidra" as const, version: "12.1.4" },
read_only: true as const,
analysis_complete: true,
analysis_timed_out: false,
+1 -1
View File
@@ -33,7 +33,7 @@ describe("Ghidra MCP capability routing", () => {
result: {
open: true,
analysis_provider_binding: {
provider: { id: "ghidra", version: "12.1.2" },
provider: { id: "ghidra", version: "12.1.4" },
},
tool_availability: expect.arrayContaining([
expect.objectContaining({
+22
View File
@@ -82,6 +82,28 @@ describe("read_bytes contract", () => {
});
});
describe("list_strings contract", () => {
it("describes optional provider string metadata inline", () => {
const contract = OFFICIAL_TOOL_CONTRACTS.find(
({ name }) => name === "list_strings",
);
expect(
contract?.outputSchema.shape.result.safeParse([
{
address: "0x1000",
value: "coffee",
string: {
encoding: "UTF-8",
termination: "present_or_not_required",
byte_length: 6,
},
},
{ address: "0x1008", value: "beans" },
]).success,
).toBe(true);
});
});
afterEach(async () => {
await Promise.all(
resources.splice(0).map(async (resource) => resource.close()),
@@ -23,7 +23,7 @@ const fixturePath = fileURLToPath(
new URL("../../../fixtures/fakeGhidra.mjs", import.meta.url),
);
const PROFILE_DIGEST = "a".repeat(64);
const PROVIDER_VERSION = "12.1.2";
const PROVIDER_VERSION = "12.1.4";
const TARGET_SHA256 = createHash("sha256")
.update(readFileSync(fixturePath))
.digest("hex");
@@ -98,7 +98,7 @@ describe("Ghidra headless launcher", () => {
const command = ghidraHeadlessCommand({
platform: "win32",
analyzeHeadlessPath:
"C:\\Program Files\\Ghidra 12.1.2\\support\\analyzeHeadless.bat",
"C:\\Program Files\\Ghidra 12.1.4\\support\\analyzeHeadless.bat",
arguments: [
"C:\\REA Runtime\\project",
"rea-project",
@@ -116,7 +116,7 @@ describe("Ghidra headless launcher", () => {
"/v:off",
"/s",
"/c",
'""C:\\Program Files\\Ghidra 12.1.2\\support\\analyzeHeadless.bat" "C:\\REA Runtime\\project" "rea-project" "-import" "C:\\REA Runtime\\target.exe""',
'""C:\\Program Files\\Ghidra 12.1.4\\support\\analyzeHeadless.bat" "C:\\REA Runtime\\project" "rea-project" "-import" "C:\\REA Runtime\\target.exe""',
],
});
});
@@ -159,7 +159,7 @@ describe("Ghidra headless launcher", () => {
runId: "d6fcbb66-e829-4ff6-a535-0035aec63139",
targetPath: "/tmp/fixture",
targetSha256: "b".repeat(64),
providerVersion: "12.1.2",
providerVersion: "12.1.4",
profileDigest: "a".repeat(64),
});
expect(launched.ok).toBe(true);
@@ -64,6 +64,23 @@ const request = async (
limits: { resultDepth: 16, resultNodes: 10_000, exceptionBytes: 4096 },
});
it("uses the caller's full output budget for exception text", async () => {
const message = "x".repeat(70_000);
const workerRequest = await request("exception.mjs", "esm", "default", [
message,
]);
workerRequest.limits.exceptionBytes = 80_000;
const result = await runWorker(workerRequest);
expect(result.code).toBe(0);
const response = JSON.parse(result.stdout) as {
readonly left: readonly {
readonly exception: { readonly message: string };
}[];
};
expect(response.left[0]?.exception.message).toBe(`fixture:${message}`);
});
describe("disposable JavaScript replay worker", () => {
it("rejects malformed runtime-hop requests before loading modules", async () => {
const result = await runWorker({