Exgit.Workspace.VFS (exgit v0.1.0)

Copy Markdown View Source

VFS.Mountable defimpl for Exgit.Workspace.

Loaded only when :vfs is available — Exgit.Workspace is fully usable without :vfs for direct API access. Mounting a workspace into a %VFS{} mount table makes it interoperable with other backends (in-memory scratch, postgres, S3) under one tree.

ws = Exgit.Workspace.open(repo, "main")
fs = VFS.new() |> VFS.mount("/repo", ws)

{:ok, content, fs} = VFS.read_file(fs, "/repo/lib/foo.ex")
{:ok, fs} = VFS.write_file(fs, "/repo/lib/foo.ex", new_source)

The mount table threads workspace state through every op, so cache growth from lazy fetches and head_tree advancement from writes are both visible to subsequent calls.

Capabilities

[:read, :write, :lazy]. We do not claim :mkdir: git trees cannot represent empty directories, so a faithful mkdir/3 has no honest semantics. Writes implicitly create parents (vfs explicitly supports this for flat-keyed backends).

Mutations through vfs vs git-aware ops

File-shaped mutations (write_file, rm) flow through this impl. Git-aware ops (Exgit.Workspace.commit/2, snapshot/1, restore/2, diff/1, checkout/2) are not part of VFS.Mountable — agents reach for them on the workspace struct directly.