feat(core): resume suspended sessions after service restart#36105
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #35646
Summary
session.time_suspendednullable timestamp with a partial index, following the table's existingtime_compacting/time_archivedidiom; it records suspension, not Session status, and stays out of publicSession.InfoSessionRestart, an inert core service with two actions:suspendActiveSessionsandresumeSuspendedSessionsserve --service) invokes the actions: resume is forked on startup and suspend runs as a teardown finalizer, after connections close and before execution teardown interrupts drainscommithooks on execution started/succeeded/failed; interruption preserves it so the suspend-then-interrupt teardown ordering holds; replay never recreates or destroys suspensionSessionExecutionLocalback intoSessionExecutionas the main layerDesign doc:
specs/v2/session-restart-continuation.md. At-most-once by choice: losing one automatic continuation after a crash mid-handoff is safer than retry loops over ambiguous provider/tool work. Hard-crash recovery remains out of scope (#35642).Verification
bun run test -- test/session-execution.test.ts test/session-projector.test.ts test/database-migration.test.ts(packages/core, 40 tests)bun run test -- test/service.test.ts(packages/cli: election + suspension consumed + onesession.execution.started)bun run migration --check(packages/core)bun typecheckin core, server, cli, and opencode