Skip to main content

Store format

This page is imported from the project's own documentation at the pinned commit. Its links to repository files are removed, and one pointer to internal test material is left out. Every byte the store writes, for anyone who needs to share a store folder. It is long and is meant for looking things up.

Every byte the store (crates/interlinked-core) writes, and the rules any other implementation must follow to share one store folder with it, process by process, at the same time. Integers are little-endian unless stated. "BLAKE2b-n(person=P)" means BLAKE2b with an n-byte digest and the personalisation string P padded with zero bytes to 16 bytes.

The store marker is il-store 1. Room genesis entries and network tokens use the 13-field entry encoding; other new entries use the 14-field encoding with a detachable body.

1. Home folder​

<home>/
FORMAT "il-store 1\n" (11 bytes). Created with O_EXCL by the first store
that opens the home.
rooms/ 0700
<room id hex>/ one folder per room (64 lower-case hex characters)
.tmp-<32 hex>/ a room being created (section 4); ignore, never read
.compact-new-<id>/ durable replacement staged by idle compaction (section 18)
.compact-old-<id>/ old room retained until replacement is installed (section 18)
roomkeys/ room idempotency keys (section 9)
roomkeys.lock flock target for roomkeys/
keys/ identities (section 10), 0700
blobs/ content-addressed blobs (section 11)
segments.lease shared while a process caches segment descriptors; exclusive for compaction
pending-erasures/ room/id markers with deletion timestamps for deferred body erasure
tombstones/ durable room-deletion and operator-purge markers
forget-pending/ local forget intents recovered after an interrupted erase
changes optional change journal (section 16)

Unknown files are ignored. Every file is created with mode 0600 and O_CLOEXEC.

2. Values and entries​

The conformance kit checks the wire vectors, entry IDs and live segment records with an independent decoder.

wire (crates/interlinked-core/src/wire.rs) is the only encoding. One value has exactly one encoding:

TagValueThen
0, 1, 2None, False, Truenothing
3int >= 0uvarint n
4int < 0uvarint (-1 - n)
5bytesuvarint length, bytes
6struvarint length, UTF-8
7listuvarint count, items
8dict (str keys)uvarint count, then per item: uvarint key length, key UTF-8, value; keys in ascending order of their UTF-8 bytes, no repeats
9float8 bytes IEEE 754, big-endian

uvarint: 7 bits per byte, low group first, high bit = more. Decoders reject: a non-minimal uvarint (a final byte 0x00 after at least one continuation byte), truncation, trailing bytes, unknown tags, unsorted or repeated dict keys, invalid UTF-8.

An older version 1 entry has 13 fields. signable = wire list of the first 12: [room bytes32, author bytes32, seq int, prev bytes32, lamport int, ts int, kind str, body bytes, key str, to [bytes...], refs [bytes...], epoch int]. pack = wire list of all 13 (the 12 plus sig bytes, empty when unsigned). Because a list header of 12 or 13 items is one byte, pack is 0x07 0x0d + signable[2:] + encoding of sig.

A version 2 entry has 14 fields. Its first 12 signed fields use body_hash bytes32 in field 8 (zero-based index 7), computed as BLAKE2b-32 of the body with person il.body.v2. Field 13 is the signature, and field 14 is the detachable body bytes: 0x07 0x0e + signable[2:] + encoding of sig + encoding of body. The id and signature cover the digest, not the detachable bytes. When the body is present, its digest must match the signed field. A detached version 2 entry keeps its id, signature, author chain, kind and body digest, with an empty body field. The same entry can therefore be verified after compaction removes its content. Version 1 bodies cannot be detached without invalidating their signed ids.

id = BLAKE2b-32(signable, person="il.entry"). A signature is Ed25519 over the 32-byte id. The genesis entry of a room has room = 32 zero bytes, seq 1, prev zero, lamport 1, kind room.create; its id is the room id. A token (contract token()) has room zero and seq 0 and is never stored.

3. Segment files​

rooms/<room>/seg.NNNNNN (six decimal digits, from seg.000000). A segment is a sequence of records with no file header:

u32 little-endian body_length | u32 little-endian crc32(body) | body

crc32 is the IEEE CRC-32 (zlib.crc32, reflected polynomial 0xEDB88320, initial and final XOR 0xFFFFFFFF). Body type byte:

Entry record, type 1 (body is 85 bytes of header, then key, kind and pack):

