fix(evidence): preserve trace uncertainty and partial provider observations
Distinguish an unresolved goal from an exhausted call graph and preserve provider failures through cancellation. Retain completed IDA replies and post-operation identity observations as partial Evidence without claiming a verified final binding. Remove source-wide bundler cache-name heuristics and stale expectations.
This commit is contained in:
@@ -42,7 +42,7 @@ describe("Webpack and Rspack runtime adapters", () => {
|
||||
expect(webpackEntry?.observations[0]?.properties).toMatchObject({
|
||||
bundler: "webpack",
|
||||
runtime_require_name: "__webpack_require__",
|
||||
runtime_module_cache_status: "observed",
|
||||
runtime_module_cache_status: "not-observed",
|
||||
entry_module_keys: ["10"],
|
||||
async_chunk_keys: ["lazy", "missing"],
|
||||
unknown_async_chunk_keys: 1,
|
||||
@@ -55,6 +55,7 @@ describe("Webpack and Rspack runtime adapters", () => {
|
||||
expect(rspackEntry?.observations[0]?.properties).toMatchObject({
|
||||
bundler: "rspack",
|
||||
runtime_require_name: "r",
|
||||
runtime_module_cache_status: "not-observed",
|
||||
entry_module_keys: ["src/entry.ts"],
|
||||
async_chunk_keys: ["model"],
|
||||
});
|
||||
@@ -156,7 +157,8 @@ const bundlerFixture = async (): Promise<string> => {
|
||||
const root = await createTestTempDirectory("rea-bundler-adapters-");
|
||||
await writeFixtureFiles(root, {
|
||||
"renderer/chunks/runtime.js": `
|
||||
var __webpack_module_cache__ = {};
|
||||
// A cache-like name here is not evidence about either registration.
|
||||
const documentation = "__webpack_module_cache__";
|
||||
(globalThis["webpackChunkcustomPortal"] = globalThis["webpackChunkcustomPortal"] || []).push([
|
||||
["main"],
|
||||
{
|
||||
@@ -179,7 +181,11 @@ const bundlerFixture = async (): Promise<string> => {
|
||||
(globalThis["webpackChunkcustomPortal"] = globalThis["webpackChunkcustomPortal"] || []).push([
|
||||
["lazy"],
|
||||
{
|
||||
20: (module) => { module.exports = "lazy"; }
|
||||
20: (module) => {
|
||||
// A marker in a different registration must not be inherited.
|
||||
const documentation = "installedModules";
|
||||
module.exports = "lazy";
|
||||
}
|
||||
}
|
||||
]);
|
||||
(self.rspackChunkcustomPortal = self.rspackChunkcustomPortal || []).push([
|
||||
|
||||
@@ -5,6 +5,7 @@ import { createAnalysisExecution } from "../../../src/application/AnalysisProvid
|
||||
import { EnhancedTools } from "../../../src/application/EnhancedTools.js";
|
||||
import {
|
||||
AnalysisCapabilityUnavailableError,
|
||||
AnalysisCancelledError,
|
||||
AnalysisOutputError,
|
||||
} from "../../../src/domain/analysisErrorCore.js";
|
||||
import type { RelationshipCoverage } from "../../../src/domain/relationshipCoverage.js";
|
||||
@@ -178,6 +179,125 @@ describe("enhanced MCP tools", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("trace_call_path MCP outcome semantics", () => {
|
||||
it("reports an unreachable goal as unknown when relationship coverage is partial", async () => {
|
||||
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([], [], {
|
||||
status: "partial",
|
||||
limitations: ["one or more callees may be missing"],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const trace = await client.callTool({
|
||||
name: "trace_call_path",
|
||||
arguments: { start: "0x1", goal: "0x2" },
|
||||
});
|
||||
expect(trace.isError).not.toBe(true);
|
||||
expect(trace.structuredContent).toMatchObject({
|
||||
normalized_result: {
|
||||
goal_status: "unknown",
|
||||
truncated: true,
|
||||
relationship_coverage: { "0x1": { status: "partial" } },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("reports an unreachable goal as unknown when an expansion fails", async () => {
|
||||
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 err(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
"fixture",
|
||||
name,
|
||||
"relationship read unavailable",
|
||||
),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
const trace = await client.callTool({
|
||||
name: "trace_call_path",
|
||||
arguments: { start: "0x1", goal: "0x2" },
|
||||
});
|
||||
expect(trace.isError).not.toBe(true);
|
||||
expect(trace.structuredContent).toMatchObject({
|
||||
normalized_result: {
|
||||
goal_status: "unknown",
|
||||
failures: [{ address: "0x1" }],
|
||||
truncated: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("reports an unreachable goal as absent after complete traversal", async () => {
|
||||
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([], [], { status: "complete" });
|
||||
},
|
||||
});
|
||||
|
||||
const trace = await client.callTool({
|
||||
name: "trace_call_path",
|
||||
arguments: { start: "0x1", goal: "0x2" },
|
||||
});
|
||||
expect(trace.isError).not.toBe(true);
|
||||
expect(trace.structuredContent).toMatchObject({
|
||||
normalized_result: {
|
||||
goal_status: "not_reached",
|
||||
truncated: false,
|
||||
residual_unknowns: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("propagates cancellation during expansion without visiting another frontier", async () => {
|
||||
const controller = new AbortController();
|
||||
const calls: string[] = [];
|
||||
const client = await connect({
|
||||
execute: async (name, arguments_, options) => {
|
||||
calls.push(name);
|
||||
if (name === "procedure_address")
|
||||
return relationshipExecution(String(arguments_.procedure));
|
||||
if (name !== "procedure_callees")
|
||||
throw new Error(`Unexpected operation: ${name}`);
|
||||
controller.abort();
|
||||
if (options?.signal?.aborted !== true)
|
||||
throw new Error("provider request was not cancelled");
|
||||
return err(new AnalysisCancelledError(name));
|
||||
},
|
||||
});
|
||||
|
||||
await expect(
|
||||
client.callTool(
|
||||
{
|
||||
name: "trace_call_path",
|
||||
arguments: { start: "0x1", goal: "0x3" },
|
||||
},
|
||||
{ signal: controller.signal },
|
||||
),
|
||||
).rejects.toThrow();
|
||||
expect(calls).toEqual([
|
||||
"procedure_address",
|
||||
"procedure_address",
|
||||
"procedure_callees",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("enhanced MCP batches", () => {
|
||||
it("returns every batch item in caller order with its own result", async () => {
|
||||
const addresses = Array.from(
|
||||
|
||||
@@ -209,7 +209,7 @@ it("preserves missing callgraph coverage through direct, graph, and trace workfl
|
||||
});
|
||||
if (!trace.ok) throw trace.error;
|
||||
expect(trace.value).toMatchObject({
|
||||
goal_status: "not_reached",
|
||||
goal_status: "unknown",
|
||||
edges: [],
|
||||
limitations: expect.arrayContaining([
|
||||
expect.stringContaining("callgraph was unavailable"),
|
||||
|
||||
Reference in New Issue
Block a user