pub struct State {Show 19 fields
pub state_id: StateId,
pub change_id: ChangeId,
pub tree: ContentHash,
pub parents: Vec<StateId>,
pub attribution: Attribution,
pub intent: Option<String>,
pub confidence: Option<f32>,
pub created_at: DateTime<Utc>,
pub verification: Option<Verification>,
pub status: Status,
pub provenance: Option<ContentHash>,
pub authored_at: Option<DateTime<Utc>>,
pub committer: Option<Principal>,
pub authored_tz_offset: i32,
pub committer_tz_offset: i32,
pub raw_message: Option<Vec<u8>>,
pub git_lossy: bool,
pub extra_headers: Vec<(Vec<u8>, Vec<u8>)>,
pub lineage: Vec<ChangeLineage>,
}Expand description
Immutable source-history state. state_id is recomputed from every encoded
field; mutable repository metadata lives in StateAttachment objects.
Fields§
§state_id: StateId§change_id: ChangeId§tree: ContentHash§parents: Vec<StateId>§attribution: Attribution§intent: Option<String>§confidence: Option<f32>§created_at: DateTime<Utc>§verification: Option<Verification>§status: Status§provenance: Option<ContentHash>Authoring timestamp for this state, when distinct from
created_at.
created_at is the committer time — when the state object
came into being in its current form. authored_at is the
author time — when someone actually wrote the change — which
survives git rebase, cherry-pick, squash-merge, and git commit --amend. The ingest-backed import git path fills
this from the git author time; native heddle commits leave it
None and blame falls back to created_at.
Part of the state hash (#564 de-lossy step 1). Author time
is part of a git commit’s identity: two commits that differ
only by author timestamp are distinct git objects, so folding
it into the hash keeps them from dedup-colliding to one State in
the content-addressed store. None hashes as a single absence
byte, so native commits are unaffected beyond the format bump.
committer: Option<Principal>The git committer identity, when distinct from the author
(Attribution::principal). Git records both an author (who wrote
the change) and a committer (who created this commit object); for
rebased / cherry-picked / amended commits the two differ. None
for native heddle commits and for legacy imports from before #565.
Timezone offset (seconds east of UTC) of the author timestamp
(State::authored_at / created_at fallback). Git stores the
author’s local offset (e.g. +0000, -0700); Heddle used to
discard it. 0 for native commits and legacy imports.
committer_tz_offset: i32Timezone offset (seconds east of UTC) of the committer timestamp
(created_at). 0 for native commits and legacy imports.
raw_message: Option<Vec<u8>>The verbatim git commit message body (everything after the header
block), preserved exactly so reconstruction is byte-stable. Distinct
from intent, which is the trimmed first line surfaced in the UI.
None for native commits and legacy imports.
Stored as raw bytes, NOT a String: a commit with a non-UTF8
encoding (latin-1, shift-jis, …) carries message bytes that are not
valid UTF-8 (e.g. 0xe9 for latin-1 é); a String could not
round-trip them byte-identically. (non-UTF8 author/committer identity
names are not yet byte-preserved — Principal is still String; see
#564.)
git_lossy: boolThe SINGLE canonical “this state’s content is NOT byte-faithful to the
original git object” marker (#567). Set to true by lossy import
population paths whenever an unrepresentable tree entry was dropped or
converted during import, so the rebuilt tree (hence commit) no longer
hashes to the original SHA. The git-export fidelity guard reads this one
flag to decide whether reconstruct-from-state is safe, instead of
enumerating import surfaces. false for native heddle commits and for
lossless imports.
Provenance metadata, NOT part of the content hash: a lossy import always drops/converts tree entries, so its tree — and therefore the rest of the hashed identity — already differs from a lossless import of the same source; folding the flag in would add nothing but break every existing content hash.
extra_headers: Vec<(Vec<u8>, Vec<u8>)>Every git commit header beyond the ones Heddle models natively
(tree/parents/author/committer), in their original order. ORDER IS
LOAD-BEARING for #566 byte-exactness — this is a Vec, never a map.
Empty for native commits and legacy imports.
gpgsig is just one of these headers and is kept INLINE at its
captured ordinal (not split into a separate field): when a commit’s
extension headers are in non-canonical order — e.g. x-custom, then
gpgsig, then mergetag — splitting gpgsig out would lose its
position and break byte-identical reconstruction. The serialization
source of truth for the signature is its position here (spike §3).
Both the header name and value are raw bytes (Vec<u8>), NOT
Strings: extra-header VALUES (a mergetag payload is a full tag
object; custom headers; gpgsig armor) can be non-UTF8, so a
String would force a lossy to_string() that destroys those bytes.
Names are ASCII by git’s spec but are bytes too so the whole tuple is
byte-exact and no conversion sneaks in.
lineage: Vec<ChangeLineage>Implementations§
Source§impl State
impl State
pub fn new( tree: ContentHash, parents: Vec<StateId>, attribution: Attribution, ) -> Self
pub fn new_snapshot( tree: ContentHash, parents: Vec<StateId>, attribution: Attribution, ) -> Self
pub fn new_merge( tree: ContentHash, parents: Vec<StateId>, attribution: Attribution, ) -> Self
pub fn new_refresh_of( tree: ContentHash, parents: Vec<StateId>, attribution: Attribution, change_id: ChangeId, ) -> Self
pub fn new_fork_of( tree: ContentHash, parents: Vec<StateId>, attribution: Attribution, ) -> Self
pub fn new_collapse_of( tree: ContentHash, parents: Vec<StateId>, attribution: Attribution, ) -> Self
pub fn with_intent(self, intent: impl Into<String>) -> Self
pub fn with_confidence(self, confidence: f32) -> Self
pub fn with_verification(self, verification: Verification) -> Self
pub fn with_provenance(self, provenance: ContentHash) -> Self
Record the authoring timestamp separately from created_at.
Used by the git-ingest importer to preserve the distinction
between “when the change was originally written” (authored)
and “when this commit object came into being” (committer time,
stored in created_at so re-imports stay deterministic).
Native heddle commits leave this None; blame display then
falls back to created_at.
Part of the state hash (#564 de-lossy step 1) — see the
authored_at field docs and update_hash.
Sourcepub fn with_committer(self, committer: Principal) -> Self
pub fn with_committer(self, committer: Principal) -> Self
Record the git committer identity (distinct from the author).
Part of the state hash — see the committer field docs and
update_hash. #564 de-lossy step 1.
Sourcepub fn with_tz_offsets(self, authored: i32, committer: i32) -> Self
pub fn with_tz_offsets(self, authored: i32, committer: i32) -> Self
Record the author/committer timezone offsets (seconds east of UTC). Part of the state hash. #564 de-lossy step 1.
Sourcepub fn with_raw_message(self, raw_message: impl AsRef<[u8]>) -> Self
pub fn with_raw_message(self, raw_message: impl AsRef<[u8]>) -> Self
Record the verbatim git commit message body, as raw bytes (so a
non-UTF8 message round-trips byte-identically; see the raw_message
field docs). Part of the state hash. #564 de-lossy step 1.
Sourcepub fn with_git_lossy(self, git_lossy: bool) -> Self
pub fn with_git_lossy(self, git_lossy: bool) -> Self
Mark this state’s content as NOT byte-faithful to the original git
object — set by the --lossy import/ingest paths when a tree entry was
dropped or converted. The git-export fidelity guard reads this single
signal to skip reconstruct-from-state (#567). Not part of the content
hash (see the git_lossy field docs).
Sourcepub fn with_extra_headers(self, extra_headers: Vec<(Vec<u8>, Vec<u8>)>) -> Self
pub fn with_extra_headers(self, extra_headers: Vec<(Vec<u8>, Vec<u8>)>) -> Self
Record the ordered remaining git commit headers as raw bytes. ORDER IS LOAD-BEARING (#566). Part of the state hash. #564 de-lossy step 1.