fix(application): accept alternative document selection in binary_ove… (#2680)
* fix(application): accept alternative document selection in binary_overview (#2460) Update binary_overview capability negotiation so that either current_document or list_documents satisfies the document identity requirement, matching resolveAnalysisDocument runtime semantics. When a provider declares neither document capability, resolveAnalysisDocument reports AnalysisCapabilityUnavailableError for current_document rather than leaking the internal list_documents fallback. Preserve list_segments as an independently mandatory requirement. * fix(application): retain document fallback provider errors Return the fallback producer error unchanged, retaining operation identity, retry advice, diagnostics and cleanup instead of fabricating missing capabilities. Source inspection and git diff --check; tests/builds/typechecks/CI reruns skipped at explicit user request. * test(application): retain document fallback error expectations Composition and MCP controls now expect the original list_documents producer error and reason. Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally. * fix(ida): assert attached-mode routing failure --------- Co-authored-by: yashas1624 <yashas1624@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
yashas1624
morluto
parent
0c6c571a01
commit
23dc8fbf83
@@ -313,4 +313,40 @@ describe("overview document identity through MCP", () => {
|
||||
.isError,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("reports document selection unavailable when neither current-document nor list-documents is supported", async () => {
|
||||
const client = await connect({
|
||||
execute: (name) => {
|
||||
if (name === "current_document" || name === "list_documents")
|
||||
return Promise.resolve(
|
||||
err(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
"fixture",
|
||||
name,
|
||||
"provider lacks document selection",
|
||||
),
|
||||
),
|
||||
);
|
||||
if (name === "list_segments") return Promise.resolve(ok([]));
|
||||
if (name === "list_procedures" || name === "list_strings")
|
||||
return Promise.resolve(ok([]));
|
||||
throw new Error(`Unexpected analysis operation: ${name}`);
|
||||
},
|
||||
});
|
||||
const result = await client.callTool({
|
||||
name: "binary_overview",
|
||||
arguments: {},
|
||||
});
|
||||
expect(result.isError).toBe(true);
|
||||
expect(parseMcpToolError(result).error).toMatchObject({
|
||||
code: "capability_unavailable",
|
||||
details: {
|
||||
provider_id: "fixture",
|
||||
operation: "list_documents",
|
||||
reason: expect.stringContaining(
|
||||
"provider lacks document selection",
|
||||
),
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { createEvidence } from "../../src/domain/evidence.js";
|
||||
import { createEvidenceBundle } from "../../src/domain/evidenceBundle.js";
|
||||
import { createAnalysisExecution } from "../../src/application/AnalysisProvider.js";
|
||||
import { EnhancedTools } from "../../src/application/EnhancedTools.js";
|
||||
import { IDA_PROVIDER_IDENTITY } from "../../src/ida/IdaProviderCapabilities.js";
|
||||
|
||||
const roots: string[] = [];
|
||||
@@ -183,3 +184,35 @@ describe("IDA provider composition", () => {
|
||||
expect(producer.closes).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("IDA binary_overview execution", () => {
|
||||
it("reports document selection unavailable when binary_overview executes against an IDA session", async () => {
|
||||
const { root, target } = await createIdaTarget();
|
||||
roots.push(root);
|
||||
const path = join(root, "registration.json");
|
||||
await writeFile(path, JSON.stringify({ command: "fixture" }));
|
||||
const config = parseConfig({ REA_IDA_MCP_CONFIG: path });
|
||||
if (!config.ok) throw config.error;
|
||||
const producer = new RecordingIdaMcp(target);
|
||||
const session = createTestBinarySession(
|
||||
new IdaProvider(config.value, {}, () => producer),
|
||||
);
|
||||
expect((await session.open(target.path)).ok).toBe(true);
|
||||
const tools = new EnhancedTools(session);
|
||||
const overview = await tools.execute("binary_overview", {});
|
||||
expect(overview).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
_tag: "AnalysisCapabilityUnavailableError",
|
||||
providerId: "ida",
|
||||
operation: "list_documents",
|
||||
message: expect.stringContaining(
|
||||
"operation is not declared by this provider",
|
||||
),
|
||||
},
|
||||
});
|
||||
const procedures = await session.execute("list_procedures", {});
|
||||
expect(procedures.ok).toBe(true);
|
||||
expect((await session.close()).ok).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user