Skip to main content

Module page

Module page 

Source
Expand description

What one answer about the mesh carries: a summary a worker can read whole, or the folded state narrowed to what was asked.

On 2026-10-10 mesh.state answered 449 kB and mesh.peers 313 kB on a mesh of twelve runtimes: 165 claims, half of them released, 126 sessions, 109 of them closed. A worker asking “who holds what” over MCP got an answer its client could not show, and a page of 80 journal events was 83 000 characters, 30 of them one session reopening itself. The fold is not wrong to keep its history; an answer is wrong to carry all of it by default.

So the default is a summary that does not grow with history — per runtime its liveness, its sessions counted by standing and its newest live claim; the totals; the open review requests and the handovers nobody has taken — bounded by SUMMARY_LIST and SUMMARY_TEXT. The whole state is still one input away, and the filters narrow it without changing its shape. The digest is always the digest of the whole fold, never of a page, because it is what two runtimes compare.

Everything here is pure: the same state, liveness and query give the same answer. A capability folds the journal, narrows the state to the query, and answers either the narrowed state or its summary:

use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::{EventBody, Journal, SessionInfo, StreamLiveness};
use majordomus_cli::mesh::page::{narrow, summarize, Query, View};
use majordomus_cli::mesh::state::fold;

let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
    "repo".into(), None).unwrap();
for n in 0..3 {
    j.append_own(EventBody::SessionOpened { info: SessionInfo::named(&format!("s{n}"), "cli") })
        .unwrap();
}
j.append_own(EventBody::SessionClosed { session: "s0".into() }).unwrap();
let state = fold(&j.events(), &|_| StreamLiveness::Own);

let query = Query { open: Some(true), ..Query::default() };
let narrowed = narrow(&state, &query);
assert_eq!(narrowed.sessions.len(), 2, "the closed session is left out");
assert_eq!(query.view(), View::Summary);
let summary = summarize(&narrowed, &[]);
assert_eq!(summary.sessions.active, 2);
assert_eq!(summary.digest, state.digest, "always the whole fold's digest");

Structs§

ClaimBrief
One live claim, told briefly: whose it is, what it is for and how many paths it holds, with its intent cut to SUMMARY_TEXT characters — enough to know whom to ask.
ClaimCounts
Claims by standing: held, conflicted, released and expired. Held and conflicted are live; the other two are history, counted rather than listed.
HandoverBrief
A handover nobody has taken, told briefly: the id mesh.handover.consume takes, who published it and what it continues. Its body stays in the full view.
Query
What a reader asks of the folded state. Every filter narrows; none changes a shape, and an input it does not know is refused rather than ignored.
ReviewBrief
An open review request, told briefly: its key, what is to be reviewed and whom it asks. Only requests nobody has answered are listed in the summary.
RuntimeSummary
One runtime, counted: its liveness and beat, its sessions and claims by standing, and its newest live claim. The summary lists these, the living runtimes first.
SessionCounts
Sessions by standing: how many are active, closed and expired. A count stays the same size however many sessions the mesh has seen, which is why the summary carries counts.
Summary
The mesh in an answer a worker reads whole: counts, each runtime, the open reviews and the untaken handovers, every list bounded by SUMMARY_LIST with the rest counted.

Enums§

ClaimFilter
Which claims a full answer keeps: all of them, the ended ones included, or only those still live — the question an executor asks before it takes a lease.
Kind
One collection of the folded state, as kind names it: a reader that wants only the reviews is not sent the claims.
View
How much an answer about the mesh carries. The summary is the default because it is the answer a worker can read whole whatever the mesh’s history; the full fold is one word away when a reader needs every record.

Constants§

SUMMARY_LIST
The most entries a summary lists in any one list; what is past it is counted.
SUMMARY_TEXT
The most characters a summary keeps of an intent or a subject; the rest is cut with ….

Functions§

narrow
The state narrowed to query. The digest is the whole fold’s, carried unchanged: it is what two runtimes compare, and a page of the state is not a state of its own.
summarize
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.