Data safety first

Rich backup beats empty latest.

Sync checks cloud first. If this device is empty but cloud has tasks, sessions, subjects, habits, exams, tests, or mock tests, IsotopeAI restores cloud before it uploads.

Source of truth

Canonical paths.

New writes go to canonical backup paths. Old import/export folders are still read so older users can recover data.

Main latest backup

{userId}/backups/latest.json

Backup history

{userId}/backups/history/{timestamp}-{hash}.json

Cloud mirror

{userId}/cloud-snapshot/latest.json

Restore rule

Do not overwrite study data.

Step 1

Count local data

The app checks tasks, sessions, subjects, habits, daily logs, tests, exams, mock tests, and timer state.

Step 2

Choose best cloud backup

A rich backup wins over a newer empty profile-only backup.

Step 3

Restore before upload

Fresh browsers must download and apply cloud data before writing canonical latest.

Blocked

BLOCKED_EMPTY_OVERWRITE

This code means cloud has richer data and the empty device is not allowed to replace it.

Read

Legacy paths

These are read for compatibility and can be promoted if they are best.

{userId}/imports/latest.json
{userId}/exports/latest.json
{userId}/cloud-snapshot/latest.json
Proof

Scripts

Use these from the repo root when you need proof.

node scripts/repair-user-backup.mjs --user <id> --dry-run
node scripts/prove-new-browser-restore.mjs
node scripts/validate-storage-cleanup.mjs --user <id> --dry-run