Welcome to the entireio-cli project! If you are new here, you are starting at the very beginning.
Imagine you are playing a difficult video game. Before you fight a boss, you save your game. If you lose, you reload that save point and try again.
In AI-assisted coding, Checkpoint Storage provides exactly this feature. It creates "Save Points" for your development session. When an AI agent writes code, it might make a mistake or delete something important. Checkpoints allow you to "rewind" time, restoring both your code and the AI's memory (the transcript) to a specific moment.
A Checkpoint captures the state of your project at a specific point in time. It is the fundamental unit of history in entireio-cli.
There are two distinct types of checkpoints to understand:
entire/a1b2c...).entire/checkpoints/v1.Let's say you are building a website, and you ask the AI to "Change the button color to blue."
Here is how the Checkpoint Storage handles this:
style.css.
The logic for saving and loading these points is defined in the Store interface. This interface handles the low-level "plumbing" of talking to Git.
Here is a simplified look at the Store interface from cmd/entire/cli/checkpoint/checkpoint.go:
// Store manages reading and writing checkpoints to Git.
type Store interface {
// Save a full snapshot to a shadow branch
WriteTemporary(ctx context.Context, opts WriteTemporaryOptions) (WriteTemporaryResult, error)
// Read the latest snapshot from a shadow branch
ReadTemporary(ctx context.Context, baseCommit, worktreeID string) (*ReadTemporaryResult, error)
// Write permanent metadata to the entire/checkpoints/v1 branch
WriteCommitted(ctx context.Context, opts WriteCommittedOptions) error
}
Explanation: The Store acts like a librarian. You give it data (Write), or ask for data (Read). It hides the complexity of how that data is organized on the shelves (Git branches).
Let's look at how we actually save a checkpoint in code.
When the AI is about to make a change, we call WriteTemporary. We need to provide the current session ID and which files have changed.
// Example: Saving a temporary checkpoint
opts := checkpoint.WriteTemporaryOptions{
SessionID: "session-123",
BaseCommit: "abc1234", // The git commit we started from
ModifiedFiles: []string{"main.go"},
CommitMessage: "AI is updating main.go",
}
// result contains the hash of the saved state
result, err := store.WriteTemporary(ctx, opts)
Explanation: This command takes the current state of main.go and saves it to a shadow branch. If main.go hasn't actually changed since the last save, the store is smart enough to skip writing (deduplication), keeping things fast.
If we need to undo, we read back the data.
// Example: Reading the latest temporary state
// We look up by the commit we started from (BaseCommit)
result, err := store.ReadTemporary(ctx, "abc1234", "")
if result != nil {
fmt.Printf("Found checkpoint created at: %s", result.Timestamp)
// We can now restore files using result.CommitHash
}
Explanation: Unlike standard databases where you look up by ID, temporary checkpoints are often looked up by the BaseCommitβthe commit your working branch is currently sitting on.
How does entireio-cli keep these checkpoints without cluttering your main Git history? It uses Shadow Branches.
When you write a temporary checkpoint, the system switches to a detached, orphan branch that doesn't share history with your main branch.
For Committed Checkpoints (the permanent ones), we store metadata in JSON files on the entire/checkpoints/v1 branch.
If we just threw 10,000 files into one folder, Git would become very slow. To solve this, we use Sharding.
The ID of a checkpoint is 12 characters, e.g., a3b2c4d5e6f7.
We split this ID to create a folder structure:
a3b2c4d5e6f7a3/b2c4d5e6f7/metadata.jsonThis ensures that no single folder contains too many files, keeping the system performant even after years of use.
The implementation resides in cmd/entire/cli/checkpoint/store.go. It wraps a standard Go git library.
// GitStore implements the Store interface using a git repository.
type GitStore struct {
repo *git.Repository
}
func NewGitStore(repo *git.Repository) *GitStore {
return &GitStore{repo: repo}
}
Explanation: The GitStore struct is simple. It just holds a reference to your repository. All the complex logic happens inside the methods (like WriteTemporary) which use repo to manipulate Git objects directly.
In this chapter, you learned:
Store interface hides the complex Git plumbing required to make this happen.Now that we know how to save checkpoints, we need to decide when to save them and how to organize them into a workflow. This is handled by the Strategy Pattern.
Next Chapter: Strategy Pattern
Generated by Code IQ