Dashboard › opencode › Distillation
1024fd66-9849-49f2-8f19-391bc277837a["lore_tm_v1_qLzz5An8JNJo43KCqKM3gCu56f6cei03OuwhCcb4rt0","lore_tm_v1_Heh65nJLgjFU5RGFMGhug7BvQcDfy0SRl9Mp2x8IuEI","lore_tm_v1_tKfjo3D4786HJE-bP3wbvB0JecONCmvRcUJmD_Qr8HE","lore_tm_v1_9fsEW75ZNtycbUUv5hkuN_xNn97ED8s7Dg9u89Lp8zc","lore_tm_v1_7QXtWvV6sw6dCOgtxmtn_zqJIwS_BE0giDMmw_w6Q64"]
Date: Sep 16, 2026
packages/core/src/session/execution/local.ts:16-25 defines make() for current-process routing of implicit-local Locations; it generates a per-process ownerID with crypto.randomUUID() and converts SESSION_EXECUTION_LEASE_MS to milliseconds as leaseDuration.packages/core/src/session/execution/local.ts:26-47 tracks active claims in Map<SessionSchema.ID, SessionExecutionClaim.Claim> and uses SessionRunCoordinator; each drain generates an executionID, attempts to insert a SessionExecutionTable claim with phase "ready" and expires_at: now + leaseDuration, and returns without running if .onConflictDoNothing() yields no claim.packages/core/src/session/execution/local.ts:48-65 selects the oldest eligible recovery for the Session where wake_pending = true and recovery_error IS NULL, ordered by time_created then execution_id; it passes the selected continuation_message_id to input.run(claim, force, recovery?.continuationMessageID).packages/core/src/session/execution/local.ts:64-99 races Session execution against lease renewal via SessionExecutionClaim.update(db, claim) repeated every leaseDuration / 3; non-interrupt-only failures are logged as "Failed to drain Session" with sessionID.packages/core/src/session/execution/local.ts:75-96: successful execution clears the claim; an interrupted execution retains a claim unless its phase is "safe"; failed claims are cleared unless their current phase is "unknown" or "continue".packages/core/src/session/execution/local.ts:103-137 exposes active, resume: coordinator.run, and wake: coordinator.wake. interrupt(sessionID) marks an active claim phase "cancelling", races coordinator interruption/claim cleanup against continued lease renewal, and tolerates SessionExecutionClaim.Lost only if no claim remains for the Session.packages/core/src/session/execution/local.ts:140-160 builds the SessionExecution.Service layer using SessionStore.Service and LocationServiceMap.Service; execution loads the Session, dies with Session not found: ${claim.sessionID} if absent, invokes runner.run({ ...claim, force, recoveryInputID }), and provides the service layer for session.location. Node dependencies are Database.node, SessionStore.node, and LocationServiceMap.node.packages/core/src/session/run-coordinator.ts:5-27 defines a per-key execution coordinator that allows different keys to run concurrently. Its API is active, run(key), wake(key), and interrupt(key, cleanup?); drain(key, force) performs the underlying work.packages/core/src/session/run-coordinator.ts:17-36 stores each active key as an Entry<E> containing done, optional owner, optional exit, pendingWake, and stopping; new entries initialize pendingWake: false and stopping: false.packages/core/src/session/run-coordinator.ts:38-69 starts work in a FiberSet; successor work first yields via Effect.yieldNow, while initial work waits on a Deferred. On successful completion with pendingWake, the same entry starts one coalesced non-forced successor; otherwise a pending wake creates a replacement entry, and the original done Deferred is completed with the drain exit.packages/core/src/session/run-coordinator.ts:72-97 gives explicit run(key) forced semantics: an idle key starts drain(key, true), an already-active key joins its done, and a stopping key waits then retries. wake(key) coalesces onto an active entry by setting pendingWake = true; an idle wake starts drain(key, false).packages/core/src/session/run-coordinator.ts:99-125 interruption semantics: interrupt() sets stopping = true, clears the prior pending wake, interrupts the owner fiber, executes cleanup, then either removes the entry or starts one non-forced successor if new work arrived during stopping. It throws "Interrupted Session execution did not settle" if the interrupted entry lacks an exit and propagates cleanup failure after settling coordinator state; the sequence is Effect.uninterruptible.packages/core/src/session/runner/index.ts:12-18 defines SessionRunner.RunError as the union of LLMError, SessionRunnerModel.Error, MessageDecodeError, ContextSnapshotDecodeError, SystemContext.InitializationBlocked, and ToolOutputStore.Error.packages/core/src/session/runner/index.ts:20-32 defines SessionRunner.Interface.run() as one local continuation from already-recorded Session history. Inputs are sessionID, force, executionID, ownerID, and optional recoveryInputID; explicit runs perform one provider attempt even if no durable work is eligible. The service identifier is @opencode/v2/SessionRunner.