Files

4.1 KiB

S-STORAGE-01..06 — Original Durable Key-Value Storage Engine (G-STORE)

  • Wave: Wave 7 (feat/roadmap-p2-wave7, branched from main at 43922d1)
  • Roadmap reference: docs/roadmap/subsystems/Storage.md, docs/roadmap/DEPENDENCIES.md

Scope & Ownership

  • Zero SQLite dependency (src/Storage/module.cmake: INTERNAL_DEPS Core Functional Time Memory Binary IO Async, zero external deps).
  • include/Void/Storage/Crc32c.hpp: native Castagnoli CRC32C (0x1EDC6F41 / reflected 0x82F63B78, golden "123456789" == 0xE3069283).
  • include/Void/Storage/Types.hpp: kStorageErrorDomain = 9, StorageErrorCode, Sequence, ByteView, OwnedBytes, OwnedValue, Durability::{Sync,Buffered}, Outcome::{NotCommitted,Committed,Unknown}, Limits (all roadmap defaults + non-zero validation), CommitReceipt, WriteFailure, ScanBounds (with prefix), ScanEntry, ScanPage, EngineState, EngineStats, unsigned-byte lexicographic comparator.
  • include/Void/Storage/FilePort.hpp + src/Storage/FilePort.cpp: FilePort, FileHandle, PosixFilePort (exclusive flock, EINTR/short-write loops, file & dir fsync, atomic same-dir rename capability check), and FaultInjectingFilePort for deterministic power-loss / short-write / sync-failure / rename-failure / unsynced-discard simulation.
  • include/Void/Storage/Format.hpp + src/Storage/Format.cpp:
    • V1 WAL (VOIDWAL1 64B segment header with CRC32C, 36B VWR1 record header with header CRC32C checked before allocating payload, 8B trailer with record CRC32C + repeated length, BEGIN/PUT/ERASE/COMMIT payloads with aggregate CRC32C).
    • V1 Immutable Sorted Table (VOIDTBL1 header, 32 KiB target sorted blocks with per-block CRC32C, sparse block index, checksummed VOIDTBF1 footer).
    • V1 Immutable Manifest (VOIDMNF1) and atomic CURRENT (VOIDCUR1).
  • include/Void/Storage/Batch.hpp, include/Void/Storage/Engine.hpp, src/Storage/Engine.cpp:
    • Conditional atomic Batch (put, erase, require_absent, require_version, require_value; rejects duplicate keys/conditions; sequence-based versioning prevents ABA).
    • Exclusive directory lock, minimal CURRENT/manifest bootstrap & WAL segment rotation publication before write admission, deterministic recovery with tail-only truncation of final active segment and fail-closed corrupt on damaged complete records or earlier closed segments.
    • Single serialized writer, pre-append reservation/encoding, infallible visibility publication, RecoveryRequired + Outcome::Unknown on post-append failure, pinned Snapshot/Cursor with continuation scans and page_too_small enforcement.
    • checkpoint() freezing memtable -> immutable table -> manifest -> CURRENT -> deferred retirement after snapshot pins release; bounded incremental compact() merging <= 4 overlapping runs while preserving versions needed by live snapshots.
  • include/Void/Storage/Tools.hpp + src/Storage/Tools.cpp: verify_directory (full block-level read-only verification), pinned export_backup / restore_backup, offline salvage_directory into a separate destination.
  • include/Void/Storage/AsyncAdapter.hpp + src/Storage/AsyncAdapter.cpp: bounded blocking async adapter following C-03 domain-result classification (stop before append -> NotCommitted, stop during sync -> retain until settled, sync succeeds after stop -> CommitReceipt, sync fails after append -> Unknown + RecoveryRequired, single delivery).
  • include/Void/Storage/Storage.hpp: umbrella header.
  • Tests & consumer: tests/standalone/Storage/Storage.cpp (CRC32C golden, format/overflow, model checker vs reference map, byte-offset truncation, corruption, fault-injected creation/rotation/sync/checkpoint/compaction crashes, retention under slow snapshots, async stop-race conformance, verify/backup/salvage), tests/package/StorageOnly/*, updated tests/package/InstalledComponents.cmake.

Verification Criteria

  • Standalone Storage;Testing RelWithDebInfo -Werror (zero external deps!): storage_* tests + ctest 2/2 (StorageOnly).
  • Full Wave 7 integrated RelWithDebInfo -Werror, full Debug ASan+UBSan -Werror, and Wave 7 Debug TSan subset.