interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / store / README.md

143 lines · 8552 bytes Raw Blame History Source

native/store: torn_slot, Store v1 C twin, sealed store

All C (gnu11), no outside library, offline. Library objects use no heap, no clock and no I/O except through disk_dev / st_dev / ts_device; every buffer is a caller-provided workspace (st_workspace about 0.9 MiB, ss_workspace about 2.0 MiB, both meant for static storage).

filewhat
torn_slot.c/.hdual-slot torn-write-safe 4096-byte record (unchanged)
store_v1.c/.hStore v1 format (ADR 0015): ObjectId, CRC32C, catalog, commit record, superblock, genesis
store_engine.c/.hStore::open / transact / read_object twin of crates/aienos-kernel/src/store/engine.rs
store_disk.cunit adapter over native/disk: 512-byte blocks = 8 per unit, 4096 = 1, base LBA, no read-modify-write
store_sealed.c/.hM5 sealed store (envelopes + transaction records + anchor)
store_mem.cmem* for the freestanding build only

What the C twin covers

Byte-identity evidence

Sealed store layout (store_sealed.h)

Mount: st_open -> ts_recover -> verify every record (class, uuid, MAC, exactly one per generation 2..G, linked digests, every envelope claimed once with a matching digest, no other kinds) -> m5_evaluate_anti_rollback. An empty anchor is accepted only at generation 1.

Commit order: (1) if the anchor lags, write the anchor for the current generation; (2) seal envelopes and the record; (3) st_transact (Store generation G+1 durable); (4) ts_commit the anchor for G+1. A crash between (3) and (4) mounts as "prepared advance" (anchor one behind) and step (1) of the next transaction catches it up. Proven by a power cut at every block boundary.

Refused: Store rolled back under the anchor, anchor two behind, a missing anchor, a forked anchor, two anchor slots with one sequence, PRODUCTION/TEST mix, another store's anchor, other volume key, swapped / unclaimed / tampered envelopes, plaintext objects, generation skip, stale commit record, replayed record, broken chain, two records for one generation, an envelope claimed twice, a version-1 transaction record (SS_E_FORMAT_VERSION) and, at read, an envelope whose id or nonce prefix does not follow the version-2 rule.

Tests

make test (ends with AIENOS_STORE_NATIVE: PASS|FAIL), make sanitize (ASan + UBSan over all tests), make mutants (TORN_SLOT_MUTANTS and AIENOS_STORE_MUTANTS), make freestanding (nm -u closes over the sibling native objects), make lib-checks. All runs are host emulation over files.

tests/SEALED-COVERAGE.md maps the sealed store's rollback and nonce-safety properties (confidentiality under nonce misuse, authentication, replay, crash consistency, whole-image freshness) to these tests and mutants, including the independent envelope-id oracle and the undetected whole-image rollback (#32).

Every /* GUARD:name */ line in the four store sources is a mutant: `make mutants` deletes it and requires some store test to fail. Three Rust-parity checks are deliberately untagged because no input can reach them alone: the engine's root commit-id comparison (the superblock-to-commit match refuses the same case first), the adjacent-generations check (the predecessor check requires the same thing) and DuplicateObjectConflict inside one request (equal ObjectIds with different kind, version or bytes need a SHA-256 collision).

Not done