---
phase: 05-dead-code-cleanup
plan: 02
type: execute
wave: 1
depends_on: []
files_modified:
  - python/opendeviationbar/orchestration/helpers.py
  - python/opendeviationbar/config/sidecar.py
  - crates/opendeviationbar-core/src/normalization_lut.rs
  - crates/opendeviationbar-streaming/src/indicators.rs
  - crates/opendeviationbar-streaming/src/stats.rs
  - crates/opendeviationbar-streaming/src/lib.rs
  - crates/opendeviationbar-cli/Cargo.toml
  - crates/opendeviationbar-core/Cargo.toml
  - Cargo.toml (workspace root)
autonomous: true
requirements: [CLEAN-02, CLEAN-03]

must_haves:
  truths:
    - "No stale TODOs referencing closed issues remain"
    - "No unused Rust dependencies remain in Cargo.toml files"
    - "No dead public modules remain in streaming crate"
    - "mise run check-full passes after all removals"
  artifacts:
    - path: "python/opendeviationbar/orchestration/helpers.py"
      provides: "Stale TODO(Issue #59) removed or updated"
    - path: "crates/opendeviationbar-core/src/normalization_lut.rs"
      provides: "Stale TODO Task #197 removed or updated"
  key_links:
    - from: "crates/opendeviationbar-streaming/src/lib.rs"
      to: "crates/opendeviationbar-streaming/src/indicators.rs"
      via: "pub mod re-export"
      pattern: "pub mod indicators"
---

