Skip to content

feat(core): resume suspended sessions after service restart#36105

Merged
kitlangton merged 3 commits into
v2from
restart-recovery
Jul 9, 2026
Merged

feat(core): resume suspended sessions after service restart#36105
kitlangton merged 3 commits into
v2from
restart-recovery

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Addresses #35646

Summary

  • add a private session.time_suspended nullable timestamp with a partial index, following the table's existing time_compacting / time_archived idiom; it records suspension, not Session status, and stays out of public Session.Info
  • add SessionRestart, an inert core service with two actions: suspendActiveSessions and resumeSuspendedSessions
  • only the managed server (serve --service) invokes the actions: resume is forked on startup and suspend runs as a teardown finalizer, after connections close and before execution teardown interrupts drains
  • clear stale suspension through EventV2 live commit hooks on execution started/succeeded/failed; interruption preserves it so the suspend-then-interrupt teardown ordering holds; replay never recreates or destroys suspension
  • consume each suspension atomically (compare-and-clear returning the row) so a Session resumes at most once; resumed drains overlap with bounded concurrency
  • migration adds the nullable column with no historical backfill; old shutdown events never arm new work
  • fold SessionExecutionLocal back into SessionExecution as the main layer

Design 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 + one session.execution.started)
  • bun run migration --check (packages/core)
  • bun typecheck in core, server, cli, and opencode
  • file-scoped Prettier and oxlint
  • pre-push full repository typecheck: 31 packages passed

@kitlangton kitlangton merged commit 6524dfc into v2 Jul 9, 2026
7 checks passed
@kitlangton kitlangton deleted the restart-recovery branch July 9, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant