Skip to content

Commit 6b552bb

Browse files
committed
feat(journal): record framing and a storage interface (C2, byte layer)
New module `journal`, not yet used by the shell state: - Framing: a record is a u32 little-endian length, the payload, and the SHA-256 of the payload. `decode` returns the records at the front of the input and how many bytes they occupy. It follows the Agda model (`JournalFraming`): a record cut short is rejected by its length, and what is accepted re-encodes to exactly the accepted bytes. - `Storage`: read, append, sync and atomic replace. - `FileStorage`: one file, created 0600, opened with O_NOFOLLOW, checked through the descriptor (regular file, owned by the current user, group and other bits removed). Replacement writes a temporary file, syncs it, renames it over the old one and syncs the directory. - `SimStorage`: the model's file, durable bytes plus pending bytes, with the crash images of the model (durable bytes and every prefix of the pending ones) and injectable failures, for the crash tests. Tests cover every prefix of a run of frames, a flipped bit at every position, an oversized length field, loose permissions, a symlink in place of the file and a directory in place of the file. Measured here (ext4 on a virtual disk): append plus sync of a 300-byte record has p50 154 us and p95 426 us, under the route plan's 2 ms threshold for syncing every record. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J4QvDjNR1ZoYKEPxSKE2nq
1 parent f3cb941 commit 6b552bb

2 files changed

Lines changed: 659 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)