refactor: return complete tool results inline
This commit is contained in:
@@ -63,7 +63,7 @@ async function runInlineEvidenceScenarios(
|
||||
expect(traced.isError).not.toBe(true);
|
||||
expect(traced.structuredContent).toMatchObject({
|
||||
result: {
|
||||
schema_version: 1,
|
||||
source_graph_id: expect.any(String),
|
||||
coverage: { status: expect.any(String) },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -10,7 +10,6 @@ import { createServer } from "../../../src/server/createServer.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
import { analyzeJavaScriptApplication } from "../../../src/application/JavaScriptApplicationService.js";
|
||||
import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascriptApplicationAnalysis.js";
|
||||
import { permissionAuthorityForRoot } from "../../fixtures/permissionAuthority.js";
|
||||
|
||||
describe("application workflow MCP parity", () => {
|
||||
it("compares exact parser export shapes through full Evidence and session IDs", async () => {
|
||||
@@ -28,19 +27,12 @@ describe("application workflow MCP parity", () => {
|
||||
join(rightRoot, "parser.mjs"),
|
||||
),
|
||||
]);
|
||||
const authority = await permissionAuthorityForRoot(
|
||||
root,
|
||||
["investigation_input"],
|
||||
["investigation_input"],
|
||||
);
|
||||
const [left, right] = await Promise.all([
|
||||
analyzeJavaScriptApplication(authority, {
|
||||
analyzeJavaScriptApplication({
|
||||
input_path: leftRoot,
|
||||
approved: true,
|
||||
}),
|
||||
analyzeJavaScriptApplication(authority, {
|
||||
analyzeJavaScriptApplication({
|
||||
input_path: rightRoot,
|
||||
approved: true,
|
||||
}),
|
||||
]);
|
||||
if (!left.ok) throw left.error;
|
||||
@@ -107,8 +99,6 @@ describe("application workflow MCP parity", () => {
|
||||
const analyzed = javascriptApplicationAnalysisResultSchema.parse(
|
||||
left.value.normalized_result,
|
||||
);
|
||||
if (analyzed.schema_version !== 2)
|
||||
throw new TypeError("Expected semantic application Evidence");
|
||||
const seed = analyzed.semantic_graph.relations[0]?.source_node_id;
|
||||
if (seed === undefined)
|
||||
throw new TypeError("Expected at least one semantic relation");
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
serializeEvidenceBundle,
|
||||
} from "../../../src/domain/evidenceBundle.js";
|
||||
import { analyzeJavaScriptApplication } from "../../../src/application/JavaScriptApplicationService.js";
|
||||
import { permissionAuthorityForRoot } from "../../fixtures/permissionAuthority.js";
|
||||
import { REPLAY_MACHINE_RUN_EXAMPLE } from "../../../src/contracts/replayMachineExample.js";
|
||||
import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascriptApplicationAnalysis.js";
|
||||
|
||||
@@ -43,7 +42,7 @@ describe("application workflow CLI parity", () => {
|
||||
]);
|
||||
expect(traced).toMatchObject({
|
||||
operation: "trace_application_feature",
|
||||
normalized_result: { schema_version: 1 },
|
||||
normalized_result: { source_evidence_id: expect.any(String) },
|
||||
});
|
||||
|
||||
const root = await createTestTempDirectory("rea-application-cli-");
|
||||
@@ -86,21 +85,13 @@ describe("application workflow CLI parity", () => {
|
||||
join(root, "app.js"),
|
||||
"function add(value) { return value + 1; } add(2);",
|
||||
);
|
||||
const authority = await permissionAuthorityForRoot(
|
||||
root,
|
||||
["investigation_input"],
|
||||
["investigation_input"],
|
||||
);
|
||||
const analyzed = await analyzeJavaScriptApplication(authority, {
|
||||
const analyzed = await analyzeJavaScriptApplication({
|
||||
input_path: root,
|
||||
approved: true,
|
||||
});
|
||||
if (!analyzed.ok) throw analyzed.error;
|
||||
const result = javascriptApplicationAnalysisResultSchema.parse(
|
||||
analyzed.value.normalized_result,
|
||||
);
|
||||
if (result.schema_version !== 2)
|
||||
throw new TypeError("Expected semantic application Evidence");
|
||||
const seed = result.semantic_graph.relations[0]?.source_node_id;
|
||||
if (seed === undefined)
|
||||
throw new TypeError("Expected at least one semantic relation");
|
||||
@@ -163,7 +154,7 @@ describe("application workflow CLI Evidence resolution", () => {
|
||||
);
|
||||
expect(traced).toMatchObject({
|
||||
operation: "trace_application_feature",
|
||||
normalized_result: { schema_version: 1 },
|
||||
normalized_result: { source_evidence_id: expect.any(String) },
|
||||
});
|
||||
|
||||
const compared = await runCli(
|
||||
@@ -244,19 +235,12 @@ describe("application workflow CLI export Evidence", () => {
|
||||
join(rightRoot, "parser.mjs"),
|
||||
),
|
||||
]);
|
||||
const authority = await permissionAuthorityForRoot(
|
||||
root,
|
||||
["investigation_input"],
|
||||
["investigation_input"],
|
||||
);
|
||||
const [left, right] = await Promise.all([
|
||||
analyzeJavaScriptApplication(authority, {
|
||||
analyzeJavaScriptApplication({
|
||||
input_path: leftRoot,
|
||||
approved: true,
|
||||
}),
|
||||
analyzeJavaScriptApplication(authority, {
|
||||
analyzeJavaScriptApplication({
|
||||
input_path: rightRoot,
|
||||
approved: true,
|
||||
}),
|
||||
]);
|
||||
if (!left.ok) throw left.error;
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
buildSyntheticJavaScriptApplicationGraph,
|
||||
} from "../../../src/domain/javascriptApplicationGraph.fixture.js";
|
||||
import { writeVersionedJavaScriptApplicationFixtures } from "../../fixtures/javascriptArtifactApplication.js";
|
||||
import { permissionAuthorityForRoot } from "../../fixtures/permissionAuthority.js";
|
||||
|
||||
const temporary: string[] = [];
|
||||
|
||||
@@ -62,7 +61,6 @@ describe("JavaScript application workflows", () => {
|
||||
case_sensitive: false,
|
||||
},
|
||||
direction: "outgoing",
|
||||
limits: traceLimits(),
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
@@ -94,7 +92,7 @@ describe("JavaScript application workflows", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps no-match and bounded frontiers explicit", () => {
|
||||
it("keeps no-match explicit and traces the full reachable graph", () => {
|
||||
const graph = buildSyntheticJavaScriptApplicationGraph();
|
||||
const noMatch = traceApplicationFeature({
|
||||
sourceEvidenceId: `ev_${"a".repeat(64)}`,
|
||||
@@ -107,7 +105,6 @@ describe("JavaScript application workflows", () => {
|
||||
case_sensitive: false,
|
||||
},
|
||||
direction: "both",
|
||||
limits: traceLimits(),
|
||||
});
|
||||
expect(noMatch).toMatchObject({
|
||||
graph: null,
|
||||
@@ -115,7 +112,7 @@ describe("JavaScript application workflows", () => {
|
||||
summary: { matched_seeds: 0 },
|
||||
});
|
||||
|
||||
const bounded = traceApplicationFeature({
|
||||
const complete = traceApplicationFeature({
|
||||
sourceEvidenceId: `ev_${"a".repeat(64)}`,
|
||||
graph,
|
||||
nativeEvidence: [],
|
||||
@@ -126,11 +123,11 @@ describe("JavaScript application workflows", () => {
|
||||
case_sensitive: false,
|
||||
},
|
||||
direction: "outgoing",
|
||||
limits: { ...traceLimits(), max_depth: 1 },
|
||||
});
|
||||
expect(bounded.coverage).toMatchObject({ status: "truncated" });
|
||||
expect(bounded.coverage.omitted_nodes).toBeGreaterThan(0);
|
||||
expect(bounded.summary.native_handoffs).toBe(0);
|
||||
expect(complete.coverage.status).toBe("complete-within-source");
|
||||
expect(complete.coverage.total_seed_matches).toBe(1);
|
||||
expect(complete.graph?.nodes.length).toBeGreaterThan(1);
|
||||
expect(complete.coverage).not.toHaveProperty("omitted_nodes");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -140,8 +137,8 @@ describe("JavaScript application comparison workflows", () => {
|
||||
temporary.push(root);
|
||||
const fixtures = await writeVersionedJavaScriptApplicationFixtures(root);
|
||||
const [left, right] = await Promise.all([
|
||||
analyzeFixture(fixtures.left, true),
|
||||
analyzeFixture(fixtures.right, true),
|
||||
analyzeFixture(fixtures.left),
|
||||
analyzeFixture(fixtures.right),
|
||||
]);
|
||||
const compared = compareApplicationVersionsEvidence({ left, right });
|
||||
if (!compared.ok) throw compared.error;
|
||||
@@ -199,8 +196,8 @@ describe("JavaScript application comparison workflows", () => {
|
||||
temporary.push(root);
|
||||
const fixtures = await writeVersionedJavaScriptApplicationFixtures(root);
|
||||
const [left, right] = await Promise.all([
|
||||
analyzeFixture(fixtures.left, true),
|
||||
analyzeFixture(fixtures.right, true),
|
||||
analyzeFixture(fixtures.left),
|
||||
analyzeFixture(fixtures.right),
|
||||
]);
|
||||
const compared = compareApplicationVersionsEvidence({ left, right });
|
||||
if (!compared.ok) throw compared.error;
|
||||
@@ -227,7 +224,6 @@ describe("JavaScript application comparison workflows", () => {
|
||||
if (rootNode === undefined) throw new Error("Synthetic graph root missing");
|
||||
const partial = createJavaScriptApplicationGraph({
|
||||
schema: "JavaScriptApplicationGraph",
|
||||
schema_version: 1,
|
||||
root_node_ids: [rootNode.node_id],
|
||||
nodes: [rootNode],
|
||||
edges: [],
|
||||
@@ -273,24 +269,9 @@ describe("JavaScript application comparison workflows", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const traceLimits = () => ({
|
||||
max_seed_matches: 25,
|
||||
max_depth: 12,
|
||||
max_nodes: 2_000,
|
||||
max_edges: 4_000,
|
||||
max_paths: 100,
|
||||
});
|
||||
|
||||
const analyzeFixture = async (root: string, sourceMaps = false) => {
|
||||
const authority = await permissionAuthorityForRoot(
|
||||
root,
|
||||
["investigation_input"],
|
||||
["investigation_input"],
|
||||
);
|
||||
const result = await analyzeJavaScriptApplication(authority, {
|
||||
const analyzeFixture = async (root: string) => {
|
||||
const result = await analyzeJavaScriptApplication({
|
||||
input_path: root,
|
||||
approved: true,
|
||||
source_map_read_approved: sourceMaps,
|
||||
});
|
||||
if (!result.ok) throw result.error;
|
||||
return result.value;
|
||||
|
||||
@@ -19,7 +19,7 @@ const expectAvailableToolInventory = async (client: Client): Promise<void> => {
|
||||
const listed = await client.listTools();
|
||||
const status = await client.callTool({
|
||||
name: "binary_session",
|
||||
arguments: { detail: "full" },
|
||||
arguments: {},
|
||||
});
|
||||
const availability = z
|
||||
.object({
|
||||
|
||||
Reference in New Issue
Block a user