Stu Mason
Stu Mason

Activity

Pull Request Merged

PR #12 merged: feat: v1.1.0 - Automatic Background Sync with Full Audit Trail

Summary

  • Adds automatic background syncing with APScheduler for all users at configurable intervals
  • Implements rate-limit-aware orchestration that respects Polar API's 15-min and 24-hour windows
  • Creates priority queue system (CRITICAL/HIGH/NORMAL/LOW) for efficient multi-user sync
  • Adds comprehensive SyncLog model for complete audit trail of every sync operation
  • Implements consistent error classification with SyncErrorType enum
  • Enables post-sync analytics (automatic baseline recalculation and pattern detection)

Key Files

  • src/polar_flow_server/services/scheduler.py - APScheduler background sync
  • src/polar_flow_server/services/sync_orchestrator.py - Rate-limit aware orchestration
  • src/polar_flow_server/services/sync_error_handler.py - Error classification
  • src/polar_flow_server/models/sync_log.py - Comprehensive audit trail model
  • alembic/versions/f7g8h9i0j1k2_add_sync_logs_table.py - Migration for sync_logs table

Configuration

Env VariableDefaultDescription
SYNC_ENABLEDtrueEnable/disable automatic syncing
SYNC_INTERVAL_MINUTES60Sync cycle interval
SYNC_ON_STARTUPtrueRun sync immediately on startup
SYNC_MAX_USERS_PER_RUNrate-limit awareMaximum users per sync cycle
SYNC_STAGGER_SECONDS5Delay between user syncs

Test Plan

  • All 74 existing tests pass
  • Lint checks pass (ruff)
  • Type checks pass (mypy)
  • Manual integration test with real Polar API
  • Verify scheduler starts on app startup
  • Verify sync_logs populated after sync cycle

Stu Mason + AI [email protected]

+2240
additions
-29
deletions
13
files changed