Expand description
Direct file access against a packchain remote (issue #65).
read_blob is the differentiated value-add of the packchain
engine: a caller fetches a single file at a ref’s tip without
cloning, materialising a working tree, or invoking git. The
lookup walks the on-bucket artefacts the Phase 2 push wrote:
chain.jsonto verify the ref exists.path-index.jsonto resolvepath→ blob SHA at tip.- Each segment’s
.idx(newest-first) to locate the blob’s pack entry. - A ranged GET against the matching
.packto fetch the entry bytes, zlib-decompressed (and delta-applied, if applicable).
The pack-index parses are amortised across calls via
PackIndexCache, a byte-bounded LRU keyed by
(prefix, content-sha). Single-shot callers can pass
&PackIndexCache::default() and let the cache GC at drop.
§Delta resolution
Pack entries may be deltas against a base elsewhere in the chain.
OFS_DELTA resolves within the same pack via a relative back-offset;
REF_DELTA resolves to a SHA which may live in any pack in the
chain. The walker recurses, capped at MAX_DELTA_DEPTH (matching
git’s own limit) so a corrupted chain with a delta cycle aborts
cleanly instead of looping forever.
§What this module does not do
- No on-disk cache: indices live in memory only. CI agents that want cross-process amortisation should layer their own.
- No directory listings:
read_blobis single-file. The nested-tree shape supports listing cleanly, but it’s a separate API and out of scope for issue #65.
Structs§
- Pack
Index Cache - In-process LRU cache of decoded pack indices keyed by
(prefix, content-sha).
Constants§
- DEFAULT_
CACHE_ CAPACITY_ BYTES - Default in-memory budget for
PackIndexCache(64 MiB), matching the cap the issue #65 plan calls out. Covers a chain of dozens of large packs without thrashing. - MAX_
DELTA_ DEPTH - Hard cap on delta-chain depth, matching git’s own
pack.deltaCacheLimit-adjacent recursion limit. A correctly built chain won’t approach this; tripping the cap means the pack is corrupted (a cycle) or pathologically deep, and either way stopping is the right call.
Functions§
- read_
blob - Read the contents of
pathatref_name’s tip from a packchain remote.