Recurring Bug Patterns

Edit
Last updated 2026-04-07 18:42 UTC
bugsdebuggingpatternsengineering

Recurring Bug Patterns

Patterns that have appeared multiple times — check here before debugging.

Trading Bugs

Phantom trades / PnL discrepancies

Symptom: Bot reports trades that don't appear on Polymarket, or P&L doesn't match wallet.
Cause: CLOB order placed but not filled; bot counts it as a trade before confirmation.
Fix: Always verify position via PolymarketClient.get_positions(), not local state.

Confidence over-inflation on small moves

Symptom: Bot betting at 0.65-0.70 confidence on 0.03-0.05% BTC moves, losing.
Cause: Booster stack (volume + flow + cross-asset) adds up to +0.08 regardless of move size.
Fix: Move-proportional boost scale: _boost_scale = min(1.0, abs(move_pct) / 0.08).
Location: bot_fishy.py before the booster section.

CL-EARLY tier multipliers never firing

Symptom: All trades at $10 base size even when conf > 0.88.
Cause: hard_cap_usdc was $14, but tier2 (2.4x) = $24 — always capped.
Fix: Raised hard_cap_usdc to $25.

Auto-tune overwriting manual config

Symptom: toxic_hours or min_move back to old values after manual reset.
Cause: strategy_adaptor auto-tune runs on schedule and uses historical data.
Fix: Add fields to config_locked_fields in trading_config.json to protect them.

Bot / Discord Bugs

Bot not responding to commands

Debug order: systemctl status → recent logs → should_respond() logic → memory files → taskboard.

Duplicate task callbacks / EXEC spam

Symptom: EXEC fires the same strategy message 7+ times.
Cause: Task processor loop bug — task marked processed but re-processed on next tick.
Fix: Add not r.get("processed") check before processing; set report["processed"] = True after.

bot_fishy.py rolling win-rate cooldown broken

Symptom: Circuit breaker fires too early or too late.
Cause: Rolling window was 8 trades; at 2 trades/hour actual volume, too few samples.
Fix: Extended to 16 trades, threshold stays 35%, cooldown 15min. Plus 2-red-window correlation skip.

Infrastructure Bugs

systemd EnvironmentFile in wrong section

Symptom: systemctl start fails with "Invalid section" error.
Cause: EnvironmentFile= placed in [Install] section instead of [Service].
Fix: Move EnvironmentFile= line to [Service] section.

VPS can't resolve own domain

Symptom: curl https://wiki.deepbluebase.xyz fails with DNS resolution error from within the server.
Cause: Local DNS doesn't see the new A record (external-only DNS propagation).
Fix: Use --resolve domain:443:IP for local testing, or test from external host.

Port 5432 already in use for Docker

Symptom: docker run -p 5432:5432 postgres fails.
Cause: System PostgreSQL already running on 5432.
Fix: Map to a different host port: -p 5433:5432.

Graphify / Knowledge Graph Bugs

Recursion depth exceeded during graph build

Symptom: Python RecursionError when running graphify on bots/.
Cause: _rebuild_code() follows symlinks and descends into node_modules (55k+ JS/TS files).
Fix: Manually collect only .py files with explicit exclusion: node_modules, pycache, symlinks, .* dirs.

generate() called with wrong arguments

Symptom: TypeError: generate() missing 7 required positional arguments.
Cause: Report generation function has a long signature that must be called exactly.
Fix: Call: generate(G, communities, cohesion, labels, gods, surprises, detection, token_cost, root, suggested_questions=questions)