From a89e7918d9298c5f310d280f2632cf65477d3d0d Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 12 Nov 2026 14:35:28 -0600 Subject: [PATCH] fix(recovery): admit a fresh isolated continuation whose task lost its workspace binding The fallback clears the task's workspace binding when it isolates a continuation, and the run then prepares a new workspace (create_new). The admission preflight still required that binding for an isolated task with no project, so it refused the continuation wake as workspace_worktree_requires_project every 15 s, re-blocked the task and added a comment each time. Co-Authored-By: Claude Opus 5.5 --- server/src/services/execution-workspace-policy.ts | 4 ++++ server/src/services/fresh-continuation-fallback.ts | 13 +++++++++++++ server/src/services/heartbeat/queue.ts | 4 +++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/server/src/services/execution-workspace-policy.ts b/server/src/services/execution-workspace-policy.ts index 4a7f9c9fa33..1b27f8fcc04 100644 --- a/server/src/services/execution-workspace-policy.ts +++ b/server/src/services/execution-workspace-policy.ts @@ -94,7 +94,11 @@ export function isUnrunnableWorktreeCombo(input: { resolvedStrategy: string | null | undefined; reusableExecutionWorkspaceAvailable?: boolean | null; hasResolvablePriorSessionWorkspace?: boolean | null; + /** The wake continues a cut-off run in a new isolated workspace that the run + * prepares itself (`create_new`); it never needs the task's old binding. */ + freshIsolatedContinuation?: boolean | null; }): boolean { + if (input.freshIsolatedContinuation === true) return false; if (input.resolvedMode !== "isolated_workspace" && input.resolvedMode !== "operator_branch") return false; if (input.resolvedStrategy !== "git_worktree") return false; if (input.issue.projectId || input.issue.projectWorkspaceId) return false; diff --git a/server/src/services/fresh-continuation-fallback.ts b/server/src/services/fresh-continuation-fallback.ts index e5e5ab91c6c..99d0e234af0 100644 --- a/server/src/services/fresh-continuation-fallback.ts +++ b/server/src/services/fresh-continuation-fallback.ts @@ -305,6 +305,19 @@ export async function readFreshContinuationReadiness(db: Db, run: Pick | null | undefined }) { + if (typeof object(input.contextSnapshot).freshContinuationIsolation !== "string") return false; + return (await readFreshContinuationReadiness(db, { id: "", companyId: input.companyId, + contextSnapshot: input.contextSnapshot ?? {} }, input.issueId)) !== null; +} + export async function ensureFreshContinuation(db: Db, input: Input): Promise { return db.transaction(tx => continueFreshInTransaction(tx as unknown as Db, input)); } diff --git a/server/src/services/heartbeat/queue.ts b/server/src/services/heartbeat/queue.ts index 8f1eecf95f1..50435ede0d7 100644 --- a/server/src/services/heartbeat/queue.ts +++ b/server/src/services/heartbeat/queue.ts @@ -3,7 +3,7 @@ import { connectionIntentService } from "../connection-intents.js"; import { verifyBlockerStallWake } from "../recovery/blocker-stall-wakeups.js"; import { CONTEXT_COMPACTION_WAKE_REASON, ContextCompactionError, isContextCompactionRun, readContextCompactionRequest } from "../context-compaction.js"; import { isProcessRunAdmissionClosed } from "./run-admission.js"; -import { continueFreshInTransaction, hasPendingFreshContinuation, settleCoalescedFreshContinuationHolds } from "../fresh-continuation-fallback.js"; +import { continueFreshInTransaction, hasPendingFreshContinuation, isFreshIsolatedContinuationWake, settleCoalescedFreshContinuationHolds } from "../fresh-continuation-fallback.js"; import { refreshRunStartYieldIfStale } from "../run-start-handover.js"; import { deliveredQueuedCommentIds } from "../queued-comment-delivery.js"; import { hasAutomaticInteractionDeliveryHold, INTERACTION_DELIVERY_DENIED, recheckQueuedRunInteractions, withInteractionDeliveryOrigin } from "../agent-interaction-delivery.js"; @@ -4273,6 +4273,8 @@ export function createHeartbeatQueue(db: Db, dependencies: HeartbeatQueueDepende reusableExecutionWorkspaceAvailable: reuseRequest.existingExecutionWorkspaceAvailable, hasResolvablePriorSessionWorkspace, + freshIsolatedContinuation: await isFreshIsolatedContinuationWake(tx as unknown as Db, { + companyId: issue.companyId, issueId: issue.id, contextSnapshot: enrichedContextSnapshot }), }) ) { if (caseRequest) waitForCaseAdmission(WORKSPACE_WORKTREE_REQUIRES_PROJECT_CODE, WORKSPACE_WORKTREE_REQUIRES_PROJECT_MESSAGE);