---
phase: 16-sidecar-aion-startup
plan: 02
subsystem: streaming-sidecar
tags: [ouroboros, aion-mode, sidecar, startup, cross-midnight, symbol-modes]
dependency_graph:
  requires:
    - phase: 16-sidecar-aion-startup
      plan: 01
      provides: Per-symbol OuroborosMode in Rust StreamManager via symbol_modes dict
  provides:
    - Branched sidecar startup: Aion symbols use checkpoint-resume, Day symbols use clean-slate
    - Conditional cross-midnight bar filters in both main loop and sync_flush
    - symbol_modes dict propagated through recovery/restart path
  affects: [kintsugi-aion, heartbeat-aion, sidecar-deployment]
tech_stack:
  added: []
  patterns: [mode-conditional-startup-branching, symbol-mode-dict-propagation]
key_files:
  created: []
  modified:
    - python/opendeviationbar/sidecar/__init__.py
    - python/opendeviationbar/sidecar/midnight.py
    - python/opendeviationbar/sidecar/recovery.py
key_decisions:
  - "symbol_modes built once in _create_engine() from registry, returned as 4th tuple element for propagation"
  - "Aion symbols get checkpoint injection + CH seeding; Day symbols get unchanged clean-slate DELETE path"
  - "DELETE loop iterates day_symbols only (not get_registered_symbols) to avoid deleting Aion bars"
  - "Cross-midnight filter defaults to 'day' for unknown symbols (safe backward compat)"
patterns-established:
  - "Mode-conditional startup: partition symbols by ouroboros_mode, run appropriate path for each set"
  - "symbol_modes propagation: _create_engine returns it, recovery.py passes it through restart"
requirements-completed: [SIDE-01, SIDE-02]
duration: 5min
completed: "2026-03-27T09:35:02Z"
---

# Phase 16 Plan 02: Sidecar Aion Startup Path Summary

Branched Python sidecar startup so Aion symbols resume from checkpoints (no midnight preflight, no clean-slate DELETE) while Day symbols retain the existing proven clean-slate path; cross-midnight filters made mode-conditional in both main loop and sync_flush

## Performance

- **Duration:** 5 min
- **Started:** 2026-03-27T09:29:19Z
- **Completed:** 2026-03-27T09:35:02Z
- **Tasks:** 2
- **Files modified:** 3

## Accomplishments

- Partitioned symbols into aion_symbols and day_symbols based on registry ouroboros_mode
- Aion startup path: checkpoint injection + ClickHouse seeding (skips midnight preflight and DELETE)
- Day startup path: unchanged clean-slate (midnight preflight + DELETE today + Parquet processing)
- Cross-midnight bar filter in main loop now conditional on symbol mode (Aion bars pass through)
- Cross-midnight bar filter in sync_flush now conditional via symbol_modes parameter
- \_create_engine() returns 4-tuple including symbol_modes; recovery.py propagates through restart
- symbol_modes dict passed to StreamManager constructor for Rust-side per-symbol mode handling

## Task Commits

Each task was committed atomically:

1. **Task 1: Branch \_create_engine() for Aion vs Day startup paths** - `fac3d5d` (feat)
2. **Task 2: Conditional cross-midnight filter in sync_flush** - `ab3fcd8` (feat)

## Files Created/Modified

- `python/opendeviationbar/sidecar/__init__.py` - Branched startup path, conditional cross-midnight filter in main loop, symbol_modes propagation
- `python/opendeviationbar/sidecar/midnight.py` - Added symbol_modes parameter to_sync_flush_rest_bars(), conditional cross-midnight filter
- `python/opendeviationbar/sidecar/recovery.py` - Extended return type to 4-tuple, propagates symbol_modes through restart

## Decisions Made

- symbol_modes dict built in_create_engine() from get_symbol_entries() registry, not rebuilt elsewhere
- DELETE loop restricted to day_symbols only (previously used get_registered_symbols which would include Aion)
- Cross-midnight filter defaults to "day" mode when symbol not found in symbol_modes (safe backward compat)
- fill_from_rest and sync_flush handle all symbols (Rust uses per-symbol mode via symbol_modes on config)

## 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 startup fully branched for Aion vs Day symbols
- Ready for kintsugi Aion repair and heartbeat Aion checks in later phases
- All existing Day-mode behavior preserved (backward compatible)

---

_Phase: 16-sidecar-aion-startup_
_Completed: 2026-03-27_
