Skip to content

AcceptedOwner sparkles:build-primitivesReviewed 2026-11-09

Content addressing — Testing ​

Companion to SPEC.md: the oracles each requirement is checked against, the trees they are checked on, and the evidence ledger.

Oracles ​

Every format is checked against an implementation that shares no code with ours. Each runs on a copy of the members' tree materialized on disk, without the literal's directories that hold no member (membersOf, after C3), while our scheme runs over the in-memory driver on the whole literal, so the two also list the tree independently.

OracleIndependenceEstablishesWhere it comes from
snix-castore ingestSnix's own implementation of its format, in RustCAC1–CAC5the flake input snix-src, built by packages.snix-castore; the shells export it as $SPARKLES_SNIX_CASTORE (Linux)
nix-store --dumpNix's own serializer, which defines the formatCAN1–CAN3the host's Nix
git write-treegit's own index and tree writer, after git add -A -fCAG1, CAG2, CAM2the host's git, in repositories made with --object-format=sha1 and sha256
A bytewise controlthe git encoding sorted by bytes: an oracle that must disagreethat CAM2's check can failBytewiseGitTree, in the test module
Each scheme alonethe fold and the stream that a tee's parts are checked againstCAT1CastoreScheme, GitTreeScheme and NarScheme, each already checked against its own oracle
Hand-encoded messagesprotobuf bytes written out by hand from the message definitionsCAC2, CAC3content_addressing.castore.encoding
bao-outboardn0's bao-tree, the crate iroh builds its outboards with, in RustC2's layout, behind CAO1 and CAO2nix/packages/bao-outboard, a few lines over bao-tree 0.17.0, built by packages.bao-outboard; the shells export it as $SPARKLES_BAO_OUTBOARD
iroh-collectionsendme's import, done by iroh-blobs 0.103.1's own store and Collection, in RustCAI1, CAI2libs/iroh-send/rust, built inside sendme 0.37's source and lock by packages.sparkles-iroh-send; the shells export it as $SPARKLES_IROH_COLLECTION
nix hash path --mode gitNix's own git-hashing dumperCAG3's SRI formthe host's Nix, with the git-hashing experimental feature
nix-store --print-fixed-pathNix's own store-path computationCAP1, CAP2the host's Nix

The bytewise control is how the ordering check is tested: on at least a quarter of the trees, git's encoding over bytewise order differs from git write-tree, so a scheme that ignored its declared order would fail.

A tee's parts are checked against the schemes alone, not against the external oracles a second time. That is sound only because each scheme alone is checked against its oracle on the same trees.

Fixtures ​

oracleTrees in content_addressing/testing.d gives every oracle the same trees:

  • hazard: a/x, a.b, a-b, a+, a0, ab/c, where git's order puts the directory a after a.b, a-b and a+ but before a0.
  • kinds: nested directories, an empty directory, a directory holding only an empty directory, an executable file, a link into the tree and a link out of it. The two memberless directories are in no name, so this tree checks that they are left out.
  • case collision: A and a, B/x and b/x.
  • no hazard and the empty tree.
  • The filesets fixture set.
  • 200 random trees from seed 20 261 108, with links, executables and empty directories, each file holding text.

Start roots beneath the root are checked on one tree, a/b/x a/b/d/y a/c a-c/z q, with the filesets a/b/** ∪ a-c/**, a/c, a/b/d/y ∪ q and nothing. The unanchored q makes the walk enter every directory, so the cases also check that the directories searched are left out.

Evidence ledger ​

Evidence is from Linux x86_64, with DMD and LDC, against Snix at revision c27950ab360b92bbb8f2ca246efd0ed895ce1e58, Nix 2.32.8 and git 2.51.2. A requirement the ledger does not list is unverified.

RequirementsStateEvidenceGap
CAM1verified (Linux x86_64)with start roots beneath the root and an unanchored pattern among them, castore equals snix-castore ingest, git equals git write-tree in SHA-1 and SHA-256 repositories, and NAR equals nix-store --dump, each of the tree holding only the members (content_addressing.castore.startRoots, content_addressing.git.startRoots, content_addressing.nar.startRoots); q and /q, **/y and the whole tree with its empty and hollow directories name the members' tree in castore, git, NAR and the tee, and a fileset with no members names the empty directory (content_addressing.merkle.C3.membersOnly); the tee equals the schemes alone (content_addressing.tee.startRoots)—
CAM2verified (Linux x86_64)git's id equals git write-tree on every fixture tree, and the bytewise control differs on more than a quarter of them (content_addressing.git.writeTree)—
CAM3verified (Linux x86_64)a leaf that rewrites its file after the stat and before the first read, growing, shrinking or emptying it, fails castore, git and the tee of castore and NAR with schemeFailed; rewritten at the same size, the file is named by the bytes read (content_addressing.merkle.CAM3.resized)NAR alone is checked only inside the tee, which reads through the same streamFile; the in-memory driver only
CAM4verified (Linux x86_64)a mount the walk does not cross, and a file removed between its directory's listing and its stat, fail castore, git, NAR and the tee with schemeFailed (content_addressing.merkle.CAM4.incomplete)the in-memory driver only: a permission error on disk is not exercised
CAM5verified (Linux x86_64)the wrapped libc allocator and the GC counter, around the scheme's own calls, count zero in a second resolution of a tree with a 300-entry directory and a 40 000-byte file, for castore, git, NAR and CastoreNar, where the first resolution counted some (content_addressing.allocation.secondResolutionHasZeroCalls, in the allocation-audit configuration)the resolution around the scheme is audited by the filesets contract, not here
CAC1–CAC5verified (Linux x86_64)the textual id equals snix-castore ingest's on every fixture tree (content_addressing.castore.snix); a hand-encoded message, the empty directory's id and nested sizes (content_addressing.castore.encoding)the test skips without $SPARKLES_SNIX_CASTORE, which the shells set on Linux only
CAN1, CAN2verified (Linux x86_64)digest and length equal those of nix-store --dump on every fixture tree (content_addressing.nar.dump)Nix is the host's, not pinned by the flake; the test skips without it
CAN3verified (Linux x86_64)start roots beneath the root, ordered a/b before a-c, and the empty fileset, against nix-store --dump (content_addressing.nar.startRoots)as CAN1
CAN4verified (Linux x86_64)toSri of the digest equals nix hash path's output on the hand-written trees, the fixture set and 20 random trees (content_addressing.nar.CAN4.sri)as CAN1
CAG1, CAG2verified (Linux x86_64)SHA-1 and SHA-256 ids equal git write-tree's on every fixture tree, the empty tree included (content_addressing.git.writeTree); the encoder's empty tree is git's well-known id (content_addressing.git.emptyTree)git is the host's, not pinned by the flake
CAT1, CAT3verified (Linux x86_64)a tee of castore and git equals castore, git and NAR alone on every fixture tree (content_addressing.tee.parts); CastoreNar equals castore and NAR alone on four start-root filesets (content_addressing.tee.startRoots)—
CAT2verified (Linux x86_64)a counting leaf in a tee hears each file once and each byte once (content_addressing.tee.readsOnce); at the backend, a tee of castore, git and NAR opens one entry per member file beyond the walk's own opens, and reads as often as one scheme alone, a 40 000-byte file included (content_addressing.tee.opensOnce)the in-memory driver only
CAO1verified (Linux x86_64)a castore fold given supplied trees for three files, of one, three and ten groups, gives the id reading them gives, and opens three entries fewer at the backend, reading only the other files; a supplied tree with a flipped top record fails the resolution with schemeFailed (content_addressing.outboard.CAO1.supplied); a truncated outboard, one claiming a larger size, and a flipped top record are refused by check (content_addressing.outboard.check)the in-memory driver only; the supply is a test store keyed by path, as nothing yet persists outboards
CAO2verified (Linux x86_64)with one byte of the third group flipped, a verifying reader returns the first two groups whole and then fails, returning no byte of the third; a truncated file fails; an empty file and one of a single group check against the root alone (content_addressing.outboard.CAO2.verifiedReader); a flipped record beneath the top fails the groups beneath it and no others (content_addressing.outboard.check); root and outboard equal bao-tree's on 55 sizes around and between group boundaries, up to 40 groups (content_addressing.outboard.baoTree)reads run from the start of the file: a range is reached by reading the groups before it, as the file handles have no positional read
CAG3verified (Linux x86_64)on the hand-written trees, the fixture set and 60 random trees, the SRI form equals nix hash path --mode git --algo sha1 and the SWHID is swh:1:dir: before the hex id git write-tree is checked against (content_addressing.git.CAG3.nixGitHash); the empty tree in both forms (content_addressing.git.CAG3.forms)—
CAT4verified (Linux x86_64)in a tee of castore and the collection over one counting leaf, the leaf hears four files and 13 bytes for a tree of four files and 13 bytes, and castore's, the collection's and NAR's ids equal each alone (content_addressing.tee.CAT4.sharedLeaf)—
CAI1, CAI2verified (Linux x86_64)on every fixture tree, the 200 random ones included, the name equals the one iroh-collection prints for the members laid out under the label, links among them left out (content_addressing.collection.irohBlobs); a metadata blob of three names, one of them 132 bytes long, is byte-equal to its hand encoding, and a two-file collection's metadata and hash sequence are hashed by hand (content_addressing.collection.CAI1.metaBlob, content_addressing.collection.CAI1.byHand); the kinds fixture leaves two links out, and the empty collection lists nothing (content_addressing.collection.CAI2.empty)—
CAI3verified (Linux x86_64)the labels "", ., .., a/b and a\b are refused and .a accepted; a member x\y and one named by the byte 0xff fail, naming it (content_addressing.collection.CAI3.refused, content_addressing.collection.isUtf8)—
CAP1, CAP2verified (Linux x86_64)on the hand-written trees, the fixture set and 40 random trees, the path under source and under a+-._?= equals nix-store --print-fixed-path --recursive sha256's, and eight names are accepted or refused as it accepts and refuses them (content_addressing.store_path.printFixedPath); a vector from Nix and the names of CAP2 by hand (content_addressing.store_path.CAP1.vector, content_addressing.store_path.CAP2.names)—