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:
@@ -441,7 +441,7 @@ describe("analysis snapshot cache partitioning", () => {
|
||||
ANALYSIS_SNAPSHOT_PROFILE,
|
||||
createEvidenceBundle([evidence]),
|
||||
);
|
||||
if (!exported.ok) throw new Error("snapshot export failed");
|
||||
if (!exported.ok) throw exported.error;
|
||||
const tampered = structuredClone(exported.value);
|
||||
const tamperedEntry = tampered.entries[0];
|
||||
if (tamperedEntry === undefined)
|
||||
@@ -499,3 +499,105 @@ describe("analysis snapshot cache partitioning", () => {
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("relationship coverage snapshot replay", () => {
|
||||
it("authenticates relationship coverage and replays legacy reads as unknown", () => {
|
||||
const cache = new AnalysisSnapshotCache();
|
||||
const operation = "procedure_callees" as const;
|
||||
const parameters = { procedure: "0x1000", document: "fixture" };
|
||||
const coverage = { status: "complete" as const };
|
||||
const execution = createAnalysisExecution(
|
||||
["0x2000"],
|
||||
ANALYSIS_SNAPSHOT_PROVIDER,
|
||||
{
|
||||
analysisProfile: ANALYSIS_SNAPSHOT_PROFILE,
|
||||
rawResult: ["0x2000"],
|
||||
relationshipCoverage: coverage,
|
||||
subject: {
|
||||
path: ANALYSIS_SNAPSHOT_TARGET.path,
|
||||
sha256: ANALYSIS_SNAPSHOT_TARGET.sha256,
|
||||
format: ANALYSIS_SNAPSHOT_TARGET.format,
|
||||
...(ANALYSIS_SNAPSHOT_TARGET.architecture === undefined
|
||||
? {}
|
||||
: { architecture: ANALYSIS_SNAPSHOT_TARGET.architecture }),
|
||||
},
|
||||
},
|
||||
);
|
||||
cache.record({
|
||||
target: ANALYSIS_SNAPSHOT_TARGET,
|
||||
profile: ANALYSIS_SNAPSHOT_PROFILE,
|
||||
operation,
|
||||
parameters,
|
||||
execution,
|
||||
});
|
||||
const evidence = createEvidence(
|
||||
ANALYSIS_SNAPSHOT_TARGET,
|
||||
ANALYSIS_SNAPSHOT_PROVIDER,
|
||||
{
|
||||
operation,
|
||||
parameters,
|
||||
result: ["0x2000"],
|
||||
rawResult: ["0x2000"],
|
||||
analysisProfile: ANALYSIS_SNAPSHOT_PROFILE,
|
||||
relationshipCoverage: coverage,
|
||||
},
|
||||
);
|
||||
const exported = cache.export(
|
||||
ANALYSIS_SNAPSHOT_TARGET,
|
||||
ANALYSIS_SNAPSHOT_PROFILE,
|
||||
createEvidenceBundle([evidence]),
|
||||
);
|
||||
if (!exported.ok) throw exported.error;
|
||||
expect(
|
||||
cache.lookup(
|
||||
ANALYSIS_SNAPSHOT_TARGET,
|
||||
ANALYSIS_SNAPSHOT_PROFILE,
|
||||
operation,
|
||||
parameters,
|
||||
)?.relationshipCoverage,
|
||||
).toEqual(coverage);
|
||||
|
||||
const tampered = structuredClone(exported.value);
|
||||
const tamperedEntry = tampered.entries[0];
|
||||
if (tamperedEntry === undefined) throw new Error("snapshot entry missing");
|
||||
tamperedEntry.execution.relationship_coverage = {
|
||||
status: "partial",
|
||||
limitations: ["forged coverage"],
|
||||
};
|
||||
expect(
|
||||
new AnalysisSnapshotCache().import(tampered, undefined, () => ok(0)).ok,
|
||||
).toBe(false);
|
||||
|
||||
const legacy = structuredClone(exported.value);
|
||||
const legacyEntry = legacy.entries[0];
|
||||
if (legacyEntry === undefined) throw new Error("snapshot entry missing");
|
||||
Reflect.deleteProperty(legacyEntry.execution, "relationship_coverage");
|
||||
const legacyEvidence = createEvidence(
|
||||
ANALYSIS_SNAPSHOT_TARGET,
|
||||
ANALYSIS_SNAPSHOT_PROVIDER,
|
||||
{
|
||||
operation,
|
||||
parameters,
|
||||
result: ["0x2000"],
|
||||
rawResult: ["0x2000"],
|
||||
analysisProfile: ANALYSIS_SNAPSHOT_PROFILE,
|
||||
},
|
||||
);
|
||||
Reflect.deleteProperty(legacyEvidence, "relationship_coverage");
|
||||
legacy.evidence_bundle = createEvidenceBundle([legacyEvidence]);
|
||||
parseAnalysisSnapshot(legacy);
|
||||
const replayCache = new AnalysisSnapshotCache();
|
||||
expect(replayCache.import(legacy, undefined, () => ok(0)).ok).toBe(true);
|
||||
expect(
|
||||
replayCache.lookup(
|
||||
ANALYSIS_SNAPSHOT_TARGET,
|
||||
ANALYSIS_SNAPSHOT_PROFILE,
|
||||
operation,
|
||||
parameters,
|
||||
)?.relationshipCoverage,
|
||||
).toEqual({
|
||||
status: "unknown",
|
||||
reason: "Snapshot entry does not report relationship coverage.",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user