Is there an existing issue for the same bug?
Environment (optional)
Memoria v0.4.0 (27107f5) upgrading to v0.5.1/current main; deployment compatibility target: MatrixOne 3.0.11.
Actual behavior
Code inspection found two legacy-snapshot compatibility gaps after subject_id was added:
- restore_table_from_snapshot deletes current rows before INSERT INTO target SELECT * FROM the historical snapshot. Historical and migrated tables have different column counts, so insertion can fail after deletion. These operations are non-atomic.
- memory_branch with from_snapshot inherits the historical schema but does not reconcile new columns before registering the branch. Subsequent operations can reference missing subject_id.
This is a code-level finding, not a report of observed production data loss. Exact-version runtime reproduction is required.
Expected behavior
Restore legacy snapshots using explicit compatible column mapping and defaults for new fields, validating/materializing the source before touching current rows. A failed replacement must not leave current data deleted. Branches created from historical snapshots must satisfy the current schema before exposure.
Steps to reproduce
- Create memories and a snapshot using the schema without subject_id.
- Upgrade and run the subject_id migration.
- Restore the historical snapshot; check data and failure safety.
- Create a branch from that snapshot, then read/write it with current code.
Additional information
Affected: memoria-git/src/service.rs, memoria-mcp/src/git_tools.rs, and memoria-storage/src/store.rs.
Add regression coverage for populated/empty historical snapshots, repeated restores, failures before/after deletion, and legacy snapshot branches. Validate on MatrixOne 3.0.11 and the development version. This fix is independent of the Astra scoped-key PR.
Is there an existing issue for the same bug?
Environment (optional)
Memoria v0.4.0 (27107f5) upgrading to v0.5.1/current main; deployment compatibility target: MatrixOne 3.0.11.
Actual behavior
Code inspection found two legacy-snapshot compatibility gaps after subject_id was added:
This is a code-level finding, not a report of observed production data loss. Exact-version runtime reproduction is required.
Expected behavior
Restore legacy snapshots using explicit compatible column mapping and defaults for new fields, validating/materializing the source before touching current rows. A failed replacement must not leave current data deleted. Branches created from historical snapshots must satisfy the current schema before exposure.
Steps to reproduce
Additional information
Affected: memoria-git/src/service.rs, memoria-mcp/src/git_tools.rs, and memoria-storage/src/store.rs.
Add regression coverage for populated/empty historical snapshots, repeated restores, failures before/after deletion, and legacy snapshot branches. Validate on MatrixOne 3.0.11 and the development version. This fix is independent of the Astra scoped-key PR.