The pure core. An event is a value recording something that happened;
apply-event folds one event into the materialized session view. It is a pure
projector — no IO, no provider/leaf/child calls. Events carry results, never
recipes (SPEC invariant), so folding a journal reconstructs state without ever
re-running expensive work.
The view mirrors the shape the rest of the engine already reads:
:session (map), :messages/:turns/:evals/:calls/:snapshots/:events
(vectors), plus :final-ref and :counters. artifacts.clj keeps these keys at
the top of its state atom alongside infra keys; apply-event only ever touches
the view keys, so infra survives untouched.
The pure core. An event is a value recording something that happened; `apply-event` folds one event into the materialized session view. It is a pure projector — no IO, no provider/leaf/child calls. Events carry *results*, never recipes (SPEC invariant), so folding a journal reconstructs state without ever re-running expensive work. The view mirrors the shape the rest of the engine already reads: `:session` (map), `:messages`/`:turns`/`:evals`/`:calls`/`:snapshots`/`:events` (vectors), plus `:final-ref` and `:counters`. `artifacts.clj` keeps these keys at the top of its state atom alongside infra keys; `apply-event` only ever touches the view keys, so infra survives untouched.
(apply-event view event)view' = (apply-event view event). Pure. Every event is recorded in :events
(the in-memory mirror of the journal); state-changing events additionally fold
into the relevant view key. Unknown/annotation events change nothing but the log.
view' = (apply-event view event). Pure. Every event is recorded in `:events` (the in-memory mirror of the journal); state-changing events additionally fold into the relevant view key. Unknown/annotation events change nothing but the log.
(fold events)Reconstruct a view from an event stream. Pure: zero provider/leaf/child calls.
Reconstruct a view from an event stream. Pure: zero provider/leaf/child calls.
(recover-child-counter view)The :child counter is encoded only in child/attached session ids (child-0007,
attached-0003); recover its high-water mark from a folded view so a resumed
session keeps numbering children correctly.
The `:child` counter is encoded only in child/attached session ids (child-0007, attached-0003); recover its high-water mark from a folded view so a resumed session keeps numbering children correctly.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |