Files
reverse-engineering-anything/tests/boundary/cli/providerSelectionRemediationCli.test.ts
T
morlutoandCursor Agent 56be61191e fix(mcp): report target after failed open (#8613)
* fix(mcp): report target after failed open

* test(session): cover failed open receipt ownership

* test(session): verify restored target receipt

* test(mcp): retain target on snapshot mismatch

* test(mcp): retain oversized open failure receipts

* test(cli): avoid continuing session receipt in one-shot errors

* fix(mcp): report provider after failed switch

* test(ghidra): verify failed open preserves annotations

* test(mcp): join queued receipt request before cleanup

* test(session): assert open failure receipts in lifecycle suites

* test(session): keep open-failure receipt checks within function limits

Move the provider-collision case and snapshot fixture setup out of the
functions that grew when both failure receipts were asserted.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-05 18:35:22 +08:00

56 lines
2.1 KiB
TypeScript

import { expect } from "vitest";
import { parseConfig } from "../../../src/config/parseConfig.js";
import { elf } from "../../../src/domain/binaryTarget.fixture.js";
import { IdaProvider } from "../../../src/ida/IdaProvider.js";
import { workspaceCliTest } from "../../support/cli/workspaceCliFixture.js";
workspaceCliTest(
"returns an unready IDA registration's repair for an explicit --provider selection",
async ({ cli, workspace }) => {
const registration = workspace.path("missing-ida.json");
const target = await workspace.write("target.elf", elf(2, 1, 62));
// The readiness owner is the oracle for the repair the caller receives.
const config = parseConfig({ REA_IDA_MCP_CONFIG: registration });
if (!config.ok) throw config.error;
const ida = new IdaProvider(config.value, {}, () => {
throw new Error("Readiness must not connect to IDA");
});
const owner = await ida.inspectAvailability();
const released = await ida.closeOwnedResources();
if (!released.ok) throw released.error;
if (owner.status !== "unavailable")
throw new Error("A missing registration must be unavailable");
const result = await cli.run({
arguments: ["decompile", target, "main", "--provider", "ida", "--json"],
environment: {
...workspace.environment,
REA_IDA_MCP_CONFIG: registration,
REA_LOG_LEVEL: "silent",
},
});
expect(result.exitCode, result.stderr).toBe(1);
expect(result.json).toMatchObject({
remediation: { action: owner.remediation },
details: {
selection_reason: "provider_unavailable",
requested_provider_id: "ida",
rejections: expect.arrayContaining([
expect.objectContaining({
provider_id: "ida",
origin: "availability",
reason: owner.reason,
remediation: owner.remediation,
}),
]),
},
});
expect(result.json).not.toHaveProperty("details.target_at_open_completion");
expect(result.json).not.toHaveProperty(
"details.provider_id_at_open_completion",
);
expect(owner.remediation).toContain("REA_IDA_MCP_CONFIG");
},
);