levi_core/entities/applied.rs
1use myko::prelude::*;
2
3/// Hub-internal LWW guard: the newest event applied per entity.
4/// id = "{item_type}:{item_id}". `ApplyLogEntry` consults this before
5/// emitting an unwrapped event so that out-of-arrival-order events cannot
6/// clobber newer state (CLIs get the same guarantee by sorting the full log
7/// before replay; the hub applies incrementally and needs the marker).
8#[myko_item]
9pub struct Applied {
10 /// (created_at, event id) of the newest event applied for this entity —
11 /// the same LWW sort key `materialize()` uses.
12 pub event_created: String,
13 pub event_oid: String,
14}
15
16pub fn applied_id(item_type: &str, item_id: &str) -> String {
17 format!("{item_type}:{item_id}")
18}