Skip to content

refactor(transport): SSOT phase 3 — clean reconnect#440

Open
dimakis wants to merge 5 commits into
mainfrom
refactor/transport-ssot-p3
Open

refactor(transport): SSOT phase 3 — clean reconnect#440
dimakis wants to merge 5 commits into
mainfrom
refactor/transport-ssot-p3

Conversation

@dimakis

@dimakis dimakis commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove ownership dance from handleReconnect — reattach/rekey/zombie cleanup removed (~60 lines). handleSendV2 already handles all of this on the first user message, making it redundant on reconnect.
  • Remove periodic sync — 5s timer in ConnectionRegistry that retried missed events is eliminated (~130 lines). Cursor-based replay on welcome covers the gap.
  • Fire-and-forget reconnect POST — client no longer defers _connected until the reconnect POST succeeds (~100 lines). Connection is marked immediately on welcome; the POST is advisory.
  • Remove ReconnectMessage from WS union — reconnect is REST-only, not dispatched via WebSocket.

Net: -1,043 lines across 9 files. All 177 affected tests pass.

Context

Phase 3 of the Transport SSOT series (P0 #431, P1 #433). The reconnect "ownership dance" duplicated logic already handled by handleSendV2 on the first user message. Periodic sync was a safety net made redundant by cursor replay on welcome.

What's kept

  • /reconnect REST endpoint + handleReconnect handler (watch + cursor reset + EventStore replay + boot context + suspend resume)
  • Client-side doPost('reconnect', ...) on welcome (fire-and-forget)
  • ConnectionRegistry.resetCursor() and cursor tracking in broadcast()

Test plan

  • npx vitest run — all 177 tests pass (ws-handler-v2, connection-registry, sse-connection)
  • Manual: kill server mid-chat, restart → verify auto-reconnect + event replay
  • Manual: background iOS app, foreground → verify suspend/resume
  • Manual: send message after reconnect → verify session resumes via handleSendV2

🤖 Generated with Claude Code

dimakis and others added 5 commits July 4, 2026 12:13
handleReconnect no longer does reattach/rekey/zombie cleanup — that's
all handled by handleSendV2 on the first user message. Reconnect now
only does: watch + cursor replay + suspend resume + boot context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Periodic sync (5s timer retrying missed events) is redundant now that
reconnect replays via EventStore cursor on welcome. Removes setEventStore,
startPeriodicSync, stopPeriodicSync, EventStoreAdapter interface, and
all associated tests and wiring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reconnect POST no longer defers _connected — the client marks connected
immediately on welcome. handleSendV2 handles ownership on first message,
and replayed events arrive via SSE regardless of POST outcome.

Removes doReconnectPost, scheduleReconnect, reconnectTimer, and
reconnectDelayMs. Replaces 12 deferred/stale/failure tests with 4
fire-and-forget tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reconnect is REST-only — keep the schema export for the REST handler
but exclude it from IncomingWsMessageV2. The WS dispatcher already
ignores it with a comment explaining why.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion

Stale session test now asserts remove is NOT called (deferred to handleSendV2).
Suspend resume test clears reattachChat mock to avoid bleed from prior tests.

Co-Authored-By: Claude Opus 4.6 <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.

1 participant