# Content-Addressed Storage (CAS) Specification
Rivox CAS (`LocalCas`) manages artifact storage under `~/.rivox/cache/cas`.
---
## 2-Level Fanout & Merkleized Directory Manifests (RFC-002)
Because operating system kernels (Linux, macOS, Windows) reject directory hard-linking with `EISDIR`, Rivox represents directory artifacts using Merkleized directory manifest trees (`TreeManifest`):
1. **File Blob Storage**: Stored at `~/.rivox/cache/cas/blobs/ab/cd/<hash>` using 2-level directory fanout to prevent ext4 directory lock overhead.
2. **Tree Manifest Storage**: Stored at `~/.rivox/cache/cas/trees/ab/cd/<tree_key>` as a canonical JSON array of relative file paths, file modes, and file blob hashes.
3. **Zero-Copy Reconstitution**: Restoring a directory artifact creates subdirectories and hard-links individual file blobs into the destination target path.
See also: [cache.md](cache.md), [internals.md](internals.md).