pub struct ChangeSet {
pub envelope: Envelope,
pub ops: Vec<Op>,
}Expand description
Envelope metadata plus an ordered list of staged operations.
Operation order is semantically load-bearing (a link may target an
earlier create ID) and is preserved exactly by the NDJSON codec.
See crates/khive-changeset/docs/api/ndjson-codec.md for the wire contract.
Fields§
§envelope: EnvelopeChange-set-wide stage-time provenance.
ops: Vec<Op>Operations in semantic application order.
Implementations§
Source§impl ChangeSet
impl ChangeSet
Sourcepub fn invert(
&self,
envelope: Envelope,
current: &CurrentState,
) -> Result<ChangeSet, InvertError>
pub fn invert( &self, envelope: Envelope, current: &CurrentState, ) -> Result<ChangeSet, InvertError>
Produces a reverse-ordered inverse with the caller’s fresh envelope.
Current records are checked and rewound in a private working copy, so repeated updates compare against the correct intermediate values. An update checks only fields it touches. A create or link must still match its staged fields and be live; its inverse is a soft delete carrying the supplied full record, including its actual timestamps.
This is a pure stage-time check, not an atomic comparison at landing.
The caller reads current records and supplies the revert’s provenance.
Neither this change-set nor current is modified, even on refusal.
§Errors
Refuses a reused envelope, delete/merge operations, missing or invalidated
current records, or a swapped update rejected by UpdateOp::new.