From Wave 5 architecture audit, finding F-N-06. Severity: medium.
Code
`kalshi/ws/client.py:196`:
```python
await self._connection._set_state(ConnectionState.STREAMING)
```
After a successful reconnect, `KalshiWebSocket._recv_loop` reaches into `ConnectionManager`'s name-mangled `_set_state`. Everything else on `ConnectionManager` treats state transitions as internal.
Why it's a problem
- Leaky abstraction — the client pokes the manager's state machine.
- A refactor that renames or removes `_set_state` silently breaks the streaming state report.
- The `on_state_change` callback fires from the "wrong" caller.
Fix
Either:
- Add a public `mark_streaming()` (or similar) on `ConnectionManager` that performs the same transition.
- Have `ConnectionManager.reconnect()` perform the CONNECTED → STREAMING transition itself after resubscribe so the client doesn't need to.
The second option moves the transition where the rest of the state machine lives.
From Wave 5 architecture audit, finding F-N-06. Severity: medium.
Code
`kalshi/ws/client.py:196`:
```python
await self._connection._set_state(ConnectionState.STREAMING)
```
After a successful reconnect, `KalshiWebSocket._recv_loop` reaches into `ConnectionManager`'s name-mangled `_set_state`. Everything else on `ConnectionManager` treats state transitions as internal.
Why it's a problem
Fix
Either:
The second option moves the transition where the rest of the state machine lives.