Skip to content

Repository files navigation

LayerFS icon

LayerFS

Ephemeral Workspaces. Durable Shared History.

CI status MIT license Developer preview WeChat QR invite Join Discord Follow @yifanxu_ephai on X

πŸš€ What is LayerFS?

Ephemeral Workspaces. Durable Shared History.

LayerFS is a SQLite-backed, content-addressed time machine for agent Workspaces. Give every filesystem-affecting tool call its own ephemeral Workspace; when retained, that call becomes one immutable Commitβ€”the base unit of the filesystem timeline. CAS, CDC, and COW store one shared base plus unique deltas instead of cloning full environments. From any Layer or eligible Commit, agents can fork zero-copy Branches, run parallel rollouts, discard failures, roll back by forking an earlier state, and promote a winning Branch with Add. The filesystem remains load-bearing for recursive multi-agent exploration without multiplying storage.

Warning

LayerFS 0.1.0 is a Developer Preview. It is intended for local evaluation, agent-runtime integration, and performance researchβ€”not production storage. It does not provide crash- or power-loss-durability guarantees. Keep an independent copy of important data.

🧱 LayerStack storage model

βš™οΈ Core storage mechanisms

CAS, CDC, and COW make LayerStack history storage-efficient by reusing unchanged objects, file regions, and filesystem structure.

The governing invariant is simple: every filesystem state is complete logically, but incremental physically. A new state should cost what changed, not the size of the Workspace it exposes. Read the CAS + CDC + COW foundations for the design rationale and step-by-step storage model.

πŸ” 01 Β· Identity πŸ“ 02 Β· Byte locality 🌳 03 Β· Structural locality
Content-addressed storage β€” Names immutable objects from their canonical bytes, verifies reads, and reuses exact duplicates across files, LayerStacks, and agents. Content-defined chunking β€” Keeps chunk boundaries stable around localized edits, so changing a small region does not require storing an entirely new large file. Copy-on-write β€” Rebuilds only the changed file and directory path when publishing a new Commit, preserving unchanged subtrees; a Branch head can then be added as the next Layer.

πŸ—ƒοΈ Check out an ephemeral filesystem from any layer

A LayerStack records complete filesystem checkpoints. Agent A can start from L1 while Agent B independently starts from L3. Each gets a private place to work while the selected history remains shared.

This is the conceptual checkout view; the public lifecycle is Layer or Commit β†’ Branch β†’ Workspace.

Top-down LayerStack with Branches, Commits, and parallel agent Workspaces

One LayerStack, many zero-copy Branches, and ephemeral COW Workspaces sharing immutable history.

πŸ“¦ Measured deduplication

The primary storage signal is semantic content growth: the canonical bytes needed by a new state. SQLite page allocation is reported separately because existing database pages can absorb new objects without changing the logical content represented by the Store.

Workload LayerFS semantic growth Cloudflare Computer LayerFS reduction
Sixteen deterministic edits 0.2250 MiB 8.0000 MiB 97.19% less
Prepend 10 bytes to 32 MiB 0.0256 MiB 32.0000 MiB 99.92% less

These measurements come from the final public-SDK, real-FUSE campaign. See the full benchmark report for physical allocation, equations, source identity, and raw evidence.


🧭 System boundaries

🧩 LayerFS components

The storage engine, SDK, CLI, and filesystem projection are implemented in the 0.1.0 Developer Preview. They remain separate public boundaries so callers do not depend on private CAS handles or storage formats.

Status Component Role
Implemented core Storage Owns identities, canonical objects, CDC, file manifests, structural COW, immutable CAS admission, lifecycle coordination, and verified reads.
Implemented preview SDK and CLI Expose filesystem, Workspace, LayerStack, Branch, Commit, publication, query, monitoring, and container-lifecycle operations through the public surfaces.
Implemented preview Filesystem projection Exposes a Workspace through host materialization or real container FUSE and captures bounded filesystem effects while delegating identity, CDC, COW, and admission to storage.
Implemented preview Container runtime Creates and controls resource-bounded Linux FUSE containers for Workspaces without placing the durable Store inside the container.

The one-Store boundary is intentional: a Client binds one SQLite Store, one Monitor, and one Workspace manager. A second Store uses a separate Client.

Each workspace exec starts a fresh process. commit publishes the Workspace state to its Branch. end removes the ephemeral projection and never commits implicitly.

πŸ› οΈ Quickstart

The current release is built from source. You need macOS or Linux and Rust 1.85 or newer. Docker, /dev/fuse, and CAP_SYS_ADMIN are needed only for managed container-FUSE workspaces. Packages are not published to crates.io in 0.1.0.

From the repository root:

git clone https://github.com/Ephemeral-AI-Lab/layerfs.git
cd layerfs

