refactor: return complete tool results inline
This commit is contained in:
@@ -42,7 +42,7 @@ describe("browser CLI parity", () => {
|
||||
operation: "list_browser_targets",
|
||||
provider: { id: "rea-cdp-browser" },
|
||||
normalized_result: {
|
||||
targets: { items: [{ target_id: "allowed-page" }] },
|
||||
targets: [{ target_id: "allowed-page" }],
|
||||
},
|
||||
});
|
||||
const inspected = await runCli(
|
||||
@@ -358,7 +358,6 @@ const completeScenarioCapture = () => {
|
||||
completeness,
|
||||
});
|
||||
return {
|
||||
schema_version: 1,
|
||||
browser: {
|
||||
mode: "connect",
|
||||
process_ownership: "external",
|
||||
|
||||
@@ -135,7 +135,7 @@ describe("compiled CLI output boundary", () => {
|
||||
'code: VALIDATION_ERROR\nmessage: "REA could not read the command arguments. Run `rea --help`, correct the arguments, then try again."\n',
|
||||
});
|
||||
const json = await cli.run({
|
||||
arguments: ["--full-output", "--json", "analyze"],
|
||||
arguments: ["--json", "analyze"],
|
||||
});
|
||||
expect(json).toMatchObject({
|
||||
exitCode: 1,
|
||||
@@ -154,7 +154,7 @@ describe("compiled CLI output boundary", () => {
|
||||
);
|
||||
|
||||
workspaceCliTest(
|
||||
"preserves artifact diagnostics in ordinary and full JSON output",
|
||||
"preserves artifact diagnostics in JSON output",
|
||||
async ({ cli, workspace }) => {
|
||||
const source = workspace.path("source");
|
||||
await mkdir(source);
|
||||
@@ -163,17 +163,15 @@ describe("compiled CLI output boundary", () => {
|
||||
await createPackageWithOptions(source, archive, { unpack: "*.js" });
|
||||
await writeFile(join(`${archive}.unpacked`, "main.js"), "changed();\n");
|
||||
|
||||
for (const flags of [["--json"], ["--full-output", "--json"]]) {
|
||||
const result = await cli.run({
|
||||
arguments: [...flags, "inventory-artifact", archive],
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
const output = JSON.stringify(result.json);
|
||||
expect(output).toContain('"logical_path":"main.js"');
|
||||
expect(output).toMatch(/"declared_sha256":"[a-f0-9]{64}"/u);
|
||||
expect(output).toMatch(/"calculated_sha256":"[a-f0-9]{64}"/u);
|
||||
expect(output).toContain('"unpacked":true');
|
||||
}
|
||||
const result = await cli.run({
|
||||
arguments: ["--json", "inventory-artifact", archive],
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
const output = JSON.stringify(result.json);
|
||||
expect(output).toContain('"logical_path":"main.js"');
|
||||
expect(output).toMatch(/"declared_sha256":"[a-f0-9]{64}"/u);
|
||||
expect(output).toMatch(/"calculated_sha256":"[a-f0-9]{64}"/u);
|
||||
expect(output).toContain('"unpacked":true');
|
||||
},
|
||||
CLI_INTEGRATION_TIMEOUT_MS,
|
||||
);
|
||||
@@ -187,7 +185,6 @@ describe("compiled CLI output boundary", () => {
|
||||
["--format", "yaml"],
|
||||
["--format", "md"],
|
||||
["--format", "jsonl"],
|
||||
["--full-output", "--json"],
|
||||
["--filter-output", "category", "--json"],
|
||||
["--token-limit", "5", "--json"],
|
||||
["--token-count", "--json"],
|
||||
|
||||
@@ -57,7 +57,7 @@ describe("Electron CLI parity", () => {
|
||||
expect(listed).toMatchObject({
|
||||
operation: "list_electron_targets",
|
||||
normalized_result: {
|
||||
targets: { items: [{ target_id: "electron-page" }] },
|
||||
targets: [{ target_id: "electron-page" }],
|
||||
},
|
||||
});
|
||||
const inspected = await runCli(
|
||||
@@ -91,11 +91,10 @@ describe("Electron CLI parity", () => {
|
||||
await writeElectronBoundaryFixture(root);
|
||||
const environment = {
|
||||
...process.env,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([root]),
|
||||
};
|
||||
|
||||
const analyzed = await runCli(
|
||||
["analyze-javascript-application", root, "--approved", "--json"],
|
||||
["analyze-javascript-application", root, "--json"],
|
||||
environment,
|
||||
);
|
||||
|
||||
@@ -125,7 +124,6 @@ describe("Electron CLI artifact behavior", () => {
|
||||
await writeElectronBoundaryFixture(root);
|
||||
const environment = {
|
||||
...process.env,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([root]),
|
||||
};
|
||||
|
||||
const analyzed = await runCli(
|
||||
@@ -134,7 +132,6 @@ describe("Electron CLI artifact behavior", () => {
|
||||
"json",
|
||||
"analyze-javascript-application",
|
||||
root,
|
||||
"--approved",
|
||||
"--artifact-format",
|
||||
"directory",
|
||||
],
|
||||
@@ -150,20 +147,16 @@ describe("Electron CLI artifact behavior", () => {
|
||||
);
|
||||
|
||||
it(
|
||||
"routes generic approved analysis of a directory to static JavaScript",
|
||||
"routes generic directory analysis to static JavaScript",
|
||||
async () => {
|
||||
const root = await createTestTempDirectory("rea-electron-routed-cli-");
|
||||
temporary.push(root);
|
||||
await writeElectronBoundaryFixture(root);
|
||||
const environment = {
|
||||
...process.env,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([root]),
|
||||
};
|
||||
|
||||
const analyzed = await runCli(
|
||||
["analyze", root, "--approved", "--json"],
|
||||
environment,
|
||||
);
|
||||
const analyzed = await runCli(["analyze", root, "--json"], environment);
|
||||
|
||||
expect(analyzed).toMatchObject({
|
||||
operation: "analyze_javascript_application",
|
||||
@@ -177,39 +170,6 @@ describe("Electron CLI artifact behavior", () => {
|
||||
},
|
||||
INTEGRATION_TEST_TIMEOUT_MS,
|
||||
);
|
||||
|
||||
it(
|
||||
"requires explicit approval before generic JavaScript analysis",
|
||||
async () => {
|
||||
const root = await createTestTempDirectory(
|
||||
"rea-electron-unapproved-cli-",
|
||||
);
|
||||
temporary.push(root);
|
||||
await writeElectronBoundaryFixture(root);
|
||||
const environment = {
|
||||
...process.env,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([root]),
|
||||
};
|
||||
|
||||
const denied = await runCli(["analyze", root, "--json"], environment);
|
||||
|
||||
expect(denied).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
operation: "analyze_javascript_application",
|
||||
issues: [
|
||||
{
|
||||
path: ["approved"],
|
||||
reason: "invalid_value",
|
||||
expected: [true],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(denied).not.toHaveProperty("details.candidate_ids");
|
||||
},
|
||||
INTEGRATION_TEST_TIMEOUT_MS,
|
||||
);
|
||||
});
|
||||
|
||||
describe("Electron CLI runtime reconciliation", () => {
|
||||
@@ -232,7 +192,6 @@ describe("Electron CLI runtime reconciliation", () => {
|
||||
operation: "reconcile_javascript_runtime",
|
||||
provider: { id: "rea-javascript-runtime-reconciliation" },
|
||||
normalized_result: {
|
||||
schema_version: 1,
|
||||
summary: { runtime_scripts: 1, matched: 1 },
|
||||
source_map_authority: { used_for_primary_matching: false },
|
||||
},
|
||||
|
||||
@@ -60,7 +60,7 @@ describe("JavaScript runtime observation CLI parity", () => {
|
||||
operation: "list_javascript_runtime_targets",
|
||||
provider: { id: "rea-v8-inspector" },
|
||||
normalized_result: {
|
||||
targets: { items: [{ target_id: inspector.targetId }] },
|
||||
targets: [{ target_id: inspector.targetId }],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -134,15 +134,15 @@ describe("process CLI errors", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("explains unsupported and unrelated capture evidence", async () => {
|
||||
it("rejects unrelated capture evidence", async () => {
|
||||
const root = await fixture();
|
||||
const legacy = join(root, "legacy.json");
|
||||
const invalidCapture = join(root, "invalid-capture.json");
|
||||
const unrelated = join(root, "unrelated.json");
|
||||
await writeFile(
|
||||
legacy,
|
||||
invalidCapture,
|
||||
JSON.stringify(
|
||||
createEvidence(undefined, PROCESS_PROVIDER, {
|
||||
predicateType: "rea.process-capture/v3",
|
||||
predicateType: "rea.process-capture/other",
|
||||
operation: "capture_process_scenario",
|
||||
parameters: {},
|
||||
result: {},
|
||||
@@ -161,14 +161,12 @@ describe("process CLI errors", () => {
|
||||
),
|
||||
);
|
||||
|
||||
const legacyResult = await compareProcessEvidenceFiles(legacy, legacy);
|
||||
expect(legacyResult).toMatchObject({
|
||||
expect(
|
||||
await compareProcessEvidenceFiles(invalidCapture, invalidCapture),
|
||||
).toMatchObject({
|
||||
error: "Process command failed",
|
||||
category: "invalid_input",
|
||||
});
|
||||
expect(JSON.stringify(legacyResult)).toContain(
|
||||
"Process Capture v3 is unsupported",
|
||||
);
|
||||
expect(await compareProcessEvidenceFiles(unrelated, unrelated)).toEqual({
|
||||
error: "Process command failed",
|
||||
category: "invalid_input",
|
||||
|
||||
@@ -3,7 +3,6 @@ import { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
@@ -24,8 +23,6 @@ import { V8_INSPECTOR_PROVIDER_IDENTITY } from "../../../src/browser/V8Inspector
|
||||
import { CLI_COMMAND_NAMES } from "../../../src/cliCommandNames.js";
|
||||
import { createCli } from "../../../src/cli.js";
|
||||
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
||||
import { analysisSnapshotSchema } from "../../../src/domain/analysisSnapshot.js";
|
||||
import { investigationWorkspaceSchema } from "../../../src/domain/investigationWorkspace.js";
|
||||
import {
|
||||
HOPPER_PROVIDER_IDENTITY,
|
||||
HOPPER_PROVIDER_TOOL_CONTRACTS,
|
||||
@@ -150,19 +147,6 @@ describe("canonical product catalog", () => {
|
||||
expect(catalog.runtime_catalog.digests.providers_sha256).toBe(
|
||||
providerCatalogDigest(catalog.providers),
|
||||
);
|
||||
expect(
|
||||
z.toJSONSchema(analysisSnapshotSchema).properties?.snapshot_version,
|
||||
).toMatchObject({
|
||||
const: catalog.schemas.find(({ id }) => id === "analysis_snapshot")
|
||||
?.version,
|
||||
});
|
||||
expect(
|
||||
z.toJSONSchema(investigationWorkspaceSchema).properties
|
||||
?.workspace_version,
|
||||
).toMatchObject({
|
||||
const: catalog.schemas.find(({ id }) => id === "investigation_workspace")
|
||||
?.version,
|
||||
});
|
||||
expect(
|
||||
JSON.parse(await readFile("docs/product-catalog.json", "utf8")),
|
||||
).toEqual(catalog);
|
||||
@@ -207,7 +191,7 @@ describe("canonical CLI catalog", () => {
|
||||
});
|
||||
|
||||
describe("canonical product catalog drift", () => {
|
||||
it("reports tool-family, setup-client, and schema fact drift", async () => {
|
||||
it("reports tool-family and setup-client fact drift", async () => {
|
||||
const catalog = await createProductCatalog(root);
|
||||
const firstFamily = catalog.tools.families[0];
|
||||
if (firstFamily === undefined) throw new TypeError("Missing tool family");
|
||||
@@ -229,20 +213,12 @@ describe("canonical product catalog drift", () => {
|
||||
configuration: "managed",
|
||||
},
|
||||
],
|
||||
schemas: catalog.schemas.map((schema) =>
|
||||
schema.id === "process_capture"
|
||||
? { ...schema, version: Number(schema.version) + 1 }
|
||||
: schema,
|
||||
),
|
||||
};
|
||||
const issues = await documentationFactIssues(root, drifted);
|
||||
expect(issues.some((issue) => issue.includes("tool family counts"))).toBe(
|
||||
true,
|
||||
);
|
||||
expect(issues.some((issue) => issue.includes("Future Client"))).toBe(true);
|
||||
expect(issues.some((issue) => issue.includes("Process Capture v5"))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("changes the provider projection digest when provider facts drift", async () => {
|
||||
|
||||
@@ -13,11 +13,9 @@ describe("reconstruction obligation ledger CLI parity", () => {
|
||||
evidence_bundle: createEvidenceBundle([]),
|
||||
reviewed_obligations: [],
|
||||
manifest: {
|
||||
schema_version: 1,
|
||||
bindings: [],
|
||||
contradictions: [],
|
||||
},
|
||||
limits: { max_obligations: 100 },
|
||||
page: { offset: 0, limit: 50 },
|
||||
};
|
||||
const { stdout } = await execute(
|
||||
|
||||
Reference in New Issue
Block a user