---
phase: 02-rust-dict-export-rename
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
  - src/helpers.rs
autonomous: true
requirements: [RENAME-03]

must_haves:
  truths:
    - "opendeviationbar_to_dict() emits 'open_time_us' and 'close_time_us' keys"
    - "cargo test passes with no failures"
    - "maturin develop builds successfully"
  artifacts:
    - path: "src/helpers.rs"
      provides: "Dict export with _us key names for microsecond timestamps"
      contains: "open_time_us"
  key_links:
    - from: "src/helpers.rs"
      to: "python/opendeviationbar/"
      via: "PyO3 dict keys consumed by Python layer"
      pattern: "open_time_us|close_time_us"
---

<objective>
Rename dict export keys from `_ms` to `_us` in helpers.rs so the Rust-to-Python dict bridge emits truthful column names matching the actual microsecond values.

Purpose: Establishes the source-of-truth naming that Python (Phase 4) and ClickHouse (Phase 3) will follow.
Output: Updated `src/helpers.rs` with `open_time_us`/`close_time_us` keys.
</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
@.planning/phases/01-test-hygiene/01-01-SUMMARY.md
</context>

<interfaces>
<!-- From src/helpers.rs lines 101-104 (current, to be changed): -->
```rust
// Timestamps + OHLCV Core — values are MICROSECONDS, column names stay _ms
// until CH schema migration (Plan 05-04). All SQL arithmetic uses /1000000.
dict.set_item(ikey(py, "open_time_ms"), bar.open_time)?;
dict.set_item(ikey(py, "close_time_ms"), bar.close_time)?;
```

Values `bar.open_time` and `bar.close_time` are already raw microseconds (no division).
Only the string key names and the comment need updating.
</interfaces>

<tasks>

<task type="auto">
  <name>Task 1: Rename dict export keys from _ms to _us in helpers.rs</name>
  <files>src/helpers.rs</files>
  <read_first>src/helpers.rs (lines 95-110)</read_first>
  <action>
In `src/helpers.rs`, function `opendeviationbar_to_dict()`:

1. Update the comment block at lines 101-102 from:

   ```
   // Timestamps + OHLCV Core — values are MICROSECONDS, column names stay _ms
   // until CH schema migration (Plan 05-04). All SQL arithmetic uses /1000000.
   ```

   to:

   ```
   // Timestamps + OHLCV Core — values are raw MICROSECONDS with truthful _us keys
   ```

2. Rename the two dict keys (lines 103-104):
   - `"open_time_ms"` -> `"open_time_us"`
   - `"close_time_ms"` -> `"close_time_us"`

3. Do NOT change the values — `bar.open_time` and `bar.close_time` are already raw microseconds. No division to remove.

4. Do NOT touch any other file. The opendeviationbar-client crate has its own `_ms` fields in SSE structs — those are out of scope for RENAME-03.

5. Run `cargo test` to verify no Rust test breaks (no Rust test references these dict string keys).

6. Run `maturin develop --python 3.13` to rebuild the Python extension so the new keys are available.

Per RENAME-03: "All Rust dict export references (helpers.rs) updated from \_ms to_us"
</action>
<verify>
<automated>cd /Users/terryli/eon/opendeviationbar-py && cargo test 2>&1 | tail -5 && grep -n "open_time_us\|close_time_us" src/helpers.rs</automated>
</verify>
<acceptance_criteria>

- `src/helpers.rs` contains `"open_time_us"` and `"close_time_us"` (zero occurrences of `"open_time_ms"` or `"close_time_ms"`)
- `cargo test` passes with zero failures
- `maturin develop` builds successfully
  </acceptance_criteria>
  <done>helpers.rs dict export emits_us keys for microsecond timestamp values, cargo test green, extension rebuilt</done>
  </task>

</tasks>

<verification>
```bash
# Verify no _ms keys remain in helpers.rs dict export
grep -c "open_time_ms\|close_time_ms" src/helpers.rs  # expect 0

# Verify \_us keys present

grep -c "open_time_us\|close_time_us" src/helpers.rs # expect 2

# Cargo test

cargo test 2>&1 | tail -3

```
</verification>

<success_criteria>
- RENAME-03 satisfied: helpers.rs dict export uses `_us` keys
- Zero `_ms` timestamp key references remain in `src/helpers.rs`
- `cargo test` passes
- Extension rebuilt via `maturin develop`
</success_criteria>

<output>
After completion, create `.planning/phases/02-rust-dict-export-rename/02-01-SUMMARY.md`
</output>
```
