diff --git a/app/schemas/triage.ts b/app/schemas/triage.ts index 706be6f..8c9c65b 100644 --- a/app/schemas/triage.ts +++ b/app/schemas/triage.ts @@ -9,7 +9,7 @@ export const TriageDecision = z questions: z.array(z.string().min(1).max(1000)).max(5).describe('Questions for the maintainer. Non-empty exactly when decision is "ask".'), rationale: z.string().min(1).max(4000).describe("Why you decided this. Shown to the maintainer when you decline."), findings: z.string().max(8000).describe("What you learned from the repository, kept for the spec writer and later rounds."), - relevantPaths: z.array(z.string().min(1)).max(50).describe("Repository-relative paths that matter for the change."), + relevantPaths: z.array(z.string().min(1)).max(50).default([]).describe("Repository-relative paths that matter for the change, when any."), }) .superRefine((value, ctx) => { if (value.decision === "ask" && value.questions.length === 0) { diff --git a/tests/sandbox-scripts.test.ts b/tests/sandbox-scripts.test.ts index a92db0a..f8d33b0 100644 --- a/tests/sandbox-scripts.test.ts +++ b/tests/sandbox-scripts.test.ts @@ -50,10 +50,15 @@ let scratch: string; let commit: string; function run(cmd: string, args: string[], opts: { cwd?: string; env?: NodeJS.ProcessEnv; input?: string } = {}) { - return new Promise<{ code: number; stdout: string; stderr: string }>((resolve) => { + return new Promise<{ code: number; stdout: string; stderr: string }>((resolve, reject) => { const child = execFile(cmd, args, { cwd: opts.cwd, env: { ...env, ...opts.env } }, (err, stdout, stderr) => { resolve({ code: err ? (typeof err.code === "number" ? err.code : 1) : 0, stdout, stderr }); }); + child.stdin?.on("error", (error: NodeJS.ErrnoException) => { + // Some failure cases exit before reading stdin. The process callback + // carries the result; a closed pipe is not a separate test failure. + if (error.code !== "EPIPE") reject(error); + }); child.stdin?.end(opts.input ?? ""); }); } diff --git a/tests/schemas.test.ts b/tests/schemas.test.ts index d1e542d..22f53f8 100644 --- a/tests/schemas.test.ts +++ b/tests/schemas.test.ts @@ -43,9 +43,12 @@ describe("TriageDecision", () => { it("rejects a misspelled field by name, so the agent can fix it", () => { const { relevantPaths, ...rest } = base; const misspelled = { ...rest, decision: "draft", questions: [], relevant_paths: relevantPaths }; - expect(issues(TriageDecision.safeParse(misspelled))).toEqual( - expect.arrayContaining(["relevantPaths: Invalid input: expected array, received undefined", ': Unrecognized key: "relevant_paths"']), - ); + expect(issues(TriageDecision.safeParse(misspelled))).toEqual([': Unrecognized key: "relevant_paths"']); + }); + + it("defaults advisory relevant paths when the model omits them", () => { + const { relevantPaths: _relevantPaths, ...withoutPaths } = base; + expect(TriageDecision.parse({ ...withoutPaths, decision: "draft", questions: [] }).relevantPaths).toEqual([]); }); });