anagrapheus.assembly.slices¶
anagrapheus.assembly.slices
¶
Slices: the only way an assembler reads, and each one remembers what it handed out.
A role is granted the slices it declares and nothing else, so what it cannot read it cannot put in a prompt. That is the narrator firewall at runtime: NVM holds the Narrator to "contract and continuity window, nothing else" with an import rule, and a slice is the same rule one level down, where a role's code may import the belief types for other reasons.
Reading through a slice, not a store, is what makes provenance free. Every slice records each thing it returns, so a context knows its sources without trusting the assembler to list them. The demo's worst prompt defect — a private remark rendered into the speaker's own prompt through shared prose — becomes an assertion on sources, which still holds when the wording changes.
Slices read at one position. A log slice is bounded by upto_seq. A belief slice
reads the store live, so it is handed a way to ask how far the belief fold has got, and
it refuses to answer when an event the fold reads lies between that and upto_seq: a
fold that moved during assembly would otherwise tear the context, with half its beliefs
from before an event and half from after it. Events the fold ignores are not a tear, so
a pin promoted into the log, or any other append no belief comes from, is not refused.
Slice
¶
Bases: Protocol
Anything a grant may hold: a reader at a position that remembers what it returned.
upto_seq is None for a slice with no position, such as a :class:Given.
An application's own reader can be a slice too — the demo's party view is one.
LogSlice
¶
Events up to upto_seq that admit accepts, decoded and upcast.
admit sees the stored envelope only, so a refused event is never upcast or
decoded. It is where a reader declares which kinds of event it may see, and where
an application keeps a private event out of a shared prompt.
Source code in src/anagrapheus/assembly/slices.py
events
¶
Admitted events above since_seq and up to this slice's position.
Source code in src/anagrapheus/assembly/slices.py
EventsSlice
¶
A fixed run of events — what a generative fold is handed — read through admit.
The chronicle's summarizer is given its range rather than reading the log, so its slice is built over that range. The position is the range's last event.
Source code in src/anagrapheus/assembly/slices.py
events
¶
The admitted events, in order.
Source code in src/anagrapheus/assembly/slices.py
BeliefSlice
¶
BeliefSlice(
store: BeliefStore,
*,
visible: Callable[[str], bool],
upto_seq: int | None = None,
folded_through: Callable[[], int] | None = None,
reader: EventReader | None = None,
claims: Callable[[Envelope], bool] | None = None,
)
The scopes visible accepts, read from a belief store folded to upto_seq.
Build one with :meth:over, which wires the rest from the fold. By hand:
folded_through reports the belief fold's position, reader reads the log and
claims says which events the fold reads (:meth:BeliefFold.claims
<anagrapheus.beliefs.fold.BeliefFold.claims>). A read refuses with
:class:~anagrapheus.assembly.errors.StaleRead when an event claims accepts
lies between the fold's position and upto_seq, whether the fold is behind (catch
up before assembling) or ahead (a belief event was appended while assembling), and
when upto_seq is past the end of the log. Only envelopes are scanned. Leave out
reader and claims and every event counts, so the fold must be exactly at
upto_seq.
Pass upto_seq=None and no folded_through for a live slice, which reads
whatever the store holds now and promises no position.
Source code in src/anagrapheus/assembly/slices.py
upto_seq
property
¶
The fold position this slice reads at, or None if it reads live.
over
classmethod
¶
over(
fold: BeliefFold,
projector: Projector,
reader: EventReader,
*,
visible: Callable[[str], bool],
upto_seq: int,
) -> BeliefSlice
A slice over fold's store at upto_seq, checked against the fold itself.
The position is asked of projector, which answers wherever the fold keeps it
— in the log's database for a durable fold, on the fold for one that is not —
so fold must be one of its folds. Only events fold claims can make a
read stale.
Source code in src/anagrapheus/assembly/slices.py
scope
¶
Every current belief scope_id holds, if it is granted.
belief
¶
One belief by exact id, or None. Only the state returned is recorded.
By exact id, always: "the first belief in the scope" reads correctly while the scope holds one thing and answers a different question once it holds two.
Source code in src/anagrapheus/assembly/slices.py
ChronicleSlice
¶
Chronicle sections covering nothing past upto_seq.
Everything returned is model-written prose, so a part citing one must be
:attr:~anagrapheus.assembly.parts.Register.generated; assemble refuses a part
that cites a section under any other register.
Source code in src/anagrapheus/assembly/slices.py
sections
¶
Every current section, oldest first.
Source code in src/anagrapheus/assembly/slices.py
Given
¶
A value handed in by the application, recorded the first time it is read.
For what a role is shown that no projection produced: the Narrator's contract, which is the Thinker's output, or a line the caller computed in memory.
Source code in src/anagrapheus/assembly/slices.py
handed_out
¶
Everything a set of slices handed out, in order, once each.