Dashboard › opencode › Distillation
cdaacc08-8dde-42cf-bb4d-3a5858517516["lore_tm_v1_a0HehmivkpcwFw-_iffoV5T22gS8mrhoqVyh_FeZCfU","lore_tm_v1_iBU-gFjbyZbkpqH7_VkFmXu_eXmmaVnFaFQRcJwTl5E","lore_tm_v1_8me3OJthK7r7zPCn74ESO_-_M26kdTMAj8ISFU4VNqg","lore_tm_v1__LuEk1MKEAM4nJ-y_hYh8BuXFDIrIbRL3jSLa6takkc","lore_tm_v1_AWute9pS1ERAWlkJ6fjrLGx047zXKP-qlL7MJU1Pg1s","lore_tm_v1_MCCkjBTdIFUjLo4arxLIpRsmvqpfkYlDpjK62me7wXc","lore_tm_v1_ZW2tskwEhCuf5qBISOzGEQEqI1-hKa7HpyA9YgJ0Wmk","lore_tm_v1_-BgyfN7s1OU47-spP1Tlw1cTPi_ndn7dq_PCPKvjJB4","lore_tm_v1_2MNVqd4APCf23z55YelxJYV0YmvcQuo293OizyX18d4"]
Date: Sep 16, 2026
packages/core/src/database/migration.gen.ts registers ./migration/20260914170650_session-recovery as the final entry in the generated migrations array (line 43); the file contains 39 tracked migration imports spanning 20260127222353_familiar_lady_ursula through 20260914170650_session-recovery.packages/core/src/database/schema.gen.ts:158-170 defines session_execution with required id, session_id, owner_id, phase, time_created, and expires_at; nullable assistant_message_id and recovery_error; primary key id; session_id cascade foreign key; and session_execution_phase_check restricting phase to 'ready', 'safe', 'unknown', or 'continue'.packages/core/src/database/schema.gen.ts:173-184 defines session_input with required id, session_id, prompt, delivery, admitted_seq, and time_created; nullable promoted_seq; wake_pending integer DEFAULT false NOT NULL; wake_attempts integer DEFAULT 0 NOT NULL; primary key id; and a cascading session_id foreign key.packages/core/src/database/schema.gen.ts:199-213 defines session_recovery with required session_id, execution_id, continuation_message_id, phase, and time_created; nullable assistant_message_id and recovery_error; wake_pending integer DEFAULT true NOT NULL; wake_attempts integer DEFAULT 0 NOT NULL; primary key execution_id; cascading foreign keys to session(id), session_message(id), and session_input(id).packages/core/src/database/schema.gen.ts:283-311 are: unique session_execution_session_idx on session_execution(session_id); session_execution_owner_idx on owner_id; session_input_wake_pending_promoted_attempts_time_created_id_idx on (wake_pending,promoted_seq,wake_attempts,time_created,id); unique session_recovery_continuation_message_idx on continuation_message_id; and session_recovery_wake_pending_error_attempts_created_execution_idx on (wake_pending,recovery_error,wake_attempts,time_created,execution_id).packages/core/test/database-migration.test.ts:117-124 runs the Linux-only command bun ${fileURLToPath(new URL("../script/migration.ts", import.meta.url))} --check, expects exit code 0, stdout containing "No schema changes, nothing to migrate", and uses a 30_000 ms timeout.packages/core/test/database-migration.test.ts:127-164 verifies all tracked migrations apply to an empty database, create session, session_input, and session_context_epoch, leave agent, replacement_seq, and revision absent from session_context_epoch, record exactly migrations.length migration rows, and generate the expected event/session-input/session-message indexes.packages/core/test/database-migration.test.ts:166-225 applies 20260914170650_session-recovery to a populated predecessor and verifies existing rows ses_existing, msg_existing, and msg_input survive; session_execution.id is required; session_input.wake_pending defaults to "false"; session_recovery.execution_id is a required primary key; assistant_message_id and recovery_error are nullable; phase is required; and inserting invalid phase 'invalid' into session_execution fails.packages/core/test/database-migration.test.ts:227-237 verifies a non-empty database containing unrelated but no session table is rejected with "Database is not empty and has no session table".packages/core/test/database-migration.test.ts:239-257 verifies contextEpochAgentMigration backfills an existing session_context_epoch rowβs agent to "build".packages/opencode/src/server/routes/instance/httpapi/groups/sync.ts defines four experimental POST sync routes under /sync: 1. /sync/start (sync.start) starts sync loops for current-project workspaces with active sessions and returns Schema.Boolean; 2. /sync/replay (sync.replay) validates/replays a complete event history, accepts ReplayPayload, returns ReplayResponse, and may return HttpApiError.BadRequest; 3. /sync/steal (sync.steal) moves a session into the current workspace through the sync event system, accepts/returns SessionPayload, and may return BadRequest; 4. /sync/history (sync.history.list) accepts aggregate-ID-to-last-known-sequence mappings, returns events newer than known sequences plus full histories for omitted aggregates, and may return BadRequest.packages/opencode/src/server/routes/instance/httpapi/groups/sync.ts are: ReplayEvent = { id: EventV2.ID, aggregateID: Schema.String, seq: NonNegativeInt, type: Schema.String, data: Schema.Record(Schema.String, Schema.Unknown) }; ReplayPayload = { directory: Schema.String, events: Schema.NonEmptyArray(ReplayEvent) }; ReplayResponse = { sessionID: Schema.String }; SessionPayload = { sessionID: SessionID }; HistoryPayload = Schema.Record(Schema.String, NonNegativeInt); and HistoryEvent uses snake-case aggregate_id.SyncApi applies InstanceContextMiddleware, WorkspaceRoutingMiddleware, and Authorization; all four endpoints use WorkspaceRoutingQuery. Its OpenAPI metadata identifies the group as "sync" and the API as "opencode experimental HttpApi" version "0.0.1".packages/core/src/session/event.ts is a 2-line compatibility/re-export module: export * from "@opencode-ai/schema/session-event" and export * as SessionEvent from "@opencode-ai/schema/session-event".