Dashboard › opencode › Distillation
4eabf40c-3c08-4623-a067-81da20225d23["lore_tm_v1_UU_B0W_C15OvqFqEQmqr8uAMlwtUwbVbSNdPe2ee6gw","lore_tm_v1_V35OcHnWBwFCyVVWqi7IY2hzKvagru22bJKrmA1xaGM","lore_tm_v1_KS-T7DYKXs7BZIIpLq9En76Q1K5mFgQRSEC4kMn9-kg","lore_tm_v1_Xr_CGrHbjVbKQq6LCpDVL6H_hgy_Lb538gdxZA9vHtI","lore_tm_v1_RpXhu3Oeoz87rRKZ_XGekL5RSaZMSjc3Dkg78hWYOsU","lore_tm_v1__r2SWOTzqfRJFSlp_lbKyoR1CpmR5LAX3fZXfivSaBY","lore_tm_v1_s4mtGfkVej3JzUeQohfuzz-TwL0YgwrNm994KRTtiNU","lore_tm_v1_pu6Cf9vnRsMz9CAZG1OW8wZtpYKCalwewByTQtYsa1c","lore_tm_v1_um9lFFB58zAVoEc2SpL6zoP1XElT3FqVFQljbseEKSk","lore_tm_v1_ngeImGdln8gpW8Gu-w7SBejTxici4FieaJUcvnWLC-4","lore_tm_v1_q8Nnvatx5iRxAuEswp5ClOgDJlEtzd0s0KkZaWhaLMA","lore_tm_v1_PkWdI5obZS7Rx2nitPT5zN3XhzmjUwPQ_U5fJfcJ2dc","lore_tm_v1_pS_eusKhKmQpSFhbssOVJjXab7FOWUPBV0BSg1EdK1g","lore_tm_v1_j9kB0Mh6j4S8DEX59_EkhEN2QG3TJxJBiyJoodXWQ5s","lore_tm_v1_scLaSqJrj5TcTCfmsG4r0sMN4_ylfgkgwGLjHjYxtlc"]
Date: Sep 15, 2026
packages/core/src/session/execution/local.ts lines 55-109. Recovery selection orders eligible SessionRecoveryTable rows by time_created then execution_id, limits to 1, and calls input.run(claim, force, recovery?.continuationMessageID) while racing a repeated SessionExecutionClaim.update(db, claim) lease refresh scheduled every leaseDuration / 3.packages/core/src/session/execution/local.ts cleanup behavior: removes the matching entry from activeClaims; clears the claim after successful execution; retains it when the exit cause contains interrupts; and after non-interrupt failure queries SessionExecutionTable by session_id, execution id, and owner_id, clearing only when the current phase is not "unknown".packages/core/src/session/execution/local.ts logs non-interrupt-only drain failures as "Failed to drain Session" with { sessionID }; interrupt-only causes are not logged as errors.packages/core/src/session/execution/local.ts; the tool reported the update succeeded.packages/core/test/session-projector.test.ts: "quarantines a malformed recovery row without blocking a valid wake" at line 400, "quarantines a malformed claim without blocking a valid claim" at line 545, "bounds each deterministic recovery scan" at line 597, and "rolls back promotion and Context Epoch mutation after ownership loss" at line 642.session_execution row with id='malformed', owner_id='dead', phase='invalid', time_created=0, and expires_at=0 after enabling PRAGMA ignore_check_constraints = ON; it also inserts a valid expired row with id: "valid", owner_id: "dead", phase: "ready", time_created: 1, and expires_at: 0.packages/core/test/session-projector.test.ts: execution "malformed" receives recovery_error: "Invalid execution phase: invalid", while SessionRecoveryTable contains a recovery row for execution_id: "valid".SessionRecovery.BATCH_SIZE + 1 sessions named ses_recovery_batch_${index.toString().padStart(3, "0")} and matching safe-phase executions named execution-${index.toString().padStart(3, "0")}. After one SessionRecovery.recover() call, only execution-${SessionRecovery.BATCH_SIZE.toString().padStart(3, "0")} is expected to remain.packages/core/src/session/runner/llm.ts: stream-start transitions use { phase: "unknown", assistant_message_id: null }; continuation commits use { phase: "continue", assistant_message_id: null }; terminal commits use { phase: "safe", assistant_message_id: null }; and final step settlement stores phase: needsContinuation ? "continue" : "safe" with assistant_message_id: needsContinuation ? assistantMessageID : null.packages/core/src/session/runner/llm.ts tracks needsContinuation; the run loop repeatedly calls runTurn, increments step, promotes steering input after the first turn, checks pending "steer" input after a continuation ends, and then checks pending "queue" input before another outer-loop run.SessionEvent.Step.Recovered projection in packages/core/src/session/projector.ts lines 392-438. It requires event.durable, validates that a supplied recovery assistantMessageID is the latest assistant message, projects the recovered event, admits a synthetic queued prompt with text "continue", and inserts a SessionRecoveryTable row with wake_pending: true.SessionEvent.Step.Recovered creates recoveryMessageID = message(event.data.executionID, event.data.assistantMessageID) and continuationMessageID = continuation(event.data.executionID). The recovery row stores assistant_message_id: null only when phase === "continue" and no assistant message ID was supplied; otherwise it stores recoveryMessageID.packages/core/src/session/projector.ts are exact messages: "Durable Session event is missing aggregate sequence", "Recovery target is not the latest assistant: ${event.data.assistantMessageID}", and "Recovery target is not an assistant: ${event.data.assistantMessageID}".packages/core/src/session/recovery-id.ts: message(executionID, assistantMessageID?) returns the supplied assistant ID or SessionMessage.ID.make(\msg_recovery_${executionID}`); continuation(executionID)returnsSessionMessage.ID.make(`msg_recovery_continue_${executionID}`)`.packages/core/test/session-runner.test.ts test "redrives only the synthetic recovery continuation". It admits unrelated queued input "unrelated admit-only" with resume: false, publishes SessionEvent.Step.Recovered for execution "lost-recovery-wake" in phase "ready", runs recovery, and expects the provider requestβs user texts to equal ["Session execution interrupted by server restart", "continue"].msg_recovery_unrelated to remain unpromoted with { promoted: null } and the recovery row to finish with { pending: false }, demonstrating that recovery redrives only its synthetic continuation.packages/core/test/session-runner.test.ts expects the execution row to be removed, at least one SessionEvent.Step.Interrupted event to exist, and assistant context to end with finish: "error" plus { type: "unknown", message: "Provider Step outcome unknown after interruption" }; interrupted tool input is represented by a tool part with state.status: "error".packages/core/src/session/runner/llm.ts. TurnTransitionError distinguishes "ContinueAfterCompaction" and "ContinueAfterOverflowCompaction"; ordinary compaction recursively resumes through runTurn, while overflow compaction resumes through runAfterOverflowCompaction.runAfterOverflowCompaction rejects a second overflow with the exact defect "Post-compaction provider attempt cannot recover another overflow"; other TurnTransitionError transitions yield once and recursively rerun without a promotion.SessionRunner.run accepts sessionID, force, executionID, ownerID, and optional recoveryInputID. Recovery mode suppresses normal steer/queue checks, sets promotion to { recoveryInputID }, always runs once, and never processes queued work afterward; ordinary mode prioritizes "steer" over "queue" and exits early when not forced and neither is pending.packages/core/test/session-runner.test.ts, including: reloaded history after one durably settled local tool call; model-switch reload before a tool-driven continuation; queued-input promotion after continuation; queued-input promotion after steering continuation; coalescing multiple active steering prompts into one continuation; durable failure of stale local tools, hosted tools, and pending tool input before continuing; interruption when permission approval is declined or a question is dismissed; and durable closure/failure of unresolved or partial tool activity on provider errors, EOF, stream failure, or interruption.packages/core/src/event.ts lines 225-354. Durable publication verifies aggregate identity, optionally enforces strict replay ownership, treats an exact replay with matching event ID/type/data as idempotent, rejects divergent replay or sequence mismatch, runs registered projectors and an optional commit(seq) inside an immediate database transaction, then upserts EventSequenceTable and inserts EventTable.packages/core/src/event.ts include: "Aggregate mismatch: expected ${input.aggregateID}, got ${aggregateID}", "Replay owner mismatch for aggregate ${aggregateID}: expected ${row.ownerID}, got ${input.ownerID ?? "none"}", "Replay diverged at aggregate ${aggregateID} sequence ${input.seq}", "Sequence mismatch for aggregate ${aggregateID}: expected ${latest + 1}, got ${seq}", and "Event ${event.id} already exists at aggregate ${stored.aggregateID} sequence ${stored.seq}".packages/core/src/event.ts: an exact idempotent replay can fill a previously null EventSequenceTable.owner_id; a non-strict replay with a conflicting established owner returns without applying the event; new events use seq = input?.seq ?? latest + 1; and projectors execute before the sequence row and event row are persisted within the same transaction.