Offset in bodySizeField
010x01
132entry id
3332author
658seq (u64, little-endian)
738lamport (u64, little-endian)
812key length k (u16, little-endian; UTF-8 bytes)
832kind length n (u16, little-endian; UTF-8 bytes)
85kkey
85+knkind
85+k+nrestEntry.pack()

The header duplicates fields of pack so an index can be built without decoding entries. Its CRC detects accidental corruption, but the header is only an index hint: verify the packed entry and compare its computed id before trusting it. Segment compaction rewrites version 2 packs with empty body fields after a valid signed tombstone; it must preserve the first 12 fields, signature, entry id, author sequence and predecessor id exactly.

Roll record, type 2: body = the single byte 0x02, so the record is exactly 01 00 00 00 | crc32(b"\x02") | 02. It ends the segment: the next record is at byte 0 of seg.(N+1). A writer appends a roll record after a write leaves the segment at or beyond its size limit (default 64 MiB; a single record may exceed it), then creates the next segment (O_CREAT; readers that get there first may create it empty too).

Offsets. A room's local offset of an entry is its 1-based position among entry records, counting through the segments in order. Offsets are what cursors point at; they are local to one store folder.

Visibility. A record exists only when all 8 + body_length bytes are present and the crc matches. A reader that meets an incomplete or crc-failing record stops there and retries later (a writer may be in the middle of write(2)).

Tail repair. Only the holder of the room write lock (section 5) repairs. When it catches up and finds, at the end of the current segment, bytes that do not form a complete record with a matching crc, the writer that produced them is dead (it would hold the lock), so it truncates the segment to the end of the last good record (ftruncate) before appending. A bad record followed by more bytes is corruption, not a torn tail: refuse with an error, never truncate.

4. Creating a room​

  1. mkdir rooms/.tmp-<32 random hex characters> (0700).
  2. Write seg.000000 there containing the genesis entry record (O_EXCL); fsync it unless durability is none.
  3. rename the folder to rooms/<room id hex>. If that fails because it exists, another process published the same room: delete the temp segment and folder and use the existing room.
  4. fsync rooms/ unless durability is none.

A room folder therefore always holds its genesis. lock, cursors, state, keys, presence, presence.lock are created on demand.

5. Locks​

All cross-process locks are flock(2) exclusive locks on a whole file (never fcntl/lockf record locks: the two kinds do not exclude each other). Each lock is released by LOCK_UN or by the process dying. No process holds two of these locks at once.

FileHeld byWhile
rooms/<r>/lockany writer of the roomcatching up + repairing the tail, checking idempotency keys, computing seq/prev/lamport, writing the records, writing the checkpoint
rooms/<r>/cursors (the table itself)a process allocating a slot or advancing a cursorread slot, compare, write
rooms/<r>/presence.locka process recording a beatread, prune, rewrite presence
roomkeys.lockcreate_room with a key; ingest of a keyed genesislook up the key, create the room, record the key

Inside one process, threads also serialise per room with an in-process lock taken before the flock (flock does not exclude threads sharing a descriptor).

6. Writing an entry (append)​

Under the room lock: catch up (read new records, repair the tail); if key is not empty and this author already has an entry with that key in the room, return it when kind, body and to are equal, else fail with KeyConflict; seq = author's last seq + 1, prev = its id (zero for the first), lamport = 1 + the highest lamport in the room, ts = wall clock ms; compute id, sign the id unless unsigned; write the record(s) with one write(2) on an O_APPEND descriptor (looping on a short write); roll if needed; apply durability; release. append_many writes the whole burst as one write(2) with consecutive seq and lamport and signs only the last entry (sign="last"). Ingest refuses an entry whose lamport is not above its author's previous one, and stores an unsigned entry only together with a later signed entry of the same author in the same call.

7. Checkpoint: state and keys​

A cold process (segments.fast_append) must not scan the whole log, so writers keep a checkpoint. Both files are written only under the room lock.

state = u32 crc32(payload) | u32 len(payload) | payload, rewritten in place with one pwrite at offset 0. A crc or length mismatch means "no checkpoint" (scan from the start).

Payload offsetSizeField
04IL1S
44version = 1
84segment number
128position in that segment (end of the last record covered)
208count = offset of the last entry covered
288highest lamport covered
368keys_len: valid bytes of keys
448mmark: offset of the latest entry whose kind starts with room. (the membership mark), 0 if none
524n authors
5672 x nper author: public key 32, u64 last seq, last id 32

