mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
* refactor(cli)!: name a failure's per-call control flag at the CLI boundary Services name the contract field a deadline failure reports in details.limit.parameter; a contract command's output projection adds details.limit.cli_flag from the command's own field-to-flag binding. BREAKING CHANGE: MCP failures no longer carry details.limit.cli_flag, and native deadline remediation text no longer names the CLI flag. CLI output still reports cli_flag for the command that ran. * fix(cli): key nested flattened members by their dotted path; restore the test's exit status * refactor(reverse): bind command_timeout_ms as the per-call control of an objdump or Rizin deadline (#11442) * refactor(reverse): bind command_timeout_ms as the per-call control of an objdump or Rizin deadline The deadline failure now comes from nativeDeadlineRecovery: it names command_timeout_ms and carries limit {control_kind: "parameter"}, so the CLI projection adds --command-timeout-ms and MCP output names the field only. The service no longer writes CLI flag text. * refactor(wasm): bind max_artifact_paths as the per-call control of an auxiliary path admission refusal (#11444)
142 lines
4.8 KiB
TypeScript
142 lines
4.8 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { AnalysisInputError } from "../../../src/domain/analysisErrorCore.js";
|
|
import { analysisErrorWithCleanupFailure } from "../../../src/domain/analysisErrorCleanup.js";
|
|
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
|
|
import { freezeJsonSnapshot } from "../../../src/domain/immutableJson.js";
|
|
import { ownedJsonObjectSchema } from "../../../src/domain/jsonValue.js";
|
|
import { ProviderCleanupError } from "../../../src/domain/providerCleanupError.js";
|
|
import { err, ok } from "../../../src/domain/result.js";
|
|
import {
|
|
projectCliAnalysisResult,
|
|
projectCliInputFields,
|
|
} from "../../../src/cli/projectCliAnalysisResult.js";
|
|
|
|
const binding = {
|
|
operation: "inspect_keyed_archive",
|
|
fields: { path: "archive" },
|
|
flags: {},
|
|
};
|
|
|
|
it("projects bound input fields without changing canonical facts or nested identities", () => {
|
|
const original = freezeJsonSnapshot(
|
|
projectAnalysisError(
|
|
new AnalysisInputError("inspect_keyed_archive", undefined, [
|
|
{
|
|
path: ["path", "path", 0],
|
|
reason: "invalid_format",
|
|
observed: { path: "verbatim source" },
|
|
},
|
|
{ path: ["root"], reason: "invalid_value", expected: ["main"] },
|
|
]),
|
|
),
|
|
);
|
|
const mapped = projectCliInputFields(original, binding);
|
|
expect(mapped).toEqual({
|
|
...original,
|
|
details: {
|
|
...original.details,
|
|
issues: [
|
|
{
|
|
path: ["archive", "path", 0],
|
|
reason: "invalid_format",
|
|
observed: { path: "verbatim source" },
|
|
},
|
|
{ path: ["root"], reason: "invalid_value", expected: ["main"] },
|
|
],
|
|
},
|
|
});
|
|
expect(original.details?.issues).toMatchObject([
|
|
{ path: ["path", "path", 0] },
|
|
{ path: ["root"] },
|
|
]);
|
|
const details = ownedJsonObjectSchema.parse(
|
|
ownedJsonObjectSchema.parse(mapped).details,
|
|
);
|
|
const mappedIssues = details.issues;
|
|
const originalIssues = original.details?.issues;
|
|
if (!Array.isArray(mappedIssues) || !Array.isArray(originalIssues))
|
|
throw new Error("Expected projected input issues");
|
|
expect(mappedIssues[1]).toBe(originalIssues[1]);
|
|
expect(ownedJsonObjectSchema.parse(mappedIssues[0]).observed).toBe(
|
|
ownedJsonObjectSchema.parse(originalIssues[0]).observed,
|
|
);
|
|
});
|
|
|
|
it("keeps cleanup history and retained output while binding the actionable primary issue", () => {
|
|
const primary = new AnalysisInputError(
|
|
"inspect_keyed_archive",
|
|
{
|
|
capturedOutput: {
|
|
stdout: "retained source output",
|
|
stderr: "",
|
|
truncated: false,
|
|
},
|
|
},
|
|
[{ path: ["path"], reason: "invalid_value" }],
|
|
);
|
|
const cleanup = new ProviderCleanupError(
|
|
"fixture",
|
|
["owned-input"],
|
|
{},
|
|
{
|
|
cleanup: { reason: "close denied", resources: ["owned-input"] },
|
|
},
|
|
);
|
|
const original = freezeJsonSnapshot(
|
|
projectAnalysisError(analysisErrorWithCleanupFailure(primary, cleanup)),
|
|
);
|
|
expect(original.code).toBe("cleanup_incomplete");
|
|
const mapped = projectCliInputFields(original, binding);
|
|
expect(mapped).toMatchObject({
|
|
code: "cleanup_incomplete",
|
|
details: {
|
|
execution_failure: "invalid_request",
|
|
issues: [{ path: ["archive"], reason: "invalid_value" }],
|
|
diagnostics: {
|
|
primary_error: { details: { issues: [{ path: ["path"] }] } },
|
|
},
|
|
captured_output: { stdout: "retained source output" },
|
|
},
|
|
});
|
|
expect(mapped).toEqual({
|
|
...original,
|
|
details: {
|
|
...original.details,
|
|
issues: [{ path: ["archive"], reason: "invalid_value" }],
|
|
},
|
|
});
|
|
const details = ownedJsonObjectSchema.parse(
|
|
ownedJsonObjectSchema.parse(mapped).details,
|
|
);
|
|
expect(details.diagnostics).toBe(original.details?.diagnostics);
|
|
expect(details.captured_output).toBe(original.details?.captured_output);
|
|
});
|
|
|
|
it("passes through successful data, unbound operations and unknown error values", () => {
|
|
const value = { path: "caller-selected data" };
|
|
expect(projectCliInputFields(value, binding)).toBe(value);
|
|
const targetError = projectAnalysisError(
|
|
new AnalysisInputError("open_binary", undefined, [
|
|
{ path: ["path"], reason: "invalid_format" },
|
|
]),
|
|
);
|
|
expect(projectCliInputFields(targetError, binding)).toBe(targetError);
|
|
const unbound = projectAnalysisError(
|
|
new AnalysisInputError("inspect_keyed_archive", undefined, [
|
|
{ path: ["root"], reason: "invalid_value" },
|
|
]),
|
|
);
|
|
expect(projectCliInputFields(unbound, binding)).toBe(unbound);
|
|
expect(projectCliAnalysisResult(err(targetError))).toBe(targetError);
|
|
expect(projectCliAnalysisResult(ok(value))).toBe(value);
|
|
const unknown = {
|
|
code: "future_failure",
|
|
details: {
|
|
operation: "inspect_keyed_archive",
|
|
issues: [{ path: ["path"] }],
|
|
},
|
|
};
|
|
expect(projectCliInputFields(unknown, binding)).toBe(unknown);
|
|
});
|