# infinityabundance/entropyfs architecture

> Architecture diagram of the GitHub repository infinityabundance/entropyfs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/infinityabundance/entropyfs
- Repository: https://github.com/infinityabundance/entropyfs

## Overview

#### 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: [`src/store/mod.rs`](https://github.com/infinityabundance/entropyfs/blob/main/src/store/mod.rs) (Object graph store), [`src/engine/mod.rs`](https://github.com/infinityabundance/entropyfs/blob/main/src/engine/mod.rs) (Filesystem engine), [`src/core/representation.rs`](https://github.com/infinityabundance/entropyfs/blob/main/src/core/representation.rs) (Representation policy), [`src/cli/mod.rs`](https://github.com/infinityabundance/entropyfs/blob/main/src/cli/mod.rs) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontends["Entry Points"]
  node_cli["CLI<br/>[mod.rs]"]
  node_fuse["FUSE frontend<br/>Linux VFS adapter<br/>[filesystem.rs]"]
  node_ublk["ublk frontend<br/>optional block adapter<br/>[target.rs]"]
  node_rust_api["Rust engine API<br/>library entry<br/>[mod.rs]"]
  node_c_go_abi["C and Go bindings<br/>FFI boundary<br/>[mod.rs]"]
end

subgraph group_engine["Engine Pipeline"]
  node_engine_core{{"Filesystem engine<br/>orchestration<br/>[mod.rs]"}}
  node_representation["Representation policy<br/>candidate selection<br/>[representation.rs]"]
  node_materialization["Materialization<br/>exact decode<br/>[materialize.rs]"]
  node_entropy["Entropy transforms<br/>reversible domain<br/>[mod.rs]"]
  node_rans["rANS coding<br/>codec layer<br/>[dispatch.rs]"]
  node_cache["Read caches<br/>metadata and data cache<br/>[materialized.rs]"]
end

subgraph group_storage["Persistent Store"]
  node_store[("Object graph store<br/>append-oriented persistence<br/>[mod.rs]")]
  node_transactions["Transactions<br/>commit control<br/>[transaction.rs]"]
  node_durability_recovery["Durability and recovery<br/>crash consistency<br/>[recovery.rs]"]
  node_io["Linux storage I/O<br/>sync and io_uring transport<br/>[mod.rs]"]
  node_format["On-disk format<br/>versioned contract<br/>[codec.rs]"]
end

subgraph group_operations["Operations"]
  node_optimizer["Representation optimizer<br/>foreground/background rewrite<br/>[background.rs]"]
  node_dsfb["DSFB selection control<br/>observation and budget<br/>[selection.rs]"]
  node_integrity_fsck["Integrity and fsck<br/>verification and repair<br/>[verify.rs]"]
  node_gc["GC and reconciliation<br/>space maintenance<br/>[gc.rs]"]
  node_evidence_metrics["Operational evidence<br/>JSON and metrics<br/>[manifest.rs]"]
end

node_cli -->|"mounts"| node_fuse
node_cli -->|"admin operations"| node_engine_core
node_cli -->|"fsck"| node_integrity_fsck
node_cli -->|"JSON and metrics"| node_evidence_metrics
node_fuse -->|"VFS operations"| node_engine_core
node_ublk -->|"block operations"| node_engine_core
node_rust_api -->|"embedded calls"| node_engine_core
node_c_go_abi -->|"ABI calls"| node_rust_api
node_engine_core -->|"writes"| node_representation
node_engine_core -->|"reads"| node_materialization
node_engine_core -->|"filesystem mutations"| node_transactions
node_cache -->|"cached logical data"| node_materialization
node_materialization -->|"reverses transforms"| node_entropy
node_materialization -->|"decodes residuals"| node_rans
node_representation -->|"evaluates transforms"| node_entropy
node_representation -->|"costs coding"| node_rans
node_representation -->|"stores descriptor and residual"| node_transactions
node_transactions -->|"updates graph"| node_store
node_store -->|"persistent reads"| node_cache
node_store -->|"commit and recovery"| node_durability_recovery
node_store -->|"segment I/O"| node_io
node_store -->|"encodes objects"| node_format
node_optimizer -->|"re-evaluates equivalents"| node_representation
node_optimizer -->|"commits rewrites"| node_transactions
node_dsfb -->|"selection budget"| node_optimizer
node_integrity_fsck -->|"scan, verify, repair"| node_store
node_gc -->|"reclaims and reconciles"| node_store
node_evidence_metrics -.->|"reports state"| node_store