keys = 40-byte records, one per keyed entry up to the checkpoint, appended with pwrite at keys_len: BLAKE2b-16(author || 0x00 || key UTF-8) (no personalisation) 16, u32 segment, u64 position of the entry's pack in that segment, u32 pack length, u64 offset. Lookups match only at multiples of 40. Bytes past keys_len are ignored (and overwritten by the next writer).

The checkpoint describes the log up to (segment, position); anything after it is read from the segments (a reader updates count, lamport, heads and mmark from those records). fast_append writes it on every call; a Store writes it right after a write when it has seen a new room.* entry (its own or another process's), otherwise every 256 entries, and on close. So the records after the checkpoint are few, and segments.room_mark(home, room) (checkpoint plus that tail, no lock) gives the membership mark cheaply: a roster built at mark M is exact while the mark is M.

(Amended 18 Nov, before any other implementation: mmark was added at offset 44 for rooms; the format is version 1 as written here.)

8. Cursors and presence​

rooms/<r>/cursors: 64-byte slots, never removed or moved.

OffsetSizeField
032reader public key
3224cursor name: UTF-8 padded with zero bytes; a name longer than 24 bytes is stored as # + the first 22 hex characters of BLAKE2b-11(name) (no personalisation), padded
568offset (u64)

A new slot is appended at file size rounded down to 64 with one pwrite of all 64 bytes (offset 0), under the cursors flock. advance under the same flock: read the 8 offset bytes; write the new value only if larger (cursors never go back); the value is first clamped to the room's tail. Readers read slots without a lock. Cursors are written with pwrite (not through a memory map) so the file change wakes waiters (section 12).

rooms/<r>/presence: one wire dict &#123;reader public key hex: [state bytes, beat time float (Unix seconds), ttl float]&#125;, replaced atomically (write presence.&lt;pid>.&lt;thread> then rename) under presence.lock. Expired items are dropped on each beat. Presence is never replicated and never fsync'd.

9. Room keys​

roomkeys/<hex of BLAKE2b-16(author || 0x00 || key UTF-8)> holds the 32-byte room id, written as <name>.<pid>.tmp then renamed, under roomkeys.lock. create_room(key=k) returns that room when its genesis body equals the new value, else raises KeyConflict.

10. Identities​

keys/<name>.key: the 32-byte Ed25519 seed (RFC 8032 secret key), mode 0600, created with O_EXCL (if it already exists, the other process's key wins). A key file readable by group or others is refused. Names match [A-Za-z0-9][A-Za-z0-9_.@-]{0,127}.

keys/<name>.pub: a cache of the public key for cold processes: public key 32 || BLAKE2b-32(seed, person="il.pubcache") 32. It is trusted only when the check matches the seed; written as <name>.pub.<pid> then renamed.

11. Blobs​

blobs/<first 2 hex>/<id hex>: the content, whole. id = BLAKE2b-32(content, person="il.blob"), computed while streaming in 1 MiB pieces. A blob is written to blobs/tmp/<32 random hex characters>, fsync'd unless durability is none (F_FULLFSYNC for always), then renamed into place (same content either way, so a race is harmless); the directory is fsync'd unless none. Chunk hashes (BLAKE2b-32 of each 1 MiB piece, person "il.blob") are computed on demand, not stored.

12. Wake-up​

A waiter registers on the file before it checks the condition, so no write is missed:

  • wait(room, after): the room's current segment file. On macOS/BSD a kqueue EVFILT_VNODE with EV_ADD | EV_CLEAR and NOTE_WRITE | NOTE_EXTEND; on Linux inotify IN_MODIFY on the file. After a roll it re-registers on the new segment.
  • wait_cursors: the room's cursors file, the same way.
  • Fallback: poll with sleeps from 50 µs doubling to 5 ms.

Writers do nothing extra: any write/pwrite/ftruncate to those files fires the event. Spurious wake-ups are allowed; waiters re-check.

13. Durability​

ModeWhen the call returns
nonedata is in the operating system (page cache): survives every process crashing, not power loss
batch (default, batch_ms 5)as none, and a background thread fsyncs written files within batch_ms
alwaysfsync'd before return; on macOS fcntl(F_FULLFSYNC) (plain fsync stops at the drive cache)

Room creation, segment rolls and blob commits also fsync their directory unless none. Cursor writes follow the mode; presence and checkpoints are never fsync'd (they can be rebuilt).

14. Room index (optional cache, added 18 Nov)​

A room may carry an index so a process opens it without reading the log. It is a cache: a store that ignores it is still correct; a store that uses it checks it and rebuilds it when it does not match. A checkpoint schedules a background index extension, and opening a room with more than 4 × store.checkpoint_every unindexed entries also schedules one. Index writers serialize on index.lock, separately from the room write lock. The header is written last, so anything past what it covers (rows, list items, hash slots) is ignored and overwritten.

index = 96-byte header, then one 64-byte row per offset (row of offset o at 96 + 64 (o - 1)):

Header offsetSizeField
04IL1X
44version 1
88rows: offsets 1 through rows, inclusive, are indexed
168slots in index.ids (power of two)
248slots in index.keys (power of two)
328items in index.keylist
404authors in index.authors
444kinds in index.kinds
488valid bytes of index.kinds
564segment where the indexed records end
608position there (the next record starts here)
688highest lamport indexed
768membership mark (offset of the latest room.* entry)
848start of the last indexed record, in its segment
924crc32 of bytes 0..92

Row: id 32, u32 segment, u32 pack length, u64 pack position, u64 lamport, u32 author number, u32 kind number.

Side files: index.authors (32-byte public keys, numbered from 0 in order of first appearance), index.kinds (u16 length + UTF-8 name each, numbered likewise), index.a.<n> and index.k.<n> (u64 offsets of author n / kind n, ascending; for an author the k-th item is seq k + 1), index.ids and index.keys (open-addressing tables of 16-byte slots: u64 key, u64 offset, empty when the offset is 0, linear probing from key & (slots - 1), at most half full; the key is the first 8 bytes of the entry id, little-endian, or of BLAKE2b-128(author 0x00 key) for keyed entries; a hit is confirmed against the row or the entry), and index.keylist (16-byte (key, offset) items, to rebuild index.keys). A table that would pass half full is rebuilt at four times the entries, rounded up to a power of two (at least 1024 slots), into a temporary file renamed into place.

Check at open: the header crc and version; the record starting at the header's last-record position has type 1 and the last row's id, and ends where the last row's pack ends. On failure the index is ignored and rebuilt from the log at the next checkpoint.

15. Settings snapshot (optional cache, added 18 Nov)​

Decision 12's registry stays the single source of truth; this file only spares a cold process from parsing the declaration files and config.toml (settings.rs, mod snapshot).

<home>/settings.snap: a 16-byte header, then a UTF-8 body.

header: "ILSN" | u32 version (2) | u32 crc32(body) | u32 len(body) (little-endian) body: lines separated by "\n", fields by NUL; list items by 0x1E decl NUL <BLAKE2b-64 of every settings/*.toml: name NUL text NUL, in name order, 16 hex digits> src NUL config.toml NUL <size, -1 when missing> NUL <mtime in ns, 0 when missing> ack NUL <name> NUL <name> ... (config.toml's i_understand; only when not empty) s NUL name NUL type NUL flags NUL source NUL value NUL default NUL unit NUL min NUL max NUL choices NUL layer (one per setting, in name order)

flags holds p (per room) and w (weakens safety); source is default or config.toml; values are text: integers in decimal, floats as the shortest text that reads back to the same number (2.0, 1e-05), true/false, strings as they are, lists joined by 0x1E; min/max empty when unbounded. It holds defaults and config.toml only: the environment and flags are applied on top by each process, with the same checks.

Version 1 (until 18 Nov) also carried a BLAKE2b-64 of the body for a second reader that no longer exists; a version-1 file fails the version check and is rewritten. The decl stamp is computed at build time. A reader uses it only when the header and its checksum check, decl equals its own declarations and every src line still matches (size and mtime). Anything else, or a process whose registry was extended from code, resolves the full way and rewrites the file (temporary file + rename; a home that cannot be written just has none). A value the format cannot carry (NUL, newline or 0x1E inside a string, an empty list item) means no snapshot.

<store>/rooms/<id>/settings.snap: a room's own settings (from room.create / room.config), written by the rooms layer after reducing them; same header.

room NUL <membership mark the values were reduced at> r NUL name NUL i|f|b|s|l NUL value (one per setting)

Use it only when the mark equals the room's current membership mark.

16. Change journal (added 18 Nov)​

<store>/changes answers "which rooms changed since position N", so a reader of many rooms (the inbox, a hook) pays for what changed, not for the number of rooms (changes.rs).

header: "ILCH" | u32 version (1) | u64 generation 16 bytes records: room id (32 bytes) | u64 the room's entry count after the write 40 bytes each

  • Writers. Every write adds one record: a single append, an append_many burst, an ingest batch, a cold append, and a room creation (count 1). It is one O_APPEND write, after the segment write and still under the room lock.

  • Generation. The creating writer's wall clock in nanoseconds, never 0, and always above the generation it replaces. So a recreated journal never reuses a generation a reader holds, and a store written under a fixed clock (the test vectors) is reproducible.

  • Creation. The file is created as a temporary file holding the header, hard-linked into place. Nobody can append before the header.

  • A failed write removes the file. Readers then rescan rather than miss the change, and the next writer starts a new generation.

  • Rotation. After its write, a writer that sees the file past store.changes_max_bytes takes flock(LOCK_EX) on it. Then, on a descriptor without O_APPEND:

    1. it truncates the file to the header;
    2. it writes a new generation.

    In that order, a reader never pairs the new generation with a position inside the old records.

  • Readers keep (generation, offset) and start from (0, 0). changes_since returns the rooms in [offset, end), each once, in first-change order, and the new position (whole records only). It answers rescan when:

    • the file is missing or damaged;
    • the generation differs, including when it changed during the read;
    • the offset is not a record boundary inside the file.

    On rescan the reader looks at every room once, then continues from the returned position. Writes after that position are always reported or force another rescan; none is lost.

17. MLS rooms (Decision 18; added 18 Nov)​

A room whose genesis says e2ee: 2 is one MLS group (RFC 9420, ciphersuite 0x0003), group id = room id. Design and reasons: docs/mls-design.md; code: crates/interlinked-mls, helper il-mls. For external joins, genesis also carries mls_relay: relay public key; without that binding the room keeps its single-committer rule. The bound relay serializes commit candidates on its own signed, contiguous per-room author chain. Nothing in the segment, index or entry layout changes. What is new is entry kinds and their bodies, which are wire dicts on entries with epoch = 0:

KindBodyWritten by
mls.keypackage{kp: KeyPackage (TLS)}; its credential is the author's Ed25519 public keya member, before the committer can add it
mls.group_info{epoch: 0, group_info: MlsMessage (TLS)}; refs = [room.create id]. The snapshot contains the ratchet tree and external public keythe first committer when it creates the group
mls.commit{epoch: n, commit: MlsMessage (TLS), group_info: MlsMessage (TLS), welcome?: MlsMessage, adds: [public keys], removes: [public keys], history?: {joiner public key hex: sealed}}; refs = [previous mls.commit id] (none for the first). The GroupInfo describes epoch n after the commit. history (shared rooms) seals the earlier epochs' history keys to each joiner with seal_tothe committer only
mls.commit external variantAdds external: true, join: room.join id; adds must contain only the entry author, removes and rejoins are empty. Its MLS message is a NewMemberCommit containing only ExternalInit. The join must be the counted, invitation-backed join at this positionthe joining identity, only with a bound relay
mls.order{candidate: mls.commit id, heads: {author key hex: seq}}; refs = [candidate]. The relay waits for the candidate's referenced join, invitation, or MLS proposals, then signs the per-author heads it holds. Readers wait for every sequence through those heads and validate against exactly that prefix. The relay's signed seq orders siblings. Invalid candidates are skipped; incomplete earlier positions leave the epoch pending. Two conflicting signed positions at one relay sequence freeze the room locallythe relay key bound in genesis
mls.order.wait, mls.order.drop{candidate: mls.commit id}; refs = [candidate]. Relay bookkeeping: wait records when missing inputs first held a candidate; drop permanently ends that wait after relay.mls_pending_ttl_s. Neither is an ordering positionthe relay key bound in genesis
mls.history_grant{to: joiner public key, sealed: seal_to(joiner, {room, join, keys: [[epoch, key], ...]})}; refs = [accepted external mls.commit id]. The bundle contains every earlier MLS epoch key, and is accepted only from the room owner or current committer at the grant's position in a shared-history roomthe owner or current committer
mls.update{proposal: MlsMessage}: an Update proposal for the author's own leafany member in the group
mls.takeover{after: mls.commit id or none}an owner (rules below)
mls.handoff{to: public key}the committer
mls.migrate{}: a version-1 encrypted room becomes MLS from here onan owner, once

New commits carry a GroupInfo. Readers check its room id, epoch, presence of a ratchet tree, and signature by the commit author against the accepted log chain. OpenMLS checks the full tree when a joiner uses the GroupInfo. Commits written before this format existed remain readable without one; such a room cannot offer external join until a later commit publishes a current GroupInfo. The new joiner's private MLS state is provisional until its candidate is the accepted ordered commit. If another candidate wins, it restores its pre-candidate state and retries from the winner's GroupInfo; a committer's losing candidate is likewise rebuilt on the winning epoch.

Application entries carry epoch = 2^32 + MLS epoch. That is above any version-1 period number, so an upgraded room tells its two kinds of entries apart. Their authenticated data is wire([kind, author, to]). The body depends on the room's history:

  • since_join: the body is an MLS PrivateMessage (TLS). A reader checks that its authenticated data equals the entry's own fields, and that the MLS sender's credential is the entry's author.
  • history: shared: the body is nonce (12) || ChaCha20-Poly1305(history key, nonce, body, aad), as in scheme 1. The history key of epoch n is MLS-Exporter("interlinked history", room id, 32) in that epoch.
    • Members keep every history key they have.
    • The committer seals all of them to each joiner in its incumbent Add commit. After a relay-bound self-join, an owner or current committer publishes a separate sealed mls.history_grant.
    • So shared history has no forward secrecy (Decision 18 (2)). il-mls status returns the one-line warning.

Upgrade. An mls.migrate by an owner, in a room whose genesis has e2ee: true or 1:

  • From that entry on the room is version 2 and the migrating owner is the first committer.
  • Entries ordered before it keep their scheme-1 key epochs and stay readable with them.
  • mls.* entries before it are ignored.

The chain. Valid entries (the membership reducer's valid set) are walked in Entry.order:

  • The committer starts as the genesis author (or the migrating owner). An mls.handoff by the committer moves the role.
  • An mls.commit counts when:
    • its author is the committer at that position;
    • its refs[0] is the head of the chain so far;
    • its epoch is the head's epoch + 1.
  • An mls.takeover counts when:
    • its author ranks owner or higher;
    • it was a member of the group at after;
    • something waited (a member with a key package and no leaf, a leaf of a non-member, or an update);
    • its timestamp is at least e2ee.committer_timeout_s past the latest of: the oldest waiting item, the committer's start, and its last commit.
  • When a takeover counts:
    • the chain is cut back to after, which voids the old committer's later commits;
    • the author becomes the committer.

Every replica computes the same chain from the same entries, in any arrival order.

Reading. A reader applies the chain's commits in order, and opens each message while the group is in that message's epoch. Messages that arrive after their epoch's commit open for 3 more epochs (PAST_EPOCHS); older ones report "epoch too old". A member whose applied commits leave the chain after a takeover restores its storage snapshot at after. Without such a snapshot it publishes a new key package to be added again.

Private state. Per identity and room, never replicated, folders 0700, files 0600:

  • <store>/mls/<identity>/<room hex>: wire dict {storage, applied, joined, removed}. storage is the openmls storage map.
  • .snap: the storage after each of the last 4 commits applied.
  • .text: the plaintexts this identity has opened or sent. An MLS message key opens a message once, and these are kept so history can be read again.
    • Format: append-only records u32 length (LE) || wire([entry id, plaintext]). A torn last record is ignored on load.
    • With e2ee.plaintext_cache = memory the file is removed, and plaintexts live only in the process. The main state still lists the ids opened, so a later read says "opened before".

The MLS signature key is separate from the identity key: HKDF-SHA256(identity seed, "", "interlinked mls signature v1", 32). It is bound to the identity by the signed mls.keypackage entry.

18. Idle segment compaction​

Store::compact_room_offline rewrites a room's records in the same arrival order and at the same offsets. For selected version 2 entry IDs it writes the signed hash and an empty body. A version 1 entry cannot lose its body without changing its signature, so a request to detach one is refused. The generated state, keys, and optional index are rebuilt by the next open. Cursors and presence are carried into the replacement.

Every process that opens segment files holds a shared lock on segments.lease while it caches their descriptors. il serve and the kept relay follower release cached descriptors after runner.compaction_idle_s without a wake (default 30 seconds), and reacquire on the next read. il sync and il compact also try pending erasures. Compaction takes an exclusive try_lock on the same lease file; a busy home defers without waiting. il status and MCP status show the pending count and oldest age. A signed deletion hides the body in read views immediately; these markers drive physical erasure at the next idle compaction. The replacement is written and synced in .compact-new-<id>, the old directory is renamed to .compact-old-<id>, then the replacement takes the room name. A crash before the second rename restores the old directory on open; a crash after it removes the old one. The swap preserves the same room ID, entry IDs, author chains, and offsets.