Skip to content

The open-source app everyone uses to manage agents at work

fix: grade Codex clarification and refusal outcomes from evidence (#14570)

Dotta3f4f8b37ba69
diff --git a/doc/evals.md b/doc/evals.md
index 061918c608..6ccc95af96 100644
--- a/doc/evals.md
+++ b/doc/evals.md
@@ -192,6 +192,78 @@ For a repeatable workflow, use the matching skill: [paperclip-evals](../.agents/
[add-runner-eval](../.agents/skills/add-runner-eval/SKILL.md), or
[add-product-e2e-eval](../.agents/skills/add-product-e2e-eval/SKILL.md).
+## Diagnose failures before buying another campaign
+
+Use this loop to turn eval failures into product improvements. The unit of work
+is a broken user outcome or invariant, not an individual red cell.
+
+1. **Freeze the evidence.** Record the inspected application revision and each
+ campaign's evaluated revision, definition/grader fingerprint, model/profile,
+ environment, exact selected IDs, attempts, and usage coverage. Read the
+ history feed and retained attempt records before launching models. A report
+ refresh, skipped workflow, passing unit suite, or old-definition green cell
+ is not a new live measurement. Inventory explicit-only suites separately
+ from `--all`.
+2. **Reconstruct the failed boundary.** Read durable task state, interactions,
+ event chronology, source/worker identity, delivered output, and the failing
+ assertion. State whether the test reached the boundary it claims to test.
+ Separate observed failure, machine class, analytical cause, and confidence.
+ A cancelled queued wake does not by itself prove lost work; a failed decline
+ assertion does not prove unauthorized execution. A saved artifact does not
+ prove the user received a correct completion update.
+3. **Group by cause and product contract.** Join cells only when their evidence
+ supports the same mechanism. Check for already-merged fixes and definition
+ corrections before proposing new work. Keep product defects, provider/model
+ behavior, grading defects, infrastructure, and unexercised boundaries
+ distinct. Preserve the original grades when attribution changes.
+4. **Design the smallest general correction.** Name the desired user behavior,
+ the authoritative state/transaction or provider boundary that owns it, the
+ affected callers, and the existing guarantees that must survive. Check it
+ against `PRODUCT.md` and `SPEC-implementation.md`. A change to an intentional
+ product rule is a contract change, not an excuse to delete its guard. Avoid
+ case-name branches, phrase-specific prompts, unconditional retries, or
+ weakening approval, ownership, cancellation, and budget gates to get green.
+5. **Prove the mechanism cheaply.** Calibrate a grader against correct and
+ plausible wrong retained evidence. Reproduce a product race with scripted
+ providers or service tests. Pair every proposed fix with a regression that
+ exercises the opposite boundary (for example, eligible delivery versus
+ revoked access, benign obsolete wake versus interrupted active work).
+ Presentation-only changes use the existing report refresh path and make no
+ provider calls; do not claim replay can prove changed runtime behavior.
+6. **Select a bounded live confirmation.** Write the exact failed representative
+ IDs and only the passing controls affected by the change. Pin the source,
+ definitions, models, and remote image. Record an attempt cap, provider and
+ compute budget, wall-clock deadline, and concurrency before dispatch under
+ the existing live-run authorization. Missing pricing means unknown, not free.
+ Do not rerun unaffected green cells during diagnosis or retry usable behavior
+ failures until they happen to pass. Preserve every attempt. Expand to a
+ compatible qualification campaign only after the causal fix passes.
+7. **Close with evidence and remaining scope.** Report original versus new
+ measurements, exact selected coverage, regression results, cost coverage,
+ and unresolved boundaries. A partial verification may close one defect; it
+ cannot turn the full catalog green or establish reliability from one attempt.
+
+Keep one triage record per cause with: affected cell IDs; evidence links;
+observed failure; supported cause and confidence; existing fix/revision; proposed
+product contract; invariant regressions; next exact live selection; budget and
+stop condition; owner; and disposition. Useful dispositions include confirmed
+product defect, model behavior, grader correction, infrastructure repair,
+fixed-but-not-remeasured, historical pass, and unqualified coverage.
+
+Parallelize independent artifact inventory, deterministic checks, and isolated
+cells. Keep a cell's dependent turns ordered. When delegating, use inexpensive
+agents for bounded extraction, catalog reconciliation, and test execution; keep
+causal attribution, product design, and final review with the lead. Begin local
+browser campaigns at the documented conservative concurrency and increase only
+with measured host headroom. Hosted fanout must respect the workflow's provider
+and fleet caps; more simultaneous timeouts do not improve wall-clock efficiency.
+
+Current tools support exact-ID selection and retained-evidence report refresh,
+but not an automatic cause-aware "rerun unresolved failures" planner. Build an
+explicit selection manifest rather than treating `--all` as that planner. Review
+the launcher's automatic retry policy when budgeting; Product E2E may create one
+fresh attempt for a retryable failure.
+
## Install the authoring skills
The reviewable sources live in this repository's `.agents/skills`. For a
diff --git a/tests/runner-e2e/README.md b/tests/runner-e2e/README.md
index 7b99f319b2..ea7acc797a 100644
--- a/tests/runner-e2e/README.md
+++ b/tests/runner-e2e/README.md
@@ -857,6 +857,26 @@ an unexecuted task after rejection is allowed. A completed onboarding parent
without the approved child is graded as a behavior failure, not retried as an
infrastructure timeout.
+The refusal checkpoint records the persisted user decision before waiting for
+the run to settle. A refusal that closes the task may end its responding run as
+cancelled; this is allowed only with the exact saved user decision, the matching
+issue/agent/comment wake, control-plane cancellation after the decision, a
+Cancelled task, and a persisted response attributed to that run. The waiter
+allows the response to arrive after cancellation. Missing responses, operator
+cleanup cancellations, provider errors, unauthorized outputs, and active runs
+still fail.
+The response check proves persistence and attribution. It does not grade the
+reply's wording; the saved task, output, and run state prove non-execution.
+
+An obsolete queued wake with `issue_terminal_status` is not a provider failure
+when `startedAt` is explicitly null and its issue is durably Done or Cancelled.
+All other run and outcome checks still apply. Run rows and billing are retained.
+Chat clarification accepts concrete information lists introduced by "I need:"
+without requiring a question mark, while work checklists, empty requests, and
+lost task ownership remain failures. These grading rules are versioned in each
+affected suite's definition metadata; they do not retroactively qualify aborted
+historical attempts.
+
`question-choice-options` fails any recorded single-select or multi-select
question with fewer than two distinct, nonempty options, including one-option
"I'll describe it" forms. It checks every captured card presentation, including
diff --git a/tests/runner-e2e/catalog.ts b/tests/runner-e2e/catalog.ts
index 6837d2399b..51ff22848f 100644
--- a/tests/runner-e2e/catalog.ts
+++ b/tests/runner-e2e/catalog.ts
@@ -1102,7 +1102,7 @@ export const runnerSuites: readonly RunnerSuiteFixture[] = [
...connectionReviewSuite.tasks],
expectedMatrixSize: 46,
excludedExecutionIds: ["neutral", "challenge"].map(variant => `lifecycle-baseline.runner-codex.local.lifecycle-repair-${variant}`),
- definitionMetadata: { version: 1, narrativeDigest: lifecycleLiveDefinitionDigest, grading: "durable-state-and-attributed-narrative", scheduling: "explicit-only" },
+ definitionMetadata: { version: 4, clarificationGrading: "wrapped-information-fields-list", narrativeDigest: lifecycleLiveDefinitionDigest, grading: "durable-state-and-attributed-narrative", scheduling: "explicit-only" },
},
{
id: "continuation", label: "Task continuation",
@@ -1151,7 +1151,7 @@ export const runnerSuites: readonly RunnerSuiteFixture[] = [
groups: ["onboarding"],
profiles: runnerProfiles.filter(profile => ["legacy-codex", "legacy-claude", "runner-codex", "runner-acpx-claude"].includes(profile.id)),
environments: [localEnvironment], tasks: firstTaskTasks, expectedMatrixSize: 52,
- definitionMetadata: { version: 3, credentialPersistenceCheck: false, questionChoiceMinimum: 2, nativeSetup: "post-onboarding-runtime-switch", productionInstructions: true, qualityGrading: "informational" },
+ definitionMetadata: { version: 4, runGrading: "evidenced-nonexecution-and-refusal", credentialPersistenceCheck: false, questionChoiceMinimum: 2, nativeSetup: "post-onboarding-runtime-switch", productionInstructions: true, qualityGrading: "informational" },
},
{
id: "agent-chat", label: "Persistent Agent Chat",
@@ -1160,7 +1160,7 @@ export const runnerSuites: readonly RunnerSuiteFixture[] = [
profiles: runnerProfiles.filter(profile => ["legacy-codex", "legacy-claude", "runner-codex", "runner-acpx-claude"].includes(profile.id)).map(defaultPermissionProfile),
environments: [localEnvironment], tasks: chatTasks, expectedMatrixSize: 28,
excludedExecutionIds: ["legacy-codex", "legacy-claude"].flatMap(profile => ["reassign-task", "create-backlog"].map(task => `agent-chat.${profile}.local.${task}`)),
- definitionMetadata: { version: 6, resetRunsCountedSeparately: true, permissions: "production-defaults", stopBoundary: "provider-turn-started", restartMemory: "required-after-restart" },
+ definitionMetadata: { version: 9, clarificationGrading: "wrapped-information-fields-list", resetRunsCountedSeparately: true, permissions: "production-defaults", stopBoundary: "provider-turn-started", restartMemory: "required-after-restart" },
},
{
id: "agent-chat-hardening", label: "Agent Chat Recovery and Coordination", manualOnly: true,
@@ -1200,7 +1200,7 @@ export const runnerSuites: readonly RunnerSuiteFixture[] = [
environments: [localEnvironment],
tasks: [...firstTaskTasks.filter(task => task.id === "interview-plan-accept"), ...chatCompletionTasks],
expectedMatrixSize: 4,
- definitionMetadata: { version: 6, instructions: "production", idleBoundaryTimeoutMs: 180_000, workerBriefTimeoutMs: 240_000, workerBriefWorkspace: "managed-project", workerBriefEvidence: "released-start-time", grading: "post-completion-reply-and-result-access", semanticReview: "required-separately", chatBoundary: "worker-gated-until-source-idle", observationWindowMs: 120_000, scheduling: "explicit-only" },
+ definitionMetadata: { version: 7, runGrading: "evidenced-nonexecution-and-refusal", instructions: "production", idleBoundaryTimeoutMs: 180_000, workerBriefTimeoutMs: 240_000, workerBriefWorkspace: "managed-project", workerBriefEvidence: "released-start-time", grading: "post-completion-reply-and-result-access", semanticReview: "required-separately", chatBoundary: "worker-gated-until-source-idle", observationWindowMs: 120_000, scheduling: "explicit-only" },
},
...(process.env.PAPERCLIP_RUNNER_E2E_CONNECTION_REVIEWS === "1" ? [connectionReviewSuite] : []),
{
diff --git a/tests/runner-e2e/chat-flow.test.ts b/tests/runner-e2e/chat-flow.test.ts
index f69ff74cd3..dad2033bcb 100644
--- a/tests/runner-e2e/chat-flow.test.ts
+++ b/tests/runner-e2e/chat-flow.test.ts
@@ -81,6 +81,43 @@ describe("chat acceptance contracts", () => {
).toBe(false);
});
+ it("recognizes the retained clarification list without treating empty requests or execution plans as clarification", () => {
+ // Reduced public reply from gha-36307603818-1 / agent-chat.legacy-codex.local.clarify-reuse.
+ expect(isChatClarificationReply(`Absolutely. Before I assign the writing, I need:
+
+- Club name and what the club is about
+- Who the note welcomes (new members, event guests, website visitors, etc.)
+- Where the note will appear and your preferred length
+- Tone (warm, formal, playful, energetic, or another style)
+- Any must-include details: benefits, meeting information, values, next step, or signatory
+
+If you only have the club name, audience, and tone, that is enough to begin; I can make sensible assumptions about the rest.`)).toBe(true);
+ expect(isChatClarificationReply("We need:\n1. Intended readers\n2. Delivery date")).toBe(true);
+ for (const body of ["I need:", "I need:\n- .\n- ...", "I needed:\n- Audience\n- Tone",
+ "I need:\n- to create the task\n- to write the note", "I need to create the task and write the note.",
+ "I need:\n- Create the task\n- Write the note", "We need:\n1. **Build** the page\n2. **Publish** the site",
+ "I need:\n- Plan the note\n- Draft it", "I need:\n- [ ] Create task\n- [ ] Write note"]) {
+ expect(isChatClarificationReply(body), body).toBe(false);
+ }
+ });
+
+ it("checks the requested information list separately from a later plan", () => {
+ expect(isChatClarificationReply("I need:\n- Audience\n- Tone\n\nOnce you answer, the plan is:\n- Create the task\n- Write the note")).toBe(true);
+ });
+
+ it("requires information fields or questions rather than arbitrary non-blacklisted bullets", () => {
+ expect(isChatClarificationReply("I need:\n- Set up the project\n- Install dependencies")).toBe(false);
+ expect(isChatClarificationReply("I need:\n- Gather the audience details\n- Decide the tone")).toBe(false);
+ expect(isChatClarificationReply("I need:\n- Audience\n- Install dependencies")).toBe(false);
+ expect(isChatClarificationReply("I need:\n- **Audience**: intended readers\n\n- [ ] Preferred format\n- When this is due")).toBe(true);
+ });
+
+ it("accepts logistical brief fields and wrapped information items", () => {
+ expect(isChatClarificationReply("I need:\n- Budget\n- Location")).toBe(true);
+ expect(isChatClarificationReply("I need:\n- Audience, including age range\nand whether these are new or existing members\n- Tone\n\nOnce you answer, I can:\n- Draft the note\n- Publish it")).toBe(true);
+ expect(isChatClarificationReply("I need:\n- Audience, including age range\n and whether these are new or existing members\n- Tone")).toBe(true);
+ });
+
it("rejects superseded plan requirements in executed output, independently of plan history", () => {
expect(() => assertChatExecutionOutput("Welcome CHAT123.", "CHAT123", "DRAFT123")).not.toThrow();
expect(() => assertChatExecutionOutput("Welcome DRAFT123 and CHAT123.", "CHAT123", "DRAFT123")).toThrow();
@@ -149,6 +186,10 @@ describe("chat acceptance contracts", () => {
assertChatTaskHandoff({ ...task, projectId: null }, [run], source),
).toThrow();
});
+ it("still rejects completed chat work that has lost its assignee", () => {
+ expect(() => assertChatTaskHandoff({ ...task, status: "done" }, [run], source)).not.toThrow();
+ expect(() => assertChatTaskHandoff({ ...task, status: "done", assigneeAgentId: null }, [run], source)).toThrow();
+ });
it.each(["project-description", "welcome-note", "output"])("finds committed %s output without accepting a copied plan or a claim", async (key) => {
const output = {
...plan,
diff --git a/tests/runner-e2e/chat-flow.ts b/tests/runner-e2e/chat-flow.ts
index f8ae68be14..1384867473 100644
--- a/tests/runner-e2e/chat-flow.ts
+++ b/tests/runner-e2e/chat-flow.ts
@@ -77,6 +77,37 @@ export function assertChatBacklogCreation(input: {
/** Clarification may request information imperatively rather than end in a question mark. */
export function isChatClarificationReply(body: string): boolean {
if (body.includes("?")) return true;
+ // A present-tense request can introduce the required information directly,
+ // without a noun such as "brief" or "details" before the list.
+ const listRequest = body.match(/\b(?:I|we)(?:'ll|\s+will)?\s+need\s*:\s*([\s\S]*)/i);
+ if (listRequest) {
+ const items: string[] = [];
+ let paragraphBoundary = false;
+ // Only the directly introduced list belongs to this request. A later
+ // paragraph can introduce a separate plan without invalidating it.
+ for (const line of listRequest[1].split(/\r?\n/)) {
+ if (!line.trim()) {
+ paragraphBoundary = true;
+ continue;
+ }
+ const item = line.match(/^\s*(?:[-*]|\d+[.)])\s+(.+)$/);
+ if (!item) {
+ // Markdown permits soft-wrapped item text without indentation. A
+ // separate paragraph or heading ends the introduced information list.
+ if (items.length && !paragraphBoundary && !/^\s*#|:\s*$/.test(line)) {
+ items[items.length - 1] += ` ${line.trim()}`;
+ continue;
+ }
+ break;
+ }
+ items.push(item[1].replace(/^\[[ xX]\]\s*/, "").replace(/^[*_`]+/, ""));
+ paragraphBoundary = false;
+ }
+ // Positively identify questions or brief fields. Unknown bullets are not
+ // evidence of clarification merely because their verbs are unlisted.
+ const information = /^(?:(?:who|what|where|when|whether|how)\b|(?:(?:any|the|your|preferred|intended|required|target|desired|existing|delivery|must-include)\s+){0,3}(?:(?:club|company|project|team|event|organization)\s+name|audience|readers|recipients|tone|voice|format|length|deadline|date|purpose|context|details|requirements|constraints|examples|links|name|budget|location|venue|schedule|timezone|language|accessibility|contact|scope|goals|background|references|assets|brand|style)\b)/i;
+ if (items.length >= 2 && items.every(item => information.test(item))) return true;
+ }
const request = body.match(
/\b(?:please\s+(?:share|provide|clarify|confirm)|tell me|let me know)\b([\s\S]*)/i,
) ?? body.match(
diff --git a/tests/runner-e2e/first-task-flow.ts b/tests/runner-e2e/first-task-flow.ts
index 0b307583d1..7ad5fce470 100644
--- a/tests/runner-e2e/first-task-flow.ts
+++ b/tests/runner-e2e/first-task-flow.ts
@@ -1,4 +1,5 @@
-import { isBlockedUnstartedWake } from "./non-execution-wake.js";
+import { isBlockedUnstartedWake, isTerminalUnstartedWake } from "./non-execution-wake.js";
+import { firstTaskRejectionReplyRecorded, isFirstTaskRejectionCancellation } from "./first-task-rejection.js";
import { answerableRuntimeRunIds } from "./runtime-question-readiness.js";
import { captureFirstTaskAttachments } from "./first-task-attachments.js";
import { waitForFirstTaskReply } from "./first-task-replies.js";
@@ -260,7 +261,7 @@ export async function runFirstTaskFlow(input: {
return checkpoint;
};
let pausedRuntimeRunIds = new Set<string>();
- const settle = async (priorRunIds: Set<string>, completion = false) => {
+ const settle = async (priorRunIds: Set<string>, completion = false, rejection = false) => {
const previousPaused = pausedRuntimeRunIds;
let stable = 0;
await pollUntil({
@@ -271,16 +272,18 @@ export async function runFirstTaskFlow(input: {
runs: await allRuns(),
tasks: await api.get<Row[]>(tasksPath),
interactions: await api.get<Row[]>(`/api/issues/${issue.id}/interactions`),
+ comments: rejection ? await api.get<Row[]>(`/api/issues/${issue.id}/comments?order=asc`) : [],
}),
- reject: ({ runs }) => {
+ reject: ({ runs, tasks }) => {
const bad = runs.find((r) =>
- ["failed", "timed_out", "cancelled"].includes(r.status) && !isBlockedUnstartedWake(r),
+ ["failed", "timed_out", "cancelled"].includes(r.status) && !isBlockedUnstartedWake(r) &&
+ !isTerminalUnstartedWake(r, tasks) && !(rejection && isFirstTaskRejectionCancellation(r, e, tasks)),
);
if (bad)
return `run status ${bad.status}: ${bad.errorCode ?? ""} ${bad.error ?? ""}`;
if (runs.length > 12) return "first-task run count exceeded 12";
},
- accept: ({ runs, tasks, interactions }) => {
+ accept: ({ runs, tasks, interactions, comments }) => {
const paused = answerableRuntimeRunIds(interactions);
const active = activeRuns(runs);
const waitingForAnswer = !completion && active.length > 0 && active.every((r) => paused.has(r.id));
@@ -294,7 +297,8 @@ export async function runFirstTaskFlow(input: {
e.initialTaskIds,
e.onboardingIssueId,
);
- stable = settled && done ? stable + 1 : 0;
+ const replied = !rejection || firstTaskRejectionReplyRecorded(e, comments, runs);
+ stable = settled && done && replied ? stable + 1 : 0;
return stable >= 3;
},
});
@@ -318,9 +322,10 @@ export async function runFirstTaskFlow(input: {
message,
deadlineAt: Math.min(deadlineAt, Date.now() + 30_000),
});
- if (phase === "accepted") await snapshot("accepted", at);
- await settle(before, complete);
- return snapshot(phase === "accepted" ? "finished" : phase);
+ const decision = phase === "accepted" || phase === "rejected";
+ if (decision) await snapshot(phase, at);
+ await settle(before, complete, phase === "rejected");
+ return snapshot(decision ? "finished" : phase);
};
let failure: unknown;
try {
diff --git a/tests/runner-e2e/first-task-rejection.ts b/tests/runner-e2e/first-task-rejection.ts
new file mode 100644
index 0000000000..2fb300af77
--- /dev/null
+++ b/tests/runner-e2e/first-task-rejection.ts
@@ -0,0 +1,45 @@
+import { firstTaskScenario } from "./first-task-cases.js";
+import type { FirstTaskEvidence, Row } from "./first-task-scoring.js";
+
+/** A checkpoint label alone is not evidence that the user declined the work. */
+export function firstTaskRejection(e: FirstTaskEvidence): Row | undefined {
+ if (e.caseId !== "reject-no-execution") return undefined;
+ const index = e.checkpoints.findIndex(c => c.phase === "rejected");
+ const checkpoint = e.checkpoints[index];
+ const before = e.checkpoints[index - 1];
+ if (!checkpoint || !before) return undefined;
+ const message = firstTaskScenario(e.caseId, e.nonce).rejection;
+ return checkpoint.comments.find(c =>
+ c.issueId === e.onboardingIssueId && c.authorUserId && !c.authorAgentId &&
+ !c.deletedAt && c.body === message && !before.comments.some(old => old.id === c.id) &&
+ Date.parse(c.createdAt) >= Date.parse(before.at),
+ );
+}
+
+function isRejectionRun(run: Row, e: FirstTaskEvidence, rejection: Row) {
+ return run.agentId === e.agentId &&
+ run.contextSnapshot?.issueId === e.onboardingIssueId &&
+ (run.contextSnapshot?.commentId === rejection.id || run.contextSnapshot?.wakeCommentId === rejection.id) &&
+ Date.parse(run.startedAt) >= Date.parse(rejection.createdAt);
+}
+
+/** Closing the declined task can cancel its responding run. Defer judgement
+ * until its reply is persisted; arbitrary operator cancellations stay failures. */
+export function isFirstTaskRejectionCancellation(run: Row, e: FirstTaskEvidence, tasks: Row[]): boolean {
+ const rejection = firstTaskRejection(e);
+ return Boolean(rejection && isRejectionRun(run, e, rejection) &&
+ run.status === "cancelled" && run.errorCode === "cancelled" &&
+ run.error === "Cancelled by control plane" &&
+ Date.parse(run.finishedAt) >= Date.parse(run.startedAt) &&
+ tasks.some(t => t.id === e.onboardingIssueId && t.status === "cancelled"));
+}
+
+/** Require a saved response from the refusal turn, not an earlier proposal. */
+export function firstTaskRejectionReplyRecorded(e: FirstTaskEvidence, comments: Row[], runs: Row[]): boolean {
+ const rejection = firstTaskRejection(e);
+ if (!rejection) return false;
+ const replyRuns = new Set(runs.filter(run => isRejectionRun(run, e, rejection)).map(run => run.id));
+ return comments.some(c => c.issueId === e.onboardingIssueId && c.authorAgentId === e.agentId &&
+ !c.deletedAt && typeof c.body === "string" && c.body.trim().length > 0 &&
+ replyRuns.has(c.createdByRunId) && Date.parse(c.createdAt) >= Date.parse(rejection.createdAt));
+}
diff --git a/tests/runner-e2e/first-task-scoring.ts b/tests/runner-e2e/first-task-scoring.ts
index d03dfe70f5..fa7b49e080 100644
--- a/tests/runner-e2e/first-task-scoring.ts
+++ b/tests/runner-e2e/first-task-scoring.ts
@@ -1,4 +1,5 @@
-import { isBlockedUnstartedWake } from "./non-execution-wake.js";
+import { isBlockedUnstartedWake, isTerminalUnstartedWake } from "./non-execution-wake.js";
+import { firstTaskRejection, firstTaskRejectionReplyRecorded, isFirstTaskRejectionCancellation } from "./first-task-rejection.js";
import { answerableRuntimeRunIds } from "./runtime-question-readiness.js";
import { sanitizeJson } from "./redaction.js";
import { createHash } from "node:crypto";
@@ -220,7 +221,7 @@ export function gradeFirstTask(e: FirstTaskEvidence): FirstTaskCheck[] {
const last = e.checkpoints.at(-1);
const approval = e.checkpoints.find((c) => c.phase === "accepted");
const rejection =
- e.caseId === "reject-no-execution"
+ firstTaskRejection(e)
? e.checkpoints.find((c) => c.phase === "rejected")
: undefined;
const extras = (c: FirstTaskCheckpoint) =>
@@ -444,11 +445,12 @@ export function gradeFirstTask(e: FirstTaskEvidence): FirstTaskCheck[] {
if (e.caseId === "reject-no-execution")
add(
"rejection-respected",
- extras(last).length === 0 &&
+ firstTaskRejectionReplyRecorded(e, last.comments, last.runs) &&
+ extras(last).length === 0 &&
last.documents.every(isPlanningDocument) &&
(last.attachments ?? []).every(isPlanningAttachment) &&
activeRuns(last.runs).length === 0,
- "Rejected work never executes",
+ "Persisted refusal receives a response without execution tasks, finished output, or remaining runs",
[last.id],
rejection
? undefined
@@ -457,8 +459,10 @@ export function gradeFirstTask(e: FirstTaskEvidence): FirstTaskCheck[] {
add(
"provider-runs-succeeded",
last.runs.length > 0 && last.runs.every((r) => r.status === "succeeded" || isBlockedUnstartedWake(r) ||
+ isTerminalUnstartedWake(r, last.tasks) ||
+ (isFirstTaskRejectionCancellation(r, e, last.tasks) && firstTaskRejectionReplyRecorded(e, last.comments, [r])) ||
(scenario.firstResponseOnly && r.status === "running" && answerableRuntimeRunIds(last.interactions).has(r.id))),
- "Provider runs succeeded, or a first-response run is paused on its recorded answerable native question",
+ "Runs succeeded, were suppressed before execution, stopped with a recorded refusal response, or paused on an answerable first-response native question",
[last.id],
);
if (e.runtimeSettings?.adapterType === "paperclip_runner" &&
diff --git a/tests/runner-e2e/first-task.test.ts b/tests/runner-e2e/first-task.test.ts
index 4c41455676..d469f3a281 100644
--- a/tests/runner-e2e/first-task.test.ts
+++ b/tests/runner-e2e/first-task.test.ts
@@ -2,6 +2,7 @@ import { captureFirstTaskAttachments } from "./first-task-attachments.js";
import type { RunnerApi } from "./api.js";
import { renderRunnerE2EDashboard } from "./dashboard.js";
import { waitForFirstTaskReply } from "./first-task-replies.js";
+import { firstTaskRejectionReplyRecorded, isFirstTaskRejectionCancellation } from "./first-task-rejection.js";
import { createIssueThreadInteractionSchema } from "../../packages/shared/src/validators/issue.js";
import { renderInteractionCard } from "./interaction-report.js";
import { main as judgeCommand } from "./first-task-judge.js";
@@ -143,6 +144,33 @@ function recording(caseId = "task-reply-accept"): FirstTaskEvidence {
checks: [],
};
}
+/** Reduced lifecycle evidence from gha-36307603818-1 / reject-no-execution.
+ * The decision checkpoint models the repaired capture order, not a historical regrade. */
+function rejectionRecording(): FirstTaskEvidence {
+ const e = recording("reject-no-execution");
+ const rejected = e.checkpoints[2];
+ rejected.phase = "rejected";
+ rejected.comments[rejected.comments.length - 1] = {
+ id: "no", issueId: "onboarding", authorUserId: "board",
+ body: firstTaskScenario(e.caseId, e.nonce).rejection,
+ createdAt: "2026-09-15T00:02:00.100Z",
+ };
+ const last = e.checkpoints[3];
+ last.tasks = [{ ...last.tasks[0], status: "cancelled" }];
+ last.documents = [];
+ last.runs = [...rejected.runs, {
+ id: "refusal-run", agentId: "agent", status: "cancelled", errorCode: "cancelled",
+ error: "Cancelled by control plane", startedAt: "2026-09-15T00:02:01Z", finishedAt: "2026-09-15T00:02:15Z",
+ contextSnapshot: { issueId: "onboarding", commentId: "no", wakeCommentId: "no" },
+ }];
+ last.comments = [...rejected.comments, {
+ id: "ack", issueId: "onboarding", authorAgentId: "agent", createdByRunId: "refusal-run",
+ body: "Understood. Stopped at your request. No welcome note or child task was created.",
+ createdAt: "2026-09-15T00:02:15.100Z",
+ }];
+ return e;
+}
+
function result(e = recording()): RunnerE2EResult {
return {
schema: "paperclip.runner-e2e.result/v2",
@@ -881,11 +909,9 @@ Accept the card above and I write it. This task stays in review until then.`;
expect(failed(e)).toContain("durable-completion");
});
it("allows closing a rejected unexecuted task, but not earlier completion or output", () => {
- const e = recording("reject-no-execution");
- e.checkpoints[2].phase = "rejected";
- e.checkpoints[3].tasks = [{ ...e.checkpoints[3].tasks[0], status: "done" }];
- e.checkpoints[3].documents = [];
- e.checkpoints[3].runs = [{ id: "parent-run", status: "succeeded" }];
+ const e = rejectionRecording();
+ e.checkpoints[3].tasks[0].status = "done";
+ e.checkpoints[3].runs.at(-1)!.status = "succeeded";
expect(failed(e)).toEqual([]);
e.checkpoints[1].tasks[0].status = "done";
expect(failed(e)).toContain("no-premature-work");
@@ -1258,3 +1284,79 @@ it("retains suppressed unstarted wakes without failing successful execution", ()
wake.startedAt = "2026-09-18";
expect(passed()).toBe(false);
});
+
+it("ignores an obsolete unstarted wake but still requires successful execution and approved output", () => {
+ const e = recording();
+ const last = e.checkpoints.at(-1)!;
+ last.runs.push({ id: "obsolete", status: "cancelled", errorCode: "issue_terminal_status",
+ startedAt: null, contextSnapshot: { issueId: "child" } });
+ expect(failed(e)).toEqual([]);
+ // The old harness aborted here while another provider run was still active.
+ last.runs[1].status = "running";
+ expect(failed(e)).toContain("provider-runs-succeeded");
+ last.runs[1].status = "cancelled";
+ last.runs[1].errorCode = "cancelled";
+ expect(failed(e)).toContain("provider-runs-succeeded");
+ last.runs[1].status = "succeeded";
+ last.documents = [];
+ expect(failed(e)).toContain("durable-completion");
+ last.tasks[1].assigneeAgentId = null;
+ expect(failed(e)).toContain("one-scoped-subtask");
+});
+
+describe("recorded refusal cancellation", () => {
+ it("waits for the refusal run's persisted reply even when it arrives after cancellation", () => {
+ const e = rejectionRecording();
+ const last = e.checkpoints.at(-1)!;
+ const run = last.runs.at(-1)!;
+ expect(isFirstTaskRejectionCancellation(run, e, last.tasks)).toBe(true);
+ const reply = last.comments.pop()!;
+ expect(firstTaskRejectionReplyRecorded(e, last.comments, last.runs)).toBe(false);
+ expect(failed(e)).toEqual(["rejection-respected", "provider-runs-succeeded"]);
+ last.comments.push(reply);
+ expect(failed(e)).toEqual([]);
+ });
+
+ it.each([
+ ["missing decision checkpoint", (e: FirstTaskEvidence) => { e.checkpoints[2].phase = "response"; }],
+ ["acceptance rather than refusal", (e: FirstTaskEvidence) => { e.checkpoints[2].comments.at(-1)!.body = "Yes, proceed"; }],
+ ["agent-authored refusal", (e: FirstTaskEvidence) => { e.checkpoints[2].comments.at(-1)!.authorAgentId = e.agentId; }],
+ ["no user attribution", (e: FirstTaskEvidence) => { delete e.checkpoints[2].comments.at(-1)!.authorUserId; }],
+ ["stale refusal", (e: FirstTaskEvidence) => { e.checkpoints[2].comments.at(-1)!.createdAt = "2026-09-15T00:00:00Z"; }],
+ ["unrelated task", (e: FirstTaskEvidence) => { e.checkpoints[3].runs.at(-1)!.contextSnapshot.issueId = "other"; }],
+ ["unrelated wake", (e: FirstTaskEvidence) => { e.checkpoints[3].runs.at(-1)!.contextSnapshot = { issueId: "onboarding", commentId: "old", wakeCommentId: "old" }; }],
+ ["operator cleanup", (e: FirstTaskEvidence) => { e.checkpoints[3].runs.at(-1)!.error = "Cancelled by a board operator"; }],
+ ["provider failure", (e: FirstTaskEvidence) => { e.checkpoints[3].runs.at(-1)!.status = "failed"; }],
+ ["provider timeout", (e: FirstTaskEvidence) => { e.checkpoints[3].runs.at(-1)!.status = "timed_out"; }],
+ ["unfinished task", (e: FirstTaskEvidence) => { e.checkpoints[3].tasks[0].status = "in_progress"; }],
+ ["missing execution timestamp", (e: FirstTaskEvidence) => { e.checkpoints[3].runs.at(-1)!.startedAt = null; }],
+ ])("does not exempt %s", (_name, mutate) => {
+ const e = rejectionRecording();
+ mutate(e);
+ const last = e.checkpoints.at(-1)!;
+ expect(isFirstTaskRejectionCancellation(last.runs.at(-1)!, e, last.tasks)).toBe(false);
+ expect(failed(e)).toContain("provider-runs-succeeded");
+ });
+
+ it.each([
+ { authorAgentId: "other" }, { createdByRunId: "parent-run" },
+ { createdAt: "2026-09-15T00:01:00Z" }, { body: " " }, { deletedAt: "2026-09-15T00:02:20Z" },
+ ])("does not accept unrelated or missing reply evidence: %j", patch => {
+ const e = rejectionRecording();
+ Object.assign(e.checkpoints[3].comments.at(-1)!, patch);
+ expect(failed(e)).toEqual(["rejection-respected", "provider-runs-succeeded"]);
+ });
+
+ it("keeps unauthorized work and active runs red despite an acknowledged cancellation", () => {
+ for (const kind of ["task", "document", "attachment", "agent", "run"]) {
+ const e = rejectionRecording();
+ const last = e.checkpoints[3];
+ if (kind === "task") last.tasks.push({ id: "unauthorized-child", status: "done" });
+ if (kind === "document") last.documents.push({ id: "output", key: "welcome", body: "Completed note" });
+ if (kind === "attachment") last.attachments = [{ id: "output", filename: "welcome.md" }];
+ if (kind === "agent") last.agents.push({ id: "unapproved-hire" });
+ if (kind === "run") last.runs.push({ id: "active", status: "running" });
+ expect(failed(e), kind).toContain(kind === "agent" ? "no-premature-work" : "rejection-respected");
+ }
+ });
+});
diff --git a/tests/runner-e2e/non-execution-wake.test.ts b/tests/runner-e2e/non-execution-wake.test.ts
index c17670d670..370fc1acae 100644
--- a/tests/runner-e2e/non-execution-wake.test.ts
+++ b/tests/runner-e2e/non-execution-wake.test.ts
@@ -1,5 +1,5 @@
import { expect, it } from "vitest";
-import { isBlockedUnstartedWake } from "./non-execution-wake.js";
+import { isBlockedUnstartedWake, isTerminalUnstartedWake } from "./non-execution-wake.js";
it("recognizes only explicitly suppressed wakes that never started execution", () => {
const run = { status: "cancelled", errorCode: "issue_dependencies_blocked", startedAt: null };
expect(isBlockedUnstartedWake(run)).toBe(true);
@@ -7,3 +7,17 @@ it("recognizes only explicitly suppressed wakes that never started execution", (
expect(isBlockedUnstartedWake({ ...run, ...patch })).toBe(false);
}
});
+
+it("requires an unstarted terminal suppression on the same terminal task", () => {
+ const run = { status: "cancelled", errorCode: "issue_terminal_status", startedAt: null, contextSnapshot: { issueId: "child" } };
+ for (const status of ["done", "cancelled"]) {
+ expect(isTerminalUnstartedWake(run, [{ id: "child", status }])).toBe(true);
+ }
+ for (const patch of [{ startedAt: "2026-09-27T09:16:00Z" }, { startedAt: undefined },
+ { errorCode: "cancelled" }, { status: "failed" }, { contextSnapshot: undefined },
+ { contextSnapshot: { issueId: "other" } }]) {
+ expect(isTerminalUnstartedWake({ ...run, ...patch }, [{ id: "child", status: "done" }])).toBe(false);
+ }
+ expect(isTerminalUnstartedWake(run, [])).toBe(false);
+ expect(isTerminalUnstartedWake(run, [{ id: "child", status: "in_progress" }])).toBe(false);
+});
diff --git a/tests/runner-e2e/non-execution-wake.ts b/tests/runner-e2e/non-execution-wake.ts
index 6065a5ce72..4e3cd1b81d 100644
--- a/tests/runner-e2e/non-execution-wake.ts
+++ b/tests/runner-e2e/non-execution-wake.ts
@@ -3,3 +3,16 @@
export function isBlockedUnstartedWake(run: Record<string, unknown>) {
return run.status === "cancelled" && run.errorCode === "issue_dependencies_blocked" && run.startedAt === null;
}
+
+/** A terminal issue may make a queued wake obsolete before provider admission. */
+export function isTerminalUnstartedWake(
+ run: Record<string, unknown>,
+ tasks: Array<{ id: string; status?: unknown }>,
+) {
+ const context = run.contextSnapshot;
+ const issueId = context && typeof context === "object" && "issueId" in context ? context.issueId : undefined;
+ return run.status === "cancelled" && run.errorCode === "issue_terminal_status" &&
+ run.startedAt === null && tasks.some(task =>
+ task.id === issueId && ["done", "cancelled"].includes(String(task.status)),
+ );
+}