Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/schemas/triage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion tests/sandbox-scripts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "");
});
}
Expand Down
9 changes: 6 additions & 3 deletions tests/schemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
});
});

Expand Down
Loading