Skip to content

Add backup and restore functionality for memory store#10

Merged
keepsloading merged 1 commit into
Memact:mainfrom
Ingole712521:fix/add_structural_validation
Jun 22, 2026
Merged

Add backup and restore functionality for memory store#10
keepsloading merged 1 commit into
Memact:mainfrom
Ingole712521:fix/add_structural_validation

Conversation

@Ingole712521

Copy link
Copy Markdown
Contributor

fix: #8
Add structural verification for memory JSON backup restore

Summary

  • Adds backup schema validation (src/memory-schemas.mjs) so restored JSON backups are checked against Memory entity models before use.
  • Adds restore helpers (src/backup-restore.mjs) — restoreMemoryFromBackup, parseMemoryBackupJson, and serializeMemoryBackup — with MemoryBackupValidationError for corrupt input.
  • Wires validation into storage so JSON file load and repository load verify backups; saves write only the clean backup shape (derived fields like graph and stats are recomputed on load).
  • Exports reindexMemoryStore from the engine so restored stores rebuild indexes safely after validation.

Why

Backups can be corrupted or tampered with (unknown keys, spoofed fields, invalid memory/relation types, bad visibility scopes). Loading them blindly could pollute the memory store or trust forged data. This change rejects invalid backups early and only restores structurally valid memory records.

- Introduced `backup-restore.mjs` for serializing and restoring memory backups.
- Updated `memory-schemas.mjs` with validation functions for memory backup shapes.
- Modified `storage.mjs` to integrate backup and restore processes during load and save operations.
- Added tests for backup and restore functionalities to ensure data integrity and validation.
@keepsloading

Copy link
Copy Markdown
Member

SSoC26 Labeling: This Pull Request has been automatically linked to the corresponding issue labels: Easy,SSoC26! Thank you for contributing!

@keepsloading keepsloading merged commit b02d4d7 into Memact:main Jun 22, 2026
@keepsloading

Copy link
Copy Markdown
Member

Hi @Ingole712521 👋 I noticed that this PR has been merged, but there is no corresponding dummy PR created in the main Context repository (Memact/Context) referencing this work. For SSoC26 tracking, please make sure to open a dummy PR in Memact/Context so your merged contribution can be verified and counted on the leaderboard. Thank you!

@keepsloading

Copy link
Copy Markdown
Member

No corresponding dummy PR was found in Memact/Context. Please create one referencing Memact/Memory#10 so this contribution can be tracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SSoC26] [Easy] test(memory): Add structural validation on backup restore

2 participants