diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 612a17a..8d5839c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -84,6 +84,7 @@ 3. Comparing calculated values to source data 4. Testing with real trades when applicable 5. **CONFIRMING CODE IS DEPLOYED** - Check container start time vs commit time +6. **VERIFYING ALL RELATED FIXES DEPLOYED** - Multi-fix sessions require complete deployment verification **CODE COMMITTED ≠ CODE DEPLOYED** - Git commit at 15:56 means NOTHING if container started at 15:06 @@ -92,6 +93,42 @@ - If container older than commit: **CODE NOT DEPLOYED, FIX NOT ACTIVE** - Never say "fixed" or "protected" until deployment verified +**MULTI-FIX DEPLOYMENT VERIFICATION** +When multiple related fixes are developed in same session: +```bash +# 1. Check container start time +docker inspect trading-bot-v4 --format='{{.State.StartedAt}}' +# Example: 2025-11-16T09:28:20.757451138Z + +# 2. Check all commit timestamps +git log --oneline --format='%h %ai %s' -5 +# Example output: +# b23dde0 2025-11-16 09:25:10 fix: Add needsVerification field +# c607a66 2025-11-16 09:00:42 critical: Fix close verification +# 673a493 2025-11-16 08:45:21 critical: Fix breakeven SL + +# 3. Verify container newer than ALL commits +# Container 09:28:20 > Latest commit 09:25:10 ✅ ALL FIXES DEPLOYED + +# 4. Test-specific verification for each fix +docker logs -f trading-bot-v4 | grep "expected log message from fix" +``` + +**DEPLOYMENT CHECKLIST FOR MULTI-FIX SESSIONS:** +- [ ] All commits pushed to git +- [ ] Container rebuilt successfully (no TypeScript errors) +- [ ] Container restarted with `--force-recreate` +- [ ] Container start time > ALL commit timestamps +- [ ] Specific log messages from each fix observed (if testable) +- [ ] Database state reflects changes (if applicable) + +**Example: Nov 16, 2025 Session (Breakeven SL + Close Verification)** +- Fix 1: Breakeven SL (commit 673a493, 08:45:21) +- Fix 2: Close verification (commit c607a66, 09:00:42) +- Fix 3: TypeScript interface (commit b23dde0, 09:25:10) +- Container restart: 09:28:20 ✅ All three fixes deployed +- Verification: Log messages include "Using original entry price" and "Waiting 5s for Drift state" + ### Critical Path Verification Requirements **Position Manager Changes:** @@ -2013,7 +2050,19 @@ trade.realizedPnL += actualRealizedPnL // NOT: result.realizedPnL from SDK - **TypeScript interface:** Added `needsVerification?: boolean` to ClosePositionResult interface - **Git commits:** c607a66 (verification logic), b23dde0 (TypeScript interface fix) - **Deployed:** Nov 16, 2025 09:28:20 CET - - **Lesson:** In DEX trading, always verify state changes actually propagated before updating local state + - **Verification Required:** + ```bash + # MANDATORY: Verify fixes are actually deployed before declaring working + docker logs trading-bot-v4 | grep "Server starting" | head -1 + # Expected: 2025-11-16T09:28:20 or later + + # Verify close verification logs on next trade close: + docker logs -f trading-bot-v4 | grep -E "(Waiting 5s for Drift|Position verified closed|needsVerification)" + + # Verify breakeven SL uses database entry: + docker logs -f trading-bot-v4 | grep "Breakeven SL: Using original entry price" + ``` + - **Lesson:** In DEX trading, always verify state changes actually propagated before updating local state. ALWAYS verify container restart timestamp matches or exceeds commit timestamps before declaring fixes deployed. 46. **100% position sizing causes InsufficientCollateral (Fixed Nov 16, 2025):** - **Symptom:** Bot configured for 100% position size gets InsufficientCollateral errors, but Drift UI can open same size position