Skip to content

fix(core): resume sessions after restart#35820

Closed
kitlangton wants to merge 3 commits into
v2from
session-recovery
Closed

fix(core): resume sessions after restart#35820
kitlangton wants to merge 3 commits into
v2from
session-recovery

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Addresses #35646

Summary

  • durably record Session execution lifecycle outcomes
  • recover Sessions whose latest execution was interrupted by server shutdown
  • serialize startup recovery with the existing cross-process EffectFlock
  • reuse existing stale-tool reconciliation so ambiguous side-effecting tools are failed rather than replayed

How it works

A recovering process acquires the global Session recovery lock before reading lifecycle state. It holds that lock while all interrupted Sessions resume. Other daemon candidates wait, then re-read lifecycle state after the first process has recorded session.execution.started or a terminal outcome, so they have nothing to resume. No new recovery table or migration is needed.

User interruptions, completed executions, failures, and unmatched execution starts are not resumed. Unexpected hard-process death still needs an explicit ownership/lease design because blindly resuming an unmatched start can duplicate provider work while another process remains alive.

Verification

  • bun run test -- test/session-execution-local.test.ts test/util/effect-flock.test.ts
  • bun typecheck in packages/core
  • file-scoped Prettier and oxlint
  • pre-push full repository typecheck: 31 packages passed

@kitlangton

Copy link
Copy Markdown
Contributor Author

Closing this draft because startup event scanning and a long-held recovery lock are the wrong shape. #35826 establishes single managed-daemon ownership first; the follow-up recovery change will use a bounded pending-recoveries projection instead of scanning history.

@kitlangton kitlangton closed this Jul 8, 2026
@kitlangton
kitlangton deleted the session-recovery branch July 9, 2026 17:21
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