fix(analysis)!: scope call-graph caveats to their observed relationships
Return deduplicated execution caveats once and preserve provider-owned relationship diagnostics and completeness on graph nodes. Keep complete relationship reads exhaustive despite contextual caveats, including portable call-path reconstruction.
Preserve omitted diagnostic fields in historical Evidence and bind reported diagnostics into semantic identity. Revise graph workflow and Ghidra adapter profiles so old cached representations cannot replay under the new contracts.
Remove stale duplicate-lookup test claims and redundant fixture validation. Prune million-entry duplicate cases while retaining argument-stack and deep-chain regressions; bounded Flameox captures identified validation and canonical hashing costs.
Validation: static and architecture checks, generated docs, 364 focused tests before pruning, 21 call-path tests after pruning, public MCP schema validation and targeted profile tests. Real engine behavior was not locally exercised.
BREAKING CHANGE: get_call_graph normalized_result now contains { graph, limitations }; traversal-depth groups are under graph.
This commit is contained in:
@@ -37,17 +37,20 @@ describe("enhanced MCP tools", () => {
|
||||
expect(graph).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
"0": [
|
||||
{
|
||||
address: "0x1",
|
||||
status: "error",
|
||||
error: {
|
||||
category: "execution_failure",
|
||||
message:
|
||||
"Analysis returned an unreadable result. Run `rea doctor` and review the reported details; repeating the unchanged request is not expected to succeed.",
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
address: "0x1",
|
||||
status: "error",
|
||||
error: {
|
||||
category: "execution_failure",
|
||||
message:
|
||||
"Analysis returned an unreadable result. Run `rea doctor` and review the reported details; repeating the unchanged request is not expected to succeed.",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
limitations: [],
|
||||
},
|
||||
});
|
||||
expect(unresolved).toEqual({
|
||||
|
||||
@@ -56,21 +56,23 @@ describe("enhanced MCP tools", () => {
|
||||
expect(graph.isError).not.toBe(true);
|
||||
expect(graph.structuredContent).toMatchObject({
|
||||
normalized_result: {
|
||||
"0": [
|
||||
{
|
||||
address: "0x1",
|
||||
status: "ok",
|
||||
calls: ["0x2"],
|
||||
limitations: [limitation],
|
||||
relationship_coverage: {
|
||||
status: "partial",
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
address: "0x1",
|
||||
status: "ok",
|
||||
calls: ["0x2"],
|
||||
limitations: [limitation],
|
||||
relationship_coverage: {
|
||||
status: "partial",
|
||||
limitations: [limitation],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
limitations: [limitation],
|
||||
},
|
||||
});
|
||||
|
||||
const trace = await client.callTool({
|
||||
name: "trace_call_path",
|
||||
arguments: { start: "0x1", goal: "0x2" },
|
||||
@@ -97,7 +99,11 @@ describe("enhanced MCP tools", () => {
|
||||
return relationshipExecution(String(arguments_.procedure));
|
||||
if (name !== "procedure_callees")
|
||||
throw new Error(`Unexpected operation: ${name}`);
|
||||
return relationshipExecution([], [caveat], { status: "complete" });
|
||||
return relationshipExecution(
|
||||
arguments_.procedure === "0x1" ? ["0x2"] : [],
|
||||
[caveat],
|
||||
{ status: "complete" },
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -107,14 +113,20 @@ describe("enhanced MCP tools", () => {
|
||||
});
|
||||
expect(graph.structuredContent).toMatchObject({
|
||||
normalized_result: {
|
||||
"0": [
|
||||
{
|
||||
limitations: [caveat],
|
||||
relationship_coverage: { status: "complete" },
|
||||
},
|
||||
],
|
||||
graph: {
|
||||
"0": [
|
||||
{ status: "ok", relationship_coverage: { status: "complete" } },
|
||||
],
|
||||
"1": [
|
||||
{ status: "ok", relationship_coverage: { status: "complete" } },
|
||||
],
|
||||
},
|
||||
limitations: [caveat],
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(graph.structuredContent)?.split(caveat)).toHaveLength(
|
||||
2,
|
||||
);
|
||||
|
||||
const trace = await client.callTool({
|
||||
name: "trace_call_path",
|
||||
@@ -129,6 +141,41 @@ describe("enhanced MCP tools", () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps unclassified legacy caveats on nodes with unknown coverage", async () => {
|
||||
const caveat = "This legacy provider does not classify call limitations.";
|
||||
const client = await connect({
|
||||
execute: async (name, arguments_) => {
|
||||
if (name === "procedure_address")
|
||||
return relationshipExecution(String(arguments_.procedure));
|
||||
if (name !== "procedure_callees")
|
||||
throw new Error(`Unexpected operation: ${name}`);
|
||||
return relationshipExecution([], [caveat]);
|
||||
},
|
||||
});
|
||||
|
||||
const graph = await client.callTool({
|
||||
name: "get_call_graph",
|
||||
arguments: { address: "0x1", direction: "forward" },
|
||||
});
|
||||
expect(graph.structuredContent).toMatchObject({
|
||||
normalized_result: {
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
status: "ok",
|
||||
relationship_coverage: { status: "unknown" },
|
||||
limitations: [
|
||||
"Provider did not report relationship coverage.",
|
||||
caveat,
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
limitations: [caveat],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("enhanced MCP batches", () => {
|
||||
|
||||
@@ -277,7 +277,7 @@ it("fetches all class pages rather than silently retaining the first upstream pa
|
||||
await verifyCleanup(launches);
|
||||
});
|
||||
|
||||
it("preserves duplicate class-name rows and reports lookup ambiguity", async () => {
|
||||
it("preserves duplicate class-name rows and occurrence counts", async () => {
|
||||
const { service, apk, launches, provider } = await setup(
|
||||
"duplicate-class-name",
|
||||
);
|
||||
|
||||
@@ -40,34 +40,41 @@ it("shows the callee edges of an ARM64 procedure in the call graph", async () =>
|
||||
result.value,
|
||||
"the root lists both observed callees instead of an empty observed list",
|
||||
).toMatchObject({
|
||||
"0": [
|
||||
{
|
||||
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.",
|
||||
]),
|
||||
},
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
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.",
|
||||
]),
|
||||
},
|
||||
{
|
||||
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.",
|
||||
]),
|
||||
},
|
||||
],
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
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.",
|
||||
]),
|
||||
},
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
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.",
|
||||
]),
|
||||
},
|
||||
{
|
||||
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.",
|
||||
]),
|
||||
},
|
||||
],
|
||||
},
|
||||
limitations: expect.arrayContaining([
|
||||
expect.stringContaining(
|
||||
"Provider version identifies the REA IDA adapter.",
|
||||
),
|
||||
]),
|
||||
});
|
||||
expect(
|
||||
requestedRoots(producer),
|
||||
@@ -183,15 +190,17 @@ it("preserves missing callgraph coverage through direct, graph, and trace workfl
|
||||
});
|
||||
if (!graph.ok) throw graph.error;
|
||||
expect(graph.value).toMatchObject({
|
||||
"0": [
|
||||
{
|
||||
status: "ok",
|
||||
calls: [],
|
||||
limitations: expect.arrayContaining([
|
||||
expect.stringContaining("callgraph was unavailable"),
|
||||
]),
|
||||
},
|
||||
],
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
status: "ok",
|
||||
calls: [],
|
||||
limitations: expect.arrayContaining([
|
||||
expect.stringContaining("callgraph was unavailable"),
|
||||
]),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const trace = await application.execute("trace_call_path", {
|
||||
@@ -239,13 +248,18 @@ it("records a failed ARM64 call graph read as the node's error, not as a complet
|
||||
result.value,
|
||||
"the transport-truncated graph is a recorded failure and no callee list is invented",
|
||||
).toEqual({
|
||||
"0": [
|
||||
{
|
||||
address: "0x1000",
|
||||
status: "error",
|
||||
error: expect.objectContaining({ code: "unreadable_output" }),
|
||||
},
|
||||
],
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
address: "0x1000",
|
||||
status: "error",
|
||||
error: expect.objectContaining({ code: "unreadable_output" }),
|
||||
},
|
||||
],
|
||||
},
|
||||
limitations: expect.arrayContaining([
|
||||
expect.stringContaining("Live results are never replayed"),
|
||||
]),
|
||||
});
|
||||
} finally {
|
||||
expect((await client.close()).ok).toBe(true);
|
||||
@@ -273,12 +287,15 @@ it("preserves an explicit root cap below the edge limit through every relationsh
|
||||
});
|
||||
if (!graph.ok) throw graph.error;
|
||||
expect(graph.value).toMatchObject({
|
||||
"0": [
|
||||
{
|
||||
calls: ["0x2000"],
|
||||
limitations: expect.arrayContaining([limitation]),
|
||||
},
|
||||
],
|
||||
graph: {
|
||||
"0": [
|
||||
{
|
||||
calls: ["0x2000"],
|
||||
limitations: expect.arrayContaining([limitation]),
|
||||
},
|
||||
],
|
||||
},
|
||||
limitations: expect.arrayContaining([limitation]),
|
||||
});
|
||||
const trace = await application.execute("trace_call_path", {
|
||||
start: "main",
|
||||
|
||||
@@ -58,14 +58,17 @@ describe("provider-derived selectors in IDA composed workflows", () => {
|
||||
result.value,
|
||||
"the resolved root stays ok and only the derived node carries the producer fault",
|
||||
).toMatchObject({
|
||||
"0": [{ address: "0x1000", status: "ok" }],
|
||||
"1": [
|
||||
{
|
||||
address: "0x2000",
|
||||
status: "error",
|
||||
error: { code: "unreadable_output" },
|
||||
},
|
||||
],
|
||||
graph: {
|
||||
"0": [{ address: "0x1000", status: "ok" }],
|
||||
"1": [
|
||||
{
|
||||
address: "0x2000",
|
||||
status: "error",
|
||||
error: { code: "unreadable_output" },
|
||||
},
|
||||
],
|
||||
},
|
||||
limitations: expect.any(Array),
|
||||
});
|
||||
} finally {
|
||||
expect((await client.close()).ok).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user