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
5 changes: 5 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ Each result line: `{ runId, status, verdict?, answer, url }` (plus `prompt`, and
on a dispatch failure). A summary table prints to stderr; the JSONL goes to `--out` (or
stdout when omitted).

`fan` exits 0 only when every run completed and, with `--qc`, every verifier answered
`VERDICT: PASS`. Only completed runs are sent to the verifier. A verifier run that fails
or times out is reported as `verification_error`, and a verifier that gives no verdict
leaves `verdict: "unknown"`; both make `fan` exit 1.

### `useagent status <runId>`

One-shot current status + answer for a run.
Expand Down
17 changes: 15 additions & 2 deletions packages/cli/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,22 @@ export async function fanCommand(client: FleetClient, args: FanArgs, io: Command
answer: settled.answer,
url: settled.url,
};
if (!args.qc) return base;
// Only finished work is judged: a reply to a run that failed or is still
// going would queue a verifier turn behind it and judge nothing finished.
if (!args.qc || settled.status !== "completed") return base;
// QC is a real reply run recorded in the SAME thread as the work it judges.
try {
const verified = await client.verify(outcome.run.runId, args.qc);
// A verifier run that failed or ran out of time judged nothing, whatever
// its partial answer says.
if (verified.status !== "completed") {
return {
...base,
status: "verification_error",
verdict: "unknown",
error: `verifier run ${verified.runId} did not complete (${verified.status})`,
};
}
return { ...base, verdict: verified.verdict };
} catch (error) {
return {
Expand All @@ -114,8 +126,9 @@ export async function fanCommand(client: FleetClient, args: FanArgs, io: Command
io.err("");
io.err(formatFanSummary(results));

// With --qc only a PASS verdict counts: "unknown" means no verifier said yes.
const allGood = results.every(
(r) => r.status === "completed" && r.error === undefined && r.verdict !== "fail",
(r) => r.status === "completed" && r.error === undefined && (r.verdict === undefined || r.verdict === "pass"),
);
return allGood ? 0 : 1;
}
72 changes: 72 additions & 0 deletions packages/cli/test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,76 @@ describe("fanCommand", () => {
error: "verifier unavailable",
});
});
test("with --qc a verifier run that fails or times out is a verification error, not a pass", async () => {
const io = captureIO(tasksFile);
const client = fakeClient({
verify: async (runId) => ({
verdict: runId === "run_0" ? "pass" : "unknown",
evidence: runId === "run_0" ? "VERDICT: PASS" : "",
runId: `${runId}:qc`,
status: runId === "run_0" ? "failed" : "timeout",
url: `https://fleet.test/session/${runId}:qc`,
}),
});
const code = await fanCommand(client, { file: "tasks.jsonl", parallel: 2, qc: "verify" }, io);
expect(code).toBe(1);
const rows = io.stdout.join("\n").trimEnd().split("\n").map((line) => JSON.parse(line));
expect(rows[0]).toMatchObject({
status: "verification_error",
answer: "done",
verdict: "unknown",
error: "verifier run run_0:qc did not complete (failed)",
});
expect(rows[1]).toMatchObject({
status: "verification_error",
verdict: "unknown",
error: "verifier run run_1:qc did not complete (timeout)",
});
});

test("with --qc a verifier that gives no verdict fails the batch", async () => {
const io = captureIO(tasksFile);
const client = fakeClient({
verify: async (runId) => ({
verdict: "unknown",
evidence: "Looks fine to me.",
runId: `${runId}:qc`,
status: "completed",
url: `https://fleet.test/session/${runId}:qc`,
}),
});
const code = await fanCommand(client, { file: "tasks.jsonl", parallel: 2, qc: "verify" }, io);
expect(code).toBe(1);
const rows = io.stdout.join("\n").trimEnd().split("\n").map((line) => JSON.parse(line));
expect(rows.map((row) => [row.status, row.verdict])).toEqual([
["completed", "unknown"],
["completed", "unknown"],
]);
expect(io.stderr.join("\n")).toContain("verdicts: 2 unknown");
});

test("with --qc only completed work is sent to the verifier", async () => {
const io = captureIO(tasksFile);
const verified: string[] = [];
const client = fakeClient({
awaitSettled: async (runId) => ({
runId,
status: runId === "run_0" ? "completed" : "timeout",
run: null,
answer: runId === "run_0" ? "done" : "",
url: `https://fleet.test/session/${runId}`,
}),
verify: async (runId) => {
verified.push(runId);
return { verdict: "pass", evidence: "VERDICT: PASS", runId: `${runId}:qc`, status: "completed", url: `https://fleet.test/session/${runId}:qc` };
},
});
const code = await fanCommand(client, { file: "tasks.jsonl", parallel: 2, qc: "verify" }, io);
expect(code).toBe(1);
expect(verified).toEqual(["run_0"]);
const rows = io.stdout.join("\n").trimEnd().split("\n").map((line) => JSON.parse(line));
expect(rows[0]).toMatchObject({ status: "completed", verdict: "pass" });
expect(rows[1]).toMatchObject({ status: "timeout" });
expect(rows[1].verdict).toBeUndefined();
});
});
Loading