Skip to main content

Module validation

Module validation 

Source
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

  1. Pre-mmap validation: Verify file integrity before memory mapping
  2. Magic number check: Ensure file is valid SSTable format
  3. Size validation: Prevent reading beyond file boundaries
  4. 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§

SSTableValidator
SSTable validator for pre-mmap validation

Enums§

ValidationError
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)