---
phase: 04-combined-websocket-streams
plan: 02
type: execute
wave: 2
depends_on: [04-01]
files_modified: []
autonomous: false
requirements: [WS-03]

must_haves:
  truths:
    - "mise run check-full passes with both WS modes (combined and per_symbol)"
    - "Human has verified the implementation is correct and deployment-ready"
  artifacts: []
  key_links: []
---

<objective>
Validate combined WS implementation via full test suite and human review.

Purpose: WS-03 requires Stathera continuity validation. The automated part (check-full) runs here. The 24h+ production validation on bigblack happens post-deploy (per D-02, monitoring is a follow-up phase). This plan gates on human verification that the implementation is correct before shipping (per D-03 thorough validation).

Output: Verified, deployment-ready combined WS implementation.
</objective>

<execution_context>
@$HOME/.claude/get-shit-done/workflows/execute-plan.md
@$HOME/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/phases/04-combined-websocket-streams/04-01-SUMMARY.md
@.planning/phases/04-combined-websocket-streams/04-RESEARCH.md
</context>

<tasks>

<task type="auto">
  <name>Task 1: Full quality gate validation</name>
  <files></files>
  <read_first>
    .planning/phases/04-combined-websocket-streams/04-01-SUMMARY.md
  </read_first>
  <action>
    Run the full quality gate to confirm nothing is broken:

    1. `mise run check-full` -- fmt, lint, test, deny all pass
    2. `cargo nextest run -p opendeviationbar-providers -E 'test(combined_ws)' -x` -- all 19 existing combined_ws tests pass
    3. `cargo nextest run -p opendeviationbar-streaming -x` -- all streaming tests pass including new ws_mode tests
    4. Verify the feature flag works end-to-end with a quick Python smoke test:
       ```python
       import os
       os.environ["OPENDEVIATIONBAR_STREAMING_WS_MODE"] = "per_symbol"
       from opendeviationbar.config.sidecar import SidecarConfig
       c = SidecarConfig(symbols=["BTCUSDT"], thresholds=[250])
       assert c.ws_mode == "per_symbol"
       ```

    WS-03 note: Full Stathera continuity validation requires a 24h+ production run on bigblack. That is a post-deploy activity tracked by D-02 (follow-up monitoring phase). This task validates that the code is correct and ready for deployment.

  </action>
  <verify>
    <automated>cd /Users/terryli/eon/opendeviationbar-py && mise run check-full 2>&1 | tail -20</automated>
  </verify>
  <acceptance_criteria>
    - mise run check-full passes (zero errors)
    - All combined_ws tests pass
    - All streaming tests pass
    - Python feature flag smoke test passes
  </acceptance_criteria>
  <done>Full quality gate green. Implementation verified correct.</done>
</task>

<task type="checkpoint:human-verify" gate="blocking">
  <name>Task 2: Human verification of WS mode implementation</name>
  <files></files>
  <action>
    Present the implementation summary to the user for review. Combined WS 2-connection split with feature flag for rollback to per-symbol mode (Phase 4: WS-01, WS-02, WS-03 code-level).

    Key changes:
    1. WsMode enum (Combined default, PerSymbol rollback) in Rust LiveEngineConfig
    2. start_ws() branches: Combined spawns 2 CombinedWebSocketStream tasks (13+13 symbols by volume), PerSymbol spawns N BinanceWebSocketStream tasks
    3. Feature flag: OPENDEVIATIONBAR_STREAMING_WS_MODE env var (combined|per_symbol)
    4. Python SidecarConfig.ws_mode plumbed through PyStreamManager to Rust
    5. symbol_task is completely unchanged (mode-agnostic via mpsc channels)

    User should review:
    1. Rust changes in crates/opendeviationbar-streaming/src/live_engine/mod.rs -- confirm start_ws() correctly branches on WsMode
    2. types.rs -- confirm WsMode enum and split_symbols_by_volume() logic
    3. Python config -- confirm env var naming follows convention (OPENDEVIATIONBAR_STREAMING_WS_MODE)
    4. Volume-based symbol grouping looks reasonable for production
    5. Per-symbol fallback path correctly spawns BinanceWebSocketStream::run_with_reconnect per symbol
    6. Per D-03: Satisfied this is ready for production deployment + 24h Stathera validation

  </action>
  <verify>
    <automated>echo "Checkpoint: awaiting human approval"</automated>
  </verify>
  <acceptance_criteria>
    - Human has reviewed all changed files
    - Human approves the implementation as deployment-ready
  </acceptance_criteria>
  <done>Human approved implementation. Ready for production deploy.</done>
</task>

</tasks>

<verification>
1. `mise run check-full` passes
2. Human approves implementation
</verification>

<success_criteria>

- Full test suite green
- Human verified implementation is deployment-ready
- Ready for production deploy + 24h Stathera continuity monitoring (WS-03 production validation tracked in follow-up phase per D-02)
  </success_criteria>

<output>
After completion, create `.planning/phases/04-combined-websocket-streams/04-02-SUMMARY.md`
</output>
