korg
A causally-ordered, rewindable event-ledger for autonomous AI agents.
Every step your AI agent takes, recorded in a hash-chained ledger you can independently verify โ tamper-evident, zero trust, no blockchain.

English ยท ็ฎไฝไธญๆ ยท ็น้ซไธญๆ

AI agents are black boxes. When they fail, you can't debug. When they succeed, you can't reproduce it.
When they do something wrong, you can't undo it.
Korg fixes this.
What Korg Does
[!NOTE]
Universal Ingestion Integration Mode:
Korg v1 is an MCP-callable audit sink. Any MCP-compatible coding agent (Claude Code, Codex, etc.) can call korg's tools to record its session as a causally-linked, replayable, rewindable ledger. The agent must be instructed to log its actions โ typically via system prompt or MCP server configuration. Fully passive auditing without agent cooperation is on the roadmap for future versions.
[!WARNING]
Trust Boundary & Deployment Scope:
Korg v1 is designed strictly for local, single-user workspaces. Multi-tenant and networked deployments require cryptographic authentication and permission bounds that are not yet shipped. Running the server on an untrusted or public network exposes workspace read/write access.
Korg is a cognitive hypervisor โ a runtime layer that sits beneath your AI agents and governs every decision they make.
It doesn't replace your LLM. It governs what the LLM does.
Foundation Model โ predicts, suggests, generates
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Korg Cognitive Runtime โ schedules, validates, isolates,
reconciles, replays, heals, governs
Every agent action is:
- Appended to an immutable, cryptographically-signed ledger
- Ordered with Hybrid Logical Clocks (causal, deterministic, globally consistent)
- Replayable โ rebuild exact state at any point in history
- Reversible โ rewind the ledger to any prior sequence point
Try the Time-Travel Demo
You can run the built-in sandbox demo to see cognitive time-travel in action. The demo sets up a temporary workspace with a buggy Python script, lets a simulated coding agent make a wrong edit, catches the test failure, rewinds the workspace and ledger to before the edit, and speculatively commits the correct fix:
You will see the complete, colorized time-travel sequence:
โก STARTING KORG COGNITIVE TIME-TRAVEL DEMO โก
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[korg] Initializing sandboxed demo environment...
[korg] Created temporary workspace with math_utils.py (subtraction bug present).
๐ PHASE 1: AGENT INITIATES RUN (WRONG PATH)
[seq 390] actor: agent:claude-code@0.2.29 | tool: user_prompt | prompt: "Fix subtraction bug and verify tests pass"
[seq 391] actor: agent:claude-code@0.2.29 | tool: Read | file: math_utils.py
[seq 392] actor: agent:claude-code@0.2.29 | tool: Edit | result: "Modified return a + b (wrong fix)"
[seq 393] actor: agent:claude-code@0.2.29 | tool: Bash | command: "pytest" -> โ FAILED (2 tests failed)
๐ LEDGER STATE (BEFORE REWIND):
Before rewind: events 390-393 (prompt, read, edit-wrong, test-failed)
โโโ seq 390 (user_prompt) -> triggered_by: None
โโโ seq 391 (Read) -> triggered_by: Some(390)
โโโ seq 392 (Edit) -> triggered_by: Some(391)
โโโ seq 393 (Bash) -> triggered_by: Some(392)
โณ PHASE 2: INITIATING REVERSIBLE REWIND TO SEQ 391
[korg] Truncating journal ledger to sequence ID 391...
[korg] Restoring workspace snapshot via git read-tree (O(1))...
[korg] Reset math_utils.py file state back to sequence 391 bug state.
[korg] Rebuilding 3 read-model projections...
๐ LEDGER STATE (AFTER REWIND):
After rewind: events 390-391 (prompt, read)
โโโ seq 390 (user_prompt) -> triggered_by: None
โโโ seq 391 (Read) -> triggered_by: Some(390)
๐ PHASE 3: AGENT DIVERGES DOWN CORRECT PATH (SPECULATIVE REPLAY)
[seq 392] actor: agent:claude-code@0.2.29 | tool: Edit | result: "Modified return a - b (correct fix)"
[seq 393] actor: agent:claude-code@0.2.29 | tool: Bash | command: "pytest" -> โ PASSED (2 passed)
๐ LEDGER STATE (AFTER DIVERGENT RUN):
After new run: events 390-393 (prompt, read, edit-right, test-passed)
โโโ seq 390 (user_prompt) -> triggered_by: None
โโโ seq 391 (Read) -> triggered_by: Some(390)
โโโ seq 392 (Edit) -> triggered_by: Some(391)
โโโ seq 393 (Bash) -> triggered_by: Some(392)
โ DEMO COMPLETE: Time-travel execution succeeded!
Ledger truncated, workspace rolled back, and a different future was successfully committed.
No other AI agent runtime lets you do this.
Core Architecture
Korg is built on the same theoretical foundations that make databases and operating systems reliable โ applied to AI cognition for the first time.
| Invariant | What it means |
|---|
| Append-only WAL | Every cognitive event is a ledger entry. Nothing is mutated, only appended. Like a database WAL, but for AI thought. |
| HLC Causal Ordering | Hybrid Logical Clocks guarantee globally consistent, causally ordered event streams โ even across distributed swarm workers. |
| Deterministic Replay | Any campaign can be replayed byte-for-byte from the ledger. Same inputs, same outputs, every time. |
| Speculative Branches | Fork execution into parallel hypothetical paths. Preview before committing. Discard freely. |
| Execution Checkpoints | Snapshot the entire runtime state: ledger offset, projection views, lease maps, workspace tree. Restore in O(1). |
| Micro-Healing | Transient failures (lock conflicts, stale state) are automatically healed at the effect level, with full retry audit trails. |
| Semantic Governance | Swarm actions are validated against BERT embedding cosine similarity โ semantic alignment, not keyword matching. |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ korg v0.1.0 โ session: 019e5333-efc9-7c70 โ โ ACTIVE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ SWARM PLAN โ LIVE MERKLE LEDGER โ
โ โโ [โ] Captain [PLANNING] โ (tx_00)โ(tx_01)โ[tx_02]โ... โ
โ โโ [โ] Harper [RESEARCH] โ โ
โ โโ [โ] Benjamin [SYNTHESIS] โ TELEMETRY โ
โ โโ [โ] Lucas [IDLE] โ โโ Velocity 85.2 t/s โโโโโ โ
โ โ โโ Entropy 0.451 โโโโโ โ
โ GOVERNANCE GATES โ โโ Progress 68.7 % โโโโ
โโ โ
โ โโ ๐ก Amber Security [IDLE] โ โ
โ โโ ๐ข Consensus [ACTIVE] โ LEDGER STREAM โ
โ โโ ๐ต Steering Fork [IDLE] โ [tx_03] Benjamin: patch auth โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Quick Start
Build from source
The crate is not yet published to crates.io; install from source:
git clone https://github.com/New1Direction/korg
cd korg
cargo build --release
./target/release/korg --help
Python bridge (for korgex / korgchat)
cd crates/korg-bridge
maturin develop # builds the PyO3 extension into the active venv
python3 -c "import korg_bridge; print(korg_bridge.__version__)"
Run your first campaign
# Interactive TUI dashboard
korg campaign --tui --prompt "Refactor the auth layer to use JWTs"
# Web cockpit at localhost:8080
korg campaign --web --prompt "Optimize the database connection pool"
# Pure autonomous goal mode (--goal is a top-level flag)
korg --goal "Write and validate a full test suite for src/parser.rs"
# Run the full multi-persona swarm on a REAL local model โ every persona
# (Captain, Harper, Benjamin, Lucas, Evaluator) runs as a real worker
# subprocess doing real, measured, attested work. Defaults to a hermetic
# deterministic provider; `--provider ollama` makes it live.
korg --goal "Fix the failing test in src/lib.rs" --provider ollama --model qwen2.5:7b
# Preview without committing (dry-run; --preview is a top-level flag)
korg --preview "Refactor the main event loop"
Rewind & Verify
# Rewind the capability journal to a specific ledger sequence point
korg rewind --seq 4
# Drive the honest pipeline on a fixture and emit a verifiable ledger
korg run-once "Fix the add function in src/lib.rs so it adds"
# Same pipeline, but with a REAL local model (ollama) on an arbitrary task โ
# the model writes the patch, Korg applies it, measures the real git diff +
# `cargo check`, and attests only what actually changed.
korg run-once "Fix the bug in src/lib.rs: max() returns the minimum.
Output the COMPLETE corrected src/lib.rs:
\`\`\`rust
$(cat your-repo/src/lib.rs)
\`\`\`" --repo your-repo --provider ollama --model qwen2.5:7b
# Independently verify any korg-ledger@v1 journal (no trust in the producer)
korg-verify <path-to-ledger.jsonl>