Dashboard › opencode › Distillation
f9e03ba7-eadf-4a2e-a57b-b8baf95f381f["lore_tm_v1_l5GJ53l_UwzDU5XB7dN11Qrx79kKZJK2OaRF7JApLlY"]
Date: Sep 17, 2026
packages/core/src/session/recovery.ts; the implementation imports SessionExecution from ./execution and uses SessionExecutionTable, SessionRecoveryTable, and SessionInputTable.packages/core/src/session/recovery.ts:76 orders execution-recovery candidates by ascending SessionExecutionTable.time_created, then ascending SessionExecutionTable.id.packages/core/src/session/recovery.ts:87 performs stale-owner takeover by setting owner_id to ownerID and expires_at to now + SESSION_EXECUTION_LEASE_MS.packages/core/src/session/recovery.ts:122-145 contains explicit handling for execution phase cancelled, fenced by SessionExecutionTable.session_id and SessionExecutionTable.id.packages/core/src/session/recovery.ts:179-223 inspects whether latestMessage?.type === "assistant", can clear the recovery claim with SessionExecutionClaim.clear(db, recoveryClaim), constructs tool-related events using callID: tool.id, and publishes the accumulated events.packages/core/src/session/recovery.ts:235-318 contains transactional recovery/finalization logic, including another SessionExecutionClaim.clear(db, recoveryClaim), reads of SessionRecoveryTable.assistant_message_id, clock access through Clock.currentTimeMillis, and error logging via Effect.logError("Failed to recover Session", cause).packages/core/src/session/recovery.ts:329-366 queries recovery records using SessionRecoveryTable.execution_id and orders them by ascending SessionRecoveryTable.time_created, then ascending SessionRecoveryTable.execution_id.packages/core/src/session/recovery.ts:405 validates each continuation with SessionInput.validateRecovery(db, row.continuationMessageID) before subsequent recovery processing.packages/core/src/session/recovery.ts:429 filters recovery wake work on SessionRecoveryTable.wake_pending === true.packages/core/src/session/recovery.ts:454-551 scans ordinary pending wake work by joining SessionInputTable on SessionInputTable.session_id === SessionTable.id; retry selection includes SessionTable.wake_attempts > 0 and SessionTable.wake_attempts <= MAX_WAKE_ATTEMPTS, and background processing is launched with Effect.forkScoped.