pub fn summarize(
state: &CooperationState,
streams: &[(String, StreamLiveness, Option<u64>)],
) -> SummaryExpand description
The summary of state (already narrowed), with each runtime’s liveness and the
milliseconds since its beat rose from streams. A runtime that only streams names is
listed with no sessions; one the state names and streams does not is expired.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::{ClaimMode, EventBody, Journal, SessionInfo, StreamLiveness};
use majordomus_cli::mesh::state::fold;
let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
"repo".into(), None).unwrap();
j.append_own(EventBody::SessionOpened { info: SessionInfo::named("s1", "claude-code") })
.unwrap();
for (claim, path) in [("c1", "apps/a"), ("c2", "apps/b")] {
j.append_own(EventBody::ClaimAcquired { claim: claim.into(), session: "s1".into(),
scope: vec![path.into()], intent: Some("work".into()), mode: ClaimMode::Exclusive,
issue: Some("#1".into()) }).unwrap();
}
j.append_own(EventBody::ClaimReleased { claim: "c1".into() }).unwrap();
let state = fold(&j.events(), &|_| StreamLiveness::Own);
use majordomus_cli::mesh::page::summarize;
let runtime = state.sessions[0].runtime.clone();
let summary = summarize(&state, &[(runtime, StreamLiveness::Own, Some(12))]);
assert_eq!(summary.runtimes[0].liveness, StreamLiveness::Own);
assert_eq!(summary.runtimes[0].last_beat_ms, Some(12));