|
| 1 | +# CLAUDE.md — gpp (git++) Project Context |
| 2 | + |
| 3 | +## What is gpp? |
| 4 | + |
| 5 | +gpp (git++) is an AI-native version control system built in Rust. It replaces Git's commit-centric model with a continuous-capture architecture designed for a world where AI agents are first-class code contributors. |
| 6 | + |
| 7 | +The core insight: Git was designed for humans making deliberate, sequential commits. AI agents produce changes continuously, across multiple files simultaneously, faster than humans can review. gpp is built for this reality. |
| 8 | + |
| 9 | +## Project Structure |
| 10 | + |
| 11 | +``` |
| 12 | +gpp/ |
| 13 | +├── CLAUDE.md # You are here |
| 14 | +├── Cargo.toml # Workspace root |
| 15 | +├── crates/ |
| 16 | +│ ├── gpp-core/ # Storage, objects, content-addressing |
| 17 | +│ ├── gpp-timeline/ # Continuous change capture engine |
| 18 | +│ ├── gpp-history/ # Curated changeset management + review workflow |
| 19 | +│ ├── gpp-graphex/ # Encrypted knowledge graph |
| 20 | +│ ├── gpp-trust/ # Agent reputation & behavioral RBAC |
| 21 | +│ ├── gpp-policy/ # Compliance-as-code engine |
| 22 | +│ ├── gpp-diff/ # Semantic diff engine (tree-sitter based) |
| 23 | +│ ├── gpp-sync/ # CRDT-based P2P replication |
| 24 | +│ ├── gpp-relay/ # Always-on relay node (sync hub, no special authority) |
| 25 | +│ ├── gpp-cost/ # Token/compute cost attribution |
| 26 | +│ ├── gpp-deps/ # Dependency intelligence |
| 27 | +│ ├── gpp-anomaly/ # Pattern detection & alerting |
| 28 | +│ ├── gpp-replay/ # Reproducible agent environments |
| 29 | +│ ├── gpp-notify/ # Event system, webhooks, chat/PM integrations |
| 30 | +│ ├── gpp-remote/ # Platform integration (GitHub, GitLab, Bitbucket APIs) |
| 31 | +│ ├── gpp-review/ # Code review workflow engine |
| 32 | +│ ├── gpp-rbac/ # Human permission model (owner/maintainer/contributor/reader) |
| 33 | +│ ├── gpp-cli/ # CLI binary |
| 34 | +│ ├── gpp-tui/ # Terminal UI (ratatui-based, lazygit-style) |
| 35 | +│ ├── gpp-sdk/ # Agent SDK (Rust + FFI for Python/JS) |
| 36 | +│ └── gpp-git-bridge/ # Git import/export compatibility |
| 37 | +├── extensions/ |
| 38 | +│ ├── gh-gpp/ # GitHub CLI (`gh`) extension |
| 39 | +│ ├── vscode-gpp/ # VS Code extension (TypeScript) |
| 40 | +│ └── neovim-gpp/ # Neovim plugin (Lua) |
| 41 | +├── docs/ |
| 42 | +│ ├── ARCHITECTURE.md |
| 43 | +│ ├── DATA_MODEL.md |
| 44 | +│ ├── CLI_SPEC.md |
| 45 | +│ ├── GRAPHEX_PROTOCOL.md |
| 46 | +│ ├── SYNC_PROTOCOL.md |
| 47 | +│ ├── SECURITY_MODEL.md |
| 48 | +│ ├── ROADMAP.md |
| 49 | +│ └── CONTRIBUTING.md |
| 50 | +├── parsers/ # Tree-sitter grammars for semantic diff |
| 51 | +│ ├── rust/ |
| 52 | +│ ├── python/ |
| 53 | +│ ├── typescript/ |
| 54 | +│ └── go/ |
| 55 | +├── policies/ # Built-in compliance policy templates |
| 56 | +│ ├── secrets-scan.policy |
| 57 | +│ ├── pci-dss.policy |
| 58 | +│ └── bangladesh-bank-pso.policy |
| 59 | +└── tests/ |
| 60 | + ├── integration/ |
| 61 | + ├── fixtures/ |
| 62 | + └── benchmarks/ |
| 63 | +``` |
| 64 | + |
| 65 | +## Architecture Overview |
| 66 | + |
| 67 | +gpp is organized as 12 core layers + 5 integration layers, each a separate Rust crate in a Cargo workspace: |
| 68 | + |
| 69 | +### Core Layers |
| 70 | +1. **Storage** (gpp-core) — Content-addressed encrypted blob store |
| 71 | +2. **Timeline** (gpp-timeline) — Continuous append-only file change capture |
| 72 | +3. **History** (gpp-history) — Curated changesets promoted from timeline |
| 73 | +4. **Graphex** (gpp-graphex) — Encrypted versioned knowledge graph |
| 74 | +5. **Trust** (gpp-trust) — Agent reputation scoring and behavioral RBAC |
| 75 | +6. **Policy** (gpp-policy) — Compliance-as-code enforcement at storage layer |
| 76 | +7. **Semantic Diff** (gpp-diff) — Tree-sitter based structural code diffing |
| 77 | +8. **Sync** (gpp-sync) — CRDT-based offline-first P2P replication |
| 78 | +9. **Cost** (gpp-cost) — Token and compute cost attribution per changeset |
| 79 | +10. **Dependencies** (gpp-deps) — Live risk-aware dependency intelligence |
| 80 | +11. **Anomaly** (gpp-anomaly) — Agent behavior pattern detection |
| 81 | +12. **Replay** (gpp-replay) — Reproducible agent environment snapshots |
| 82 | + |
| 83 | +### Integration Layers |
| 84 | +13. **Relay** (gpp-relay) — Always-on sync hub (not a server with authority — just a persistent peer) |
| 85 | +14. **Review** (gpp-review) — Code review workflow (pending/approved/rejected/changes-requested) |
| 86 | +15. **RBAC** (gpp-rbac) — Human permission model (owner/maintainer/contributor/reader) |
| 87 | +16. **Notify** (gpp-notify) — Event system with webhooks, Slack/Discord/email integration |
| 88 | +17. **Remote** (gpp-remote) — Platform integration layer (GitHub, GitLab, Bitbucket APIs) |
| 89 | + |
| 90 | +### Client Interfaces |
| 91 | +- **CLI** (gpp-cli) — Primary command-line interface |
| 92 | +- **TUI** (gpp-tui) — Interactive terminal UI (ratatui-based, lazygit-style) |
| 93 | +- **SDK** (gpp-sdk) — Agent SDK with Rust + Python + JS bindings |
| 94 | +- **MCP Server** — Model Context Protocol server for AI tool integration |
| 95 | +- **gh-gpp** — GitHub CLI extension |
| 96 | +- **vscode-gpp** — VS Code extension |
| 97 | +- **neovim-gpp** — Neovim plugin |
| 98 | + |
| 99 | +### Agent Interaction Tiers |
| 100 | +gpp supports three tiers of AI agent integration: |
| 101 | +- **Tier 1 (Passive):** Agent edits files normally, timeline captures everything. Zero config. Works with any AI tool. |
| 102 | +- **Tier 2 (Context-aware):** Agent connects via MCP, queries Graphex for project context. Better changes because of context. |
| 103 | +- **Tier 3 (Native):** Agent uses gpp SDK directly — creates exploration branches, proposes changesets with intent, reports costs. |
| 104 | + |
| 105 | +### Deployment Modes |
| 106 | +- **Mode 1 (Serverless P2P):** Direct peer-to-peer sync. No hosted dependency. |
| 107 | +- **Mode 2 (Relay):** `gpp-relay` binary as always-online sync hub. Any team member can run one. Stores encrypted objects, never decrypts. |
| 108 | +- **Mode 3 (Hosted Platform):** Optional `gpp.dev` web UI for browsing, reviewing, dashboards. Everything works without it. |
| 109 | + |
| 110 | +### GitHub Integration Strategy |
| 111 | +gpp treats GitHub as a first-class sync target, not a competitor. The Git bridge pushes/pulls normal Git commits. Graphex, timeline, trust, cost, and policies live locally — GitHub only sees clean Git history. Optional GitHub API integration via `gpp remote` enables auto-opening PRs with rich descriptions, syncing issue references, and CI/CD hooks. |
| 112 | + |
| 113 | +## Key Design Decisions |
| 114 | + |
| 115 | +- **Rust only.** Performance, memory safety, single binary distribution. No runtime dependencies. |
| 116 | +- **Content-addressed storage** using BLAKE3 hashing (faster than SHA-256, cryptographically secure). |
| 117 | +- **Encryption via age (filippo.io/age)** for the Graphex layer and sensitive metadata. |
| 118 | +- **Tree-sitter** for language-aware semantic diffing — pluggable parsers per language. |
| 119 | +- **CRDT (Conflict-free Replicated Data Types)** for sync — specifically Automerge-style operation-based CRDTs. |
| 120 | +- **SQLite** for local indexes (timeline index, graph adjacency, trust scores) — embedded, no server. |
| 121 | +- **Git bridge** for import/export compatibility — never break existing workflows. |
| 122 | +- **MCP (Model Context Protocol)** for agent SDK integration — agents query Graphex via MCP server. |
| 123 | + |
| 124 | +## Conventions |
| 125 | + |
| 126 | +- All monetary/token cost values stored as integers (micro-dollars, 1 = $0.000001) |
| 127 | +- All timestamps are UTC, stored as i64 Unix microseconds |
| 128 | +- All IDs are BLAKE3 hashes, displayed as base32 (human-readable, case-insensitive) |
| 129 | +- Error handling uses `thiserror` for library crates, `anyhow` for CLI |
| 130 | +- Logging uses `tracing` crate throughout |
| 131 | +- Config files use TOML format |
| 132 | +- Test coverage target: 80%+ for core crates, 60%+ for CLI |
| 133 | + |
| 134 | +## Build & Run |
| 135 | + |
| 136 | +```bash |
| 137 | +cargo build --release |
| 138 | +cargo test --workspace |
| 139 | +cargo run --bin gpp -- init --graphex |
| 140 | +``` |
| 141 | + |
| 142 | +## What NOT to Do |
| 143 | + |
| 144 | +- Do NOT add any C dependencies — pure Rust or Rust bindings only |
| 145 | +- Do NOT use async in the storage layer — keep it synchronous for simplicity |
| 146 | +- Do NOT store plaintext secrets anywhere, even in test fixtures |
| 147 | +- Do NOT break Git bridge compatibility without explicit approval |
| 148 | +- Do NOT use unwrap() in library code — always propagate errors |
0 commit comments