Dashboard › opencode › Distillation
8e62508d-51b1-4a45-b7e0-9e581a6dd78a["lore_tm_v1_kCdACLoQUKZf2pTIpyxXFC6IPNwNbUAbWzBj9w9Aj1Y","lore_tm_v1_2UfE7kbmKDvUoudkg5pbJMyOnoUV2cICZpT0yvkQnvs","lore_tm_v1_KJ3DuRQqJTjt4fLsAp6zUn7v_074kqJnu5h_hu-0tuk","lore_tm_v1_UIpWjX8thMWl6iEHmAUCe2k5aZ5Yd7UyJddkYflYlek"]
Date: Sep 15, 2026
/home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:150-170 showed session_context_epoch references session(id) with ON DELETE CASCADE; session_execution has columns id, session_id, owner_id, optional assistant_message_id, phase, time_created, expires_at, and optional recovery_error, with primary key session_execution_pk, a cascading session_id foreign key, and session_execution_phase_check restricting phase to 'ready', 'safe', 'unknown', or 'continue'./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:173-183 defines session_input with id as primary key; required session_id, prompt, delivery, admitted_seq, and time_created; optional promoted_seq; wake_pending integer DEFAULT false NOT NULL; and a cascading foreign key from session_id to session(id)./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:186-195 defines session_message with primary-key id, required session_id, type, seq, time_created, time_updated, and serialized data, plus a cascading foreign key to session(id)./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:198-211 defines session_recovery with required session_id, execution_id, continuation_message_id, phase, and time_created; optional assistant_message_id and recovery_error; wake_pending integer DEFAULT true NOT NULL; primary key session_recovery_pk on execution_id; and cascading foreign keys to session(id), session_message(id) through assistant_message_id, and session_input(id) through continuation_message_id./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:214-245 defines session with primary-key id; required project_id, slug, directory, title, version, time_created, and time_updated; optional workspace_id, parent_id, path, share_url, summary fields, metadata, revert, permission, agent, model, time_compacting, and time_archived; usage defaults cost real DEFAULT 0, tokens_input, tokens_output, tokens_reasoning, tokens_cache_read, and tokens_cache_write all integer DEFAULT 0 NOT NULL; and a cascading project_id foreign key to project(id)./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:248-269 defines todo with composite primary key todo_pk(session_id, position), required content, status, priority, timestamps, and cascading session deletion; it also defines session_share with primary-key session_id, required id, secret, url, timestamps, and a cascading foreign key to session(id)./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts:271-311 include: unique event_aggregate_seq_idx(aggregate_id, seq); event_aggregate_type_seq_idx(aggregate_id, type, seq); unique permission_project_action_resource_idx(project_id, action, resource); message_session_time_created_id_idx(session_id, time_created, id); part_message_id_id_idx(message_id, id); and part_session_idx(session_id).session_execution indexes are unique session_execution_session_idx(session_id)—enforcing at most one execution row per session—and session_execution_owner_idx(owner_id).session_input indexes are session_input_session_pending_delivery_seq_idx(session_id, promoted_seq, delivery, admitted_seq), unique session_input_session_admitted_seq_idx(session_id, admitted_seq), unique session_input_session_promoted_seq_idx(session_id, promoted_seq), and session_input_wake_pending_promoted_time_created_id_idx(wake_pending, promoted_seq, time_created, id).session_message indexes are unique session_message_session_seq_idx(session_id, seq), session_message_session_type_seq_idx(session_id, type, seq), session_message_session_time_created_id_idx(session_id, time_created, id), and session_message_time_created_idx(time_created).session_recovery_continuation_message_idx(continuation_message_id), session_project_idx(project_id), session_workspace_idx(workspace_id), session_parent_idx(parent_id), and todo_session_idx(session_id)./home/byk/Code/opencode/packages/core/src/session/recovery-id.ts exports message(executionID, assistantMessageID?), which preserves a supplied assistantMessageID or creates SessionMessage.ID.make(\msg_recovery_${executionID}`), and continuation(executionID), which creates SessionMessage.ID.make(`msg_recovery_continue_${executionID}`)`./home/byk/Code/opencode/packages/core/src/session/message-updater.ts:105-149 projects "session.next.agent.switched" to SessionMessage.AgentSwitched, "session.next.model.switched" to SessionMessage.ModelSwitched, "session.next.prompted" to SessionMessage.User, and "session.next.context.updated" to SessionMessage.System; "session.next.moved" and "session.next.prompt.admitted" return Effect.void."session.next.prompted" projector preserves event.data.messageID, event.metadata, event.data.prompt.text, .files, .agents, and event.data.timestamp; the "session.next.context.updated" projector preserves messageID, text, and timestamp but does not attach event metadata in the shown code./home/byk/Code/opencode/packages/core/src/session/message-updater.ts:150-172 projects "session.next.synthetic" to SessionMessage.Synthetic with sessionID, text, messageID, and timestamp, and projects "session.next.shell.started" to SessionMessage.Shell with metadata, callID, command, initial output: "", and timestamp."session.next.step.recovered" handler, at /home/byk/Code/opencode/packages/core/src/session/message-updater.ts:251.