How infinityabundance/entropyfs works
Purpose and Entry Points
EntropyFS is a native Rust, Linux-oriented filesystem/storage engine that persists reversible representation descriptors and residuals, then deterministically materializes exact logical bytes. It can be used as a CLI-mounted FUSE filesystem, an embeddable Rust engine, a C ABI, or Go binding. Entrypoints: src/main.rs, src/lib.rs, src/engine/mod.rs; C/Go boundaries: include/entropyfs.h, src/ffi/mod.rs, go/entropyfs/engine.go.
Frontends and External Boundaries
The CLI provides lifecycle, mount, inspection, fsck, GC, metrics, snapshots, and optimization commands through src/cli/mod.rs, src/cli/mount.rs, and src/cli/fsck.rs. The FUSE frontend translates Linux VFS operations into engine/store operations, including inode, directory, file, locking, and xattrs: src/fuse/filesystem.rs, src/fuse/mount.rs, src/fuse/file.rs. An optional Linux ublk block-device frontend is isolated in src/ublk/target.rs and src/ublk/block.rs.
Representation and Materialization Pipeline
Writes evaluate bounded candidate representations, cost them, and retain an exact reversible descriptor or RAW fallback. Core representation policy and materialization live in src/core/representation.rs, src/core/candidate.rs, and src/core/materialize.rs. The entropy subsystem supplies deterministic universes, coordinates/ranks, transforms, residuals, sparse forms, and palettes: src/entropy/mod.rs, src/entropy/universe.rs, src/entropy/transform.rs. rANS codecs and model/residual handling are a separate coding layer in src/rans/dispatch.rs, src/rans/model.rs, and src/rans/sequence.rs.
Persistent Store, Transactions, and Recovery
The store is an append-oriented persistent object graph with segments, indexes, roots, extents, inodes/directories, snapshots, and epochs. Core persistence/control points are src/store/mod.rs, src/store/transaction.rs, and src/store/segment.rs; namespace and extent state are in src/store/inode.rs, src/store/directory.rs, and src/store/extent_tree.rs. Durability, recovery, and version progression are explicit boundaries: src/store/durability.rs, src/store/recovery.rs, src/store/epoch.rs. The versioned on-disk codec/superblock contract is defined by src/format/codec.rs, src/format/superblock.rs, and src/format/features.rs.
Optimization, Selection, and Caching
Foreground and background optimization search for lower-cost equivalent representations without changing logical bytes. Scheduling and rewrite policy are in src/optimizer/foreground.rs, src/optimizer/background.rs, and src/optimizer/rebase.rs. DSFB observes candidate/search behavior and controls selection budget but has no decode authority: src/dsfb/observer.rs, src/dsfb/selection.rs, src/dsfb/semantics.rs. Metadata and materialized-data caches sit above persistent reads in src/cache/metadata.rs, src/cache/materialized.rs, and src/cache/model.rs.
Integrity, Maintenance, and Runtime Infrastructure
Integrity is layered over content, records, and roots in src/integrity/content.rs, src/integrity/record.rs, and src/integrity/root.rs. Fsck scans/verifies the stored graph and supports repair via src/fsck/scan.rs, src/fsck/verify.rs, and src/fsck/repair.rs; GC and physical-space reconciliation are src/store/gc.rs and src/store/physical.rs. Linux I/O supports synchronous and io_uring transports behind src/store/io/mod.rs, src/store/io/sync.rs, and src/store/io/uring.rs; workers are managed by src/store/workers.rs. Material runtime dependencies are Linux x86_64, FUSE (/dev/fuse/fusermount3), and optionally io_uring and ublk; no network service is required.
Compatibility and Operational Contract
Persistent formats are explicit, versioned, and incompatibility-feature gated. Golden stores preserve compatibility expectations under testdata/golden/; format policy and layout are documented in docs/format/compatibility-policy.md and docs/format/ondisk-v1.md. JSON operational surfaces, evidence capture, and metrics are represented by src/cli/json.rs, src/cli/metrics.rs, and src/evidence/manifest.rs.
Main entry points: store/mod.rs Object graph store · engine/mod.rs Filesystem engine · representation.rs Representation policy · cli/mod.rs CLI
Components 21
Entry Points
- CLI · Lifecycle, mount, inspection, fsck, GC, metrics, and snapshot commands.
src/cli/mod.rs - FUSE frontend · Maps VFS inode, directory, file, lock, and xattr operations to the engine.
src/fuse/filesystem.rs - ublk frontend
src/ublk/target.rs - Rust engine API
src/engine/mod.rs - C and Go bindings
src/ffi/mod.rs
Engine Pipeline
- Filesystem engine · Coordinates logical filesystem operations, representation, and transactions.
src/engine/mod.rs - Representation policy · Chooses a bounded reversible descriptor or RAW fallback.
src/core/representation.rs - Materialization · Deterministically reconstructs logical bytes.
src/core/materialize.rs - Entropy transforms · Universes, coordinates, transforms, residuals, sparse forms, and palettes.
src/entropy/mod.rs - rANS coding · Encodes and decodes models, sequences, and residuals.
src/rans/dispatch.rs - Read caches
src/cache/materialized.rs
Persistent Store
- Object graph store · Persists segments, indexes, roots, extents, namespace state, snapshots, and epochs.
src/store/mod.rs - Transactions · Stages and commits persistent object-graph changes.
src/store/transaction.rs - Durability and recovery · Persists commits and recovers version progression.
src/store/recovery.rs - Linux storage I/O
src/store/io/mod.rs - On-disk format · Codec, superblock, and incompatibility-feature gates.
src/format/codec.rs
Operations
- Representation optimizer · Finds lower-cost equivalent representations without changing bytes.
src/optimizer/background.rs - DSFB selection control · Controls search budget but has no decode authority.
src/dsfb/selection.rs - Integrity and fsck · Verifies content, records, and roots; scans and repairs stored graphs.
src/fsck/verify.rs - GC and reconciliation
src/store/gc.rs - Operational evidence
src/evidence/manifest.rs
Connections 28
- CLI → FUSE frontend: mounts
- CLI → Filesystem engine: admin operations
- CLI → Integrity and fsck: fsck
- CLI → Operational evidence: JSON and metrics
- FUSE frontend → Filesystem engine: VFS operations
- ublk frontend → Filesystem engine: block operations
- Rust engine API → Filesystem engine: embedded calls
- C and Go bindings → Rust engine API: ABI calls
- Filesystem engine → Representation policy: writes
- Filesystem engine → Materialization: reads
- Filesystem engine → Transactions: filesystem mutations
- Read caches → Materialization: cached logical data
- Materialization → Entropy transforms: reverses transforms
- Materialization → rANS coding: decodes residuals
- Representation policy → Entropy transforms: evaluates transforms
- Representation policy → rANS coding: costs coding
- Representation policy → Transactions: stores descriptor and residual
- Transactions → Object graph store: updates graph
- Object graph store → Read caches: persistent reads
- Object graph store → Durability and recovery: commit and recovery
- Object graph store → Linux storage I/O: segment I/O
- Object graph store → On-disk format: encodes objects
- Representation optimizer → Representation policy: re-evaluates equivalents
- Representation optimizer → Transactions: commits rewrites
- DSFB selection control → Representation optimizer: selection budget
- Integrity and fsck → Object graph store: scan, verify, repair
- GC and reconciliation → Object graph store: reclaims and reconciles
- Operational evidence → Object graph store: reports state