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 syncsrc/polar_flow_server/services/sync_orchestrator.py- Rate-limit aware orchestrationsrc/polar_flow_server/services/sync_error_handler.py- Error classificationsrc/polar_flow_server/models/sync_log.py- Comprehensive audit trail modelalembic/versions/f7g8h9i0j1k2_add_sync_logs_table.py- Migration for sync_logs table
Configuration
| Env Variable | Default | Description |
|---|---|---|
SYNC_ENABLED | true | Enable/disable automatic syncing |
SYNC_INTERVAL_MINUTES | 60 | Sync cycle interval |
SYNC_ON_STARTUP | true | Run sync immediately on startup |
SYNC_MAX_USERS_PER_RUN | rate-limit aware | Maximum users per sync cycle |
SYNC_STAGGER_SECONDS | 5 | Delay 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