Repository Mode
Repository mode is the part of Graft that makes SQLite database snapshots behave like project files.
Discovery
Section titled “Discovery”Given a database path:
/work/app/app.dbGraft walks upward looking for:
/work/app/.graft/If found, the database belongs to that repository. If not found, repository commands fail until graft_init or graft_clone creates one.
Path Normalization
Section titled “Path Normalization”The VFS receives database paths from SQLite. On macOS and other systems, the same physical directory can appear through aliases such as:
/var/folders/.../private/var/folders/...Repository mode normalizes path-like tags by canonicalizing the parent directory and keeping the file name. This prevents the same app.db from being treated as two different database tags.
Repo-Local Runtime
Section titled “Repo-Local Runtime”Before a database attaches to a repository, the extension may use process-temporary base storage. After repository discovery, it forks the runtime to use:
.graft/store/That gives each project isolated durable storage.
Index State
Section titled “Index State”The index records the next commit’s file states. For normal staged entries, stage 0 contains the snapshot that will be committed.
Merge conflicts use multiple stages:
stage 1: basestage 2: oursstage 3: theirsConflict resolution chooses one side or writes a resolved database state, then records a normal stage 0 entry again.
Worktree Dirty State
Section titled “Worktree Dirty State”The VFS marks a repo-relative path dirty when SQLite commits page changes. Status then compares:
HEAD tree vs indexindex vs worktreeconflict stagesphysical SQLite files found by directory scanThat is why graft status can report:
untracked: app.dbmodified: app.dbdeleted: app.dbPhysical SQLite Files
Section titled “Physical SQLite Files”Repository mode can stage SQLite database files from the physical worktree, even if the current process did not write them through the VFS. Graft validates that the file has a SQLite header and compatible page size, imports pages into repo-local storage, and records a snapshot.
This is useful for migration, but normal editing should use the Graft VFS so status and dirty state stay immediate.