From 39d8250d56782e7ebda556cddf8e0e222e4a6477 Mon Sep 17 00:00:00 2001 From: paperclipbugbot Date: Fri, 27 Nov 2026 00:38:34 -0800 Subject: [PATCH] fix(native): keep a completion reviewer's remote run through a restart Restart recovery's ownership gate treated every run whose agent is not the task's assignee as task_ownership_or_status_changed. A completion reviewer is never the assignee, so a deploy stopped every interrupted remote reviewer run, reported it as a run failure and left the review request open. Accept the run's still-valid native review assignment, as ordinary session resumption already does. Co-Authored-By: Claude Opus 5.5 --- .../native-runtime/native-restart-recovery.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/src/services/native-runtime/native-restart-recovery.ts b/server/src/services/native-runtime/native-restart-recovery.ts index d6454f9f533..742aca63ede 100644 --- a/server/src/services/native-runtime/native-restart-recovery.ts +++ b/server/src/services/native-runtime/native-restart-recovery.ts @@ -4,6 +4,7 @@ import { nativeRunHandedOffTask } from "./native-human-self-handoff.js"; import { CONTROLLER_LEASE_RENEW_MS } from "../controller-instance-lease.js"; import { currentControllerProcessStamp, UNKNOWN_PROCESS_SPACE } from "../controller-process-identity.js"; import { readNativeSessionResumptionAgent, restoreNativeSessionExecution } from "./native-session-resumption-admission.js"; +import { getNativeReviewAssignment } from "./native-review-participant.js"; import { notifyLiveRunRecovery } from "../live-run-recovery-notifications.js"; import { NATIVE_AGENT_DIRECTORY_BUSY_WAIT, NATIVE_RETAINED_OWNER_WAIT } from "./native-controller-recovery.js"; import { notifyNativeEnvironmentSettlement } from "../native-environment-settlement-notifications.js"; @@ -1887,9 +1888,18 @@ export async function claimNativeRestartRecoveries(input: { if (stopCleanup && classification.claimKind !== "reattach_remote_runner") { return { kind: "blocked", runId: row.run.id, reason: "native_stop_requires_existing_remote_session" } as const; } + const taskClosed = ["done", "cancelled"].includes(row.issueStatus); + // A completion reviewer runs on the worker's task, so the task's assignee + // is never the reviewer. Its still-open review assignment is what lets it + // run there, as in ordinary session resumption. Only a review the task + // has moved past counts as an ownership change. + const reviewStillAssigned = !taskClosed && row.issueAssigneeAgentId !== row.run.agentId + && await getNativeReviewAssignment(tx as unknown as Db, { + companyId: row.run.companyId, issueId: row.coordinator.issueId, agentId: row.run.agentId, + contextSnapshot: row.run.contextSnapshot, + }) !== null; const ownershipChanged = - row.issueAssigneeAgentId !== row.run.agentId || - ["done", "cancelled"].includes(row.issueStatus); + (row.issueAssigneeAgentId !== row.run.agentId && !reviewStillAssigned) || taskClosed; if (needsResumptionAdmission && (!durableAuthority || ownershipChanged || classification.claimKind !== "reattach_remote_runner")) { if (!admission.exhausted) { const deferred = await deferRemoteRetry("native_retry_remote_authority_unverified");