pub struct OpRecord {
pub op_id: String,
pub hlc: Hlc,
pub device_id: String,
pub seq: u64,
pub prev: Option<String>,
pub scope: Scope,
pub surface: Surface,
pub payload: Value,
}Expand description
One state-changing operation in the oplog.
Fields§
§op_id: StringContent-derived id (see module docs): dedup key for retransmission and tamper-evident cover of the whole record.
hlc: HlcTotal-order stamp. Invariant: hlc.device_id == device_id.
device_id: StringThe device (replica) that emitted the op. Matches the replica
strings car_state::crdt already uses.
seq: u64Per-device append index (0-based, contiguous).
prev: Option<String>op_id of this device’s previous op (None iff seq == 0) — the
per-device hash-chain link that makes the log order-verifiable.
scope: Scope§surface: Surface§payload: ValueSurface-specific payload (possibly E2E ciphertext in B6).
Implementations§
Source§impl OpRecord
impl OpRecord
Sourcepub fn new(
hlc: Hlc,
seq: u64,
prev: Option<String>,
scope: Scope,
surface: Surface,
payload: Value,
) -> Self
pub fn new( hlc: Hlc, seq: u64, prev: Option<String>, scope: Scope, surface: Surface, payload: Value, ) -> Self
Build an op and stamp its content-derived id. Callers normally go
through DeviceLog::append, which manages seq/prev/hlc.
Sourcepub fn compute_op_id(&self) -> String
pub fn compute_op_id(&self) -> String
Recompute the content-derived id from the record’s fields (the B7
SHA-256 + 0x1f discipline; op- + 32 hex chars).
Sourcepub fn stable_key(&self) -> String
pub fn stable_key(&self) -> String
The stable key the fold dedups logical entities on: the payload’s
"id" string when present (the proposal’s fact_id / record-id
keys), else the canonical content hash (which realizes e.g. the
conversation (speaker,text,timestamp) dedup — identical content is
one entity). Prefixed so the two forms can never collide.
NOT used for event-stream surfaces (routing) — the fold keys those by
op_id via OpRecord::fold_key, because an event stream is a
multiset: identical content is two events, not one entity.
Sourcepub fn fold_key(&self) -> String
pub fn fold_key(&self) -> String
The key the fold stores this op under: OpRecord::stable_key for
logical-entity surfaces, op_id for event-stream surfaces
(Surface::is_event_stream — the proposal’s routing MULTISET:
every emitted observation survives the fold; only retransmission of
the same op dedups). Prefixes keep the three key forms (id:,
h:, op:) disjoint.