ADR 0015 — Attachments are content-addressed
Status: accepted · 2026-09-18
Context. Some observations come with a file: the text of a transcript, a photo, a voice message, a note's image. Such a file is too large, binary or private to sit inside a line, and the line is hashed, so whatever goes into it is canonicalised on every verify. Four profiles already point at such files (transcript/v1, crossing-package/v1, message/v1, note/v1), each waiting for the spec to say where the bytes live and what a missing file means for verify. Three ways to hold them: inline in the line as base64; in a store the record carries with it; in a blob service the record refers to.
Decision. A file is stored once, inside the record, at <root>/attachments/<sha256>, named by the lowercase hex SHA-256 of its exact bytes, with no extension and no subdirectories. A line references it by the digest, the path, the length and an IANA media type; a profile chooses the field name and keeps the shape. The store is write-once and never pruned: the same bytes imported twice are one file, and a line that points at a file is the reason the file stays (ADR 0001: attachments are record, not cache). The chain covers lines, not bytes: the digest is in the line, so a changed file is detectable, but the file is not in the hash pre-image. verify reports a missing attachment separately and exits 0 when the chain is intact; a present file whose bytes do not match its name is an error. A record with no attachments/ directory is valid, and conformance does not require the store. SPEC §1.1 states these rules.
Rejected: base64 inline. Putting the bytes in the payload keeps the record in one set of files, but every byte then enters the hash chain: a decade of photos would be canonicalised on every verify, the month files would be gigabytes of base64 nobody reads, and the line, meant to be one observation a person can read, would be a wall of encoded data. It also loses de-duplication: the same file imported from two sources would be two copies in two lines.
Rejected: an external blob service. Naming the file by a URL in an object store keeps the record small, but the record then depends on something outside itself (ADR 0001: files are the truth). A folder copied to a new disk in ten years would have lines that point at a service that no longer answers, and verify could not tell a lost file from a lost network. Content addressing keeps the digest as the reference, so a future exporter MAY copy the bytes anywhere, but the record itself holds them.
Consequences. attachments/ is part of what a backup must copy and what a migration must carry across; a store command, when it is built, writes the file before the line that points at it, so a crash leaves an unreferenced file, never a dangling reference. verify grows a second report, missing attachments, that does not change its exit status. A crossing package (RFC 0005) ships copies of the referenced files under the same names, so a recipient checks them the same way. Encryption of tier 2 and 3 attachments at rest is for the version that defines the encryption envelope (SPEC §4).