thedotmack/claude-mem · warning
Sync hub epoch changed — cursor reset, full re-pull…
Error message
Sync hub epoch changed — cursor reset, full re-pull required, eligible native revisions requeued
What it means
SyncApply detects that the hub epoch stored locally differs from the epoch reported by the hub, meaning the hub's change history was reset or replaced. The library resets the sync cursor and requeues eligible native revisions because incremental deltas are no longer valid against the new epoch. This is a warning, not a crash: applyOps continues after performing the reset inside a transaction.
Solutions
- Accept the full re-pull: let the client re-pull all data from the new epoch (this is the designed recovery path).
- Verify the hub URL/DB is the intended one — confirm you did not accidentally point at a fresh or staging hub.
- If the epoch change was unintentional (hub rebuilt), restore the hub database that matches the stored epoch.
- If old requeued revisions conflict, clear local sync state and perform a clean initial sync.
Example fix
// before: stale hub URL in config hubUrl: 'https://sync-staging.internal' // after: point back at the hub holding the matching epoch hubUrl: 'https://sync-prod.internal'
Defensive patterns
Strategy: fallback
Validate before calling
const stored = loadStoredEpoch();
if (stored !== null && stored !== hubEpoch) {
console.warn('Epoch mismatch: full re-pull will occur');
} Prevention
- Pin the hub URL/instance and avoid switching between environments mid-sync
- Back up the hub DB before rebuilds to preserve the epoch
- Monitor for epoch-change warnings as a signal of hub rebuilds
When it happens
Trigger: applyOps -> handleEpoch when the locally stored epoch is non-null and the incoming hub epoch differs (hub server was recreated, its database wiped/re-seeded, or a different backend URL now serves a fresh epoch).
Common situations: Developer points the worker at a new/reset sync hub, restores the hub DB from a snapshot with a different epoch, or runs against a staging hub after previously syncing with production.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Backfill failed
- canonical content
- Chroma unavailable before write; leaving documents unsynced
- cloud sync ack conflict for
- cloud sync identity unavailable; refusing an unreplicated…
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/070438c0c6b2bab0.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/sync/SyncApply.ts:404
SELECT 1
FROM sync_launch_exclusions AS launch
WHERE launch.kind = ?
AND launch.origin_local_id = CAST(${table}.id AS TEXT)
AND (
LENGTH(launch.through_rev) > LENGTH(CAST(${table}.sync_rev AS TEXT))
OR (
LENGTH(launch.through_rev) = LENGTH(CAST(${table}.sync_rev AS TEXT))
AND launch.through_rev >= CAST(${table}.sync_rev AS TEXT)
)
)
)
`).run(kind).changes;
}
}
});
tx();
if (stored !== null) {
logger.warn('SYNC_APPLY', 'Sync hub epoch changed — cursor reset, full re-pull required, eligible native revisions requeued', {
oldEpoch: stored,
newEpoch: epoch,
requeued,
});
return true;
}
logger.info('SYNC_APPLY', 'Adopted initial sync hub epoch', { epoch });
return false;
}
// -------------------------------------------------------------------------
// applyOps
// -------------------------------------------------------------------------
/**
* Apply one pulled batch. Ops must be in ascending seq order (the hub
* returns them that way). Runs in ONE transaction: row upserts, mutation
* UPDATEs, and the cursor advance commit together or roll back together.View on GitHub (pinned to d8bc9755e7)