<objective>
Remove dead Rust code, unused dependencies, and stale TODOs identified in the adversarial audit (#298).

Purpose: Clean up ~600 LOC of dead Rust modules (indicators, stats in streaming crate), unused Cargo dependencies, stale TODOs pointing to closed issues, and minor Python dead code. The Python dead functions from #298 have already been cleaned in prior sessions.

Output: Clean codebase with no dead public modules, no unused dependencies, no stale TODOs.
</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/STATE.md
</context>

<tasks>

<task type="auto">
  <name>Task 1: Remove dead Rust code and unused dependencies</name>
  <files>
    crates/opendeviationbar-streaming/src/indicators.rs
    crates/opendeviationbar-streaming/src/stats.rs
    crates/opendeviationbar-streaming/src/lib.rs
    crates/opendeviationbar-cli/Cargo.toml
    crates/opendeviationbar-core/Cargo.toml
    Cargo.toml
  </files>
  <read_first>
    - crates/opendeviationbar-streaming/src/lib.rs
    - crates/opendeviationbar-streaming/Cargo.toml
    - crates/opendeviationbar-cli/Cargo.toml
    - crates/opendeviationbar-core/Cargo.toml
    - Cargo.toml (workspace root, check [workspace.dependencies])
  </read_first>
  <action>
Per #298 audit findings, remove dead Rust code:

1. **Dead streaming modules (~400 LOC)**: Remove `indicators.rs` (5 unused indicators: SMA, EMA, MACD, RSI, CCI) and `stats.rs` (StreamingStatsEngine, never used externally) from `crates/opendeviationbar-streaming/src/`. Remove their `pub mod` declarations from `lib.rs`. Verify no external crate imports these modules first: `grep -r "indicators\|StreamingStatsEngine\|SMA\|EMA\|MACD\|RSI\|CCI" crates/ src/ --include="*.rs" | grep -v "opendeviationbar-streaming/src/"`.

2. **Unused Cargo dependencies**:
   - `opendeviationbar-cli/Cargo.toml`: Remove `opendeviationbar-batch`, `opendeviationbar-streaming`, `polars` if they are listed but never imported. Verify with: `grep -r "opendeviationbar_batch\|opendeviationbar_streaming\|polars" crates/opendeviationbar-cli/src/`.
   - `opendeviationbar-core/Cargo.toml`: Move `serde_json` to `[dev-dependencies]` if only used in `#[cfg(test)]`. Verify: `grep -r "serde_json" crates/opendeviationbar-core/src/ | grep -v "#\[cfg(test)\]"` — if no non-test uses, move it.
   - `opendeviationbar-core/Cargo.toml` and root `Cargo.toml`: Remove top-level `arrow` dep if only sub-crates (`arrow-array`, `arrow-schema`) are used. Verify: `grep -r "^use arrow::" crates/opendeviationbar-core/src/ src/`.

3. **Suppressed dead code**: Remove `#[allow(dead_code)]` from `combined_ws.rs` WsControlRateLimiter if it truly has no callers (check with grep). Remove `init()` from `opendeviationbar/src/lib.rs:204` if empty and uncalled.

After each removal, run `cargo check --workspace` to verify compilation. Do NOT remove anything that causes a compilation error — restore and skip it.
</action>
<verify>
<automated>cd /Users/terryli/eon/opendeviationbar-py && cargo check --workspace 2>&1 | tail -5</automated>
</verify>
<acceptance_criteria> - indicators.rs and stats.rs removed from streaming crate (or confirmed still needed) - Unused Cargo dependencies cleaned up - cargo check --workspace passes - No #[allow(dead_code)] on truly dead items
</acceptance_criteria>
<done>Dead Rust modules and unused dependencies removed, workspace compiles cleanly</done>
</task>

<task type="auto">
  <name>Task 2: Clean stale TODOs and minor Python dead code</name>
  <files>
    python/opendeviationbar/orchestration/helpers.py
    python/opendeviationbar/config/sidecar.py
    crates/opendeviationbar-core/src/normalization_lut.rs
  </files>
  <read_first>
    - python/opendeviationbar/orchestration/helpers.py (lines 730-740)
    - python/opendeviationbar/config/sidecar.py (line 217)
    - crates/opendeviationbar-core/src/normalization_lut.rs (lines 325-370)
  </read_first>
  <action>
1. **Stale TODO in helpers.py:735**: `TODO(Issue #59)` — check if Issue #59 is closed (`gh issue view 59 --json state -q .state`). If closed, remove the TODO comment. Keep the `_ = inter_bar_lookback_count` line (parameter is still accepted by the API) but update the docstring to note inter-bar features are not yet supported for Exness without referencing a closed issue.

1. **Stale TODOs in normalization_lut.rs:330,366**: `TODO Task #197` — check if Issue #197 is closed. If closed, remove the TODO comments from the `#[ignore]` attributes. Keep the `#[ignore]` if the tests genuinely should be ignored, but remove the stale issue reference.

2. **Unused variable in sidecar.py:217**: `env_settings` flagged by vulture (100% confidence). Read the surrounding context to understand if this is truly dead or if it is used later. If dead, remove it.

3. **Final sweep**: Run `grep -rn "TODO.*Issue #\|TODO.*Task #" python/ crates/ src/ --include="*.py" --include="*.rs" | head -20` to find any other stale TODOs. For each, check if the referenced issue is closed. Remove closed-issue TODOs.

Run `mise run check-full` after all changes.
</action>
<verify>
<automated>mise run check-full</automated>
</verify>
<acceptance_criteria> - No TODOs referencing closed issues remain - Unused Python variables cleaned - mise run check-full passes (fmt + lint + test + deny)
</acceptance_criteria>
<done>All stale TODOs cleaned, unused variables removed, full quality gate passes</done>
</task>

</tasks>

<verification>
- `cargo check --workspace` passes
- `mise run check-full` passes
- `grep -rn "TODO.*Issue #59\|TODO.*Task #197" crates/ python/` returns nothing
- `cargo clippy --workspace -- -W dead_code 2>&1 | grep "warning" | wc -l` shows reduced warnings
</verification>

<success_criteria>
Dead Rust modules removed, unused dependencies cleaned, stale TODOs resolved. mise run check-full passes.
</success_criteria>

<output>
After completion, create `.planning/phases/05-dead-code-cleanup/05-02-SUMMARY.md`
</output>
