Skip to content

refactor(stream): clarify lifecycle and raw frame ownership - #48

Merged
Richard-LZ-Zhang merged 2 commits into
codex/order-lifecycle-storagefrom
codex/stream-lifecycle-readability
Nov 2, 2026
Merged

Richard-LZ-Zhang merged 2 commits into
codex/order-lifecycle-storagefrom
codex/stream-lifecycle-readability

Conversation

@Richard-LZ-Zhang

Copy link
Copy Markdown
Collaborator

The shared Stream previously selected between raw and decoded parsing hooks, while connection status changes were split between the receive loop and a generic status helper. This change gives each adapter one raw-frame entry point and makes lifecycle transitions update their related state before publishing status events.

Changes:

  • Keep start() and clarify that it schedules receiving without waiting for connection, subscriptions or book readiness. Give the receiver task and receive loop descriptive names.
  • Replace status() with private connection/gap/resync/error operations; retain a separate status emitter for construction and venue-specific redaction. WebSocket and gRPC loops use the same explicit lifecycle operations.
  • Make WebSocket handle_raw(raw) -> list[Event] the sole parsing contract. Adapters own framing, decoding and native/Python fallback. Preserve gRPC's decoded-message hook.
  • Rename the optional connection factory to websocket_connection_opener across adapters and tests.
  • Move attribute explanations above assignments across the SDK. The first commit isolates comment-only edits; the second contains the Stream refactor, affected tests and migration documentation in docs/streaming.md.

Validation against experimental base 1dc1999 and SDK head 7a71bd9:

  • Native streaming/adapter/parity suite: 324 passed, 3 optional-protobuf skips. The 323 sandbox-safe cases and loopback reconnect case were run separately because the sandbox blocks listening sockets.
  • Forced-Python streaming suite: 257 passed, 70 skipped (67 native-only cases and 3 optional-protobuf cases).
  • Feed, combo-warmer and server integration tests: 77 passed.
  • All 73 nonfunctional Python-file changes preserve executable ASTs and real module/class/function docstrings after removing only standalone explanatory strings.
  • Independent in-session reviews covered lifecycle/cancellation, adapter compatibility, native fallback, credential redaction, performance and maintainability. No unresolved findings. Added migration guidance after review.
  • git diff --check passed. No live venue or account execution tests were run.

Compatibility: the approved constructor/hook/status renames require custom subclasses and diagnostic callers to migrate as documented. This PR targets codex/order-lifecycle-storage; it does not merge the experiment into public main or change release/version pins. MarketDataStream/UserDataStream separation, immutable public books, change waiting and queue-policy redesign remain outside this PR.

Review limitation: automatic approval rejected the optional external Codex CLI review because it would export repository content. No external CLI review was run; the in-session reviews above completed.

@Richard-LZ-Zhang
Richard-LZ-Zhang merged commit 7b91777 into codex/order-lifecycle-storage Nov 2, 2026
5 checks passed
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