vault maintenance (defrag, resize, health, dynamic index)#88
Merged
Conversation
DefragMove struct, plan_defrag(), apply_move(), complete_defrag(), needs_defrag() methods with 7 unit tests.
DefragResult struct, vault_defragment() with crash-safe per-move WAL protection, post-commit secure erase of stale ciphertext, per-move checkpoint. 11 integration tests.
Add #[frb(non_opaque)] to DefragResult, per-move secure erase of stale ciphertext tail (after WAL commit), per-move WAL checkpoint, WalOp::WriteSegment in defrag + crash recovery test.
…tation Adelayoub/vault defragmentation
For now there's no functionality, it will be broken down into two different functions.
Ferhat/vault resize
Resize: WAL recovery now skips shadow write (position depends on capacity
which may differ after interrupted resize). Post-recovery reconciliation
fixes file size and shadow when index.capacity != actual file size.
Removed redundant shadow reads/writes and WAL reopens during grow/shrink.
Defrag: prevent data corruption on crash during overlapping moves (gap <
segment size). Save segment data to {vault}.defrag backup before
overlapping writes. vault_open restores from backup when both .defrag and
uncommitted WAL exist; deletes stale backup otherwise.
Added tests: same-capacity no-op, shrink-after-defrag, mid-grow crash
recovery, overlapping defrag move crash recovery.
Remove noisy comments, fix silent u32 truncation with try_from, add #[frb(non_opaque)] to VaultCapacityInfo, delegate vault_capacity() to health() to eliminate duplication, make types module public for FRB codegen, and add missing test assertions + full-capacity edge case.
Adel/vault health check
…defrag, resize, health
Replace fixed 64KB INDEX_PAD_SIZE with capacity-proportional index.
Header stores index_size (bytes 8-11) so vault_open reads it back.
- compute_index_size(): 64KB per MB, min 64KB, max 16MB cap
- VaultHeader gains index_size field (u32)
- Layout functions (shadow_index_offset, wal_region_offset,
total_vault_size, data_region_offset) take dynamic index_pad_size
- VaultHandle stores index_pad_size for all operations
- SegmentIndex::to_bytes(pad_size) accepts dynamic pad size
- read_encrypted_index validates allocation size (OOM guard)
- WAL MAX_SNAPSHOT_SIZE aligned to MAX_INDEX_PAD_SIZE + overhead
- 5 new tests: header roundtrip, compute_index_size edge cases
- 284/284 tests pass, clippy clean
…izing fix(evfs): scale segment index size with vault capacity
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.
Summary
used + free_list + unallocated == total)defragment,resize,health) + 7 integration testsdart analyzecleanWhat changed
Rust core
format.rs:compute_index_size(capacity),VaultHeader.index_sizefield (bytes 8-11), dynamic layoutfunctions
wal.rs:MAX_SNAPSHOT_SIZEaligned toMAX_INDEX_PAD_SIZEmod.rs:vault_defragment(),vault_resize(),vault_health()APIshelpers.rs:flush_index,read_encrypted_index,capacity_from_file_sizeaccept dynamic sizestypes.rs:VaultHandle.index_pad_size,DefragResult,VaultHealthInfo(withis_consistent)Dart
vault_service.dart:defragment(),resize(),health()static methodsevfs_test.dart: 7 new integration tests (defrag compact, defrag no-op, grow, shrink, shrink-reject, healthfresh, health lifecycle)
Security
index_sizedeterministic from file sizeMIN_INDEX_PAD_SIZE(64KB) /MAX_INDEX_PAD_SIZE(16MB) boundsread_encrypted_indexcap, WAL snapshot capTest plan
cargo clippy -- -D warningscleandart analyze— no issues found