Impact Life Executive Dashboard v17 - Resilient Upstream Sync Edition
===============================================================

Reason for this update
----------------------
The upstream Payments API was observed timing out after about 120 seconds while more than 35 MB had already been received. A single one-day request can therefore be too large for the provider/proxy path.

What changed
------------
1. Initial provider requests are now minute-sized (default: 60 minutes), not one-day batches.
2. Responses are capped at a configurable safety size (default: 12 MB). If exceeded, the request is stopped early and the same range is split into smaller halves.
3. cURL timeout defaults to 90 seconds. Timeout-heavy ranges are split automatically before a typical 120-second gateway limit is reached.
4. Adaptive splitting continues down to a configurable minimum batch (default: 5 minutes).
5. Temporary network failures, HTTP 429 and HTTP 5xx responses use configurable retries (default: 2).
6. Automatic sync now resumes near the latest successfully covered Payments/Claims API range with a one-hour overlap instead of re-downloading a broad recent period every 10 minutes.
7. Payments and Claims keep independent success checkpoints. If Claims fails after Payments succeeds, the Payments checkpoint is still retained.
8. Existing UPSERT/deduplication logic is preserved, so overlap and adaptive slices do not create duplicate records.
9. Sync Settings now exposes Initial API Batch, Minimum Adaptive Batch, API Timeout, Maximum Response Size and Retry Count.
10. Dashboard/service-worker/cache assets are bumped to v17.

Existing deployment upgrade
---------------------------
A. Back up the application and database.
B. Replace the application files with this v17 package.
C. Run upgrade_sync_v17.sql against the current dashboard database. The PHP settings page also has a backward-compatible auto-upgrade path for these columns.
D. Open sync_settings.php and confirm the recommended values:
   - Initial API Batch: 60 minutes
   - Minimum Adaptive Batch: 5 minutes
   - API Request Timeout: 90 seconds
   - Maximum Response Size: 12 MB
   - Transient Retry Count: 2
E. Run a narrow Payments test first, then use the manual sync or cron scheduler.

Expected behavior after the reported timeout
--------------------------------------------
If a 60-minute slice is still too large or slow, its Sync Log can show FAILED for that parent attempt, followed by smaller child slices that complete successfully. The overall sync succeeds only after every required child slice completes.

Important
---------
Do not solve this issue only by raising the timeout above 120 seconds. That would remain vulnerable to an upstream gateway/proxy timeout and would continue transferring very large JSON payloads.
