<?php
// ============================================================
//  MediCore — Local ↔ Cloud Sync Configuration
//  File: includes/sync-config.php
//
//  Edit these constants before enabling sync/worker.php on the
//  Local Server, and before deploying api/sync-receiver.php on the
//  Cloud Server. See SYNC_ARCHITECTURE.md for the full design.
// ============================================================

// ── This branch's identity ─────────────────────────────────────
// Branch 1 is the default/only branch until more are provisioned.
// See SYNC_ARCHITECTURE.md §15 "Multi-branch support" before adding
// a second Local Server against the same Cloud Server.
if (!defined('SYNC_BRANCH_ID'))   define('SYNC_BRANCH_ID',   1);
if (!defined('SYNC_BRANCH_NAME')) define('SYNC_BRANCH_NAME', 'Main Branch');

// ── Cloud Server endpoint ───────────────────────────────────────
// Point this at your deployed api/sync-receiver.php once the Cloud
// Server exists. Until then, leave the placeholder — sync/worker.php
// will simply detect it can't connect, mark sync_status offline, and
// keep queuing locally. Nothing is lost; nothing breaks Local
// operations either way (see SYNC_ARCHITECTURE.md §5).
if (!defined('SYNC_CLOUD_URL')) {
    define('SYNC_CLOUD_URL', 'https://YOUR-CLOUD-SERVER.example.com/medicore/api/sync-receiver.php');
}

// ── Shared secret ────────────────────────────────────────────────
// Pre-filled with a random secret generated for this deployment.
// MUST match byte-for-byte with the Cloud Server's copy of this file
// (includes/sync-config.php on the cPanel side) or every batch will
// be rejected with "Invalid or missing signature". Treat it like a
// password: don't post it anywhere public. Regenerate on both sides
// together if you ever need to rotate it:
//   php -r "echo bin2hex(random_bytes(32));"
if (!defined('SYNC_SHARED_SECRET')) {
    define('SYNC_SHARED_SECRET', '57b54153ec4511793ee2512a448dd539b5bea28492533ed712e18ddbbb9812de');
}

// ── Tuning ────────────────────────────────────────────────────
if (!defined('SYNC_BATCH_SIZE'))       define('SYNC_BATCH_SIZE', 100);     // rows per HTTP push
if (!defined('SYNC_HTTP_TIMEOUT'))     define('SYNC_HTTP_TIMEOUT', 8);     // seconds — fail fast
if (!defined('SYNC_MAX_ATTEMPTS'))     define('SYNC_MAX_ATTEMPTS', 20);    // after this, row flagged 'failed' (still retried)
if (!defined('SYNC_BACKOFF_BASE_MS'))  define('SYNC_BACKOFF_BASE_MS', 2000);   // first retry ~2s later
if (!defined('SYNC_BACKOFF_MAX_MS'))   define('SYNC_BACKOFF_MAX_MS', 300000); // backoff caps at 5 minutes
