---
phase: 17-kintsugi-aion-repair
plan: 02
subsystem: kintsugi
tags: [ouroboros, aion, kintsugi, stathera, tid-range-repair, parquet]

# Dependency graph
requires:
  - phase: 17-01
    provides: Per-symbol ouroboros_mode lookup via _get_mode_for_symbol() and conditional today-guard
  - phase: 14-rust-core-gap-fields-conditional-reset
    provides: Conditional Ouroboros reset in Rust processor (Aion skips midnight reset)
provides:
  - _repair_aion() function for TID-range gap repair of Aion symbols
  - Dispatch branch in _repair() routing Aion to TID-range and Day to day-recompute
affects: [heartbeat-aion-checks, fleet-recompute, kintsugi-daemon]

# Tech tracking
tech-stack:
  added: []
  patterns:
    [
      "TID-range repair: single continuous processor across day boundaries",
      "Parquet-first data sourcing with REST fallback for gap repair",
    ]

key-files:
  created: []
  modified:
    - python/opendeviationbar/kintsugi/repair.py

key-decisions:
  - "Aion interior gaps use include_incomplete=False (bars connect to next known bar)"
  - "Aion genesis shards use include_incomplete=True and mark last bar orphan"
  - "REST fallback delegates to _process_gap_fallback_starttime with overlap_strategy=replace"

patterns-established:
  - "Aion repair: single processor, no day resets, TID-filtered Parquet trades"

requirements-completed: [KINT-01]

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

# Phase 17 Plan 02: Aion Repair Strategy Summary

**TID-range gap repair for Aion symbols via \_repair_aion() with Parquet-first sourcing and single continuous processor**

## Performance

- **Duration:** 2 min
- **Started:** 2026-03-27T15:31:35Z
- **Completed:** 2026-03-27T15:33:30Z
- **Tasks:** 1
- **Files modified:** 1

## Accomplishments

- Implemented `_repair_aion()` function that reprocesses the exact TID range of a gap through a single continuous processor (no day-boundary resets)
- Added dispatch branch in `_repair()` routing Aion symbols to TID-range repair while leaving day-mode path completely unchanged
- Parquet-first data sourcing (zero network cost) with REST fallback for uncached days
- Orphan marking only for genesis Aion shards (forming edge), not interior gaps (bars connect seamlessly)

## Task Commits

Each task was committed atomically:

1. **Task 1: Implement \_repair_aion() and branch \_repair() dispatch** - `e60088d` (feat)

## Files Created/Modified

- `python/opendeviationbar/kintsugi/repair.py` - Added \_repair_aion() function and Aion dispatch branch in \_repair()

## Decisions Made

- Aion interior gaps use `include_incomplete=False` because the forming bar at the gap boundary connects to the next known bar
- Aion genesis shards use `include_incomplete=True` and mark the last bar as orphan (no next bar to connect to)
- REST fallback delegates to existing `_process_gap_fallback_starttime` with `overlap_strategy="replace"` for atomic writes
- Day-mode functions (`_try_parquet_day_replace`, `_try_vision_day_replace`, `_repair_under_lock`) are completely untouched

## Deviations from Plan

None - plan executed exactly as written.

## Issues Encountered

- Worktree was behind main (missing phase 13-17 Plan 01 changes). Resolved via fast-forward merge from main before starting work.

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness

- Kintsugi now supports both Day (day-recompute) and Aion (TID-range) repair strategies
- Ready for heartbeat Aion checks and fleet-wide Aion symbol onboarding
- All 6 kintsugi modules are Aion-aware: discovery, repair (with \_repair_aion), verify, telemetry, daemon, dead-letter

---

_Phase: 17-kintsugi-aion-repair_
_Completed: 2026-03-27_
