Expand description
Git-tree-backed MemWriter — the second
storage adapter. Buffers mutations
in memory and applies them to a tree built via
gix::object::tree::Editor, then advances the target ref via
gix::Repository::commit_as.
No working tree is written: the mem’s content lives only in the
multi-root mem-repo-git object store, one branch per mem. Each
commit rebuilds the tree from the buffered op log against the
snapshotted parent tree.
§Snapshot + CAS
On the first mutation of a “session” (the period between two
successful commits, or between construction and the first commit),
the writer snapshots the current ref tip’s gix::ObjectId. That
snapshot is the parents argument to
gix::Repository::commit_as; gix’s underlying ref-edit transaction
enforces PreviousValue::ExistingMustMatch(previous) for non-HEAD
refs, which is the exact CAS guard we want. If a concurrent writer
advanced the ref between snapshot and commit, the gix call returns
gix::commit::Error::ReferenceEdit; we re-resolve the live tip and
surface super::MemWriterError::HashMismatch with the new tip’s
hex OID. That maps into
[crate::EngineError::HashMismatch] so MCP agents see a stable
_hash to retry with.
No internal retry loop: every CAS conflict bubbles up. Cross-process contention in Phase 1 is intentionally simple — concurrency hardening comes later (D7 in the design doc).
Structs§
- Branch
Blob - One blob entry returned by
read_branch_blobs— the mem-relative forward-slash path and the blob bytes. The list is sorted bypathso callers (e.g. archive emitters) get deterministic ordering without a re-sort. - GitTree
MemWriter - Git-tree-backed implementation of
MemWriter. Holds the gitdir path and target ref name; opens thegix::Repositoryper call (matches the [crate::vcs::GixVcs] pattern, sincegix::RepositoryisSendbut notSync— its object-database cache uses interior mutability viaRefCell).
Enums§
- Branch
Read Error - Errors surfaced by
read_branch_blobs. Wraps the gix repo / reference / object operations so callers can map a missing branch or a malformed object to a structured error without re-importing gix’s error types.
Functions§
- read_
branch_ blobs - Walk every blob in the tree pointed at by
<gitdir>:<ref_name>’s commit and return their (path, bytes) pairs sorted by path. The branch tip’s commit is peeled to a tree, then the tree is recursed breadth-first. Subtrees are descended; symlinks and non-blob entries are skipped (mem content is regular files only).