Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(jeb): isolate invalid timeout from shared startup (#3964)

ShuaixinHuangd67d895c2636
diff --git a/src/config/parseConfig.ts b/src/config/parseConfig.ts
index a1c1e0b28..c00f787a8 100644
--- a/src/config/parseConfig.ts
+++ b/src/config/parseConfig.ts
@@ -43,7 +43,12 @@ export const defaultHopperLauncherPath = (
export const parseConfig = (
environment: Readonly<Record<string, string | undefined>>,
): Result<AppConfig, ConfigurationError> => {
- const parsed = parseEnvironment(environment);
+ // JEB validates its own timeout during optional provider composition. It is
+ // not an AppConfig setting and must not prevent unrelated CLI/MCP startup.
+ // Registration validation still checks the complete environment directly.
+ const { REA_JEB_MCP_TIMEOUT_MS: _jebTimeout, ...appEnvironment } =
+ environment;
+ const parsed = parseEnvironment(appEnvironment);
if (!parsed.ok) return parsed;
const env = parsed.value;
return ok({
diff --git a/tests/acceptance/providers/jebConfigurationIsolation.test.ts b/tests/acceptance/providers/jebConfigurationIsolation.test.ts
new file mode 100644
index 000000000..7dba82050
--- /dev/null
+++ b/tests/acceptance/providers/jebConfigurationIsolation.test.ts
@@ -0,0 +1,96 @@
+import { Client } from "@modelcontextprotocol/client";
+import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
+import { resolve } from "node:path";
+import { expect } from "vitest";
+
+import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
+import { workspaceCliTest as test } from "../../support/cli/workspaceCliFixture.js";
+import type { TestWorkspace } from "../../support/workspace/workspaceFixture.js";
+
+const isolatedEnvironment = (workspace: TestWorkspace) => ({
+ PATH: "",
+ HOME: workspace.home,
+ USERPROFILE: workspace.home,
+ APPDATA: workspace.path("appdata"),
+ LOCALAPPDATA: workspace.path("localappdata"),
+ XDG_CONFIG_HOME: workspace.path("config"),
+ XDG_CACHE_HOME: workspace.path("cache"),
+ TEMP: workspace.root,
+ TMP: workspace.root,
+ ...(process.platform === "win32"
+ ? { SystemRoot: process.env.SystemRoot ?? "" }
+ : {}),
+ HOPPER_LAUNCHER_PATH: workspace.path("missing-hopper"),
+ REA_LOG_LEVEL: "silent",
+ REA_JEB_MCP_TIMEOUT_MS: "1.5",
+});
+
+test("keeps compiled CLI discovery usable while JEB rejects its malformed timeout", async ({
+ cli,
+ workspace,
+}) => {
+ const environment = isolatedEnvironment(workspace);
+ for (const command of ["capabilities", "providers"]) {
+ const result = await cli.run({
+ arguments: [command, "--json"],
+ environment,
+ });
+ expect(result.exitCode, result.stderr).toBe(0);
+ expect(result.json).toMatchObject({
+ capabilities: expect.arrayContaining([
+ expect.objectContaining({
+ provider: expect.objectContaining({ id: "rea-artifact-graph" }),
+ }),
+ ]),
+ });
+ }
+ const refusal = await cli.run({
+ arguments: ["inspect-jeb-client", "--json"],
+ environment,
+ });
+ expect(refusal.exitCode, refusal.stderr).toBe(1);
+ expect(refusal.json).toMatchObject({
+ code: "configuration_invalid",
+ details: { settings: [{ setting: "REA_JEB_MCP_TIMEOUT_MS" }] },
+ });
+});
+
+test("starts production stdio MCP and retains peer requests around a JEB configuration refusal", async ({
+ workspace,
+}) => {
+ const transport = new StdioClientTransport({
+ command: process.execPath,
+ args: [resolve("scripts/rea.mjs"), "mcp"],
+ cwd: workspace.root,
+ env: isolatedEnvironment(workspace),
+ stderr: "pipe",
+ });
+ const client = new Client({ name: "jeb-isolation-acceptance", version: "1" });
+ let stderr = "";
+ transport.stderr?.on("data", (chunk: Buffer) => {
+ stderr += chunk.toString("utf8");
+ });
+ try {
+ await client.connect(transport);
+ await client.ping();
+ const definition = (await client.listTools()).tools.find(
+ ({ name }) => name === "inspect_jeb_client",
+ );
+ if (definition === undefined)
+ throw new Error(`Production MCP omitted inspect_jeb_client: ${stderr}`);
+ const refusal = parseMcpToolError(
+ await client.callTool(
+ { name: "inspect_jeb_client", arguments: {} },
+ { toolDefinition: definition },
+ ),
+ );
+ expect(refusal.error).toMatchObject({
+ code: "configuration_invalid",
+ details: { settings: [{ setting: "REA_JEB_MCP_TIMEOUT_MS" }] },
+ });
+ await client.ping();
+ } finally {
+ await client.close();
+ await transport.close();
+ }
+});
diff --git a/tests/boundary/cli/jebCli.test.ts b/tests/boundary/cli/jebCli.test.ts
index 6e2325c7f..56c4ee15b 100644
--- a/tests/boundary/cli/jebCli.test.ts
+++ b/tests/boundary/cli/jebCli.test.ts
@@ -31,13 +31,25 @@ it("validates decompile item input before contacting the engine", async () => {
});
});
-it("reports an invalid endpoint without breaking other commands", async () => {
- const environment = { REA_JEB_MCP_URL: "http://localhost:8425/mcp" };
- const jeb = await serveCli(["inspect-jeb-client", "--json"], environment);
- expect(JSON.parse(jeb.stdout)).toMatchObject({
- code: "configuration_invalid",
- details: { settings: [{ setting: "REA_JEB_MCP_URL" }] },
- });
- const capabilities = await serveCli(["capabilities", "--json"], environment);
- expect(capabilities.exitCode).toBe(0);
-});
+it.each([
+ { setting: "REA_JEB_MCP_URL", value: "http://localhost:8425/mcp" },
+ { setting: "REA_JEB_MCP_TIMEOUT_MS", value: "1.5" },
+])(
+ "reports invalid $setting without breaking other commands",
+ async ({ setting, value }) => {
+ const environment = { [setting]: value };
+ const jeb = await serveCli(["inspect-jeb-client", "--json"], environment);
+ expect(JSON.parse(jeb.stdout)).toMatchObject({
+ code: "configuration_invalid",
+ details: { settings: [{ setting }] },
+ });
+ const capabilities = await serveCli(
+ ["capabilities", "--json"],
+ environment,
+ );
+ expect(capabilities.exitCode).toBe(0);
+ expect(JSON.parse(capabilities.stdout)).toMatchObject({
+ capabilities: expect.any(Array),
+ });
+ },
+);