Skip to content

feat(storage): add bounded atomic backups#919

Closed
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/atomic-backup-service
Closed

feat(storage): add bounded atomic backups#919
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/atomic-backup-service

Conversation

@luoye520ww

Copy link
Copy Markdown
Collaborator

Problem

Data migrations and imports need a bounded backup primitive with atomic writes and validated restore before callers can safely integrate it.

Scope

This PR adds only the backup core and real temporary-directory tests. It does not hook migration, import/export, upgrades, UI, or automatic retention into callers.

Changes

  • Write non-sensitive text backups through the existing atomic writer.
  • Enforce per-backup, total-byte, and per-id count limits with bounded rotation.
  • Reject sensitive payloads, unsafe IDs, malformed records, symlink paths, path traversal, and checksum changes.
  • Restore with bounded chunked reads and before/after file validation.

Validation

pm.cmd exec vitest run src/main/services/atomic-backup-service.test.ts (3 passed)

pm.cmd run typecheck (passed)

pm.cmd --prefix kun run typecheck (passed)

pm.cmd run lint (passed)

pm.cmd run build (passed)

  • git diff --check (passed)

Review

Completed functional, lifecycle, data integrity, security, cross-platform, performance, compatibility, test quality, and scope review. The service is isolated from callers and only rotates files it created for the same backup id.

Follow-ups

Separate PRs should wire this service before config migration, project import, database migration, and app upgrade.

@luoye520ww

Copy link
Copy Markdown
Collaborator Author

This work is consolidated into #942, which combines the Thread Store Doctor, bounded backups, and schema write guard with one tested scope. Closing the duplicate to keep review focused.

@luoye520ww luoye520ww closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant