Storage Kit
Content-addressed binary storage engine — format v2. The storage engine underneath bitchain. Published on crates.io as
slashbuilder-storage-kit; the library is imported asstorage_kit.
Storage Kit is the SlashBuilder Kit ecosystem's content-addressed storage engine: BLAKE3
hashing, content-defined (FastCDC) or fixed-size chunking, recursive
fragmentation (fragment lists that themselves become content-addressed
objects once they exceed a size threshold, so multi-terabyte files don't
bloat a single reference list), Zstd-compressed packfiles on disk, and
per-partition isolation and dedup. It relocated here from
slash-builder/bitchain as a location fix, not a reimplementation — the
engine is unchanged, only where it lives.
slash-builder/bitchain is this crate's first consumer: it depends on
storage-kit for the engine and keeps only the CLI surface, its own
manifest format, and GC. This crate does not depend on bitchain, and
it deliberately owns no manifest type — bitchain and bitchain-volume
each keep their own distinct manifest shape over the same engine.
v1 (SHA-256, the old Store/Block/Manifest scaffold) is gone. This
crate implements format v2 only; a --legacy v1 read path, if one is ever
needed, is a bitchain-CLI-level concern, not this crate's.
Status
Pre-1.0. The crate-root re-export block in src/lib.rs is the frozen
public surface (locked 2026-08-26) — see that file's doc comment for the
normative statement. Context and Address ((hash, context) addressing)
were retired in 0.2.0; see CHANGELOG.md. Breaking the frozen surface
needs an explicit maintainer decision and a changelog entry, not a patch.
Versions at a glance
The crate version (SemVer, in Cargo.toml) and the on-disk FORMAT_VERSION
are independent numbers. Pre-1.0, a breaking change bumps the crate's
minor version; 1.0 happens only when the API and its conformance tests are
frozen.
| Crate version | FORMAT_VERSION |
What it is |
|---|---|---|
0.1.x |
2 | The format-v2 engine (BLAKE3, FastCDC, Zstd packfiles, recursive fragmentation) |
0.2.0 |
3 | Format v3: Context/Address retired, create/open split, partition record |
| not yet released | 4 | Key-and-encryption seam (in design); would be 0.3.0 |
The minimum supported Rust version (MSRV) is 1.88. Raising it is a
minor-version change, noted in CHANGELOG.md.
Quick start
[]
= "0.2"
The package is slashbuilder-storage-kit; the library name is unchanged, so
you write use storage_kit::.... If you prefer the short name in
Cargo.toml, rename the dependency:
storage-kit = { package = "slashbuilder-storage-kit", version = "0.2" }.
use ;
// One partition per tenant — storage-kit never dedups across a partition
// boundary. `PartitionId::for_person` / `PartitionId::for_household` /
// `PartitionId::for_service` are the domain-separated constructors;
// `PartitionId::derive` is the general-purpose one. A partition is
// provisioned explicitly with `create` (its id must be derived from the
// subject you name); `open` is for a partition that already exists.
let partition_id = for_person;
let spec = PartitionSpec ;
let mut store = create?;
// Hashing is deterministic (BLAKE3) — the hash IS the block's identity,
// and a `put` for content already present in the partition is a no-op
// dedup hit, not a duplicate write.
let bytes = b"hello, world";
let hash = store.put?;
println!;
let back = store.get?; // verifies the BLAKE3 hash on every fetch
assert_eq!;
Large content goes through recursive fragmentation rather than a single
put/get — see storage_kit::build_fragment_tree /
storage_kit::read_fragment_tree, re-exported at the crate root.
Data model
Hash — 32-byte BLAKE3 digest; sole key for physical block storage
and within-partition dedup.
PartitionId — 16-byte tenant-isolation id. Canonical construction is
PartitionId::derive("<domain>:<id>"); for_person(account_id)
and for_household(hid) are the standalone-first domain-
separated convenience constructors (R3).
ChunkingProfile
— how raw content is split: Fixed { block_size } or
FastCdc { min_size, avg_size, max_size } (the default).
Recorded so any implementation reconstructing the same
bytes with the same profile reaches the same root hash.
FragmentTree — result of fragmenting a byte slice: a root Hash plus a
RootType (Leaf if the content fit in one chunk, List if
there are one or more fold levels above the leaves).
The engine addresses by (partition, hash). The earlier Context and
Address types ((hash, context) addressing) were retired in 0.2.0;
logical identity belongs to the reference layer of the product above this
crate, not to the engine.
Traits
ImmutableStore: # the four-method contract, frozen
get(&hash) -> Vec<u8> # verifies BLAKE3 on every read
has(&hash) -> bool
put(&[u8]) -> Hash # dedups within the partition
partition_id() -> PartitionId
MutableStore: # cache-state only — not used by the
load(key) -> Vec<u8> # bitchain protocol itself; manifests
store(key, bytes) # are immutable artifacts, no "advance
cas(key, expected, new) -> bool # the latest pointer" op
list(prefix) -> Vec<String>
AsyncImmutableStore: # async counterpart to ImmutableStore,
get(&hash) -> Result<Vec<u8>, _> # for the backend transport layer
put(&[u8]) -> Result<Hash, _>
has(&hash) -> Result<bool, _>
partition_id() -> PartitionId
Implementations that actually exist:
PartitionStore— the referenceImmutableStore: packfile-backed local filesystem storage, one partition per directory, self-healing.idxrebuild from.packfiles on open.LocalBackend,S3Backend,HttpBackend— asyncAsyncImmutableStoretransport wrappers over the same content-addressed contract, for host applications that need non-blocking I/O.S3Backendtargets S3 and S3-compatible object stores (MinIO, and — as of thes3feature landing — Wasabi/B2/R2);HttpBackendtalks to a Refraction server.
obliterate and copy_between_partitions are not implemented —
ImmutableStore has the four methods above, not six. MultiUriImmutableStore
(try manifest URIs in order until one succeeds) is specified but unbuilt
and likely belongs in bitchain, since it needs a manifest to read URIs
from and this crate owns no manifest type.
Cargo features
[]
= { = "0.2", = false, = ["s3"] }
s3(default-on) — pulls inaws-sdk-s3/aws-config/bytesand compilesbackend::S3Backend.http(default-on) — pulls inreqwestand compilesbackend::HttpBackend.
default = ["s3", "http"], so existing consumers see no change with no
action. A local-only consumer (no cloud transport, PartitionStore /
LocalBackend only) can build with default-features = false to link
neither cloud SDK. LocalBackend itself is always compiled — it has no
cloud dependency.
Partitions and dedup
Every store is opened against exactly one PartitionId, and dedup is and
stays scoped to that single partition — no pack ever spans partitions.
Sharing content into a household is a copy written into the
household's own partition, not a cross-partition reference; callers wrap
that copy under a per-member household key above this crate, since this
crate has no key-wrapping concept.
PartitionId::for_person(account_id) / PartitionId::for_household(hid) /
PartitionId::for_service(service_id) are domain-separated convenience
constructors over PartitionId::derive — a person partition and a household
partition never collide even if account_id and hid happen to share a
string value.
Hash invariant
A block's hash is its identity. ImmutableStore/AsyncImmutableStore
implementations verify the BLAKE3 hash of bytes returned from get
against the requested hash before returning. A mismatch is
StorageError::HashMismatch { expected, actual } and is treated as
storage corruption. Never compromise this invariant — it's the load-
bearing property of the whole system.
Scope
In scope. BLAKE3 hashing, FastCDC-or-fixed chunking, Zstd-compressed
packfile storage, recursive fragmentation, partition isolation, the
ImmutableStore/MutableStore traits and PartitionStore, the async
backend layer (LocalBackend/S3Backend/HttpBackend), hash
verification on every fetch.
Out of scope. A CLI surface — that's the bitchain product. A server — that's Refraction. Any manifest format — owned by each consuming product. Block availability semantics for peer-to-peer or hub-mediated sharing — that is a concern of the application layer above this crate.
Building from source
&&
Rust 2021 edition; MSRV 1.88. Needs no private registry and no network service: the tests use a temporary directory only.
Contributing
Contributions welcome under Apache-2.0. Sign your commits with
git commit -s (Developer Certificate of Origin).
The frozen public surface (src/lib.rs's root re-export block) is
conservative on purpose. A change to it needs an explicit maintainer
decision and a changelog entry, not a patch. See CONTRIBUTING.md.
License
Apache-2.0 — see LICENSE.
About
Part of the SlashBuilder Kit ecosystem, at
slash-builder. Storage Kit is the engine
underneath the bitchain CLI, bitchain-volume and Refraction.
Maintained by SlashBuilder / Douglas Lockamy.