π The Graph Model Explained
How Atomic tracks every changeβand why nothing is ever truly deleted
Understanding the Numbersβ
When you use Atomic, you'll see output like this:
$ atomic record -m "initial"
[dev 1/XWMUEDIX] initial
1 file changed, +3 vertices, ~0 edges, 21 bytes
$ atomic record -m "edit file"
[dev 2/YRFGB3CG] edit file
1 file changed, +1 vertices, ~1 edges, 30 bytes
What do +3 vertices and ~1 edges mean? Why does creating a file use 3 vertices, but editing it only uses 1?
This guide explains Atomic's graph model in plain termsβand reveals why this design is revolutionary for tracking AI-generated code.
How Atomic Stores Your Filesβ
Unlike Git (which stores snapshots), Atomic stores your files as a directed graph:
- Vertices = chunks of content (pieces of text)
- Edges = connections showing the order of content
Think of it like a chain of puzzle pieces, where each piece is some text and the connections tell you what order to read them in.
FileAdd: Creating a New File (+3 vertices)β
When you create a file called hello.txt with content Hello World, Atomic creates 3 vertices:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FileAdd: 3 Vertices Created β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ROOT (virtual) β
β β β
β βΌ β
β βββββββββββββββββββ β
β β NAME VERTEX β βββ "hello.txt" (the filename) β
β β "hello.txt" β Lives in the parent directory β
β ββββββββββ¬βββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β INODE VERTEX β βββ Empty marker (like a file's ID card) β
β β (empty) β Survives renames, identifies the file β
β ββββββββββ¬βββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β CONTENT VERTEX β βββ "Hello World" (actual file content) β
β β "Hello World" β β
β βββββββββββββββββββ β
β β
β Stats: +3 vertices, ~0 edges β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why 3 vertices?β
| Vertex | Purpose |
|---|---|
| Name vertex | The filename, stored in the parent directory's graph |
| Inode vertex | An empty marker that identifies this file (survives renames) |
| Content vertex | The actual text content |
Edit/Replacement: Modifying a File (+1 vertex, ~1 edge)β
Now let's say you change Hello World to Hello Universe.
Old approach (full replacement): Delete everything, recreate 3 new vertices. Wasteful!
Atomic's approach (Edit/Replacement): Only change what's different:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Replacement: 1 Vertex + 1 Edge β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β BEFORE: AFTER: β
β β
β βββββββββββββββββββ βββββββββββββββββββ β
β β NAME VERTEX β β NAME VERTEX β (unchanged) β
β β "hello.txt" β β "hello.txt" β β
β ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ β
β β β β
β βΌ βΌ β
β βββββββββββββββββββ βββββββββββββββββββ β
β β INODE VERTEX β β INODE VERTEX β (unchanged) β
β ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ β
β β β β
β βΌ βΌ β
β βββββββββββββββββββ βββββββββββββββββββ β
β β "Hello World" ββββββββββββββββΊβ "Hello World" β DELETED β
β β β mark as β β³β³β³β³β³β³β³β³β³β³β³β³β³ β (edge mod) β
β βββββββββββββββββββ deleted ββββββββββ¬βββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β "Hello Universe"β NEW VERTEX β
β β β (+1 vertex) β
β βββββββββββββββββββ β
β β
β Stats: +1 vertices (new content), ~1 edges (mark old as deleted) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why +1 vertex, ~1 edge?β
| Operation | What it means |
|---|---|
| +1 vertex | The new content "Hello Universe" is a new chunk |
| ~1 edge | We modified an edge to mark "Hello World" as deleted |
The old content isn't erasedβit's marked with a DELETED flag on its edge. The vertex still exists in the graph!
The Diff Algorithm's Roleβ
The diff algorithm (Myers or Patience) compares old vs new content and tells us:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Diff Algorithm Output β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Old Content: New Content: Diff Operations: β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββββ β
β β line1 β β line1 β β KEEP line1 β β
β β line2 β vs β MODIFIED β => β DELETE line2 β β
β β line3 β β line3 β β INSERT MODIFIED β β
β ββββββββββββββββ ββββββββββββββββ β KEEP line3 β β
β ββββββββββββββββββββββββ β
β β
β DELETE = mark existing vertex's edge as DELETED (~1 edge) β
β INSERT = create new vertex for new content (+1 vertex) β
β KEEP = do nothing, content already exists in graph β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Quick Reference: Operation Statsβ
| Operation | Vertices Added | Edges Modified | Why |
|---|---|---|---|
| FileAdd (new file) | +3 | ~0 | Name + Inode + Content |
| Edit (insert only) | +1 | ~0 | Just new content chunk |
| Edit (delete only) | +0 | ~1 | Mark old content as deleted |
| Replacement (change) | +1 | ~1 | New content + mark old as deleted |
| FileDel (delete file) | +0 | ~1+ | Mark file edges as deleted |
| FileMove (rename) | +1 | ~1 | New name vertex + delete old name edge |
Soft Deletes: The Key to Everythingβ
Here's the crucial insight: content is never truly deleted in Atomic.
When you "delete" something, we just mark an edge with a DELETED flag. The original vertexβand all its metadataβremains in the graph forever.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Soft Delete Preserves History β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Git Model (Hard Delete): Atomic Model (Soft Delete): β
β β
β ββββββββββββββββ ββββββββββββββββ β
β β "old code" β β "old code" β β
β β by: Alice β βββΊ GONE! β by: Alice β βββΊ STILL HERE! β
β β AI: Claude β β AI: Claude β (just hidden) β
β ββββββββββββββββ ββββββββ¬ββββββββ β
β β DELETED flag β
β βΌ β
β ββββββββββββββββ β
β β "new code" β β
β β by: Bob β β
β β AI: none β β
β ββββββββββββββββ β
β β
β In Git: You lose Alice's In Atomic: Alice's attribution β
β attribution when Bob rewrites is preserved. We know the NEW β
β the code. code replaced HER code. β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why This Matters: AI Attributionβ
This graph model is revolutionary for tracking AI-generated code.
The Problem with Gitβ
In Git, when someone rewrites AI-generated code, you lose the original attribution:
# Alice uses Claude to generate auth code
git commit -m "Add authentication (AI-generated)"
# Bob rewrites it for security
git commit -m "Fix security issue in auth"
# Now: WHO originally wrote the auth logic?
# Git says: Bob. The AI attribution is buried in history.
The Atomic Solutionβ
Every vertex carries its full provenanceβforever:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Provenance Through Edits β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Change #1: AI generates function β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β Vertex: "function authenticate() {..." β β
β β Author: Alice β β
β β Provenance: β β
β β - AI: Claude Opus 4 β β
β β - Type: code_generation β β
β β - Tokens: 1,247 β β
β β - Cost: $0.03 β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β β
β β Change #2: Human fixes a bug β
β β (Replacement: ~1 edge, +1 vertex) β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β Vertex: "function authenticate() {..." β βββ DELETED but β
β β Author: Alice β PRESERVED! β
β β Provenance: Claude Opus 4 β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β Vertex: "function authenticate() {..." β βββ New vertex β
β β Author: Bob β Human edit β
β β Provenance: none (human-written) β β
β β REPLACES: [points to Alice's vertex] β βββ Link to original! β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β
β We can ALWAYS trace back: β
β "This code was originally AI-generated by Claude for Alice, β
β then modified by Bob (human) to fix a bug" β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
What Metadata is Preserved?β
Every vertex in Atomic carries rich metadata:
Vertex {
content: "function validate(input) { ... }",
change_hash: "ABC123...",
author: "Alice <alice@company.com>",
timestamp: "2024-01-25T10:30:00Z",
provenance: Some(Provenance {
vendor: Anthropic,
model: "claude-opus-4",
tool: Cursor,
suggestion_type: CodeGeneration,
tokens: TokenUsage { input: 500, output: 747 },
cost: Cost { amount: 0.03, currency: USD },
session_id: "sess_abc123",
}),
}
This metadata travels with the vertex foreverβeven when "deleted", the vertex exists and can be queried.
Unrecord: Undo Without Losing Historyβ
In Git, undoing a commit either:
git revertβ Creates a new commit that undoes changes (loses context)git resetβ Erases commits entirely (loses everything)
In Atomic, Unrecord preserves everything:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Unrecord: Undo Without Losing History β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Original State: After Bad Change: After Unrecord: β
β β
β βββββββββββ βββββββββββ βββββββββββ β
β β "good" β β "good" β DELETED β "good" β ALIVE β
β β AI:opus β β AI:opus β β AI:opus β β
β βββββββββββ ββββββ¬βββββ βββββββββββ β
β β β
β βΌ β
β βββββββββββ βββββββββββ β
β β "bad" β β "bad" β DELETED β
β β AI:none β β AI:none β (unrecorded)β
β βββββββββββ βββββββββββ β
β β
β The "good" vertex with AI attribution is RESURRECTED. β
β The "bad" vertex is now marked as deleted. β
β ALL METADATA IS PRESERVED - nothing is ever lost! β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Credit Command: Who Wrote What?β
The graph model enables powerful attribution queries:
$ atomic credit src/auth.rs
Lines 1-50: Alice (human) - original implementation
Lines 51-80: Claude Opus 4 (AI) - generated for Bob
Lines 81-95: Carol (human) - bug fix
Lines 96-120: Claude Opus 4 (AI) - generated for Bob
βββ modified by Dave (human) - security review
AI Summary:
- 45% of current code has AI provenance
- Original AI cost: $0.12 (2,847 tokens)
- AI code modified 2x by humans
This is only possible because we never delete the original vertices.
CRDT Properties: Why Order Doesn't Matterβ
The graph model gives Atomic CRDT-like merge properties:
- Vertices are immutable β Once created, content never changes (we just add new vertices)
- Deletions are markers β Old content isn't erased, just flagged (can be resurrected!)
- Order is flexible β Edges define order, and independent changes merge automatically
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Why This Enables Clean Merges β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Alice's change: Bob's change: β
β Edit line 2 Edit line 5 β
β +1 vertex, ~1 edge +1 vertex, ~1 edge β
β β β β
β βββββββββββββ¬ββββββββββββββββββββ β
β β β
β βΌ β
β Merge Result: β
β Both changes apply cleanly! β
β +2 vertices, ~2 edges β
β β
β Because the vertices don't overlap, there's no conflict. β
β Each change adds its own vertex and modifies its own edge. β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Comparison: Git vs Atomicβ
| Feature | Git | Atomic |
|---|---|---|
| Delete old content | Erased from current tree | Soft-deleted (edge flag) |
| Original metadata | Lost on rewrite | Preserved forever |
| AI attribution | Only in commit message | In every vertex |
| Undo (unrecord) | Reverts lose context | Resurrects original |
| Audit trail | Commit history only | Complete graph traversal |
| Legal compliance | Manual tracking | Built into the model |
Try It: See the Graph in Actionβ
# Create a repository
atomic init my-project && cd my-project
# Create and record a file
echo "Hello World" > hello.txt
atomic add hello.txt
atomic record -m "Add hello"
# Output: +3 vertices, ~0 edges
# Edit the file
echo "Hello Universe" > hello.txt
atomic record -m "Edit hello"
# Output: +1 vertices, ~1 edges
# See what's in the change
atomic change
# Shows: Β± hello.txt (+1 vertex, ~1 edge: replace)
Summaryβ
Atomic stores your code as a graph of immutable vertices connected by edgesβ"deleting" content just marks edges as deleted, preserving all metadata forever.
This isn't just a technical detailβit's what makes Atomic the system of record for AI-assisted development:
- β Legal compliance: Always prove what was AI-generated
- β Audit trail: Complete history of human vs AI contributions
- β Cost tracking: AI token usage preserved even after rewrites
- β Credit/blame: Know who introduced what, even after refactoring
The Replacement model (+1 vertex, ~1 edge) is fundamental to Atomic's value proposition. By keeping old content instead of erasing it, every piece of code maintains its complete lineage.