Dashboard › opencode › Distillation
15c6006d-c1d5-478e-9eba-7e2a0d96dcf4["lore_tm_v1_Uv5nwZSNId7a66P1qI8W_r1BnqxFsZHBi6MgDt53BHc","lore_tm_v1_UBSLmvzdCPnhZLtRWHHCQa8jqQFMCl9eiKGhe2c59jE"]
Date: Sep 14, 2026
packages/core/test/database-migration.test.ts test resets incompatible projected Session messages before adding sequence order creates legacy tables session, message, part, event, and session_message, plus indexes session_message_session_time_created_id_idx and session_message_session_type_time_created_id_idx.legacy_message with data {"role":"user"}, legacy_part with data {"type":"text","text":"hello"}, and stale projected row stale_projection; after DatabaseMigration.applyOnly(db, [sessionMessageProjectionOrderMigration]), it expects the legacy message and part rows to remain unchanged while session_message is empty.sessionMessageProjectionOrderMigration, the migration test inserts fresh_projection into session_message with type="user", seq=7, time_created=2, time_updated=2, and data='{}', then expects { id: "fresh_projection", seq: 7 }.packages/core/test/database-migration.test.ts contains a following test named runs session usage backfill in order with schema changes, which begins from a session table with id and required time_updated and a message table with id, session_id, and data.PASS: base ab9408c81cc9916177641ae8e9f08624fc27b5b9, head dc661f30cb2055ad6248fdc59b14998d834497be, exactly 1 head parent equal to the stated base, matching git merge-base, passing git diff --check, and required binary-diff SHA-256 e414f577c79eab2ae49be387b2f6fb48b013f9d8a61618d5298d62229bf8e4eb.git show <head>:<path>; reviewed scope included Session recovery events, projections, claims, migrations, startup wiring, tests, generated schema, and .lore.md, with no binary blob.repo-setup skill was unavailable, so the assistant instead read immutable HEAD copies of applicable AGENTS.md and CONTRIBUTING.md.fatal: path 'packages/opencode/dist/opencode-linux-x64/bin/opencode' exists on disk, but not in 'dc661f30cb2055ad6248fdc59b14998d834497be'.safe. runTurnAttempt invokes compaction at packages/core/src/session/runner/llm.ts:224-225, phase changes to unknown only at llm.ts:304-312, and compaction calls dependencies.llm.stream(...) at packages/core/src/session/compaction.ts:202-211; unlike the main stream deferred with Stream.suspend at llm.ts:259, proactive compaction bypasses that protection.safe claim, causing recovery to report a generic execution interruption and potentially repeat a compaction request whose prior outcome is unknown. The automatic-compaction test at packages/core/test/session-runner.test.ts:1073-1143 checks request content and count but not claim phase at dispatch.SessionExecutionLocal clears every successful or non-interrupting failed drain at packages/core/src/session/execution/local.ts:38-47.step-finish returns successfully through packages/core/src/session/runner/llm.ts:407-414; finish is a no-op at packages/core/src/session/runner/publish-llm-event.ts:433-434; publisher defects, malformed events, and post-provider snapshot failures propagate as non-interrupt defects and trigger claim deletion without publishing Step.Ended, Step.Failed, or Step.Interrupted.step-finish at packages/core/test/session-runner.test.ts:3307-3330 and malformed duplicate stream events at packages/core/test/session-runner.test.ts:3417-3429; neither checks for a terminal assistant projection or retained recovery claim.Step.Failed deletes the claim atomically, while Step.Ended marks it safe and successful drain cleanup deletes it. The defect is limited to incomplete and abnormal provider termination.step-finish sets assistantActive=false at packages/core/src/session/runner/publish-llm-event.ts:427-431; the decline handler at packages/core/src/session/runner/llm.ts:346-351 publishes terminal failure only if the assistant is still active, then returns an interrupt.SessionExecutionLocal preserves claims for interrupted exits at packages/core/src/session/execution/local.ts:44-46; the internally generated user-decline interrupt does not go through SessionExecution.interrupt, so cleanup at execution/local.ts:51-54 is skipped. The reproducing test emits step-finish, rejects the question, and verifies an interrupt at packages/core/test/session-runner.test.ts:2868-2889, but does not inspect SessionExecutionTable; assistant concluded this can accidentally trigger restart recovery.packages/core/src/session.ts:430-432 makes the operation uninterruptible and packages/core/src/session/execution/local.ts:53 clears the claim after coordinator shutdown.packages/core/src/session/recovery.ts:49-84, but performs advisory wake afterward at line 104; startup scans only SessionExecutionTable at line 21. A crash after transaction commit but before wake leaves a durable pending continuation with no execution claim, so startup finds nothing to resume.packages/core/src/session/execution/local.ts:44-46, and only after drain return does SessionRunCoordinator inspect pendingWake and start the successor at packages/core/src/session/run-coordinator.ts:40-64; a crash between these operations can strand a durable prompt admitted just after the runnerβs final pending-input check.packages/core/test/session-projector.test.ts:36-41,177-205. Repeated crashes before promotion can admit multiple queued recovery continuations because each new execution receives a new execution ID and continuation ID.packages/core/src/session/message-updater.ts:261-271 settles pending and running tools with Tool execution outcome unknown after server restart, while .lore.md:231,475 requires exact text Tool execution interrupted.packages/core/test/session-projector.test.ts:86-123.EventV2 at packages/core/src/event.ts:236-353 and packages/core/src/session/projector.ts:390-430; execution and continuation unique indexes at packages/core/src/session/sql.ts:186-190 prevent 2 successful recoveries of the same execution.packages/core/src/session/recovery.ts:21; owner_id is written but never consulted by recovery. A second process sharing the database can recover work still owned by a live first process. Assistant considered this acceptable only under the repositoryβs single-process execution limit, not clustered-safe; the test named across repeated startup scans is sequential rather than concurrent at packages/core/test/session-projector.test.ts:200-201.packages/core/src/database/migration/20260914170650_session-recovery.ts:4-23, execution table and recovery column migration packages/core/src/database/migration/20260914214636_session-execution.ts:4-24, then phase column migration packages/core/src/database/migration/20260914222526_session-execution-phase.ts:4-9, registered at packages/core/src/database/migration.gen.ts:43-45.packages/core/src/session/sql.ts:168-210 and packages/core/src/database/schema.gen.ts:157-203,273-298; however, no changed test applies the 3 incremental migrations to a database at the exact base schema, and fresh in-memory layers use the generated final schema, so upgrade-only failures can escape detection.Step.Interrupted and Step.Recovered are durable and included in both event inventories at packages/schema/src/session-event.ts:196-221,475-542.packages/core/test/session-projector.test.ts:135-156 clears projections and replays recorded immutable event data.packages/core/src/session/recovery.ts:25-38, and the projector checks again inside the event transaction at packages/core/src/session/projector.ts:393-409.packages/core/src/session/recovery.ts:33-35, covered by packages/core/test/session-projector.test.ts:216-259.safe atomically with Compaction.Ended at packages/core/src/session/runner/llm.ts:319-337 and packages/core/src/session/compaction.ts:223-234; transaction structure was judged correct, though tests do not independently prove the commit.SessionRecovery.node at packages/server/src/routes.ts:27-39 and packages/opencode/src/server/routes/instance/httpapi/server.ts:299-304.packages/core/test/session-execution-local.test.ts:67-78.DO-NOT-MERGE.