Expand description
Byte-exact git commit object serialization from a Heddle State (#566).
Reconstructs the exact bytes git cat-file commit <sha> prints from the
de-lossy fidelity fields #565 captured, so that re-framing (§0) and
SHA-1-hashing the result reproduces the original commit’s object id. This
is the consumer that makes #565’s fields load-bearing and the step that lets
the git mirror be eliminated (#568): a commit can be rebuilt from Heddle
state alone — no stored git object.
The wire format is specced byte-for-byte in
.heddleco-orchestrator/briefs/spike-566-serializer-format.md; the §N
references below point into it. Tag-object reconstruction
(reconstruct_tag_bytes) is deferred to #575, where annotated tags become
first-class content-addressed objects; lightweight tags need no object (just
a ref at the commit).
Functions§
- commit_
object_ id - The git object id (SHA-1) of a commit whose reconstructed content bytes are
content: frame per §0, then hash. Equals the original commit SHA exactly whencontentis byte-identical to the original object. - frame_
git_ object - Frame an object’s content for hashing per spike §0:
<kind> <ascii-decimal-len>\0<content>. A git object’s id is the SHA-1 of THIS buffer — never of the bare content (git cat-filestrips the framing).<len>is the byte length ofcontent(after all folding/newlines), with no leading zeros. - reconstruct_
commit_ bytes - Reconstruct the byte-exact git commit object content (the bytes
git cat-file commitprints, WITHOUT the §0 framing) forstate. - write_
commit_ object - Frame + write a reconstructed commit object’s
contentbytes intorepo’s object database, returning its git OID — the SHA-1 of the framed object (§0), equal to the original commit’s id exactly whencontentis byte-identical to the original.