Skip to content

04 Checkout And Restore

ActionDestinationMoves ref/indexReplaces tracked worktree
hydrationlocal object/page/payload storenono
materializationrepository-relative physical pathdepends on calleryes
exportcaller-selected independent pathnono

Row diff can create a temporary materialized_compat database. It lives in an isolated temporary directory and is not application-worktree materialization.

switch, revision checkout, restore, hard reset, pull, clone, and some merge operations compute a checkout plan. Before applying it, Graft resolves and validates tree/blob data, hydrates missing immutable dependencies, checks collisions, determines affected paths, and performs replacement preflight before changing repository state where ordering permits.

Planning may hydrate data, but it may not move HEAD, modify the index, or touch application files.

Checkout installs a new ordinary SQLite file and does not preserve its inode. Even an idle connection can continue referring to the old file description. The safe host lifecycle is:

drain transactions / optionally checkpoint
|
close affected application SQLite handles
|
run materializing Graft operation
|
success: reopen
failure: inspect status and path results, reconcile, then reopen or retry

operationMaterializesWorktree(name) is a conservative pre-call gate. true means the operation can materialize for some input. Post-call worktree_paths reports the exact effect.

The adapter validates a regular file, probes an exclusive transaction with bounded timeout, checkpoints and truncates WAL when required, returns to rollback-journal mode, removes regular sidecars, and holds a replacement guard. It writes the complete snapshot to a unique same-directory temporary file, flushes it, atomically renames/replaces the path, and updates its volume binding.

An active writer, long transaction, busy WAL, non-regular sidecar, or path collision fails without overwriting the main file.

Multi-path checkout is not one filesystem transaction

Section titled “Multi-path checkout is not one filesystem transaction”

Affected SQLite files are moved to private .graft/tmp/workspace-checkout-* backups. Graft then materializes SQLite, artifacts, and bindings path by path. A later failure triggers reverse-order restoration. One rename may be atomic; the whole multi-path checkout is not. After failure, inspect graft status and returned path actions rather than guessing from one visible file.

worktree.materialize_sqlite = false stops ordinary checkout plans from projecting SQLite snapshots. Canonical repository state and volume bindings still change, and explicit resolution or ordinary artifacts can still write the worktree. Use the operation gate, not this setting alone, to manage application handles.

OperationCan materializeMain change
status, log, diff, fetchnoread or local repository storage only
add, commitnoindex/objects/ref
restore staged, mixed resetnoindex/ref classification
switch, checkout, path restoreyesapply checkout plan
hard reset, pull, cloneyescanonical state plus projection
planMergenoread-only plan, optional hydration
applyMerge, resolution, abortyesresult or restored files
exportnoindependent destination

Non-materializing does not mean no disk writes: fetch writes stores and commit writes objects/refs. It only promises not to replace application-owned tracked paths.