fix(contracts): align CLI/MCP boundary contracts (#946)
* fix(cli): validate native scenario and preserve JSON paths * fix(process): reject invalid UTF-8 JSON inputs * fix(cli): retain missing JSON path diagnostics * test(cli): cover relative brace and bracket JSON paths * test(cli): reject missing native scenario steps * fix(mcp): advertise reserved process environment key * fix(process): reject NUL in process scenario values * fix(process): advertise NUL input constraints to MCP * fix(cli): report scenario input schema issues * fix(contracts): align CLI and MCP input validation * fix(mcp): document semantic output constraints * fix(mcp): describe process journal compatibility * docs: regenerate catalog after schema grouping * docs: regenerate catalog after main merge * fix(cli): preserve JSON and native UI input diagnostics * test(mcp): reuse advertised tool schemas in managed flow
This commit is contained in:
@@ -2,8 +2,45 @@ import { describe, expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { projectInputIssues } from "./inputIssueProjection.js";
|
||||
import { processScenarioSchema } from "./processScenario.js";
|
||||
|
||||
describe("input issue projection", () => {
|
||||
it("preserves static regex guidance without echoing the rejected value", () => {
|
||||
const schema = z.object({
|
||||
value: z.string().regex(/^[^\0]*$/u, "Values cannot contain NUL"),
|
||||
});
|
||||
const input = { value: "private\0value" };
|
||||
const parsed = schema.safeParse(input);
|
||||
if (parsed.success) throw new Error("expected invalid input");
|
||||
|
||||
expect(projectInputIssues(parsed.error.issues, input)).toEqual([
|
||||
{
|
||||
path: ["value"],
|
||||
reason: "invalid_format",
|
||||
expected: "regex",
|
||||
message: "Values cannot contain NUL",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("projects reserved process environment key constraints at the key path", () => {
|
||||
const input = {
|
||||
executable: "/usr/bin/true",
|
||||
environment: { REA_PROCESS_RUN_ID: "caller-value" },
|
||||
};
|
||||
const parsed = processScenarioSchema.safeParse(input);
|
||||
if (parsed.success) throw new Error("expected invalid input");
|
||||
|
||||
expect(projectInputIssues(parsed.error.issues, input)).toEqual([
|
||||
{
|
||||
path: ["environment", "REA_PROCESS_RUN_ID"],
|
||||
reason: "invalid_format",
|
||||
expected: "regex",
|
||||
message: "REA_PROCESS_RUN_ID is reserved by the process adapter",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("preserves schema-authored custom correction guidance", () => {
|
||||
const schema = z
|
||||
.object({ left: z.string().optional(), right: z.string().optional() })
|
||||
|
||||
Reference in New Issue
Block a user