Dashboard › opencode › Distillation
a04a80ec-f4eb-495c-973a-4cfb8953b7d8["lore_tm_v1_fO9Rg7qHUjEHcUM-TQcQA2Yztb8qqgUUYBaBRi0FV28","lore_tm_v1_EvVZRYFqIrpuH7uzg2KAj1NZrbLnD4QgaWSixIuqBvw","lore_tm_v1_G3DiotF0KwugzAKsx8HuyYOdAVL6U-C_E9uUq4BuFjk","lore_tm_v1_LGrUaTrYKTfoaEjfODoOebfx5nwiZF9EnzqhOhM-f3c"]
Date: Sep 16, 2026
packages/core/src/session/sql.ts: imports sql from drizzle-orm and check from drizzle-orm/sqlite-core; adds SessionTable.wake_attempts as non-null integer defaulting to 0.SessionInputTable.wake_pending as a non-null boolean integer defaulting to false, plus index session_input_wake_pending_promoted_session_idx over wake_pending, promoted_seq, and session_id.SessionRecoveryTable mapped to session_recovery, with fields: session_id, execution_id, nullable assistant_message_id, non-null continuation_message_id, phase ("ready" | "unknown" | "continue"), wake_pending defaulting to true, wake_attempts defaulting to 0, nullable recovery_error, and non-null time_created.SessionRecoveryTable uses primary key session_recovery_pk on execution_id, unique index session_recovery_continuation_message_idx on continuation_message_id, and index session_recovery_wake_pending_error_attempts_created_execution_idx over wake_pending, recovery_error, wake_attempts, time_created, and execution_id.SessionExecutionTable mapped to session_execution, with fields id, session_id, owner_id, nullable assistant_message_id, phase ("ready" | "safe" | "unknown" | "continue"), time_created, expires_at, and nullable recovery_error.SessionExecutionTable uses primary key session_execution_pk on id, unique index session_execution_session_idx on session_id, index session_execution_owner_idx on owner_id, and check constraint session_execution_phase_check limiting phase to 'ready', 'safe', 'unknown', or 'continue'.SESSION_EXECUTION_LEASE_MS = 30_000."adds final recovery ownership tables to a populated predecessor" in packages/core/test/database-migration.test.ts, using migration 20260914170650_session-recovery; it verifies existing session, session_message, and session_input rows survive, session_execution.id is required, session_input.wake_pending defaults to "false", session.wake_attempts defaults to "0", session_recovery.execution_id is a required primary key, assistant_message_id and recovery_error are nullable, phase is required, and invalid execution phase 'invalid' is rejected.packages/core/test/session-execution-local.test.ts with tests that clear a claim after a successful drain, preserve a claim when its scope closes, and clear a claim after explicit interruption."never starts a second owner while the lease is live"."never overwrites an expired lease"."never re-enters its own uncertain live lease"."never revives an expired claim on heartbeat"."never recovers a live execution lease".SessionExecutionLocal tests verify heartbeat expiry is renewed from the current clock; cancellation settles before a pending successor starts; and cancellation fails when cleanup loses execution ownership."atomically reconciles one abandoned execution into one continuation", "records a recovery continuation without forging an assistant identity", "recovers each abandoned execution once across repeated startup scans", "never recovers an execution superseded by a newer assistant", and "redrives a durable recovery wake after admission"."quarantines a malformed recovery row without blocking a valid wake", "quarantines a full batch of poison recovery rows before redriving valid work", "fairly redrives recovery and ordinary work beyond a full bounded batch", "bounds ordinary redrive writes to one scheduler row per Session", and "never wakes work settled between selection and redrive CAS"."quarantines a continuation that belongs to another Session", "rejects a recovered assistant from another Session", "quarantines a recovery wake behind a newer assistant", "never promotes a recovery superseded before scanner validation", "quarantines an assistant-less recovery superseded before scanner validation", and "never promotes a quarantined recovery continuation as an ordinary steer"."redrives durable ordinary input execution intent after a lost advisory wake", "redrives ordinary input without recovering a claim that crashed before promotion", "redrives one existing recovery after its replacement claim crashes before promotion", and "never recovers a pre-promotion claim when input commits at the recovery boundary"."quarantines a malformed claim without blocking a valid claim" and "bounds each deterministic recovery scan"."rolls back promotion and Context Epoch mutation after ownership loss", "never advances the Context Epoch after ownership changes", "rolls back claim renewal when Context Epoch advance fails", and "fences a paused owner after expiry, reconciliation, and takeover"."never wakes execution when retrying an already promoted prompt", "durably records execution intent before advisory wake", "replays historical prompt admission without execution intent as admit-only", "turns an admit-only exact retry into durable execution intent", and "never arms durable wake for a conflicting execution retry"."redrives only the synthetic recovery continuation", "clears durable execution intent when ordinary input is promoted", and "redrives an ordinary prompt after its advisory wake is lost"."never dispatches a provider after ownership changes", "never publishes streamed output after ownership changes", "never starts a local tool after ownership changes", and "never fails interrupted tools after ownership changes"."keeps automatic compaction unknown until Compaction.Ended commits" and "recovers the continuation committed with Compaction.Ended"."never commits continuation before unresolved hosted tools are reconciled", "never commits a Step end after the provider stream fails", "keeps a provider defect after Step finish unknown", "keeps provider failure unknown until unresolved tools are durable", and "recovers the continuation committed with a settled tool step"."retains the claim after Step interruption until runner finalizers finish"."finalizes interruption when cleanup dies" to packages/core/test/session-run-coordinator.test.ts: the first run is interrupted, cleanup dies with Error("cleanup defect"), a pending second wake still starts, the defect remains visible via Cause.hasDies, runs equals 2, and the coordinator’s active set ends empty.packages/core/test/session-runner-recorded.test.ts to replace direct SessionRunCoordinator wiring with SessionExecutionLocal.make({ run: (claim, force, recoveryInputID) => sessionRunner.run({ ...claim, force, recoveryInputID }) }) and provides LayerNode.compile(Database.node) alongside runnerLayer.packages/core/test/session-runner-tool-events.test.ts to provide startCommit: () => Effect.void and eventCommit: () => Effect.void to the LLM event publisher.