Three fixes for consolidation reliability:
1. Fire-and-forget API: POST /memory/consolidate now launches consolidation
as an asyncio background task and returns immediately. The old approach
blocked until Cat's WS response, which could take 5+ minutes (LLM
extraction calls), exceeding both the WS timeout and browser fetch
timeout. Web UI now polls /memory/status to track completion.
2. Increased timeout: cat_client.trigger_consolidation() timeout raised
from 300s to 600s (configurable via parameter). Logs unexpected WS
message types for debugging.
3. Better logging: Consolidation log messages prefixed with 🌙 for
grep-friendliness. cat_client errors include exc_info=True for
traceback visibility. Web UI shows elapsed time while polling.
Step 2 of memory system overhaul: automated scheduling.
- New consolidation_scheduler.py: run_nightly_consolidation() function that
checks Cat health, triggers consolidation via WebSocket, and tracks
run history with success/failure stats
- bot.py on_ready: register APScheduler cron job (hour=4, minute=0)
alongside the existing daily DM analysis job
- routes/memory.py: expose consolidation status (last_run, last_result,
last_error, is_running, total_runs, successful_runs) in the
/memory/status API response
- Web UI: show consolidation schedule info (last run time, success/fail,
run counts) below the manual consolidate button, with 'running now'
indicator when active
The 'sleep consolidation' metaphor is now actually automated instead of
being manual-only.
- 217 error returns across 18 route files + api.py now use JSONResponse
with appropriate HTTP status codes instead of returning HTTP 200
- Status code distribution: 500 (121), 400 (39), 503 (28), 404 (24), 409 (3), 502 (2)
- Fixed language.py tuple-return bug (was serializing as JSON array)
- Fixed bare except clauses in bipolar_mode.py and voice.py
- Body-level error schemas preserved (status/error + success/error patterns)
so web UI continues working without changes
- chat.py (SSE) unchanged: errors sent within stream protocol
- All 170 tests pass