fix: address MCP resource review feedback
This commit is contained in:
@@ -8,7 +8,10 @@ import {
|
||||
createAnalysisExecution,
|
||||
type AnalysisOperationPort,
|
||||
} from "../src/application/AnalysisProvider.js";
|
||||
import { AnalysisProtocolError } from "../src/domain/errors.js";
|
||||
import {
|
||||
AnalysisCancelledError,
|
||||
AnalysisProtocolError,
|
||||
} from "../src/domain/errors.js";
|
||||
import { err, ok } from "../src/domain/result.js";
|
||||
|
||||
const provider = { id: "fixture", name: "Fixture", version: "1" };
|
||||
@@ -30,9 +33,19 @@ describe("analysis context queries", () => {
|
||||
return Promise.resolve(
|
||||
ok(createAnalysisExecution("0x401000", provider)),
|
||||
);
|
||||
if (operation === "current_procedure")
|
||||
if (operation === "resolve_containing_procedure")
|
||||
return Promise.resolve(
|
||||
err(new AnalysisProtocolError("cursor is not in a procedure")),
|
||||
ok(
|
||||
createAnalysisExecution(
|
||||
{
|
||||
query_address: "0x401000",
|
||||
found: false,
|
||||
procedure: null,
|
||||
reason: "not_in_procedure",
|
||||
},
|
||||
provider,
|
||||
),
|
||||
),
|
||||
);
|
||||
return Promise.resolve(
|
||||
err(new AnalysisProtocolError(`unexpected ${operation}`)),
|
||||
@@ -51,6 +64,10 @@ describe("analysis context queries", () => {
|
||||
operation: "current_document",
|
||||
parameters: {},
|
||||
});
|
||||
expect(calls).toContainEqual({
|
||||
operation: "resolve_containing_procedure",
|
||||
parameters: { document: "fixture", address: "0x401000" },
|
||||
});
|
||||
});
|
||||
|
||||
it("uses an explicit document without passing it to current_document and preserves procedure failures", async () => {
|
||||
@@ -70,7 +87,7 @@ describe("analysis context queries", () => {
|
||||
await expect(
|
||||
getNavigationContext(analysis, { document: "fixture" }),
|
||||
).resolves.toEqual(err(failure));
|
||||
expect(calls).toEqual(["current_address", "current_procedure"]);
|
||||
expect(calls).toEqual(["current_address", "resolve_containing_procedure"]);
|
||||
});
|
||||
|
||||
it("keeps unsupported address facets local and filters bookmarks", async () => {
|
||||
@@ -90,7 +107,11 @@ describe("analysis context queries", () => {
|
||||
return Promise.resolve(
|
||||
ok(
|
||||
createAnalysisExecution(
|
||||
{ address: "0x401000", name: "main" },
|
||||
{
|
||||
query_address: "0x401000",
|
||||
found: true,
|
||||
procedure: { address: "0x401000", name: "main" },
|
||||
},
|
||||
provider,
|
||||
),
|
||||
),
|
||||
@@ -119,7 +140,7 @@ describe("analysis context queries", () => {
|
||||
};
|
||||
|
||||
const result = await inspectAddressContext(analysis, {
|
||||
address: "0x401000",
|
||||
address: "401000",
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
ok: true,
|
||||
@@ -137,4 +158,20 @@ describe("analysis context queries", () => {
|
||||
});
|
||||
expect(bookmarkInputs).toEqual([{}]);
|
||||
});
|
||||
|
||||
it("propagates cancellation instead of degrading it to an unavailable facet", async () => {
|
||||
const cancelled = new AnalysisCancelledError("comment");
|
||||
const analysis: AnalysisOperationPort = {
|
||||
execute: (operation) =>
|
||||
Promise.resolve(
|
||||
operation === "comment"
|
||||
? err(cancelled)
|
||||
: ok(createAnalysisExecution(null, provider)),
|
||||
),
|
||||
};
|
||||
|
||||
await expect(
|
||||
inspectAddressContext(analysis, { address: "0x401000" }),
|
||||
).resolves.toEqual(err(cancelled));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -295,6 +295,11 @@ describe("binary session", () => {
|
||||
).toBe(true);
|
||||
expect(replayCalls).toEqual(["health", "set_address_name", "address_name"]);
|
||||
expect(replay.exportAnalysisSnapshot().ok).toBe(false);
|
||||
expect((await replay.open(first)).ok).toBe(true);
|
||||
expect(replay.exportAnalysisSnapshot()).toMatchObject({
|
||||
ok: true,
|
||||
value: { entries: [{ operation: "address_name" }] },
|
||||
});
|
||||
await replay.close();
|
||||
|
||||
const mismatch = new BinarySession(cacheProvider([]));
|
||||
|
||||
@@ -12,6 +12,52 @@ import { createInvestigationWorkspace } from "../src/domain/investigationWorkspa
|
||||
const provider = { id: "fixture", name: "Fixture", version: "1" };
|
||||
|
||||
describe("evidence MCP resources", () => {
|
||||
it("publishes mutable snapshot changes for every Evidence mutation", () => {
|
||||
const session = new BinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
let updates = 0;
|
||||
session.onAnalysisSnapshotChanged(() => {
|
||||
updates += 1;
|
||||
});
|
||||
const first = createEvidence(undefined, provider, {
|
||||
operation: "notification_probe",
|
||||
parameters: {},
|
||||
result: 1,
|
||||
});
|
||||
expect(session.recordEvidence(first)).toEqual({ ok: true, value: "added" });
|
||||
expect(session.recordEvidence(first)).toEqual({
|
||||
ok: true,
|
||||
value: "duplicate",
|
||||
});
|
||||
const imported = createEvidence(undefined, provider, {
|
||||
operation: "import_notification_probe",
|
||||
parameters: {},
|
||||
result: 2,
|
||||
});
|
||||
expect(
|
||||
session.importEvidenceBundle(createEvidenceBundle([imported])),
|
||||
).toEqual({ ok: true, value: 1 });
|
||||
expect(
|
||||
session.recordUnknown({
|
||||
approved: true,
|
||||
question: "Does mutation publish a snapshot update?",
|
||||
severity: "low",
|
||||
domain: "notifications",
|
||||
supporting_evidence_ids: [first.evidence_id],
|
||||
contradicting_evidence_ids: [],
|
||||
required_authority: "controlled-replay",
|
||||
required_confidence: "observed",
|
||||
required_environment: null,
|
||||
recommended_probes: [],
|
||||
relationships: [],
|
||||
}).ok,
|
||||
).toBe(true);
|
||||
expect(updates).toBe(3);
|
||||
});
|
||||
|
||||
it("retains bundles without eviction and rejects a seventeenth digest", () => {
|
||||
const session = new BinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
|
||||
Reference in New Issue
Block a user