feat(native): return a retained summary view of binary layouts on request (#1570)
inspect_binary_layout accepts the same optional detail input as analyze_javascript_application. The default complete delivery is unchanged; detail "summary" retains the complete layout Evidence in the session and returns its inspect_analysis_view summary, whose parent_evidence_id selects sections, symbols, mitigations or linkage later. Both tools share one detail schema and output projection. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c19e15a2b3
commit
5156ba44c5
@@ -3,15 +3,22 @@ import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { expect, it, onTestFinished } from "vitest";
|
||||
|
||||
import { BinaryLayoutService } from "../../../src/application/binaryDiagnostics/BinaryLayoutService.js";
|
||||
import { toolContract } from "../../../src/contracts/toolContracts.js";
|
||||
import { ok } from "../../../src/domain/result.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { analysisViewLayoutFixture } from "../../fixtures/analysisView.js";
|
||||
import { BINARY_LAYOUT_TEST_PROVIDER } from "../../fixtures/binaryDiagnostics/layout.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
const contract = toolContract("analyze_javascript_application");
|
||||
|
||||
const connect = async (retainsEvidence: boolean) => {
|
||||
const connect = async (
|
||||
retainsEvidence: boolean,
|
||||
binaryLayout?: BinaryLayoutService,
|
||||
) => {
|
||||
const session = createTestBinarySession(() => {
|
||||
throw new Error("JavaScript analysis must not start a deep provider");
|
||||
});
|
||||
@@ -26,6 +33,7 @@ const connect = async (retainsEvidence: boolean) => {
|
||||
},
|
||||
},
|
||||
},
|
||||
binaryLayout === undefined ? {} : { binaryLayout },
|
||||
);
|
||||
const client = new Client({ name: "analysis-summary-detail", version: "1" });
|
||||
onTestFinished(async () => {
|
||||
@@ -123,3 +131,40 @@ it("refuses summary detail when the server cannot retain the complete Evidence",
|
||||
message: expect.stringContaining("detail complete"),
|
||||
});
|
||||
});
|
||||
|
||||
it("returns the summary of retained binary layout Evidence", async () => {
|
||||
const layout = analysisViewLayoutFixture();
|
||||
const client = await connect(
|
||||
true,
|
||||
new BinaryLayoutService({
|
||||
identity: BINARY_LAYOUT_TEST_PROVIDER,
|
||||
inspect: () => Promise.resolve(ok(layout)),
|
||||
}),
|
||||
);
|
||||
const layoutContract = toolContract("inspect_binary_layout");
|
||||
const summary = await client.callTool({
|
||||
name: layoutContract.name,
|
||||
arguments: { path: layout.artifact.path, detail: "summary" },
|
||||
});
|
||||
expect(summary.isError).not.toBe(true);
|
||||
const evidence = layoutContract.outputSchema.parse(summary.structuredContent);
|
||||
expect(evidence).toMatchObject({
|
||||
operation: "inspect_analysis_view",
|
||||
normalized_result: {
|
||||
kind: "summary",
|
||||
parent_operation: "inspect_binary_layout",
|
||||
},
|
||||
});
|
||||
const [parentId] = evidence.evidence_links;
|
||||
const sections = await client.callTool({
|
||||
name: "inspect_analysis_view",
|
||||
arguments: {
|
||||
source: { kind: "retained-evidence", evidence_id: parentId },
|
||||
view: { kind: "page", collection: "sections", offset: 0, limit: 8 },
|
||||
},
|
||||
});
|
||||
expect(sections.isError).not.toBe(true);
|
||||
expect(sections.structuredContent).toMatchObject({
|
||||
normalized_result: { kind: "page", parent_evidence_id: parentId },
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user