diff --git a/doc/plans/2026-10-03-cursor-production-readiness.md b/doc/plans/2026-10-03-cursor-production-readiness.md index 4d69bd37f15..565c412a099 100644 --- a/doc/plans/2026-10-03-cursor-production-readiness.md +++ b/doc/plans/2026-10-03-cursor-production-readiness.md @@ -250,7 +250,7 @@ full single-path shape update before execution progress. Every attested notice retains that same digest; late, changed, multi-path, and unsafe input stays unproven. This changes passive evidence, not provider permissions or file access. Committed Cursor permission declines followed by a completed turn without a -semantic result now fail the run once, keep the task open, and assign recovery to +semantic result now fail the run once, block the unfinished task, and assign recovery to the operator with no automatic wake. Other missing-result recovery remains intact. The decision proof binds company, agent, run, turn, normalized session, source, request, and strict event order. It does not assert response delivery or absence @@ -260,3 +260,15 @@ Focused verification passed: 534 controller tests, 43 Cursor runtime tests, and 43 fixture evidence tests, plus affected typechecks. The provider CLI pin, native patch, and command/profile digest remain unchanged; the candidate source and Node pack identities must be rebuilt before repeating affected qualification. + +The first local repeat at `c45cf9` confirmed the named permission-declined failure +without another provider attempt. It remains failed because the fixture expected +In Progress while canonical failure recovery projected Blocked. The release +contract now requires Blocked for the new explicit permission-declined failure; +historical generic missing-result evidence retains its prior status contract. +Exact delivery, a single terminal, absent effects and process retirement remain +mandatory. A reproduced Stop-precedence race is also repaired: acknowledged +operator and reassignment cancellation wins over the new typed decline error. +The frozen v11 runtime packs and image remain at `c45cf9`; these follow-up changes +touch the controller and harness only, and their distinct source identity is +recorded with subsequent results. diff --git a/server/src/services/native-runtime/native-session-executor.test.ts b/server/src/services/native-runtime/native-session-executor.test.ts index 839e25557a1..0fbd6dc58ae 100644 --- a/server/src/services/native-runtime/native-session-executor.test.ts +++ b/server/src/services/native-runtime/native-session-executor.test.ts @@ -7375,21 +7375,25 @@ describe("native warm session supervision", () => { }); describe("native session bounded recovery", () => { - it("leaves a denied Cursor task open and gives recovery to the operator without another provider attempt", async () => { + it("blocks a denied Cursor task and gives recovery to the operator without another provider attempt", async () => { const updates: Array<{ table: unknown; values: Record }> = []; const failure = new NativeCursorPermissionDeclinedError(); state.execute.mockReset().mockRejectedValueOnce(failure); state.upsertRecoveryAction.mockReset().mockResolvedValue({}); + const updateIssue = vi.fn(async () => ({ status: "blocked", statusVersion: 7 })); + const service = vi.spyOn(issueServiceModule, "issueService").mockReturnValue({ update: updateIssue } as unknown as ReturnType); + try { await expect(executePaperclipNativeSession({ db: leaseDb(execution, {}, {}, updates), execution, runnerInstanceId: "runner" })).rejects.toBe(failure); expect(updates.find(update => update.table === nativeRunFinalizations && update.values.phase === "terminal_failure")?.values).toMatchObject({ failureCode: "native_permission_declined", nextAttemptAt: null, failureDetail: { recoverable: false, nextAction: expect.stringContaining("Automatic recovery is stopped") }, }); - expect(updates.some(update => update.table === issues && update.values.status === "blocked")).toBe(false); + expect(updateIssue).toHaveBeenCalledWith(execution.binding.issueId, { status: "blocked" }, expect.anything()); expect(state.upsertRecoveryAction).toHaveBeenCalledWith(expect.objectContaining({ cause: "native_permission_declined", ownerType: "board", wakePolicy: null })); expect(state.execute).toHaveBeenCalledTimes(1); + } finally { service.mockRestore(); } }); - it.each(["operator", "reassignment"])("does not turn an acknowledged %s Stop before completion into a failure or a retry", async (source) => { + it.each([["operator", "missing-result"], ["reassignment", "missing-result"], ["operator", "permission-declined"], ["reassignment", "permission-declined"]])("does not turn an acknowledged %s Stop before %s completion into a failure or a retry", async (source, failureKind) => { const updates: Array<{ table: unknown; values: Record }> = []; const stop: Record = {}; state.execute.mockReset().mockImplementationOnce(async () => { @@ -7399,7 +7403,7 @@ describe("native session bounded recovery", () => { schema: "paperclip.native-cancellation.v1", ...execution.binding, scope: "run", reasonCode: "cancellation_run_only", dispatched: true, dispatchState: "acknowledged", intentAuditId: "intent", acknowledgementAuditId: "ack", } }); - throw new Error("native_finalization_missing: session returned no semantic result"); + throw failureKind === "permission-declined" ? new NativeCursorPermissionDeclinedError() : new Error("native_finalization_missing: session returned no semantic result"); }); state.upsertRecoveryAction.mockClear(); await expect(executePaperclipNativeSession({ diff --git a/server/src/services/native-runtime/native-session-executor.ts b/server/src/services/native-runtime/native-session-executor.ts index 1572c39e712..53bd18860f0 100644 --- a/server/src/services/native-runtime/native-session-executor.ts +++ b/server/src/services/native-runtime/native-session-executor.ts @@ -6074,7 +6074,6 @@ export function nativeSessionRecoveryProjection(input: { exhausted, issueStatus: exhausted && - input.failureCode !== "native_permission_declined" && input.failureCode !== NATIVE_ADOPTED_RUNNER_AUTHENTICATION_TIMEOUT ? ("blocked" as const) : null, @@ -8742,7 +8741,7 @@ async function executePaperclipNativeSessionWithinScope( // another turn to perform completion bookkeeping. const stoppedBeforeFirstTurn = error instanceof Error && error.message === "native_session_cancelled"; if (protocolIntegrityFailure === null && error instanceof Error && - (stoppedBeforeFirstTurn || error.message === "native_finalization_missing: session returned no semantic result")) { + (stoppedBeforeFirstTurn || error instanceof NativeCursorPermissionDeclinedError || error.message === "native_finalization_missing: session returned no semantic result")) { const [stoppedRun] = await input.db.select().from(heartbeatRuns).where(and( eq(heartbeatRuns.id, input.execution.binding.runId), eq(heartbeatRuns.companyId, input.execution.binding.companyId), diff --git a/tests/runner-e2e/cursor-native-evidence.test.ts b/tests/runner-e2e/cursor-native-evidence.test.ts index ea0ee23776c..48b83d0670a 100644 --- a/tests/runner-e2e/cursor-native-evidence.test.ts +++ b/tests/runner-e2e/cursor-native-evidence.test.ts @@ -126,7 +126,7 @@ it("requires a correlated failed semantic finalization after the delivered denia const input = { runId: "run", turnId: "turn", requestId: "request", issue: { id: "issue", status: "in_progress" }, run: { id: "run", nativeIssueId: "issue", runtimeMode: "native", status: "failed", errorCode: "native_session_interrupted", error: "native_finalization_missing: session returned no semantic result" }, events: [evidence, terminal] }; expect(hasCursorDeniedTurnTerminal(input)).toBe(true); - const declined = { ...input, run: { ...input.run, errorCode: "native_permission_declined", error: "native_finalization_missing: session returned no semantic result; Cursor permission was declined; explicit direction is required" } }; + const declined = { ...input, issue: { ...input.issue, status: "blocked" }, run: { ...input.run, errorCode: "native_permission_declined", error: "native_finalization_missing: session returned no semantic result; Cursor permission was declined; explicit direction is required" } }; expect(hasCursorDeniedTurnTerminal(declined)).toBe(true); expect(hasCursorDeniedTurnTerminal({ ...declined, events: [terminal] })).toBe(false); for (const status of ["succeeded", "cancelled", "timed_out", "running"]) expect(hasCursorDeniedTurnTerminal({ ...input, run: { ...input.run, status } })).toBe(false); diff --git a/tests/runner-e2e/cursor-native-evidence.ts b/tests/runner-e2e/cursor-native-evidence.ts index 79afb5df2cf..f905c63e6b4 100644 --- a/tests/runner-e2e/cursor-native-evidence.ts +++ b/tests/runner-e2e/cursor-native-evidence.ts @@ -76,7 +76,7 @@ export function hasCursorDeniedTurnTerminal(input: { const missingResult = run.errorCode === "native_session_interrupted" && run.error === "native_finalization_missing: session returned no semantic result"; const declined = run.errorCode === "native_permission_declined" && run.error === "native_finalization_missing: session returned no semantic result; Cursor permission was declined; explicit direction is required"; if (!id(input.runId) || !id(input.turnId) || !id(input.requestId) || run.id !== input.runId || run.nativeIssueId !== issue.id - || run.status !== "failed" || run.runtimeMode !== "native" || issue.status !== "in_progress" + || run.status !== "failed" || run.runtimeMode !== "native" || issue.status !== (declined ? "blocked" : "in_progress") || (!missingResult && !declined)) return false; const terminals = input.events.map(rec).map(row => ({ row, event: rec(rec(row.payload).prpEvent) })) .filter(({ event }) => ["turn.completed", "turn.failed", "turn.cancelled", "turn.interrupted"].includes(event.eventType)); diff --git a/tests/runner-e2e/cursor-native-flow.ts b/tests/runner-e2e/cursor-native-flow.ts index 291fa8e0eb9..a89c3800f67 100644 --- a/tests/runner-e2e/cursor-native-flow.ts +++ b/tests/runner-e2e/cursor-native-flow.ts @@ -343,7 +343,8 @@ export async function runCursorNativeFlow(input: { check("browser-exact-denial", posted.turnId === event.turnId && posted.requestKind === "permission_approval" && posted.resolution?.action === "decline", "Browser denied the exact native run/request/turn"); const identity = { runId: native.runId, turnId: event.turnId, requestId: request.requestId, method: "session/request_permission" as const, action: "decline" as const }; const rejectDenial = (state: Awaited>) => state.runs.length !== 1 - || ["succeeded", "cancelled", "timed_out"].includes(state.runs[0]?.status) || state.issue.status !== "in_progress" + || ["succeeded", "cancelled", "timed_out"].includes(state.runs[0]?.status) + || (state.issue.status !== "in_progress" && !(state.issue.status === "blocked" && state.runs[0]?.status === "failed" && state.runs[0]?.errorCode === "native_permission_declined")) ? "Denied Cursor operation claimed success, changed task disposition, or created another run" : undefined; await pollUntil({ label: "exact native denial delivery and settled call", deadlineAt: input.deadlineAt, load, reject: rejectDenial, accept: state => hasDeliveredCursorNativeRequest({ ...identity, events: state.runEvents }) @@ -356,7 +357,7 @@ export async function runCursorNativeFlow(input: { await sampleDenied("after-terminal", remoteFinal ?? undefined); check("negative-task-unfinished", hasCursorDeniedTurnTerminal({ run: terminal.runs[0], issue: terminal.issue, events: terminal.runEvents, ...identity }), "Denied native turn supplied no semantic completion; its failed run does not falsely complete the task"); await page.reload(); - await expect(page.getByTestId("issue-detail-header").getByRole("button", { name: "Change status (current: In Progress)", exact: true })).toBeVisible(); + await expect(page.getByTestId("issue-detail-header").getByRole("button", { name: `Change status (current: ${terminal.issue.status === "blocked" ? "Blocked" : "In Progress"})`, exact: true })).toBeVisible(); const comments = await api.get(`/api/issues/${issue.id}/comments`); await input.evidence("api-state.json", { ...terminal, run: runs[0], comments, checks, notices: denialNotices, commandSha256: deniedCommand!.commandSha256, denialTerminalProven, runEventsByRun: [{ runId: native.runId, events: terminal.runEvents }] }); await input.capture("final-state", "Cursor denied command ended without completing the task", "final-state.png");