Skip to content

Conversation

@natgurlain
Copy link
Contributor

Summary

  • Add APScheduler-based background job system with 6 scheduled jobs: memory consolidation (interval), goal check (interval), calendar scan (interval), strategist tick (interval), daily briefing (cron), and evening review (cron)
  • Add ConnectionManager WebSocket registry for broadcasting proactive/ambient messages to connected clients
  • Wire scheduler into app lifespan (start after DB init, shutdown before close) and register WS connections in the chat endpoint

Details

New modules:

  • src/scheduler/engine.pyinit_scheduler() / shutdown_scheduler() using AsyncIOScheduler, all jobs gated by settings.scheduler_enabled
  • src/scheduler/connection_manager.pyConnectionManager with connect, disconnect, broadcast (auto-prunes dead connections)
  • src/scheduler/jobs/memory_consolidation.py — Finds sessions updated within last hour and runs consolidate_session() (periodic catch-all alongside the ad-hoc trigger in ws.py)
  • src/scheduler/jobs/{goal_check,calendar_scan,strategist_tick,daily_briefing,evening_review}.py — Stub jobs logging execution, to be implemented in later Phase 3 PRs

Modified:

  • src/app.py — Scheduler init/shutdown in lifespan
  • src/api/ws.pyws_manager.connect() / disconnect() on WebSocket lifecycle

Tests (12 new):

  • ConnectionManager: connect/disconnect tracking, broadcast delivery, dead connection pruning
  • Scheduler engine: disabled returns None, enabled registers all 6 jobs, safe shutdown
  • Memory consolidation job: processes recent sessions, skips old ones, continues on individual failure

Test plan

  • All 144 tests pass (132 existing + 12 new)
  • Start backend: logs show "Scheduler started with 6 jobs"
  • Stub jobs log at configured intervals
  • SCHEDULER_ENABLED=false → no scheduler starts
  • WS connect/disconnect reflected in connection manager

🤖 Generated with Claude Code

Set up APScheduler-based background job system with WebSocket connection
registry for broadcasting proactive messages. Includes memory consolidation
job (periodic catch-all) and stub jobs for goal check, calendar scan,
strategist tick, daily briefing, and evening review.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@natgurlain natgurlain merged commit f14afe4 into main Feb 10, 2026
2 checks passed
@natgurlain natgurlain deleted the feat/scheduler-infrastructure branch February 10, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant