diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 1dc2e63..82d927d 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1263,12 +1263,22 @@ docker logs -f trading-bot-v4 | grep "expected log message from fix" ### Critical Path Verification Requirements +**MANDATORY: ALWAYS VERIFY DRIFT STATE BEFORE ANY POSITION OPERATIONS (Dec 9, 2025)** +- **NEVER trust bot logs, API responses, or database state alone** +- **ALWAYS query Drift API first:** `curl -X POST /api/trading/sync-positions -H "Authorization: Bearer $API_SECRET_KEY"` +- **Verify actual position.size, entry price, current P&L from Drift response** +- **Only AFTER Drift verification:** proceed with close, modify orders, or state changes +- **Incident:** Agent closed position based on stale bot data when user explicitly said NOT to close +- **Why:** Bot logs showed "closed" but Drift still had open position - catastrophic if user wants to keep position open +- **This is NON-NEGOTIABLE** - verify Drift state before ANY position operation + **Position Manager Changes:** - [ ] Execute test trade with DRY_RUN=false (small size) - [ ] Watch docker logs for full TP1 → TP2 → exit cycle - [ ] SQL query: verify `tp1Hit`, `slMovedToBreakeven`, `currentSize` match Position Manager logs - [ ] Compare Position Manager tracked size to actual Drift position size - [ ] Check exit reason matches actual trigger (TP1/TP2/SL/trailing) +- [ ] **VERIFY VIA DRIFT API** before declaring anything "working" or "closed" **Exit Logic Changes (TP/SL/Trailing):** - [ ] Log EXPECTED values (TP1 price, SL price after breakeven, trailing stop distance)