Expand description
SSTable Validation Layer
Implements defense-in-depth validation for memory-mapped files to prevent crashes from corrupted, truncated, or tampered files.
§Safety Guarantees
- Pre-mmap validation: Verify file integrity before memory mapping
- Magic number check: Ensure file is valid SSTable format
- Size validation: Prevent reading beyond file boundaries
- Checksum verification: Detect bit rot and tampering
§Formal Safety Invariant
∀p ∈ MappedPages: validate_before_mmap(file) = Ok ⟹ p.valid = true
This establishes that all memory-mapped pages are valid before dereferencing.
Structs§
- SSTable
Validator - SSTable validator for pre-mmap validation
Enums§
- Validation
Error - Validation error types
Constants§
- FOOTER_
SIZE - Footer size in bytes
- MAGIC_
NUMBER - SSTable magic number: “AFFv2025” in ASCII
- MIN_
SSTABLE_ SIZE - Minimum valid SSTable size (header + at least one edge + footer) Header (8 bytes magic) + Edge (128 bytes) + Footer (144 bytes) = 280 bytes
Functions§
- validate_
sstable_ file - Validate SSTable file at path (convenience function)