cargo build --release -p layerfs-cli
export LAYERFS_BIN="$PWD/target/release/layerfs"
export LAYERFS_CONTEXT="$PWD/.layerfs/context"
mkdir -p "$PWD/.layerfs"

"$LAYERFS_BIN" db create "$PWD/.layerfs/store.sqlite"
"$LAYERFS_BIN" context use --store "$PWD/.layerfs/store.sqlite"
"$LAYERFS_BIN" layerstack init --name demo --empty
"$LAYERFS_BIN" query layerstacks

This creates a SQLite Store and an empty LayerStack with a genesis Layer. Continue with the complete quickstart for Branch creation, Workspace execution, commits, cleanup, directory imports, managed containers, and real FUSE.

When importing an existing directory, keep the Store file outside the directory being imported or projected:

mkdir -p "$PWD/import-root"
printf 'hello\n' > "$PWD/import-root/hello.txt"
"$LAYERFS_BIN" layerstack init --name imported "$PWD/import-root"

πŸ—‚οΈ Repository layout

crates/
β”œβ”€β”€ layerfs-content           content-addressed objects, chunking, extents, trees
β”œβ”€β”€ layerfs-layerstack-store  SQLite schema, history, identities, object admission
β”œβ”€β”€ layerfs-workspace         ephemeral workspaces, capture, execution, containers
β”œβ”€β”€ layerfs-materialization   directory materialization and capture
β”œβ”€β”€ layerfs-fuse              Linux FUSE and host/proxy adapters
β”œβ”€β”€ layerfs-daemon            authenticated container mount/execution protocol
β”œβ”€β”€ layerfs-monitor           receipts, timings, snapshots, dedup analysis
β”œβ”€β”€ layerfs-sdk               public Rust client and value types
└── layerfs-cli               `layerfs` command-line interface

tools/layerfs-eval             Store and Branch integrity evaluator
benchmark/                     filesystem and end-to-end benchmarks
containers/layerfs-fuse        managed Linux FUSE runtime image
docs/versioned/0.1.0          current versioned product manual
release-notes/0.1.0            release contract, evidence, and limitations

⚠️ Current limitations

LayerFS is suitable for evaluation and integration work, but the preview boundary matters:

  • 0.1.0 operates against one Store per Client; there is no cross-host synchronization;
  • live-process transaction visibility does not imply crash or power-loss durability;
  • the SDK is consumed from this repository; there is no published crates.io package or default runtime image;
  • managed FUSE requires Docker, /dev/fuse, and CAP_SYS_ADMIN;
  • the managed container is not a complete hostile-code security boundary;
  • the detached CLI context owner does not forward an interactive PTY; and
  • CLI JSON output is a preview text envelope, not a stable machine API.

Read the full limitations before using LayerFS with important data.

πŸ“š Documentation

Start with the documentation index, or jump directly to a focused guide:

Goal Guide
Learn the concepts Core concepts
Run the CLI and SDK Quickstart
Find a CLI command CLI reference
Integrate with Rust Rust SDK reference
Configure container FUSE Container runtime
Understand storage Storage format
Review performance evidence Benchmark results
Contribute changes Development guide

The first-principles learning site is educational material and may describe future work. The versioned repository manual defines the current product contract.

πŸ—ΊοΈ Roadmap

Stage Focus Status
0.1.0 Developer Preview One SQLite Store, immutable LayerStack history, Branches, Workspaces, public SDK/CLI, host materialization, container FUSE, monitoring, and benchmark evidence. Released as source under v0.1.0.
0.1.1 Make the current path boringly reliable: FUSE conformance, large and mixed-edit capture, prepend handling, bounded resources, and lifecycle cleanup. Proposed; preserve the 0.1.0 schema, identities, SDK, CLI, and runtime bounds.
Next minor Establish a portable projection foundation, including capability-detected reflink/clonefile paths and a future OverlayFS projection. Planned; requires a new compatibility contract.
Later Add platform/runtime expansion and verified Store export, import, and synchronization. Research; no cross-host synchronization is part of 0.1.0.

See the roadmap checklist and roadmap planning notes for acceptance gates, ownership boundaries, and sequencing. Use the Rust SDK reference to integrate the current public SDK.

🀝 Contributing

Bug reports, reproducible performance evidence, documentation corrections, and focused pull requests are welcome. Before opening a change, review the development guide and run the repository’s relevant verification commands.

πŸ’¬ Community

WeChat QR code for the Ephemeral AI Lab group

πŸ“„ License

LayerFS is licensed under the MIT License.

About

LayerFS gives every agent an isolated, disposable filesystem fork without copying the shared base. Useful states become durable, deduplicated checkpoints with workspace-scoped tool historyβ€”ready to branch, rewind, or reuse across parallel development, environment experiments, and MCTS-style rollouts.

Resources

Stars

76 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages