fix(analysis): preserve relationship coverage across evidence and replay
Separate observed relationship coverage from general provider caveats. Authenticate and replay coverage without changing legacy Evidence IDs; expose unknown and capped relationship sets through CLI/MCP graphs and traces. Validated focused domain, snapshot, IDA/Ghidra boundary, MCP, schema, package and static checks. Provider fixtures establish contract behavior; licensed engine behavior was not reverified.
This commit is contained in:
+18
-2
@@ -5,6 +5,7 @@ import {
|
||||
} from "../domain/analysisErrorCore.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import type { RelationshipCoverage } from "../domain/relationshipCoverage.js";
|
||||
import { ZodError } from "zod";
|
||||
import {
|
||||
idaAddressSchema,
|
||||
@@ -48,6 +49,7 @@ export interface CallGraphCallees {
|
||||
readonly name: string;
|
||||
}[];
|
||||
readonly limitations: readonly string[];
|
||||
readonly coverage: RelationshipCoverage;
|
||||
}
|
||||
|
||||
/** No function edges can be observed when the server lacks the graph tool. */
|
||||
@@ -57,6 +59,10 @@ export const unavailableCallGraph = (reason: string): CallGraphCallees => ({
|
||||
UNRECOGNIZED_CALLEE_LIMITATION,
|
||||
`Upstream callgraph was unavailable (${reason}); callee edges remain unknown.`,
|
||||
],
|
||||
coverage: {
|
||||
status: "unknown",
|
||||
reason: `Upstream callgraph was unavailable (${reason}); callee edges remain unknown.`,
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -95,6 +101,7 @@ export const readCallGraphCallees = async (
|
||||
BigInt(left) < BigInt(right) ? -1 : BigInt(left) > BigInt(right) ? 1 : 0,
|
||||
);
|
||||
const limitations = [UNRECOGNIZED_CALLEE_LIMITATION];
|
||||
const coverageLimitations: string[] = [];
|
||||
const truncated =
|
||||
row.truncated === true ||
|
||||
row.per_func_capped === true ||
|
||||
@@ -104,8 +111,13 @@ export const readCallGraphCallees = async (
|
||||
const saturated =
|
||||
row.max_edges_per_func !== undefined &&
|
||||
edges.length >= row.max_edges_per_func;
|
||||
if (truncated) limitations.push(TRUNCATED_LIMITATION);
|
||||
else if (saturated) limitations.push(POSSIBLY_TRUNCATED_LIMITATION);
|
||||
if (truncated) {
|
||||
limitations.push(TRUNCATED_LIMITATION);
|
||||
coverageLimitations.push(TRUNCATED_LIMITATION);
|
||||
} else if (saturated) {
|
||||
limitations.push(POSSIBLY_TRUNCATED_LIMITATION);
|
||||
coverageLimitations.push(POSSIBLY_TRUNCATED_LIMITATION);
|
||||
}
|
||||
|
||||
const names = new Map<string, string>();
|
||||
if (targets.length > 0) {
|
||||
@@ -149,5 +161,9 @@ export const readCallGraphCallees = async (
|
||||
};
|
||||
}),
|
||||
limitations,
|
||||
coverage:
|
||||
coverageLimitations.length === 0
|
||||
? { status: "complete" }
|
||||
: { status: "partial", limitations: coverageLimitations },
|
||||
};
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
functionInstructionWindowSchema,
|
||||
} from "../domain/hopperValues.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import type { RelationshipCoverage } from "../domain/relationshipCoverage.js";
|
||||
import { readCallGraphCallees, unavailableCallGraph } from "./IdaCallGraph.js";
|
||||
import type { IdaMcpConnection } from "./IdaMcpConnection.js";
|
||||
import type { IdaOperation } from "./IdaProviderCapabilities.js";
|
||||
@@ -65,6 +66,7 @@ export class IdaOperationRunner {
|
||||
readonly raw: IdaRawObservation[] = [];
|
||||
readonly locations: EvidenceLocation[] = [];
|
||||
readonly limitations: string[] = [];
|
||||
relationshipCoverage: RelationshipCoverage | undefined;
|
||||
constructor(
|
||||
private readonly connection: IdaMcpConnection,
|
||||
private readonly protocol: "legacy" | "modern",
|
||||
@@ -203,6 +205,7 @@ export class IdaOperationRunner {
|
||||
(tool, args) => this.call(tool, args),
|
||||
fn.address,
|
||||
);
|
||||
this.relationshipCoverage = graph.coverage;
|
||||
this.limitations.push(...graph.limitations);
|
||||
for (const callee of graph.callees)
|
||||
if (!result.has(callee.address))
|
||||
@@ -366,6 +369,11 @@ export class IdaOperationRunner {
|
||||
this.limitations.push(
|
||||
"Modern upstream xrefs classify references as code or data, without proving call edges. Direct callers are unavailable in this profile.",
|
||||
);
|
||||
this.relationshipCoverage = {
|
||||
status: "unknown",
|
||||
reason:
|
||||
"Modern upstream xrefs do not establish direct caller relationships.",
|
||||
};
|
||||
return [];
|
||||
} else {
|
||||
const page = modernCalleesSchema.parse(
|
||||
@@ -379,6 +387,15 @@ export class IdaOperationRunner {
|
||||
this.limitations.push(
|
||||
"Upstream callees capped results at 500; additional callees remain unknown.",
|
||||
);
|
||||
this.relationshipCoverage =
|
||||
page.more === true
|
||||
? {
|
||||
status: "partial",
|
||||
limitations: [
|
||||
"Upstream callees capped results at 500; additional callees remain unknown.",
|
||||
],
|
||||
}
|
||||
: { status: "complete" };
|
||||
for (const item of page.callees) {
|
||||
if ("type" in item && item.type === "external")
|
||||
result.set(
|
||||
@@ -392,6 +409,11 @@ export class IdaOperationRunner {
|
||||
const resolved = identity(await this.resolve(query));
|
||||
result.set(resolved.address, resolved);
|
||||
}
|
||||
if (this.relationshipCoverage === undefined)
|
||||
this.relationshipCoverage = {
|
||||
status: "unknown",
|
||||
reason: "The legacy relationship response does not report coverage.",
|
||||
};
|
||||
return [...result.values()];
|
||||
}
|
||||
|
||||
|
||||
@@ -211,6 +211,9 @@ export class IdaSessionClient implements AnalysisClient {
|
||||
observations: jsonValueSchema.parse(runner.raw),
|
||||
},
|
||||
limitations: [...IDA_LIMITATIONS, ...runner.limitations],
|
||||
...(runner.relationshipCoverage === undefined
|
||||
? {}
|
||||
: { relationshipCoverage: runner.relationshipCoverage }),
|
||||
locations: [
|
||||
{ kind: "artifact-path", path: this.target.path },
|
||||
...runner.locations,
|
||||
|
||||
Reference in New Issue
Block a user