Cairn

Patch-based version control for successful cargo builds

The Problem

You spend 3 hours coding. You run cargo build. 500 errors. You don't remember what you changed.

Git shows you a diff with 800 lines across 12 files. You spend 2 hours trying to undo your changes. You give up and git reset --hard to your last commit from yesterday, losing everything.

Cairn solves this: Every successful build is automatically captured as a patch. One command rolls back to any previous working state.

Build-Gated Snapshots

With Git, you can commit anything—broken code, untested changes, WIP disasters. Your history becomes polluted with commits that don't even compile.

Cairn's guarantee: Every snapshot in history is guaranteed to build successfully.

$ cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 2.34s
✓ Cairn: Snapshot created (a3f8d9e1)

$ cairn list
● a3f8d9e1 - just now - "Successful build"  ← GUARANTEED TO WORK
● d7e2c1f - 1 hr ago - "Successful build"   ← GUARANTEED TO WORK
● 9f1d3e7 - yesterday - "Successful build"  ← GUARANTEED TO WORK

Build succeeds → Cairn saves it automatically. Build fails → Nothing happens. You cannot pollute history with broken code.

How It Works

Automatic Snapshots

Instant Rollback

$ cairn rollback a3f8d9e1
Restored to patch a3f8d9e1 (37 minutes ago)
✓ Rolled back 10,000 files (1 changed) in 16ms

$ cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.23s

Patch-Based, Not Snapshot-Based

Technical Details

VSF Encoding

Patches stored in Versatile Storage Format:

Race Condition Solved

If you edit files while build is running, Cairn snapshots what cargo actually compiled, not what's on disk when the build finishes. Uses cargo's fingerprint as source of truth.

Atomic Operations

Prior Art

Cairn builds on:

What's novel:

Status

Cairn is in active development. Linear history only (no merges yet—coming with commutation). Rust-specific for now, can be adapted for other languages later.

→ View on GitHub