regent library

Classes

AnyProjection
The common face of Projection and UnitProjection — what a Regency.merges set holds.
AnyStore<S>
What a @stores row may hold: a keyed Store or a Unit. S is the state a read of the regent returns — the keyed collection for a store, the value for a unit — so one typed lookup serves both kinds.
At<Handle>
A POSITION in the queue that answers ledger.at(...) with its typed Handle — the spec instance carries the handle type, so the lookup is fully typed with no name in between. Every regent kind is a position (store → StoreMemory, unit → UnitMemory, guard → GuardMemory), and the two positions nobody declares are the static sentinels:
Bus
The message bus — the RICH tier's transport. Dispatch messages through guards to typed subscribers. Transport-agnostic: feed it from WS, HTTP, a local DB, or a local optimistic dispatch(..., optimistic: true). Decoupled from canon and from Flutter; a StoreMemory subscribes to it, and a riverpod notifier can subscribe via on too — neither owns the other.
CoveredRanges<C extends Comparable<C>>
The cursor intervals an authority has covered — a plain folded VALUE, pure and axis-blind (the consumer decides what C means: a DateTime, an int, a name). Absence WITHIN a covered interval is a fact ("gone"); absence outside is silence.
Deleted<K, E>
EntryPosition
The sentinel for the queue's ingress — see At.entry.
ExitPosition
The sentinel for the queue's end — see At.exit.
Feed
The stream-only face of a sentinel position: typed message taps, no dispatch — nobody injects mid-queue.
ForwardJudgment
Continue msg at the next row — judged by everything above this guard.
Guard<M extends Msg>
A PURE judge standing at its row of the queue: every traversing message of the M family is submitted to judge, whose returned set IS its verdict — one verb for every shape of judgment:
GuardEvent<M extends Msg>
One judgment's full story, emitted AFTER the verdict ran: the submitted message and what the guard launched for it, atomically — for a Veto, an empty verdict IS the block. Observation only (ledger.at(spec)); the flow itself never depends on it.
GuardMemory<M extends Msg>
The live handle at a guard's row (ledger.at(const CachedGate())): the judged input and the verdict, observable — a judge holds no state, so its memory is pure story. Plural members are streams, all derived from the atomic events:
Inserted<K, E>
Judgment
One LAUNCH — the element of a guard's verdict. A guard at index x may target exactly TWO indices, the only two that preserve the system's theorem (no row ever sees a message that skipped a guard above it):
Ledger
The queue of positions, behind TWO doors:
LedgerRows
The registration face Regent.mount dispatches into — Ledger implements it; the indirection keeps the regent tiers free of the ledger's own import.
MintJudgment
Derive msg as a NEW round from the top of the queue, after the current round completes. Unjournaled: re-derived on replay.
Msg
A FACT. The journal stores it, replay re-delivers it — so it must never mutate after construction. The annotation makes the analyzer enforce final fields on every subclass.
Projection<S extends Identifiable<K>, K, E>
A READ RESOLVER for a merge edge (user.merge(viewer, const ViewerSupportsUser()) in the entities graph): the SOURCE store's state answers the TARGET surface's per-key reads at the source's OWN identity — S extends Identifiable<K> IS the claim; there is no key method anywhere.
Pure
Marks a method (or class) as PURE — its body may read only its parameters, locals, pattern-bound variables, and compile-time constants, and may call only other pure functions. No ambient or mutable state, no clock, no randomness, no I/O. Purity is what makes a fold deterministic and therefore replay-able: replay(a) == replay(b) is a law only because the folds between cannot reach outside their arguments.
Regency
The app as a VALUE: an ordered set of regents plus merge edges. A graph IS a regent, and a regent is a one-row graph — Ledger.root takes a single Regent, so the smallest ledger is Ledger.root(const NavUnit()) and the largest is a const tree:
Regent
A REGENT — a row of the ledger — anything that occupies a row of the regents enum: stores, units, guards, vetoes. Row order is traversal order: a message walks the rows top to bottom.
RowChange<K, E>
One row's movement inside one fold — the store's change feed at row grain, derived from StoreEvent.changed (no map walk).
Store<K, E extends Identifiable<K>, M extends Msg>
The PURE, const registry descriptor: how a message folds into an entry's state. No mutable state, no ref, const — so it can sit in a spec. The live store (StoreMemory) is created separately and wired to a Bus.
StoreEvent<K, E extends Identifiable<K>, M extends Msg>
One fold's full story, emitted by a store AFTER the reduce ran: the cause and its consequence, atomically — an effect filtering these can never race the fold. Filters recover every narrower feed: structural (the list shell), changed.contains(id) (per key), a before/after delta (state TRANSITIONS), a msg-type check (post-fold message observation).
StoreMemory<K, E extends Identifiable<K>, M extends Msg>
The live store for a Store: the folded collection driven off a Bus, plus read-time merge edges and the change/event feeds. It holds NO other state — optimism, in-flight status, freshness, and settlement all live in consumer ROWS (docks, in-flight units, coverage), where they replay.
StreamSubscription<T>
A subscription on events from a Stream.
Unit<S, M extends Msg>
The UNIT sibling of Store: one value, cardinality one — for entities whose identity is the session (the wire sends their facts KEYLESS: a viewer profile, a requests+unseen state). Same purity contract.
UnitEvent<S, M extends Msg>
The unit form of StoreEvent.
UnitMemory<S, M extends Msg>
The live memory for a Unit: the value driven off a Bus.
UnitProjection<S, T>
The UNIT form of Projection — a unit-target merge edge (viewer.from(viewerPending, const ApplyPending()) in the regents merges set): the SOURCE unit's state answers the TARGET unit's read. Keyless — a unit has cardinality one, so the edge always applies; resolve no-ops itself when the source carries nothing. Read-time only: the fold and guards' read never see it.
Updated<K, E>
Veto<M extends Msg>
The refusing specialization — a guard that only ever passes or drops. TRUE from block drops the message.

Mixins

Identifiable<I>
Entities are VALUES: folds produce new instances; a mutated entity corrupts before/after events and optimistic refolds — enforced here for every class that wears the mixin.

Extensions

IdentifiableIterable on Iterable<T>
IdentifiableList on List<T>
IdentifiableMapExtension on Map<I, T>
StoreEventStream on Stream<StoreEvent<K, E, M>>
The keyed-store counterpart of UnitEventStream.
UnitEventStream on Stream<UnitEvent<S, M>>
Pure sugar over a UNIT's post-fold event stream — the recurring effect idioms as verbs. Extensions on the STREAM (not the memory), so they compose after any filter and over replayed feeds alike.

Constants

pure → const Pure
The @pure marker — mirrors @immutable's lowercase-const convention.

Functions

replay(Regent root, List<Msg> order) Map<Object, Object?>
The state the WHOLE ledger folds from order — its replay. Builds a pure ledger from root (a Regency or any single regent), folds the messages synchronously, and returns every regent's state keyed by SPEC INSTANCE — z[const Todos()]. Deterministic: the folds are pure, so the same messages always yield the same snapshot — replay is the operation purity buys you.
replayStore<K, E extends Identifiable<K>, M extends Msg>(Store<K, E, M> store, List<Msg> order) IdentifiableMap<K, E>
A single store's replayed collection — the narrow form of replay for a store whose reduce reads only its own state (no guards, no merge edges).

Typedefs

IdentifiableMap<K, E extends Identifiable<K>> = Map<K, E>
Identity = Identifiable<String>
IdentityMap<T extends Identity> = Map<String, T>
ReadStore = S Function<S>(AnyStore<S> spec)
A guard's view of the world: this ledger's own state, looked up by regent IDENTITY — read(const BrowseDeck()), read(const AuthMachine()). Const canonicalization makes the constructor expression the regent's canonical NAME: const X() written in a judge IS the instance the row holds (same class, different args = a different regent; two rows may not hold identical instances — enforced at registration). Bound to the ledger the guard stands in, so a replayed ledger reads itself. Throws when no row holds the instance (wrong args, or a missing const).