Skip to content

PatrickChoDev/lvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LVC - Lightning Version Control

A next-generation version control system combining the best ideas from Git, Pijul, and Jujutsu with modern performance optimizations.

🚀 Vision

LVC is designed to be a decentralized, offline-first, patch-based VCS that provides:

  • 🔄 Changeset-based workflow (like Jujutsu)
  • 📌 Patch-aware merging (like Pijul)
  • 💾 Content-addressable storage with BLAKE3 hashing
  • Hybrid diff engine (Myers + Histogram algorithms)
  • 🧠 Intelligent conflict resolution
  • 🧩 Extensible plugin system (Lua-based)

📦 Technology Stack

Component Technology Purpose
Storage Format CBOR Efficient binary serialization for long-term storage
Hashing BLAKE3 Fast, secure content addressing
Configuration YAML Human-readable config with comments
Scripting Lua Lightweight plugin system
Diff Engine Myers + Histogram Optimal diffs with performance heuristics

🔧 Project Status

✅ Phase 1: Core Diff Engine (COMPLETED)

The hybrid diff engine is fully implemented and tested:

  • Myers Algorithm: Optimal shortest edit sequence computation
  • Histogram Preprocessing: Performance optimization for large, repetitive files
  • Linear Space Variant: Memory-efficient diffing for massive inputs
  • Unified Diff Format: Git-compatible output format
  • Comprehensive Testing: 25+ test cases covering edge cases

✅ Phase 2: Object Store & Serialization (COMPLETED)

The content-addressable object storage system is fully implemented and tested:

  • CBOR Serialization: Efficient binary encoding for all object types
  • BLAKE3 Content Addressing: Fast, secure hashing for object identification
  • File System Storage: Two-level directory structure for scalability
  • Object Types: Complete type system (Blob, Tree, Commit, Patch)
  • Integrity Verification: Automatic hash validation on load
  • Comprehensive Testing: 46+ test cases covering all object operations

Key Features

// Simple API
use lvc_core::diff::diff;

let old = &["line1", "line2", "line3"];
let new = &["line1", "modified", "line3"];
let result = diff(old, new);

// Rich metadata
println!("Algorithm: {}", result.stats.algorithm_used);
println!("Time: {} μs", result.stats.computation_time_us);
println!("Similarity: {:.1}%", result.stats.similarity_ratio() * 100.0);

Performance Characteristics

  • Small files: Lightning-fast Myers algorithm (sub-microsecond)
  • Large files: Automatic histogram optimization
  • Memory efficient: Linear space algorithms for massive inputs
  • Intelligent selection: Automatic algorithm choice based on content

Key Features

// Object store operations
use lvc_core::object_store::{ObjectStore, Object, types::*};

let store = ObjectStore::new("path/to/repo");
store.initialize().unwrap();

// Store any object type
let blob = Blob::new(b"file content");
let object_id = store.store_object(&Object::Blob(blob)).unwrap();

// Load with automatic integrity verification
let loaded = store.load_object(&object_id).unwrap();

Storage Format

.lvc/
├── objects/          # CBOR-encoded, BLAKE3-hashed objects
│   ├── ab/cdef...    # Two-level directory structure
│   └── cd/ef12...
├── patches/          # Fine-grained atomic edits (planned)
├── changesets/       # Grouped patches with metadata (planned)
├── refs/             # Branch and tag references (planned)
├── index             # Staging area (planned)
└── config.yaml       # Repository configuration (planned)

⏳ Upcoming Phases

Phase Focus Status
Phase 3 CLI Commands (init, add, commit, log) NEXT
Phase 4 Merge Engine & Conflict Resolution Planned
Phase 5 Plugin System & Extensibility Planned
Phase 6 Networking (clone, fetch, push) Planned
Phase 7 User Interface Planned

🧪 Demo & Testing

# Run the demo
cd lvc
cargo run

# Run all tests
cargo test

# Run specific module tests
cargo test diff::myers
cargo test diff::histogram

Sample Output

🔥 LVC Core - Advanced VCS Foundation
=====================================

✅ Phase 1: Hybrid Diff Engine - COMPLETED
✅ Phase 2: Object Store - COMPLETED
⏳ Phase 3: CLI Commands - NEXT

📋 Demo 1: Basic Diff Operations
---------------------------------
Operations:
   function calculate() {
  -    let x = 10;
  -    let y = 20;
  +    let x = 15;
  +    let y = 25;
  +    let z = 5;
   }
Stats: 9 ops, 22.2% similarity

💾 Demo 5: Object Store & CBOR Serialization
---------------------------------------------
✓ Stored blob: 08d1515f (51 bytes)
✓ Stored tree: 5ea0b20f (1 entry)
✓ Stored commit: 055a08df (initial)
✓ Store stats: 3 objects, 616 B

🎉 Object store foundation is working!
📦 CBOR serialization: ✓
🔒 BLAKE3 content addressing: ✓
💾 File system storage: ✓
🔍 Integrity verification: ✓

🏗️ Architecture

Diff Engine Architecture

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   diff::diff()  │───▶│ Algorithm Select │───▶│ Myers / Histogram│
└─────────────────┘    └──────────────────┘    └─────────────────┘
                              │
                              ▼
                       ┌──────────────────┐
                       │ DiffResult       │
                       │ - ops: Vec<Op>   │
                       │ - stats: Stats   │
                       │ - timing: u64    │
                       └──────────────────┘

Algorithm Selection Logic

  1. Small files (< 100 lines): Myers algorithm
  2. Large files with repetition: Histogram + Myers
  3. Large files without repetition: Myers
  4. Massive files (> 10k lines): Linear space Myers

🧩 Future Plugin System

-- Example: Pre-commit hook
function pre_commit(changeset)
    if changeset:affects("*.rs") then
        return shell("cargo fmt --check")
    end
    return true
end

-- Example: Deploy hook
function post_push(branch)
    if branch == "main" then
        shell("kubectl apply -f deploy/")
    end
end

📊 Benchmarks

Early performance testing shows:

  • Myers Algorithm: ~1μs for small files
  • Histogram Optimization: 50%+ speedup on repetitive content
  • Memory Usage: O(N) space complexity with linear variant
  • Scalability: Handles files with 100k+ lines efficiently
  • Object Storage: Sub-millisecond CBOR serialization
  • BLAKE3 Hashing: ~100MB/s throughput for content addressing
  • Comprehensive Testing: 46 test cases, all passing

🤝 Contributing

This project has strong foundations with two major phases completed. Key areas for contribution:

  1. CLI Development: User-facing commands (init, add, commit, log)
  2. Patch Theory: Implementing changeset-based merging
  3. Repository Management: Index, refs, and branch handling
  4. Testing: Integration tests and performance benchmarks

📚 References

  • Myers Algorithm: "An O(ND) Difference Algorithm and Its Variations" by Eugene W. Myers
  • Pijul: Patch-based version control theory
  • Jujutsu: Modern VCS workflow concepts
  • Git: Proven version control foundations

About

Lightning version control

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages