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:
@@ -120,8 +120,17 @@ describe("process CLI errors", () => {
|
||||
const root = await fixture();
|
||||
const malformed = join(root, "malformed.json");
|
||||
const invalid = join(root, "invalid.json");
|
||||
const invalidUtf8 = join(root, "invalid-utf8.json");
|
||||
await writeFile(malformed, "not-json");
|
||||
await writeFile(invalid, "{}");
|
||||
await writeFile(
|
||||
invalidUtf8,
|
||||
Buffer.concat([
|
||||
Buffer.from('{"executable":"'),
|
||||
Buffer.from([0xff]),
|
||||
Buffer.from('"}'),
|
||||
]),
|
||||
);
|
||||
|
||||
expect(
|
||||
await captureProcessScenarioFile(join(root, "missing.json")),
|
||||
@@ -137,6 +146,12 @@ describe("process CLI errors", () => {
|
||||
message:
|
||||
"Process input file is not valid JSON. Repair the file, then try again.",
|
||||
});
|
||||
expect(await captureProcessScenarioFile(invalidUtf8)).toEqual({
|
||||
error: "Process command failed",
|
||||
category: "invalid_input",
|
||||
message:
|
||||
"Process input file is not valid JSON. Repair the file, then try again.",
|
||||
});
|
||||
expect(await captureProcessScenarioFile(invalid)).toEqual({
|
||||
error: "Process command failed",
|
||||
code: "invalid_request",
|
||||
@@ -153,6 +168,66 @@ describe("process CLI errors", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects NUL arguments before process launch", async () => {
|
||||
const root = await fixture();
|
||||
const scenario = join(root, "nul-argument.json");
|
||||
await writeFile(
|
||||
scenario,
|
||||
JSON.stringify({ executable: process.execPath, arguments: ["\0"] }),
|
||||
);
|
||||
|
||||
expect(await captureProcessScenarioFile(scenario)).toMatchObject({
|
||||
error: "Process command failed",
|
||||
code: "invalid_request",
|
||||
category: "invalid_input",
|
||||
details: {
|
||||
operation: "capture_process_scenario",
|
||||
issues: [
|
||||
{
|
||||
path: ["arguments", 0],
|
||||
reason: "invalid_format",
|
||||
expected: "regex",
|
||||
message:
|
||||
"Values passed to operating-system APIs cannot contain NUL",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("process CLI environment key diagnostics", () => {
|
||||
it("reports the reserved process environment key constraint", async () => {
|
||||
const root = await fixture();
|
||||
const scenario = join(root, "reserved-environment.json");
|
||||
await writeFile(
|
||||
scenario,
|
||||
JSON.stringify({
|
||||
executable: process.execPath,
|
||||
environment: { REA_PROCESS_RUN_ID: "caller-value" },
|
||||
}),
|
||||
);
|
||||
|
||||
expect(await captureProcessScenarioFile(scenario)).toMatchObject({
|
||||
error: "Process command failed",
|
||||
code: "invalid_request",
|
||||
category: "invalid_input",
|
||||
details: {
|
||||
operation: "capture_process_scenario",
|
||||
issues: [
|
||||
{
|
||||
path: ["environment", "REA_PROCESS_RUN_ID"],
|
||||
reason: "invalid_format",
|
||||
expected: "regex",
|
||||
message: "REA_PROCESS_RUN_ID is reserved by the process adapter",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("process CLI evidence validation", () => {
|
||||
it("captures the minimal executable-and-arguments scenario", async () => {
|
||||
const root = await fixture();
|
||||
const scenario = join(root, "scenario.json");
|
||||
|
||||
Reference in New Issue
Block a user