Repository navigation
fix(export): keep junction dumps FK-consistent with soft-deleted memories - #1253
Merged
Merged
Conversation
…ries Structural export filtered memories to live rows but dumped room_memories, memory_edges, and timeline_events in full, so any store holding soft-deleted memories produced an export whose junction rows reference memories absent from the dump - failing FK-enforced import into a fresh store (or silently dangling with FK off). graph_nodes.memory_id pointing at a dead memory was exported verbatim for the same reason. Filter every memory-referencing section by the same liveness predicate at export time, null graph-node links to dead memories (mirroring the schema's ON DELETE SET NULL), and count manifest sections with the same filtered queries so manifest counts match the rows actually exported. Closes #1243
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Sep 15, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Structural export (
export_full) now keeps every memory-referencing section consistent with the live-memory filter the memories section already used:room_memories,memory_edges, andtimeline_eventsdumps join againstmemoriesand drop rows referencing a soft-deleted (deprecated = 1) memory (formemory_edges, both endpoints must be live).graph_nodesrows survive, but amemory_idpointing at a soft-deleted memory is exported asNULL(import-side effect matches the schema'sON DELETE SET NULLfor hard deletes).COUNT(*)over the raw tables even when the dump filtered them — already inconsistent formemoriestoday).STRUCTURAL_EXPORT_VERSIONstays1: import unchanged, old exports still import fine.Why
Any real production store accrues soft-deleted memories (contradiction resolution, forget flows). With one present, the export contained junction rows referencing memories absent from the dump, so FK-enforced import into a fresh store aborted the atomic import (or silently dangled with FK off). Found by the v0.18.0 pre-release cora scan. Closes #1243.
Testing
test_structural_export_drops_soft_deleted_memory_references: seeds live + soft-deleted memories with room membership, a memory edge, a timeline event, and graph-node links; asserts filtered sections, nulled node link, no dead content in the dump, manifest counts, and a clean FK-enforced import into a fresh store. Verified red before the fix (export carried 2 memories / 1 room link) and green after.cargo test -p uteke-core --lib: 561 passed / 0 failed (33 ignored).cargo fmt --checkandcargo clippy -p uteke-core --lib -- -D warningsclean.