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

 
 
 

Contributors

Languages