Appearance
UC-026.5: Deep System Resilience โ
๐ 1. Context & Problem Statement โ
- API Limits & Multi-Page Syncing: Ingesting historical activities was limited to 1 page (30 items), flooding users with years-old rides in the Inbox, while a Delta Sync should only import recent updates.
- Duplicate Activities & Clash Warning: High-latency multi-device submissions create duplicate entries. Syncing needs a conflict detection engine based on timestamp clashes.
- Distance Anomalies: Errors in GPS files or manual edits can cause extreme mileage inputs (e.g. >300 km) that throw off component wear calculation unless protected.
โ๏ธ 2. Backend Logic & API (apps/api) โ
- Incremental Sync Loop: Refactored
GET /api/strava/syncto paginate through pages of lengthper_pagedynamically until an incomplete page length is received. - Onboarding Seed Rule: On the user's initial sync (where
lastStravaSyncDateis null), set the status of exactly the first 2 activities to'PENDING'(to prevent inbox flood) and all remaining historical pages to'HISTORY'. - Deep Resync & Bulk API: Added
POST /api/strava/sync/deepfor historical resyncing andPOST /api/strava/activities/bulkfor multi-row confirmations.
๐จ 3. User Interface (apps/web) โ
- Double-Ingestion Clash Banners: Activities starting within 5 minutes of each other are flagged with a prominent "Duplicate Timestamp Clash" alert in the Inbox.
- Sanity Lock Bypass: Activities exceeding 300 km display an "Abnormal Distance" locked dialog. The user must manually click a confirmation checkbox to bypass the lock and confirm the ride.
- Bulk Actions Dashboard: A sticky bottom HUD allows select-all checking to bulk confirm or ignore multiple activities at once.
๐งช 4. Testing Requirements โ
- Integration Tests: Verify seed-rule logic on initial sync. Assert timestamp conflict grouping.