Skip to content

test(session_manager): prove agent sessions survive daemon restart/upgrade (#2335)#2350

Open
harshitsinghbhandari wants to merge 2 commits into
AgentWrapper:mainfrom
harshitsinghbhandari:ao/agent-orchestrator-19/decouple-session-lifetime
Open

test(session_manager): prove agent sessions survive daemon restart/upgrade (#2335)#2350
harshitsinghbhandari wants to merge 2 commits into
AgentWrapper:mainfrom
harshitsinghbhandari:ao/agent-orchestrator-19/decouple-session-lifetime

Conversation

@harshitsinghbhandari

Copy link
Copy Markdown
Collaborator

Closes #2335 (the "do first" item).

Context

After tracing the runtime path end to end, #2335 was narrowed: the daemon is already disposable and agent sessions are already durable across restart/upgrade. The runtime lives out-of-process on both platforms (tmux server on Unix; detached conpty host + ptyregistry on Windows), graceful shutdown deliberately does not tear sessions down (daemon/daemon.go), and boot Reconcile adopts survivors. The one thing missing was an automated proof that this holds, which the issue flagged as "do first... if green, the bulk of this issue is closeable as already-done."

What this PR adds

TestReconcile_AdoptAcrossDaemonRestart drives the full boot-time Reconcile() pass over the exact mix of session states a daemon restart/upgrade leaves behind, and asserts sessions are decoupled from the daemon's lifetime:

  • Alive orchestrator → adopted in place: same id, still live, runtime never torn down, and no new session minted. This is the id-increment regression guard (the promptless-orchestrator adoption failure that used to mint a fresh id 14→15→16).
  • Alive worker → adopted as a no-op.
  • Dead worker (runtime died with the daemon) → work captured into a preserve ref, restore marker written, then relaunched under its original id on the same boot; one-shot marker consumed (Killed sessions resurrect as alive after Cmd+Q restart (stale session_worktrees restore marker) #2319).
  • Truly-dead, unmarked session → not resurrected (stays terminated).

Graceful ao stop and crash both converge on this same boot-time Reconcile path (shutdown does not teardown), so the test covers both.

Assessed and deferred (per the issue's own framing)

Verification

go build ./...   # clean
go vet ./...      # clean
go test ./...     # 1685 passed in 80 packages

🤖 Generated with Claude Code

harshitsinghbhandari and others added 2 commits July 2, 2026 19:26
…dopt (AgentWrapper#2335)

Add an end-to-end Reconcile() durability test covering the full mix of
session states a daemon restart/upgrade leaves behind: an alive
orchestrator and worker are adopted in place under their original ids
(no id increment, runtime never torn down), a worker whose runtime died
with the daemon is captured and relaunched under its original id, and a
truly-dead unmarked session is not resurrected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decouple agent-session lifetime from daemon lifetime (survive daemon restart/upgrade)

1 participant