thedotmack/claude-mem · error
cloud sync unavailable; refusing an unreplicated delete
Error message
cloud sync unavailable; refusing an unreplicated delete
What it means
deleteSyncedContent also refuses to delete a row that has an acknowledged entity head in sync_entity_heads when cloud sync is not configured/available at all. Such a row is known to replicas elsewhere; deleting it locally without sync would strand those replicas, so the route returns 503.
Solutions
- Re-enable and configure cloud sync so the delete can be replicated, then retry
- Delete the row through a device where sync is active
- If the data is truly orphaned, clear the matching sync_entity_heads row first so the guard no longer sees an acknowledged head
- Verify you are targeting the right record — the entity may be intentionally protected as replicated content
Example fix
// before
store.db.prepare('DELETE FROM observations WHERE id = ?').run(id); // 503 guard fires first
// after
store.db.prepare('DELETE FROM sync_entity_heads WHERE kind = ? AND origin_local_id = ?').run(kind, id);
store.db.prepare('DELETE FROM observations WHERE id = ? AND origin_device_id IS NULL').run(id); Defensive patterns
Strategy: validation
Validate before calling
const head = db.prepare('SELECT 1 FROM sync_entity_heads WHERE kind = ? AND origin_local_id = ?').get(kind, id);
if (head && !cloudSyncConfigured) throw new Error('Refusing delete: entity is replicated but sync is not configured'); Try / catch
const res = await fetch(`/api/summaries/${id}`, { method: 'DELETE' });
if (res.status === 503) {
const body = await res.json();
if (body.error.includes('unreplicated delete')) {
// re-enable sync or remove the entity head intentionally, then retry
}
} Prevention
- Keep cloud sync configured wherever a previously-synced database is used
- Treat sync_entity_heads as replication metadata — only clear it deliberately
- When migrating between machines, bring the sync configuration along with the database
- Surface 503 delete responses to the user instead of silently retrying forever
When it happens
Trigger: DELETE of an observation/summary/prompt whose row exists in sync_entity_heads (was previously synced) while cloudSync is unconfigured (cloudSync null or isConfigured() false) — the fallback SQL check finds an acknowledged head and returns 503.
Common situations: User disabled or never configured cloud sync but the local database still contains rows synced by a previous configuration; switching sync backends; restoring a database from a synced device onto a machine without sync configured.
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
- cloud sync identity unavailable; refusing an unreplicated…
- pull
- push
- Service initializing
- sync hub pull: malformed /changes response
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/7962282ab6a60f38.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/worker/http/routes/DataRoutes.ts:374
}
const cloudSync = this.dbManager.getCloudSync();
let entityRev: string | null = null;
if (cloudSync?.isConfigured()) {
if (!cloudSync.status().deviceId) {
res.status(503).json({ error: 'cloud sync identity unavailable; refusing an unreplicated delete' });
return;
}
entityRev = cloudSync.queueDelete(kind, originLocalId);
} else {
// A row with an acknowledged entity head must never be silently deleted
// while its sync identity is unavailable: that would strand replicas.
const acknowledged = store.db.prepare(`
SELECT 1 AS found FROM sync_entity_heads
WHERE kind = ? AND origin_local_id = ? LIMIT 1
`).get(kind, originLocalId) as { found: number } | undefined;
if (acknowledged) {
res.status(503).json({ error: 'cloud sync unavailable; refusing an unreplicated delete' });
return;
}
store.db.prepare(
`DELETE FROM ${table} WHERE id = ? AND origin_device_id IS NULL`
).run(originLocalId);
}
res.json({ success: true, id: originLocalId, kind, entity_rev: entityRev });
}
private handleGetStats = this.wrapHandler((req: Request, res: Response): void => {
const db = this.dbManager.getSessionStore().db;
const packageRoot = getPackageRoot();
const packageJsonPath = path.join(packageRoot, 'package.json');
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
const version = packageJson.version;
View on GitHub (pinned to d8bc9755e7)