Dashboard › opencode › Distillation
3d4e7dfc-f8b1-46ee-a988-b757acddcb2e["lore_tm_v1_6hHAOTLcuEZYAt3LFT4KT0o6Rxu9e18mZY150wk6wRw","lore_tm_v1_6R6vuqam6T8N_dg2ty8VzdpF5dCtpI2a1drs9Y_w-SA","lore_tm_v1_aJ4vR_Semmpc4vT8-KQ_G6tzzS1snI4uez145EyvTXs","lore_tm_v1_VKod12X4JpOk17_Y4QfSbCzPFDdY90uWVHxha8juRt4","lore_tm_v1_IwGHnBJbkI6f6myWIZTVEEZ0NSXH-tL7LbYyTBRfCdw"]
Date: Sep 16, 2026
packages/core/src/session/projector.ts found recovery validates an optional assistantMessageID against the latest assistant row ordered by descending SessionMessageTable.seq; it defects with Recovery target is not the latest assistant: ${event.data.assistantMessageID} if it is absent or stale, and with Recovery target is not an assistant: ${event.data.assistantMessageID} if decoding does not produce an assistant.SessionEvent.Step.Recovered projection in packages/core/src/session/projector.ts requires event.durable, derives continuationMessageID via continuation(event.data.executionID), and idempotently returns if a SessionRecoveryTable row already exists for the same execution_id and session_id.packages/core/src/session/projector.ts projects the recovery event, admits a synthetic continuation input with prompt: Prompt.make({ text: "continue" }), delivery: "queue", requestExecution: false, and admittedSeq: event.durable.seq, then inserts a SessionRecoveryTable row containing the execution ID, optional assistant message ID, continuation message ID, phase, wake_pending: true, and event timestamp using .onConflictDoNothing().packages/core/src/session/projector.ts resolves the boundary by matching both session ID and message ID, defects with Revert boundary message not found: ${event.data.messageID} if absent, deletes later SessionMessageTable rows where seq > boundary.seq, deletes SessionInputTable rows whose admitted_seq or promoted_seq exceeds the boundary, and clears the session’s revert state.packages/core/src/session/sql.ts defines SessionRecoveryTable with primary key session_recovery_pk on execution_id, unique index session_recovery_continuation_message_idx on continuation_message_id, phases "ready" | "unknown" | "continue", default wake_pending = true, default wake_attempts = 0, nullable recovery_error, and cascading foreign keys to the session, assistant message, and continuation input.packages/core/src/session/sql.ts defines SessionExecutionTable with primary key session_execution_pk on id, unique index session_execution_session_idx on session_id to permit only one claim per session, owner index session_execution_owner_idx, phases "ready" | "safe" | "unknown" | "continue", and check constraint session_execution_phase_check; SESSION_EXECUTION_LEASE_MS is exactly 30_000.SessionInputTable recovery wake state in packages/core/src/session/sql.ts uses wake_pending defaulting to false, wake_attempts defaulting to 0, and index session_input_wake_pending_promoted_attempts_time_created_id_idx over (wake_pending, promoted_seq, wake_attempts, time_created, id).packages/core/src/database/migration/20260914170650_session-recovery.ts, ID 20260914170650_session-recovery, adds session_input.wake_pending and session_input.wake_attempts; creates session_execution and session_recovery; and creates indexes session_execution_session_idx, session_execution_owner_idx, session_input_wake_pending_promoted_attempts_time_created_id_idx, session_recovery_continuation_message_idx, and session_recovery_wake_pending_error_attempts_created_execution_idx.packages/core/test/event.test.ts includes durable replay/tailing, replay-handoff wake retention, sequence mismatch, unknown event type, contiguous aggregate validation, replay-owner fencing, strict owner conflicts, stale replay suppression, and divergent stale replay rejection; packages/core/test/session-prompt.test.ts includes historical admit-only replay and conversion of an exact retry into durable execution intent.