# Live state cleanup before restarting paper/shadow experiments

Use when live entries are paused after a negative live-history review, but paper/shadow experiments should continue using Mainnet market data read-only.

## Pattern

1. Run read-only Mainnet reconcile first and inspect:
   - exchange open positions and open orders
   - reduce-only stops per open position
   - local runtime `open_entries`
   - kill-switch / block-new-entry state
2. If reconcile reports a local-only position such as `local_journal_position_without_exchange_position:<coin>`, treat it as a **local stale runtime-state problem**, not an exchange action request.
3. Before editing local live runtime state:
   - create a timestamped backup beside the state file
   - verify the coin is absent from exchange positions/orders
   - never submit a compensating order just to satisfy local state
4. Remove only the stale local `open_entries[coin]` row.
5. Keep new live entries blocked while any live position remains under review:
   - preserve the kill-switch file
   - set/preserve local `block_new_entries: true` in live runtime state if the runner reads it
6. Re-run read-only reconcile immediately. Success criteria:
   - `status=ok`
   - `alerts=[]`
   - `stops_missing_count=0`
   - existing exchange position still has a reduce-only stop
   - no new Mainnet signed action occurred
7. Only then restart paper/shadow jobs. Paper restart must be visibly side-effect-free:
   - `CTB_PAPER_TRADING=true`
   - `CTB_DRY_RUN=false` for simulated fills only
   - no `CTB_LIVE_TRADING_ALLOWED=true`
   - process env verified from `/proc/<pid>/environ`

## Pitfalls

- Do not confuse a clean reconcile for “live-ready”: open positions/orders before start and an active kill-switch still block autonomous live restart.
- Do not restart paper based only on a supervisor `started` list; wait briefly and verify `running=true` and `env_ok=true` after process startup.
- If a shadow strategy may run several minutes before writing signal/trade journals, verify PID/env/state mtime rather than assuming silence means failure.
