Storage layout
The object keys, the bundle format, and the stored record that every object Nova writes uses.
Nova stores records in two kinds of object. A transit bundle is one flight: recent records from many streams, written to a WAL slot. A stream object holds a run of one stream's records, copied out of transit bundles later. Both use one format, the bundle. Every key can be derived from metadata, so no read lists a bucket. Every object is written once, with a create that fails if the key exists, so no object is overwritten in place.
Where it lives
| Package | What it owns |
|---|---|
internal/objectkey | Every object key: WALSlot, LedgerPrefix, StreamObject, StreamObjectRevision, and their parsers |
internal/storage/bundle | Building, publishing, and reading bundles: the footer, point reads, and relocation into new objects |
internal/storage/codec | The shared encodings: the chunk directory, the chunk index, the trailer (chunkdir.go), and the stored record (stored.go) |
internal/storage/loglet | The slot envelope in front of a transit bundle |
Object keys
| Family | Key | Derived from | Lifetime |
|---|---|---|---|
| WAL slot (transit bundle) | Standard: wal/<h>/<star>/<epoch>/<seq>; Express: wal/<star>/<epoch>/<seq> | The ledger record and its slot layout, plus a slot number | Trimmed once absorbed and copied by denorm; poison stays until the star is decommissioned |
| Stream object | streams/<bucket>/<stream-id>/<epoch>/<firstSeq> | The catalog entry: bucket, stream, epoch, first record | Until trim or retention removes its last live record |
| Stream object revision | The same key with ~<revision> appended, revision 1 or more | The catalog entry's revision | The same; a new revision is published before the old one is repointed and reaped |
<seq> and <firstSeq> are zero-padded to 20 digits, so key order matches number order. The epoch is not padded.
func LedgerPrefix(layout SlotLayout, star stream.StarID, epoch stream.Epoch) string {
tail := star.String() + "/" + strconv.FormatUint(uint64(epoch), 10) + "/"
if layout == SlotLayoutHashed {
return "wal/" + ledgerHash(star, epoch) + "/" + tail
}
return StarSlotPrefix(star) + strconv.FormatUint(uint64(epoch), 10) + "/"
}
func StreamObject(bucket string, id stream.ID, epoch stream.Epoch, first stream.SeqNum) string {
return fmt.Sprintf("streams/%s/%s/%d/%020d", bucket, id, epoch, first)
}WAL slots
A node has one WAL per storage class. A WAL is a sequence of ledgers, one per epoch, and each ledger is a run of numbered slots. A reader that holds the ledger's layout, star, epoch, and a slot number reaches any slot with one point GET. Within a ledger, key order is slot order.
New Standard ledgers use the hashed layout. <h> is an FNV-1a hash of the star's 16 bytes and the epoch's 8, folded to 16 bits and written as four hex characters. Star IDs are UUIDv7, so they sort by time. Without the hash, every star's WAL would land in one fresh key range after a fleet roll, a range S3 has not yet split. Each ledger still keeps one prefix of its own, wal/<h>/<star>/<epoch>/. Express ledgers, and Standard ledgers minted with --wal-key-layout=star, use wal/<star>/<epoch>/<seq>: directory buckets scale per bucket, not per prefix.
The layout is recorded on the ledger when it is minted, and copied onto its span rows and denorm markers. Every reader derives keys from that record, so changing the flag affects new ledgers only.
Rolling back past the hashed layout
A build older than the hashed readers derives star-layout keys for a hashed ledger. It would fence a crashed node's hashed ledger as empty, which loses that ledger's acknowledged but unabsorbed records, and its trims would leave the ledger's slots behind. Never run such a build while hashed ledgers exist.
Stream objects
Stream object keys share a bucket and stream prefix, which suits cost reports, storage-class rules, and erasure. The key is a pure function of what the object covers, so a retried denorm derives the same key. Keys carry no random suffix. The catalog rows in the metadata store are the index, so no index object exists.
An object's storage class is stored in every reference, catalog entry, orphan intent, and due marker that names it. Nova picks the storage backend from that value, not from the key. Stream objects always use standard storage. Only live Express WAL slots use express storage.
Bundle format
A bundle holds chunks grouped by stream, a footer, and a fixed trailer. The object alone is enough to decode it.
[ slot envelope, 60 bytes, transit bundles only ]
[ chunk: stream A, records 1000..1130 ] stored records, back to back
[ chunk: stream B, records 7..9 ]
[ chunk: stream C, records 44100..44107 ]
[ footer: directory entries | chunk index ]
[ trailer, 40 bytes ]The slot envelope comes first in transit bundles only. It holds the magic CHNE, version 1, the kind (flight or poison), the epoch, the slot number, the writer nonce, the object size, the footer's offset and length, and a CRC-32C. WAL, slots and ledgers shows its encoding. A poison slot is the envelope alone. The bundle starts at byte 60, and every offset a reference stores counts from the start of the object.
A chunk holds consecutive records of one stream. Stored records sit back to back with no offsets, so a denorm job can copy a whole chunk into another object without decoding it.
The footer has a directory and a chunk index. Each directory entry records the stream, the first sequence number, the count, the data offset, the chunk's CRC-32C (DataCRC), and each record's length, timestamp, and end-of-batch flag. Version 2 adds content-byte counts and per-record checksums. The chunk index has one fixed-width row per chunk, sorted by stream and first sequence number:
// IndexRowSize is one chunk-index row: stream[16] firstID[8] count[8]
// chunkBytes[8] entryOff[4] entryLen[4] entryCRC[4]. Rows are fixed
// width and sorted by (stream, firstID), so a point reader
// binary-searches without decoding an entry.
const IndexRowSize = 52A reader binary-searches the index and decodes only the entry it needs. A probe that needs only byte ranges reads the index alone.
The trailer is 40 bytes: the magic CBDL, the format version, the directory's offset, length, and CRC, and the index's length and CRC. Readers fetch the footer at the coordinates a reference or envelope gives. With only the object's size, they read the trailer first. The writer stamps version 2, and readers accept versions 1 and 2. A version outside that range returns ErrUnsupportedVersion, which is separate from ErrCorrupt, so an operator can tell old software from damaged data.
Stored record format
A stored record is a flag byte, an optional header table, and the body. The directory holds its total length, sequence number, timestamp, and checksums. Record and batch limits count content bytes: the body plus header names and values.
┌──────┬───────┬─────────────────────────────┬────────────────┬──────┐
│ flag │ count │ (nameLen, valueLen) × count │ names + values │ body │
└──────┴───────┴─────────────────────────────┴────────────────┴──────┘
└── header table: only when the record has headers ───┘
flag byte, bits from the least significant
bits 0-1 count width 00 = no headers: the body follows at once
01 = the count is one byte
10, 11 = reserved
bits 2-3 name-length width 00…11 = 1…4 bytes, little-endian
bits 4-5 value-length width the same scale
bits 6-7 reserved must be zero
header table, only when the record has headers
count one byte
(nameLen, valueLen) × count fixed-width pairs, in header order
name₀ value₀ name₁ value₁ … the bytes, in the same order
body the rest: no length of its own (the chunk
directory frames the whole stored record)The writer picks the smallest widths that fit the record's longest header name and longest value. A 300-byte value, for example, needs two-byte value lengths in that record's table. A decoder reads the fixed-width table, computes byte ranges, and slices out names and values.
Two records, byte for byte:
body "hi", no headers:
00 68 69 3 stored bytes, 2 content bytes
body "hi", one header k=v:
01 flag: one-byte count, 1-byte lengths
01 one header
01 01 len("k"), len("v")
6b 76 "k" "v"
68 69 "hi"
8 stored bytes, 4 content bytesA record without headers costs one byte of framing: the zero flag byte. 0x00 is the only valid flag for such a record. The decoder refuses reserved flag bits, count widths 10 and 11, a zero count with a one-byte count width, width bits on a record without headers, and a table or header bytes that run past the record's length. Each of these means corruption. Using a reserved bit needs a new container version.
Transit bundles
A transit bundle holds one flight's batches, sorted by stream and first sequence number. The node writes it once, with a conditional create, into the next slot of its WAL. Sharing one object across streams shares the request cost of their writes. The indexer then writes a span ref per stream, which names the slots and footer ranges holding that stream's records. Slot keys follow from those coordinates. See WAL, slots and ledgers.
A transit bundle stays until denorm has copied every stream's chunks out of it and the auditor's trim cursor passes it. --denorm-linger (5m), --denorm-age-cap (24h, Standard), and --express-denorm-age-cap (1h, Express) set when that happens. See Stream objects and denorm.
Stream objects
A stream object holds consecutive records of one stream, assembled from transit chunks. A catalog row lists a run of these objects, and each entry holds the fields that give an object's key. Denorm builds the objects and owns their retry rules: it creates each key once, adopts an object a cut-short run already created, and extends a stream's last object before it writes full-size ones. See The commit protocol.
A complete object never changes at its key. A rewrite takes the next revision instead: it publishes ~<revision+1>, repoints the catalog, and only then schedules the old object's deletion. Extending a stream's last object and garbage collection both rewrite this way. A crash between the steps leaves both versions readable.
Express buckets
--s3-express-buckets lists one directory bucket per availability zone, as zone=bucket pairs. Each Express WAL slot is written to every bucket under the same key. Reads try the bucket for the node's --zone first, then another bucket when the object is missing or the read fails. Deletes go to every bucket, and a missing copy is not an error.
Only live Express WAL slots use express storage. Express streams keep their stream objects in standard storage, so the express price applies only while records are in transit. Nova never relies on a bucket's listing order, which is not lexicographic for directory buckets.
Crash points
| Crash after | State left behind | What the re-run does |
|---|---|---|
| The orphan intent, before the object's create | An intent naming a key that does not exist | The retry derives the same key and creates it; an unused intent is cleared by the orphan duty |
| The create, before the catalog commit | A complete object that no reference names | The retry finds the object standing and adopts it after checking its footer |
| A revision's create, before the catalog repoint | Two revisions; the catalog names the old one | The retry repoints; the unreferenced revision stays under its intent |
| The catalog repoint, before the old object's reap check is armed | Two revisions; the catalog names the new one; the job's marker still stands | The re-run finds no entry naming the old object, arms its reap check, then resolves the marker |
Bounds and signals
| Item | Size |
|---|---|
| Slot envelope | 60 bytes |
| Trailer | 40 bytes |
| Chunk index row | 52 bytes |
| Stored-record framing without headers | 1 byte |
| Header count per stored record | One byte, so at most 255; appends are refused above 100 |
nova.objectstore.duration reports each storage operation's latency, labelled by operation and by key family (wal, streams, or other). A throttle shows up on the key range it hit. A corrupt object reads as codec: corrupt artifact, and an object written by a newer format as codec: unsupported artifact version.
Tests
internal/objectkey:TestWALSlotDerivableAndOrdered,TestHashedSlotKeysLeadWithTheLedgersHash,TestHashedLayoutSpreadsLedgers,TestParseWALSlotReadsBothLayouts,TestKeyShapesFollowTheRecordedScheme.internal/storage/codec:TestStoredRecordHeaderlessIsOneByte,TestStoredRecordMinimalWidths,TestStoredRecordDecodeRefusals,TestDirectoryTrailerRoundTrip,TestRejectsUnsupportedVersion,TestIndexAnswersPointQuestions.internal/storage/bundle:TestPublishFetchReadRoundTrip,TestV1RemainsReadableAndVerifiesPartialReads,TestV2PointReadVerifiesOnlyItsRecordRange,TestRelocateProducesIdenticalObject.