From 65499cd329586468bc4ef8e9698dcd896551c2bc Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Tue, 1 Dec 2026 14:03:38 -0500 Subject: [PATCH] fix(call-graph)!: report each node's coverage limits once, in relationship_coverage (#15582) get_call_graph copied each node's relationship coverage into the node's limitations: a partial coverage's limitations, an unknown coverage's reason (including the synthesized "Provider did not report relationship coverage."), and its diagnostics. Every ok node therefore repeated what its relationship_coverage already said, which costs tokens on every node of a large graph. A node now keeps limitations only for the provider's own caveats that no coverage classified, when the provider reported no relationship coverage. Graph-wide limitations are unchanged. BREAKING CHANGE: get_call_graph nodes no longer repeat relationship_coverage limitations, reason or diagnostics in their limitations field. Read relationship_coverage for a node's coverage limits; node limitations now hold only unclassified provider caveats. --- src/application/EnhancedTools.ts | 24 ++++--------- ....01-lists-the-complete-target-open.test.ts | 3 -- .../enhancedTools.callPathsAndBatches.test.ts | 15 ++++---- .../providers/ida/calleeRelationships.test.ts | 36 ++++++++++++------- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/application/EnhancedTools.ts b/src/application/EnhancedTools.ts index 07323a2a9e6..f7f848a3751 100644 --- a/src/application/EnhancedTools.ts +++ b/src/application/EnhancedTools.ts @@ -633,25 +633,13 @@ export class EnhancedTools { limited_directions: directionFallback, } : withRequiredLimitedDirections(reportedCoverage, directionFallback); - const relationshipLimitations = + // relationship_coverage already carries reported limitations, its + // reason and its diagnostics. A node keeps only the provider's own + // caveats that no coverage classified. + const nodeLimitations = reportedCoverage === undefined - ? [ - ...execution.limitations, - "Provider did not report relationship coverage.", - ] - : [ - ...(reportedCoverage.status === "partial" - ? reportedCoverage.limitations - : reportedCoverage.status === "unknown" - ? [reportedCoverage.reason] - : []), - ...("diagnostics" in reportedCoverage - ? reportedCoverage.diagnostics - : []), - ]; - const nodeLimitations = [...new Set(relationshipLimitations)].sort( - compareUnicodeCodePoints, - ); + ? [...new Set(execution.limitations)].sort(compareUnicodeCodePoints) + : []; nodes.push({ address: current.address, status: "ok", diff --git a/tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts b/tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts index 0ace858c892..cc5a4a536f1 100644 --- a/tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts +++ b/tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts @@ -334,7 +334,6 @@ describe("enhanced MCP tools", () => { address: "0x1", status: "ok", calls: ["0x2", "0x3"], - limitations: ["Provider did not report relationship coverage."], relationship_coverage: { status: "unknown", reason: "Provider did not report relationship coverage.", @@ -347,7 +346,6 @@ describe("enhanced MCP tools", () => { address: "0x2", status: "ok", calls: ["0x1"], - limitations: ["Provider did not report relationship coverage."], relationship_coverage: { status: "unknown", reason: "Provider did not report relationship coverage.", @@ -358,7 +356,6 @@ describe("enhanced MCP tools", () => { address: "0x3", status: "ok", calls: [], - limitations: ["Provider did not report relationship coverage."], relationship_coverage: { status: "unknown", reason: "Provider did not report relationship coverage.", diff --git a/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts b/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts index fa7d6819ba0..52bcab067e1 100644 --- a/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts +++ b/tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts @@ -44,7 +44,7 @@ const relationshipExecution = ( ); describe("enhanced MCP relationship limitations", () => { - it("preserves per-node relationship limitations and keeps observed edges", async () => { + it("reports a node's relationship limitations once, in its coverage, and keeps observed edges", async () => { const limitation = "ARM64 call targets are only partially resolved."; const client = await connect({ execute: async (name, arguments_) => { @@ -78,7 +78,6 @@ describe("enhanced MCP relationship limitations", () => { address: "0x1", status: "ok", calls: ["0x2"], - limitations: [limitation], relationship_coverage: { status: "partial", limitations: [limitation], @@ -89,6 +88,13 @@ describe("enhanced MCP relationship limitations", () => { limitations: [limitation], }, }); + // The node does not repeat what its coverage already states. + const root = ( + graph.structuredContent as { + normalized_result: { graph: Record }; + } + ).normalized_result.graph["0"]?.[0]; + expect(root).not.toHaveProperty("limitations"); const trace = await client.callTool({ name: "trace_call_path", arguments: { start: "0x1", goal: "0x2" }, @@ -210,10 +216,7 @@ describe("enhanced MCP graph caveats", () => { { status: "ok", relationship_coverage: { status: "unknown" }, - limitations: [ - "Provider did not report relationship coverage.", - caveat, - ], + limitations: [caveat], }, ], }, diff --git a/tests/boundary/providers/ida/calleeRelationships.test.ts b/tests/boundary/providers/ida/calleeRelationships.test.ts index 87dde805edb..2e1fff6ac71 100644 --- a/tests/boundary/providers/ida/calleeRelationships.test.ts +++ b/tests/boundary/providers/ida/calleeRelationships.test.ts @@ -109,9 +109,11 @@ it("shows the callee edges of an ARM64 procedure in the call graph", async () => address: "0x1000", status: "ok", calls: ["0x2000", "0x3000"], - limitations: expect.arrayContaining([ - "This relationship read does not establish calls to targets IDA does not recognize as functions; imports and other non-function call targets remain unknown.", - ]), + relationship_coverage: expect.objectContaining({ + diagnostics: [ + "This relationship read does not establish calls to targets IDA does not recognize as functions; imports and other non-function call targets remain unknown.", + ], + }), }, ], "1": [ @@ -119,17 +121,21 @@ it("shows the callee edges of an ARM64 procedure in the call graph", async () => address: "0x2000", status: "ok", calls: [], - limitations: expect.arrayContaining([ - "This relationship read does not establish calls to targets IDA does not recognize as functions; imports and other non-function call targets remain unknown.", - ]), + relationship_coverage: expect.objectContaining({ + diagnostics: [ + "This relationship read does not establish calls to targets IDA does not recognize as functions; imports and other non-function call targets remain unknown.", + ], + }), }, { address: "0x3000", status: "ok", calls: [], - limitations: expect.arrayContaining([ - "This relationship read does not establish calls to targets IDA does not recognize as functions; imports and other non-function call targets remain unknown.", - ]), + relationship_coverage: expect.objectContaining({ + diagnostics: [ + "This relationship read does not establish calls to targets IDA does not recognize as functions; imports and other non-function call targets remain unknown.", + ], + }), }, ], }, @@ -286,9 +292,10 @@ it("preserves missing callgraph coverage through direct, graph, and trace workfl { status: "ok", calls: [], - limitations: expect.arrayContaining([ - expect.stringContaining("callgraph was unavailable"), - ]), + relationship_coverage: expect.objectContaining({ + status: "unknown", + reason: expect.stringContaining("callgraph was unavailable"), + }), }, ], }, @@ -389,7 +396,10 @@ it("preserves an explicit root cap below the edge limit through every relationsh "0": [ { calls: ["0x2000"], - limitations: expect.arrayContaining([limitation]), + relationship_coverage: expect.objectContaining({ + status: "partial", + limitations: [limitation], + }), }, ], },