---
phase: 20-aion-aware-sidecar-startup
plan: 01
subsystem: sidecar
tags: [aion, crossover-tid, sidecar-startup, clickhouse, stathera]

requires:
  - phase: 16-sidecar-aion-startup
    provides: "Aion startup path with checkpoint-resume and per-symbol mode branching"
provides:
  - "Aion fill_from_rest seeded at max(ch_last_tid, crossover_tid - 1)"
  - "Targeted today-DELETE for Aion bars preserving pre-midnight bars"
  - "Zero midnight-boundary Stathera gaps on sidecar restart"
affects: [sidecar-startup, kintsugi-aion-repair, heartbeat-stathera]

tech-stack:
  added: []
  patterns: ["crossover-TID max-seed via Rust max() accumulation"]

key-files:
  created: []
  modified:
    - python/opendeviationbar/sidecar/__init__.py
    - python/opendeviationbar/sidecar/config_helpers.py

key-decisions:
  - "Crossover seed in _seed_trade_ids_from_clickhouse (self-contained, not _create_engine)"
  - "DELETE IN PARTITION with ouroboros_mode='aion' filter as belt-and-suspenders"

patterns-established:
  - "Aion startup: seed + DELETE today + fill_from_rest (mirrors Day path pattern)"

requirements-completed: [START-01, START-02, START-03]

duration: 2min
completed: 2026-03-27
---

# Phase 20 Plan 01: Aion-Aware Sidecar Startup Summary

**Crossover-TID max-seed + targeted today-DELETE for Aion symbols to eliminate 8 midnight-boundary Stathera gaps**

## Performance

- **Duration:** 2 min
- **Started:** 2026-03-27T19:57:27Z
- **Completed:** 2026-03-27T19:59:14Z
- **Tasks:** 2
- **Files modified:** 2

## Accomplishments

- Aion symbols seeded at max(ch_last_tid, crossover_tid - 1) via Rust max() accumulation
- Today's Aion bars DELETEd before fill_from_rest (pre-midnight bars preserved)
- Day-mode startup path completely unchanged (backward compatible)

## Task Commits

Each task was committed atomically:

1. **Task 1: Add crossover-TID-aware seeding for Aion symbols** - `7fcfb1a` (feat)
2. **Task 2: Add targeted today-DELETE for Aion symbols before fill_from_rest** - `113b822` (feat)

## Files Created/Modified

- `python/opendeviationbar/sidecar/config_helpers.py` - Added symbol_modes parameter + crossover-TID max-seed for Aion
- `python/opendeviationbar/sidecar/__init__.py` - Pass symbol_modes to seeding + Aion today-DELETE block

## Decisions Made

- Crossover seed logic placed inside `_seed_trade_ids_from_clickhouse` (keeps function self-contained)
- `DELETE IN PARTITION` with `ouroboros_mode = 'aion'` filter as belt-and-suspenders safety
- Non-fatal try/except on both crossover seed and DELETE (matches Day path error handling pattern)

## Deviations from Plan

None - plan executed exactly as written.

## Issues Encountered

None

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness

- Sidecar Aion startup path now eliminates midnight-boundary gaps
- Ready for deploy + restart verification on bigblack
- After deploy, Stathera audit should show zero midnight gaps for all Aion symbols

---

_Phase: 20-aion-aware-sidecar-startup_
_Completed: 2026-03-27_