click node_cli "https://github.com/infinityabundance/entropyfs/blob/main/src/cli/mod.rs"
click node_fuse "https://github.com/infinityabundance/entropyfs/blob/main/src/fuse/filesystem.rs"
click node_ublk "https://github.com/infinityabundance/entropyfs/blob/main/src/ublk/target.rs"
click node_rust_api "https://github.com/infinityabundance/entropyfs/blob/main/src/engine/mod.rs"
click node_c_go_abi "https://github.com/infinityabundance/entropyfs/blob/main/src/ffi/mod.rs"
click node_engine_core "https://github.com/infinityabundance/entropyfs/blob/main/src/engine/mod.rs"
click node_representation "https://github.com/infinityabundance/entropyfs/blob/main/src/core/representation.rs"
click node_materialization "https://github.com/infinityabundance/entropyfs/blob/main/src/core/materialize.rs"
click node_entropy "https://github.com/infinityabundance/entropyfs/blob/main/src/entropy/mod.rs"
click node_rans "https://github.com/infinityabundance/entropyfs/blob/main/src/rans/dispatch.rs"
click node_cache "https://github.com/infinityabundance/entropyfs/blob/main/src/cache/materialized.rs"
click node_store "https://github.com/infinityabundance/entropyfs/blob/main/src/store/mod.rs"
click node_transactions "https://github.com/infinityabundance/entropyfs/blob/main/src/store/transaction.rs"
click node_durability_recovery "https://github.com/infinityabundance/entropyfs/blob/main/src/store/recovery.rs"
click node_io "https://github.com/infinityabundance/entropyfs/blob/main/src/store/io/mod.rs"
click node_format "https://github.com/infinityabundance/entropyfs/blob/main/src/format/codec.rs"
click node_optimizer "https://github.com/infinityabundance/entropyfs/blob/main/src/optimizer/background.rs"
click node_dsfb "https://github.com/infinityabundance/entropyfs/blob/main/src/dsfb/selection.rs"
click node_integrity_fsck "https://github.com/infinityabundance/entropyfs/blob/main/src/fsck/verify.rs"
click node_gc "https://github.com/infinityabundance/entropyfs/blob/main/src/store/gc.rs"
click node_evidence_metrics "https://github.com/infinityabundance/entropyfs/blob/main/src/evidence/manifest.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_fuse,node_ublk,node_rust_api,node_c_go_abi toneBlue
class node_engine_core,node_representation,node_materialization,node_entropy,node_rans,node_cache toneAmber
class node_store,node_transactions,node_durability_recovery,node_io,node_format toneMint
class node_optimizer,node_dsfb,node_integrity_fsck,node_gc,node_evidence_metrics toneRose
```

## Components

### Entry Points

- [CLI](https://github.com/infinityabundance/entropyfs/blob/main/src/cli/mod.rs): Rust CLI · Lifecycle, mount, inspection, fsck, GC, metrics, and snapshot commands. · `src/cli/mod.rs`
- [FUSE frontend](https://github.com/infinityabundance/entropyfs/blob/main/src/fuse/filesystem.rs): Linux VFS adapter · Maps VFS inode, directory, file, lock, and xattr operations to the engine. · `src/fuse/filesystem.rs`
- [ublk frontend](https://github.com/infinityabundance/entropyfs/blob/main/src/ublk/target.rs): optional block adapter · `src/ublk/target.rs`
- [Rust engine API](https://github.com/infinityabundance/entropyfs/blob/main/src/engine/mod.rs): library entry · `src/engine/mod.rs`
- [C and Go bindings](https://github.com/infinityabundance/entropyfs/blob/main/src/ffi/mod.rs): FFI boundary · `src/ffi/mod.rs`

### Engine Pipeline

- [Filesystem engine](https://github.com/infinityabundance/entropyfs/blob/main/src/engine/mod.rs): orchestration · Coordinates logical filesystem operations, representation, and transactions. · `src/engine/mod.rs`
- [Representation policy](https://github.com/infinityabundance/entropyfs/blob/main/src/core/representation.rs): candidate selection · Chooses a bounded reversible descriptor or RAW fallback. · `src/core/representation.rs`
- [Materialization](https://github.com/infinityabundance/entropyfs/blob/main/src/core/materialize.rs): exact decode · Deterministically reconstructs logical bytes. · `src/core/materialize.rs`
- [Entropy transforms](https://github.com/infinityabundance/entropyfs/blob/main/src/entropy/mod.rs): reversible domain · Universes, coordinates, transforms, residuals, sparse forms, and palettes. · `src/entropy/mod.rs`
- [rANS coding](https://github.com/infinityabundance/entropyfs/blob/main/src/rans/dispatch.rs): codec layer · Encodes and decodes models, sequences, and residuals. · `src/rans/dispatch.rs`
- [Read caches](https://github.com/infinityabundance/entropyfs/blob/main/src/cache/materialized.rs): metadata and data cache · `src/cache/materialized.rs`

### Persistent Store

- [Object graph store](https://github.com/infinityabundance/entropyfs/blob/main/src/store/mod.rs): append-oriented persistence · Persists segments, indexes, roots, extents, namespace state, snapshots, and epochs. · `src/store/mod.rs`
- [Transactions](https://github.com/infinityabundance/entropyfs/blob/main/src/store/transaction.rs): commit control · Stages and commits persistent object-graph changes. · `src/store/transaction.rs`
- [Durability and recovery](https://github.com/infinityabundance/entropyfs/blob/main/src/store/recovery.rs): crash consistency · Persists commits and recovers version progression. · `src/store/recovery.rs`
- [Linux storage I/O](https://github.com/infinityabundance/entropyfs/blob/main/src/store/io/mod.rs): sync and io_uring transport · `src/store/io/mod.rs`
- [On-disk format](https://github.com/infinityabundance/entropyfs/blob/main/src/format/codec.rs): versioned contract · Codec, superblock, and incompatibility-feature gates. · `src/format/codec.rs`

### Operations

- [Representation optimizer](https://github.com/infinityabundance/entropyfs/blob/main/src/optimizer/background.rs): foreground/background rewrite · Finds lower-cost equivalent representations without changing bytes. · `src/optimizer/background.rs`
- [DSFB selection control](https://github.com/infinityabundance/entropyfs/blob/main/src/dsfb/selection.rs): observation and budget · Controls search budget but has no decode authority. · `src/dsfb/selection.rs`
- [Integrity and fsck](https://github.com/infinityabundance/entropyfs/blob/main/src/fsck/verify.rs): verification and repair · Verifies content, records, and roots; scans and repairs stored graphs. · `src/fsck/verify.rs`
- [GC and reconciliation](https://github.com/infinityabundance/entropyfs/blob/main/src/store/gc.rs): space maintenance · `src/store/gc.rs`
- [Operational evidence](https://github.com/infinityabundance/entropyfs/blob/main/src/evidence/manifest.rs): JSON and metrics · `src/evidence/manifest.rs`

## Connections

- 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
