Skip to content

[AIT-672] transport: introduce explicit state enums for transport and turn lifecycle#52

Open
lawrence-forooghian wants to merge 3 commits intomainfrom
client-transport-state-machine
Open

[AIT-672] transport: introduce explicit state enums for transport and turn lifecycle#52
lawrence-forooghian wants to merge 3 commits intomainfrom
client-transport-state-machine

Conversation

@lawrence-forooghian
Copy link
Copy Markdown
Contributor

@lawrence-forooghian lawrence-forooghian commented Apr 13, 2026

Summary

  • Replace _closed boolean in ClientTransport with a ClientTransportState enum (READY, CLOSED)
  • Replace started/ended booleans in server Turn with a TurnState enum (INITIALIZED, STARTED, ENDED)
  • Rename the unrelated TurnState interface in TurnManager to ActiveTurnsEntry to free the name

Establishes infrastructure for explicit state machines, following the pattern used by Ably channels and chat rooms. No behaviour change — all existing guards are mechanically mapped to the new enums.

🤖 Generated with Claude Code

lawrence-forooghian and others added 3 commits April 13, 2026 13:50
Introduce an internal ClientTransportState enum with READY and CLOSED
cases, replacing the _closed boolean field. This establishes the
infrastructure for an explicit state machine, matching our other SDKs
and giving us a structure within which to introduce further states in
the future.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Free the TurnState name for the turn lifecycle state enum being
added in the next commit. The interface describes an entry in the
_activeTurns map, so ActiveTurnsEntry is a better fit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the two boolean flags (started, ended) tracking server turn
lifecycle with an explicit TurnState enum (INITIALIZED → STARTED →
ENDED). This makes valid transitions self-documenting and prevents
impossible states, consistent with how Ably's other SDKs model
lifecycle and with the ClientTransportState enum added in c13618c.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 92.73% 1992 / 2148
🔵 Statements 90.95% 2133 / 2345
🔵 Functions 93.33% 364 / 390
🔵 Branches 78.08% 898 / 1150
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/core/transport/client-transport.ts 92.03% 83.58% 90.9% 93.75% 160, 345, 362, 408, 454, 482, 570-580, 591, 611-624, 782, 839
src/core/transport/server-transport.ts 93.78% 70.93% 90.9% 94.15% 100-107, 189, 226-244
src/core/transport/turn-manager.ts 93.75% 80% 100% 93.75% 90, 93
Generated in workflow #48 for commit b640511 by the Vitest Coverage Report Action

@lawrence-forooghian lawrence-forooghian changed the title transport: introduce explicit state enums for transport and turn lifecycle [AIT-672] transport: introduce explicit state enums for transport and turn lifecycle Apr 13, 2026
@lawrence-forooghian lawrence-forooghian requested review from a team and JoaoDiasAbly and removed request for a team April 13, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant