# Roadmap: v1.5 Sidecar Startup Architecture

## Overview

Sub-minute sidecar startup with verify-first yesterday handling. Replace the 4-hour sequential yesterday repair with a fast integrity check + kintsugi signal file. Three phases: integrity check (Phase 7), kintsugi priority queue (Phase 8), and end-to-end validation (Phase 9).

## Phases

- [ ] **Phase 7: Yesterday Integrity Check + Signal File** - Replace _repair_yesterday_if_needed() with fast integrity check (crossover TID alignment + Stathera audit) and signal file for broken symbols. Scope: sidecar/midnight.py + new signal module. Requirements: STARTUP-01, STARTUP-02.
- [ ] **Phase 8: Kintsugi Yesterday Priority Queue** - Read yesterday-repair signal file, inject flagged symbols at HEAD of repair queue, consume + delete after processing. Scope: kintsugi/orchestrator.py + kintsugi/discovery.py. Requirements: STARTUP-03.
- [ ] **Phase 9: Sub-Minute Startup Validation** - Remove remaining yesterday repair code, end-to-end timing on bigblack, heartbeat startup time reporting, deploy + verify sub-60s. Scope: sidecar startup + heartbeat + deploy. Requirements: STARTUP-04.

## Phase Details

### Phase 7: Yesterday Integrity Check + Signal File

**Goal:** Replace blocking sequential yesterday repair with fast verify-then-signal.

**Success Criteria:**

- Clean yesterday detected in < 5s (2 CH queries per symbol)
- Broken symbols flagged with specific reason (orphan_misaligned, stathera_gap, stathera_overlap)
- Signal file written atomically to /var/tmp/opendeviationbar-yesterday-repair.json
- _repair_yesterday_if_needed() removed from sidecar startup critical path

**Requirements:** STARTUP-01, STARTUP-02

### Phase 8: Kintsugi Yesterday Priority Queue

**Goal:** Kintsugi consumes yesterday-repair signal and repairs flagged symbols with 24-worker parallelism.

**Success Criteria:**

- Signal file read at start of each kintsugi pass
- Flagged symbols injected at HEAD of repair queue (before normal shard discovery)
- Signal file consumed and deleted after processing
- Yesterday repairs complete within first kintsugi pass (< 5 min at 24 workers)

**Requirements:** STARTUP-03

### Phase 9: Sub-Minute Startup Validation

**Goal:** End-to-end proof that sidecar startup is < 60 seconds on bigblack.

**Success Criteria:**

- systemctl start to first WS trade processed < 60s (measured)
- No synchronous yesterday repair in startup critical path
- Heartbeat shows sidecar healthy within 2 cycles (10 min)
- Deploy + verify on bigblack

**Requirements:** STARTUP-04
