contexa
Git-inspired context management for LLM agents. COMMIT, BRANCH, MERGE, and CONTEXT operations over a persistent versioned memory workspace.
Rust implementation of the contexa framework.
Based on: arXiv:2508.00031 -- "Git Context Controller: Manage the Context of LLM-based Agents like Git" (Junde Wu et al., 2025)
Installation
[]
= "0.1"
Quick Start
use GCCWorkspace;
Core Concepts
OTA Logging (Observation-Thought-Action)
let rec = ws.log_ota?;
println!; // 1 (auto-incremented)
println!; // RFC3339
COMMIT -- Save Milestones
let commit = ws.commit?;
assert_eq!;
assert_eq!;
BRANCH -- Explore Alternatives
ws.branch?;
ws.log_ota?;
ws.commit?;
assert_eq!;
println!; // ["main", "redis-cache"]
MERGE -- Integrate Results
let merge_commit = ws.merge?;
// Appends branch OTA trace to main's log
// Creates a merge commit on main
// Marks branch as "merged" in metadata
assert_eq!;
CONTEXT -- Retrieve History
let ctx = ws.context?; // K=1: paper default
println!; // "main"
println!; // Global project roadmap
println!; // Last K CommitRecords
println!; // All OTA records
println!; // BranchMetadata
// Formatted markdown summary for LLM prompt injection
println!;
API Overview
GCCWorkspace
| Method | Signature | Description |
|---|---|---|
new |
(project_root: impl AsRef<Path>) -> Self |
Create workspace handle |
init |
(&mut self, roadmap: &str) -> Result<()> |
Create .GCC/ structure |
load |
(&mut self) -> Result<()> |
Load existing workspace |
log_ota |
(&self, obs, thought, action) -> Result<OTARecord> |
Append OTA step |
commit |
(&self, contribution, prev?, roadmap?) -> Result<CommitRecord> |
Checkpoint milestone |
branch |
(&mut self, name, purpose) -> Result<()> |
Create and switch branch |
merge |
(&mut self, branch, summary?, target) -> Result<CommitRecord> |
Merge branch |
context |
(&self, branch?, k) -> Result<ContextResult> |
Retrieve context |
switch_branch |
(&mut self, name) -> Result<()> |
Switch active branch |
list_branches |
(&self) -> Vec<String> |
List all branches |
current_branch |
(&self) -> &str |
Get current branch |
Data Models
| Struct | Description |
|---|---|
OTARecord |
Single Observation-Thought-Action cycle |
CommitRecord |
Milestone commit snapshot |
BranchMetadata |
Branch creation intent and status (Serde-serializable) |
ContextResult |
Result of CONTEXT retrieval with .summary() method |
GCCError |
Error type covering IO, YAML, and workspace errors |
Directory Structure
your-project/
.GCC/
main.md # Global roadmap
branches/
main/
log.md # Continuous OTA trace
commit.md # Milestone-level summaries
metadata.yaml # Branch intent & status
feature-branch/
log.md
commit.md
metadata.yaml
All data is stored as human-readable Markdown and YAML.
Running Tests
8 tests + 1 doc-test cover all GCC commands.
Dependencies
- serde + serde_yaml -- YAML serialization for branch metadata
- chrono -- UTC timestamps (RFC3339)
- uuid -- Commit ID generation (v4 UUIDs, first 8 chars)
- thiserror -- Ergonomic error types
License
MIT License. See LICENSE for details.
Citation