Nab • (raw)
Date: 2026 Nov 17
Updated: 2026-Nov-17 07:18:49-0500
Words: 458
b3sum: 5ed43438…
Format
Archive Header
| Offset | Size | Type | Value (hex) | Meaning |
|---|---|---|---|---|
| 0 | 4 | bytes | 4E 41 42 00 |
NAB\0 |
| 4 | 4 | u32 BE | 00 00 51 26 |
format datestamp |
| 8 | 4 | bytes | 4C 45 58 49 |
dedication |
the format datestamp is days since the unix epoch (01 Jan 1970). the current one is 20774 (17 Nov 2026), stored as 00 00 51 26.
Record Header
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 4 | u32 BE | Format datestamp |
| 4 | 32 | bytes | Unkeyed BLAKE3-256 of the reconstructed content of this version |
| 36 | 8 | i64 BE | Timestamp, signed Unix seconds; equal to or after the previous record’s |
| 44 | 8 | u64 BE | Version index; greater than the previous record’s |
| 52 | 1 | u8 | Base distance: 0 = snapshot, 1–255 = base is index − distance; must be ≤ index |
| 53 | 7 | u56 BE | Operand byte count n (below 2^56) |
| 60 | 4 | u32 BE | CRC32C |
| 64 | n | bytes | Operands |
the CRC32C (Castagnoli, check value 0xE3069283) covers header bytes 0–59, then all n operand bytes. the CRC field itself (60–63) is excluded.
Commands
nab patch CONTENT [ARCHIVE] [--timestamp SECONDS] [--force-unadulterated-patch | --overwrite-last] [--verbose] nab log ARCHIVE [--json]
nab rebuild ARCHIVE [VERSION]
nab diff ARCHIVE [VERSION [VERSION]]
nab verify ARCHIVE
nab recover DAMAGED OUTPUT
nab --version
patch appends a new version. without ARCHIVE it uses .<filename>.nab next to the file
- the timestamp defaults to the current time and can’t be earlier than the latest version’s
- if the content is identical to the latest version nothing is written, unless
--force-unadulterated-patchis passed --overwrite-lastreplaces the latest version instead of appending--verboseprints one line likeappended 3,overwrote 3orunchanged 3.
log reads only the headers: index, BLAKE3, base, base distance, timestamp and operand byte count - doesn’t check CRCs - --json prints one JSON object per line
rebuild reconstructs one version and prints the output to the terminal
- if no
[VERSION]is passed, it rebuilds the latest by default - it always replays the version’s chain back to its snapshot, checks each record’s CRC, and checks the rebuilt version against the BLAKE3 hash before outputting the result
diff with no versions compares the latest version against the working file, with one version compares that version against the working file, and with two compares the two versions.
- for terminal output it uses
git diff --no-index, falling back todiff -u.
verify checks the whole archive: the header, every CRC, ordering, the base graph, and every version rebuilt and checked against its BLAKE3.
recover scans the damaged file byte by byte for valid records and writes them, sorted by index, into a new archive. it never modifies the input, and the output must not already exist. repeated indices keep the first copy, and a record whose timestamp would go backwards is skipped.