Host Storage
Branch data lives on your host filesystem under~/.graft/. This section explains the layout and how the object pool works.
Directory Layout
Object Pool
The object pool atobjects/ stores file content keyed by BLAKE3 hash.
Storage Format
a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890ab is stored at:
Operations
| Operation | Description |
|---|---|
Put(hash, reader) | Store a blob; idempotent (no-op if already present) |
Get(hash) | Open a blob for reading |
Has(hash) | Check if a blob exists |
PutFile(path) | Hash a file on disk and store it |
Deduplication
Blobs are immutable and content-addressed. If two files have the same content (e.g., an unchanged Postgres heap file across commits), they map to the same hash and are stored exactly once. ThePut operation checks Has first and returns immediately if the blob exists.
Object Materialization
When Graft needs to restore a branch (checkout, rollback, reset), it materializes files from the object pool into the branch directory.Diff-Based Materialization
Rather than copying every file, Graft:- Walks the current branch directory and computes BLAKE3 hashes
- Compares the result against the target tree entries
- Skips files that already match (same hash)
- Only copies, removes, or replaces files that differ
Reflink / Copy
For each file that needs to be materialized, Graft attempts a reflink (copy-on-write) usingcp -c:
cp -c fails (unsupported filesystem, missing binary), Graft falls back to a full byte-by-byte copy:
Excluded Files
Certain runtime files are never stored in the object pool or copied between branches:| Pattern | Reason |
|---|---|
*.sock | Database Unix sockets (created on every start) |
*.pid | PID files (process-specific, invalid after restart) |
postmaster.pid | Postgres-specific PID file |
Host vs Docker Volume Storage
| Aspect | Docker Volume | Host Filesystem |
|---|---|---|
| Location | Inside Docker’s Linux VM | ~/.graft/ on your Mac |
| Access | Container only | Finder, ls, any tool |
| Hardlinks | Impossible (cross-VM) | Native (APFS) |
| Backup | docker run ... tar | cp -r |
| Performance | VM overhead | Native I/O |