Expand description
Transfer-layer helpers: delta-aware pack planning and the packlist discovery wire format.
These sit ABOVE the on-disk pack format (SPEC-PACKFILE / SPEC-DELTA)
and below the transport. The push path uses plan_pack to decide
which objects of a ref’s closure to send, and how — raw, or as a delta
against a base the remote already holds. The plan is then serialised
with crate::pack::PackWriter into one or more packs — split when
the plan’s payload exceeds a single pack’s cap (issue #831; the CLI’s
remote_dispatch::build_and_upload_packs owns the splitting) — each
keyed by its own BLAKE3 digest.
Because a delta-encoded pack is keyed by the pack digest (not by the
reconstructed object’s hash), the fetch side can no longer find it by
walking object hashes. Each push records a PackListNode — this
module’s small versioned wire format — holding the pack(s) it added plus
a prev pointer to the previous node, forming a per-branch chain. The
push side advertises the chain head through a refs/mkit/packmap/<branch>
metadata ref whose value is the BLAKE3 of the head node (itself stored as
a pack object). The fetch side reads that ref, walks the chain, and
unpacks every pack oldest-first. Chaining keeps each push O(1) on the
wire rather than re-uploading the whole history’s list.
Content addressing is unchanged: delta is a transfer encoding only. The
reconstructed object’s id (BLAKE3 of its canonical bytes, or the merkle
BMT root for a Tree/ChunkedBlob — see crate::merkle) is
re-verified by PackReader before storing.
Structs§
- Pack
List Node - A single node in a branch’s packlist chain.
- Pack
Plan - A deterministic plan for the pack(s) a push uploads for one ref — serialised into a single pack when it fits under the payload cap, or split across several when it doesn’t (issue #831).
- Planned
Delta - One delta entry in a
PackPlan: a target object encoded against a base the remote already holds.
Enums§
- Pack
List Error - Errors decoding a
PackListNodeblob.
Constants§
- PACKLIST_
MAGIC - ASCII magic at the start of every packlist node (“mkit pack list”).
- PACKLIST_
MAX_ ENTRIES - Hard cap on packs recorded in a single node — a normal push records one; refuse to allocate unboundedly on a malformed blob.
- PACKLIST_
VERSION - Current packlist version. Readers reject anything else so a future format change is a loud error, not a silent misparse.
Functions§
- decode_
packlist - Parse a packlist node blob.
- encode_
packlist - Serialise one packlist node: the
MKPL/version guard header followed by theprev/packsbody encoded withcommonware-codec(idiomaticOption+Vec). - plan_
pack - Plan the pack for pushing
new_tipto a remote whose current tip isold_tip(Nonefor a first push or a remote we cannot diff against). - select_
chunk_ delta_ bases - Choose, for each changed
FastCDCchunk or small blob innew_tip, a base object fromold_tipto delta against.