refactor: return complete analysis results inline
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
} from "../../../src/cliOutput.js";
|
||||
|
||||
const CLI_INTEGRATION_TIMEOUT_MS = 60_000;
|
||||
const CLI_VARIANT_TIMEOUT_MS = 120_000;
|
||||
|
||||
describe("CLI output argument and sanitization boundary", () => {
|
||||
it("rejects token windows that would corrupt structured output", () => {
|
||||
@@ -175,59 +174,4 @@ describe("compiled CLI output boundary", () => {
|
||||
},
|
||||
CLI_INTEGRATION_TIMEOUT_MS,
|
||||
);
|
||||
|
||||
workspaceCliTest(
|
||||
"keeps operation failure status independent of output controls",
|
||||
async ({ cli }) => {
|
||||
const variants = [
|
||||
["--format", "toon"],
|
||||
["--format", "json"],
|
||||
["--format", "yaml"],
|
||||
["--format", "md"],
|
||||
["--format", "jsonl"],
|
||||
["--filter-output", "category", "--json"],
|
||||
["--token-limit", "5", "--json"],
|
||||
["--token-count", "--json"],
|
||||
];
|
||||
|
||||
for (const flags of variants) {
|
||||
const result = await cli.run({
|
||||
arguments: [
|
||||
...flags,
|
||||
"investigate-versions",
|
||||
"/tmp/left",
|
||||
"/tmp/right",
|
||||
"/tmp/workspace.json",
|
||||
],
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
exitCode: 1,
|
||||
stdout: expect.any(String),
|
||||
});
|
||||
}
|
||||
},
|
||||
CLI_VARIANT_TIMEOUT_MS,
|
||||
);
|
||||
|
||||
workspaceCliTest(
|
||||
"keeps failure logs out of structured stdout",
|
||||
async ({ cli }) => {
|
||||
const result = await cli.run({
|
||||
arguments: [
|
||||
"--json",
|
||||
"investigate-versions",
|
||||
"/tmp/left",
|
||||
"/tmp/right",
|
||||
"/tmp/workspace.json",
|
||||
],
|
||||
environment: { REA_LOG_LEVEL: "error" },
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
exitCode: 1,
|
||||
stderr: expect.stringContaining('"status":"error"'),
|
||||
});
|
||||
expect(result.json).toMatchObject({ error: "ApprovalRequired" });
|
||||
},
|
||||
CLI_INTEGRATION_TIMEOUT_MS,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,6 @@ describe("reconstruction obligation ledger CLI parity", () => {
|
||||
bindings: [],
|
||||
contradictions: [],
|
||||
},
|
||||
page: { offset: 0, limit: 50 },
|
||||
};
|
||||
const { stdout } = await execute(
|
||||
process.execPath,
|
||||
|
||||
@@ -95,8 +95,6 @@ describe("evidence bundle filesystem adapter", () => {
|
||||
await compareEvidenceBundlesCommand({
|
||||
leftPath: path,
|
||||
rightPath: path,
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
policy: policy(directory),
|
||||
}),
|
||||
).toMatchObject({
|
||||
|
||||
@@ -121,7 +121,7 @@ describe("JavaScript export return-shape comparison", () => {
|
||||
});
|
||||
|
||||
describe("JavaScript export return-shape selection", () => {
|
||||
it("reports selector candidates and enforces candidate, variant, and change limits", async () => {
|
||||
it("returns complete candidate, variant, and change inventories", async () => {
|
||||
const candidates = await analyzeSources({
|
||||
left: `
|
||||
export const first = () => ({ type: "first" });
|
||||
@@ -132,38 +132,30 @@ describe("JavaScript export return-shape selection", () => {
|
||||
});
|
||||
const missing = compare(candidates[0], candidates[1], {
|
||||
leftExportName: "missing",
|
||||
limits: { max_candidate_exports: 1 },
|
||||
});
|
||||
expect(missing.left).toMatchObject({
|
||||
status: "missing",
|
||||
omitted_candidates: 2,
|
||||
candidates: [expect.objectContaining({ module_path: "parser.mjs" })],
|
||||
omitted_candidates: 0,
|
||||
candidates: expect.arrayContaining([
|
||||
expect.objectContaining({ export_name: "first" }),
|
||||
expect.objectContaining({ export_name: "second" }),
|
||||
expect.objectContaining({ export_name: "third" }),
|
||||
]),
|
||||
});
|
||||
expect(missing.coverage.status).toBe("truncated");
|
||||
|
||||
const parsers = await sourceOwnedParsers();
|
||||
const variantLimited = compare(parsers[0], parsers[1], {
|
||||
limits: { max_return_variants: 1 },
|
||||
});
|
||||
expect(variantLimited.coverage).toMatchObject({
|
||||
status: "truncated",
|
||||
omitted_left_variants: 2,
|
||||
omitted_right_variants: 2,
|
||||
});
|
||||
const variants = compare(parsers[0], parsers[1]);
|
||||
expect(variants.coverage.omitted_left_variants).toBe(0);
|
||||
expect(variants.coverage.omitted_right_variants).toBe(0);
|
||||
|
||||
const changes = await analyzeSources({
|
||||
left: `export default () => ({ type: "item" });`,
|
||||
right: `export default () => ({ type: "item", depth: 1, level: 2 });`,
|
||||
});
|
||||
const changeLimited = compare(changes[0], changes[1], {
|
||||
limits: { max_changes: 1 },
|
||||
});
|
||||
expect(changeLimited.summary.added).toBe(2);
|
||||
expect(changeLimited.changes).toHaveLength(1);
|
||||
expect(changeLimited.coverage).toMatchObject({
|
||||
status: "truncated",
|
||||
omitted_changes: 1,
|
||||
});
|
||||
const complete = compare(changes[0], changes[1]);
|
||||
expect(complete.summary.added).toBe(2);
|
||||
expect(complete.changes).toHaveLength(2);
|
||||
expect(complete.coverage.omitted_changes).toBe(0);
|
||||
});
|
||||
|
||||
it("refuses an exact selector that resolves to multiple graph nodes", async () => {
|
||||
@@ -241,11 +233,6 @@ const compare = (
|
||||
options: {
|
||||
readonly leftExportName?: string;
|
||||
readonly rightExportName?: string;
|
||||
readonly limits?: Partial<{
|
||||
readonly max_candidate_exports: number;
|
||||
readonly max_return_variants: number;
|
||||
readonly max_changes: number;
|
||||
}>;
|
||||
} = {},
|
||||
) =>
|
||||
compareJavaScriptExportShapes({
|
||||
@@ -261,11 +248,6 @@ const compare = (
|
||||
modulePath: "parser.mjs",
|
||||
exportName: options.rightExportName ?? "default",
|
||||
},
|
||||
limits: {
|
||||
max_candidate_exports: options.limits?.max_candidate_exports ?? 100,
|
||||
max_return_variants: options.limits?.max_return_variants ?? 128,
|
||||
max_changes: options.limits?.max_changes ?? 1_000,
|
||||
},
|
||||
});
|
||||
|
||||
const analyzeGraph = async (root: string) => {
|
||||
|
||||
@@ -49,7 +49,7 @@ describe("reconstruction coverage persistence", () => {
|
||||
).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
_tag: "InvestigationWorkspaceError",
|
||||
_tag: "WorkspaceStorageError",
|
||||
reason: "revision-conflict",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -286,7 +286,6 @@ const projectStore = (
|
||||
projectRoot: string,
|
||||
grants: readonly ReturnType<typeof projectGrant>[],
|
||||
): ProjectPermissionStore => ({
|
||||
schema_version: 1,
|
||||
project_id: `project_${createHash("sha256").update(projectRoot).digest("hex")}`,
|
||||
project_root: projectRoot,
|
||||
grants: [...grants],
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { realpath } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { AnalysisOperationPort } from "../../../src/application/AnalysisProvider.js";
|
||||
@@ -10,7 +8,6 @@ import { createServer } from "../../../src/server/createServer.js";
|
||||
|
||||
describe("MCP permission preflight", () => {
|
||||
it("denies extraction before dispatch and returns exact typed remediation", async () => {
|
||||
const outputRoot = join(await realpath("/tmp"), "rea-permission-denied");
|
||||
let dispatches = 0;
|
||||
const analysis: AnalysisOperationPort = {
|
||||
execute: () => {
|
||||
@@ -30,8 +27,6 @@ describe("MCP permission preflight", () => {
|
||||
const result = await client.callTool({
|
||||
name: "extract_artifact",
|
||||
arguments: {
|
||||
approved: true,
|
||||
output_root: outputRoot,
|
||||
occurrence_ids: [`occ_${"0".repeat(64)}`],
|
||||
},
|
||||
});
|
||||
@@ -44,7 +39,7 @@ describe("MCP permission preflight", () => {
|
||||
code: "permission_required",
|
||||
details: {
|
||||
capability: "artifact_extract",
|
||||
missing: { roots: [outputRoot] },
|
||||
missing: { roots: [expect.stringMatching(/rea-extracted-/u)] },
|
||||
},
|
||||
remediation: {
|
||||
restart_required: true,
|
||||
|
||||
@@ -220,8 +220,6 @@ const capability = (provider: ProviderIdentity): CapabilityDescriptor => ({
|
||||
operation: "address_name",
|
||||
available: true,
|
||||
reason: null,
|
||||
pagination: "none",
|
||||
exhaustive: true,
|
||||
effects: {
|
||||
mutatesArtifact: false,
|
||||
launchesProcess: true,
|
||||
@@ -231,7 +229,6 @@ const capability = (provider: ProviderIdentity): CapabilityDescriptor => ({
|
||||
changesPermissions: false,
|
||||
requiresRoot: false,
|
||||
},
|
||||
limits: { maxResults: null, maxPayloadBytes: 1_000, timeoutMs: 1_000 },
|
||||
limitations: [],
|
||||
});
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ describe("reconstruction coverage MCP parity", () => {
|
||||
};
|
||||
const authority = await permissionAuthorityForRoot(
|
||||
root,
|
||||
["investigation_workspace_read", "investigation_workspace_write"],
|
||||
["investigation_workspace_read", "investigation_workspace_write"],
|
||||
["reconstruction_coverage_read", "reconstruction_coverage_write"],
|
||||
["reconstruction_coverage_read", "reconstruction_coverage_write"],
|
||||
);
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
|
||||
@@ -7,7 +7,7 @@ import { createServer } from "../../../src/server/createServer.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
|
||||
describe("reconstruction obligation ledger MCP parity", () => {
|
||||
it("returns an Evidence-backed page inline", async () => {
|
||||
it("returns the complete Evidence-backed ledger inline", async () => {
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -28,7 +28,6 @@ describe("reconstruction obligation ledger MCP parity", () => {
|
||||
bindings: [],
|
||||
contradictions: [],
|
||||
},
|
||||
page: { offset: 0, limit: 50 },
|
||||
},
|
||||
});
|
||||
expect(result.isError).not.toBe(true);
|
||||
|
||||
@@ -27,8 +27,6 @@ const availabilityProvider = (): AnalysisProvider => {
|
||||
operation: "current_address",
|
||||
available: true,
|
||||
reason: null,
|
||||
pagination: "none",
|
||||
exhaustive: true,
|
||||
effects: {
|
||||
mutatesArtifact: false,
|
||||
launchesProcess: false,
|
||||
@@ -38,11 +36,6 @@ const availabilityProvider = (): AnalysisProvider => {
|
||||
changesPermissions: false,
|
||||
requiresRoot: false,
|
||||
},
|
||||
limits: {
|
||||
maxResults: null,
|
||||
maxPayloadBytes: null,
|
||||
timeoutMs: null,
|
||||
},
|
||||
limitations: [],
|
||||
};
|
||||
return {
|
||||
@@ -69,8 +62,6 @@ const statusCapability = (
|
||||
operation,
|
||||
input_contract_version: 1,
|
||||
output_contract_version: 1,
|
||||
pagination: "none" as const,
|
||||
exhaustive: true,
|
||||
effects: {
|
||||
mutates_artifact: false,
|
||||
launches_process: false,
|
||||
@@ -80,11 +71,6 @@ const statusCapability = (
|
||||
changes_permissions: false,
|
||||
requires_root: false,
|
||||
},
|
||||
limits: {
|
||||
max_results: null,
|
||||
max_payload_bytes: null,
|
||||
timeout_ms: null,
|
||||
},
|
||||
limitations: [],
|
||||
...(availability.available
|
||||
? { available: true as const, reason: null, availability_code: null }
|
||||
@@ -109,10 +95,9 @@ describe("server and catalog identity", () => {
|
||||
expect(SDK_IDENTITY.server).toBe(
|
||||
packageJson.dependencies["@modelcontextprotocol/server"],
|
||||
);
|
||||
expect(CLI_COMMAND_NAMES).toHaveLength(68);
|
||||
expect(new Set(CLI_COMMAND_NAMES).size).toBe(68);
|
||||
expect(new Set(CLI_COMMAND_NAMES).size).toBe(CLI_COMMAND_NAMES.length);
|
||||
expect(CATALOG_IDENTITY.counts).toEqual({
|
||||
cli_commands: 68,
|
||||
cli_commands: CLI_COMMAND_NAMES.length,
|
||||
mcp_tools: TOOL_CONTRACTS.length,
|
||||
mcp_prompts: 6,
|
||||
});
|
||||
|
||||
@@ -300,8 +300,6 @@ const provider = (closed: string[]): AnalysisProvider => {
|
||||
operation: "current_document",
|
||||
available: true,
|
||||
reason: null,
|
||||
pagination: "none",
|
||||
exhaustive: true,
|
||||
effects: {
|
||||
mutatesArtifact: false,
|
||||
launchesProcess: false,
|
||||
@@ -311,11 +309,6 @@ const provider = (closed: string[]): AnalysisProvider => {
|
||||
changesPermissions: false,
|
||||
requiresRoot: false,
|
||||
},
|
||||
limits: {
|
||||
maxResults: null,
|
||||
maxPayloadBytes: null,
|
||||
timeoutMs: null,
|
||||
},
|
||||
limitations: [],
|
||||
};
|
||||
return {
|
||||
|
||||
@@ -51,7 +51,6 @@ describe("tool result projection", () => {
|
||||
const result = toCallToolResult(
|
||||
err(
|
||||
new HopperProcessError(80, {
|
||||
schema_version: 1,
|
||||
component: "hopper_private_display",
|
||||
operation: "launch",
|
||||
status: "error",
|
||||
|
||||
@@ -36,7 +36,7 @@ describe("Ghidra local transport", () => {
|
||||
const path = join(root, "bridge-endpoint.json");
|
||||
await writeFile(
|
||||
path,
|
||||
`${JSON.stringify({ schema_version: 1, host: "127.0.0.1", port: 49152 })}\n`,
|
||||
`${JSON.stringify({ host: "127.0.0.1", port: 49152 })}\n`,
|
||||
);
|
||||
|
||||
await expect(
|
||||
@@ -51,9 +51,9 @@ describe("Ghidra local transport", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ schema_version: 1, host: "0.0.0.0", port: 49152 },
|
||||
{ schema_version: 1, host: "127.0.0.1", port: 0 },
|
||||
{ schema_version: 1, host: "127.0.0.1", port: 49152, token: "leak" },
|
||||
{ host: "0.0.0.0", port: 49152 },
|
||||
{ host: "127.0.0.1", port: 0 },
|
||||
{ host: "127.0.0.1", port: 49152, token: "leak" },
|
||||
])(
|
||||
"rejects an invalid or expanded TCP endpoint: $host:$port",
|
||||
async (value) => {
|
||||
|
||||
@@ -101,7 +101,6 @@ class ExitingLauncher implements BridgeLauncher {
|
||||
class DiagnosticExitingLauncher implements BridgeLauncher {
|
||||
launch() {
|
||||
const diagnostic: HopperStartupDiagnostic = {
|
||||
schema_version: 1,
|
||||
component: "hopper_private_display",
|
||||
operation: "launch",
|
||||
status: "error",
|
||||
|
||||
@@ -39,7 +39,6 @@ type DiagnosticOverrides = Partial<
|
||||
|
||||
const diagnostic = (overrides: DiagnosticOverrides = {}) => {
|
||||
const common = {
|
||||
schema_version: 1,
|
||||
component: "hopper_private_display",
|
||||
operation: "probe",
|
||||
reason: "ready",
|
||||
|
||||
@@ -52,7 +52,9 @@ describe("managed static provider path boundary", () => {
|
||||
);
|
||||
expect(boundaries.ok).toBe(true);
|
||||
if (!boundaries.ok) return;
|
||||
expect(asManagedNativeBoundaryResult(boundaries.value)).toMatchObject({
|
||||
const boundaryResult = asManagedNativeBoundaryResult(boundaries.value);
|
||||
expect(boundaryResult).not.toHaveProperty("schema_version");
|
||||
expect(boundaryResult).toMatchObject({
|
||||
artifact: { path, sha256: parsed.value.sha256, format: "pe" },
|
||||
module_refs: [],
|
||||
pinvoke_imports: [],
|
||||
|
||||
@@ -508,7 +508,6 @@ describe("controlled JavaScript replay cancellation and export", () => {
|
||||
const metadata = await stat(path);
|
||||
expect(metadata.mode & 0o777).toBe(0o600);
|
||||
expect(JSON.parse(await readFile(path, "utf8"))).toMatchObject({
|
||||
schema_version: 1,
|
||||
sources: null,
|
||||
});
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user