pub struct State {Show 18 fields
pub change_id: ChangeId,
pub tree: ContentHash,
pub parents: Vec<ChangeId>,
pub attribution: Attribution,
pub intent: Option<String>,
pub confidence: Option<f32>,
pub created_at: DateTime<Utc>,
pub verification: Option<Verification>,
pub signature: Option<StateSignature>,
pub status: Status,
pub provenance: Option<ContentHash>,
pub logical_change_id: Option<ChangeId>,
pub context: Option<ContentHash>,
pub authored_at: Option<DateTime<Utc>>,
pub risk_signals: Option<ContentHash>,
pub review_signatures: Option<ContentHash>,
pub discussions: Option<ContentHash>,
pub structured_conflicts: Option<ContentHash>,
/* private fields */
}Expand description
A state is an immutable snapshot with rich metadata.
On-disk encoding is rmp-serde’s positional struct format (a fixed-length tuple). This is sensitive to field order: inserting a field in the middle of the tuple breaks every pre-existing on-disk state. The invariant we keep going forward is:
New optional fields are added at the tail of the struct, below
status, with#[serde(default)]. Mid-struct inserts are forbidden. rmp-serde’s positional deserializer tolerates missing trailing fields when they have aDefaultimpl, so tail-only growth is forward-compatible automatically.
Required (non-optional) fields — change_id, tree, parents,
attribution, created_at, status — must never move. Optional fields
may be reordered only among themselves, and only at the tail.
Fields§
§change_id: ChangeId§tree: ContentHash§parents: Vec<ChangeId>§attribution: Attribution§intent: Option<String>§confidence: Option<f32>§created_at: DateTime<Utc>§verification: Option<Verification>§signature: Option<StateSignature>§status: Status§provenance: Option<ContentHash>§logical_change_id: Option<ChangeId>§context: Option<ContentHash>Optional context tree root for code annotations.
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. We hash that into the
state id so re-imports of the same git history produce
deterministic Heddle hashes. But for blame display we usually
want the author time — when someone actually wrote the
change — which survives git rebase, cherry-pick, squash-
merge, and git commit --amend. The bridge git ingest
importer fills this from git_commit.authored_at; native
heddle commits leave it None and blame falls back to
created_at.
risk_signals: Option<ContentHash>Content hash of the state’s RiskSignalBlob,
when present. Computed and persisted whenever risk signals fire on a
state. None for states from before W1 and for states where no
signals fired.
Hash framing: a single 0 byte when None, [1] + 32-byte hash when
Some. Legacy states without this field deserialize as None and
hash byte-identical to before W1.
review_signatures: Option<ContentHash>Content hash of the state’s ReviewSignaturesBlob,
when reviewers have signed off (read / agent-preview / agent-co-review).
discussions: Option<ContentHash>Content hash of the state’s DiscussionsBlob,
when discussions are anchored to this state.
structured_conflicts: Option<ContentHash>Content hash of the state’s StructuredConflict,
when this state captures an unresolved merge conflict as data.
Implementations§
Source§impl State
impl State
pub fn new( tree: ContentHash, parents: Vec<ChangeId>, attribution: Attribution, ) -> Self
pub fn new_snapshot( tree: ContentHash, parents: Vec<ChangeId>, attribution: Attribution, ) -> Self
pub fn new_merge( tree: ContentHash, parents: Vec<ChangeId>, attribution: Attribution, ) -> Self
pub fn new_refresh_of( tree: ContentHash, parents: Vec<ChangeId>, attribution: Attribution, logical_change_id: ChangeId, ) -> Self
pub fn new_fork_of( tree: ContentHash, parents: Vec<ChangeId>, attribution: Attribution, ) -> Self
pub fn new_collapse_of( tree: ContentHash, parents: Vec<ChangeId>, 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_signature(self, signature: StateSignature) -> Self
pub fn with_provenance(self, provenance: ContentHash) -> Self
Sourcepub fn with_context(self, context: ContentHash) -> Self
pub fn with_context(self, context: ContentHash) -> Self
Set the context tree root.
Sourcepub fn with_risk_signals(self, risk_signals: ContentHash) -> Self
pub fn with_risk_signals(self, risk_signals: ContentHash) -> Self
Attach a RiskSignalBlob hash.
Render-time tick budgeting (selecting which signals to surface) is a
view over this stored data, not part of storage itself.
Not part of the state hash. Risk signals are derived data computed
about a state from the diff against its parent; including them in
identity would make the same logical state hash differently depending
on which signals fired. That breaks every “is this the same state?”
check in the system. See authored_at for the same pattern.
Sourcepub fn with_review_signatures(self, review_signatures: ContentHash) -> Self
pub fn with_review_signatures(self, review_signatures: ContentHash) -> Self
Attach a ReviewSignaturesBlob
hash. The state’s authoring StateSignature is unaffected; review
signatures live alongside it and accumulate over time.
Not part of the state hash. Review signatures accumulate
post-capture; including them in identity would mean every signature
re-keys the state. See authored_at for the same pattern.
Sourcepub fn with_discussions(self, discussions: ContentHash) -> Self
pub fn with_discussions(self, discussions: ContentHash) -> Self
Attach a DiscussionsBlob hash.
Not part of the state hash. Discussions evolve independently of
the state they’re anchored to — appending a turn must not change the
state’s identity. See authored_at for the same pattern.
Sourcepub fn with_structured_conflicts(
self,
structured_conflicts: ContentHash,
) -> Self
pub fn with_structured_conflicts( self, structured_conflicts: ContentHash, ) -> Self
Attach a StructuredConflict hash.
Not part of the state hash. Conflict objects describe the merge’s
disagreement; the state’s tree and parents already encode what’s being
merged. See authored_at for the same pattern.
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.
Not part of the state hash. created_at is what hashes;
this field is purely metadata for display. A re-imported repo
that picks up updated authored timestamps will produce the
same Heddle State hashes as before.