仓库模型
Graft repository mode 给 SQLite 应用数据目录一个 Git-like 形状:
project/ data.sqlite analytics.sqlite attachments/ settings.json .graft/worktree 是普通应用文件;.graft/ 保存 repository metadata、objects、refs、
index、本地 SQLite storage 和 external payload cache。
Worktree
Section titled “Worktree”Repository path 相对于 worktree:
data.sqliteanalytics.sqliteattachments/report.pdfsettings.jsongraft sql --db data.sqlite 和其他 SQLite client 一样打开物理文件。
repository command 会把绝对路径映射回 data.sqlite。可选的 vfs=graft 模式
改为把 live pages 存入 Graft Volume,但保持相同的 repository path identity。
index 是 staging area。stage SQLite 数据库会记录当前数据库状态的 snapshot descriptor;stage 文件会记录 artifact object 或 external payload pointer。
graft add data.sqlitegraft add attachments/report.pdfgraft commit -m "save state"merge conflict 的 base/ours/theirs stages 也存放在 index 中。
对于物理数据库,graft add 通过 SQLite 取得一致 backup,再按 4 KiB Graft
storage chunk 和当前 index 或 HEAD 比较。未变化的 chunk 继续引用原 snapshot,
只有变化 chunk 扩展 storage history。这个存储粒度独立于物理数据库的 SQLite
page size。
Commits、Trees、Refs
Section titled “Commits、Trees、Refs”commit 指向 tree,tree 把 repository paths 映射到 typed objects:
data.sqlite sqlite_snapshot_v1settings.json file_blob_v1attachments/report.pdf large_file_pointer_v1branches 和 tags 是 .graft/refs/ 下的 refs,HEAD 指向当前 branch 或一个
detached commit。
Project Isolation
Section titled “Project Isolation”repository mode 是项目本地的。两个目录都可以有 data.sqlite,但它们拥有不同
的 .graft/、refs、objects、remotes、index、storage 和 payload cache。