kcode-k1-chat-thread-session-view 0.2.1

Process-local read projection for one K1 chat-thread session actor
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
# K1 chat-thread session view

## Public contract

- `SessionView` owns the process-local read projection for one Session Actor. `new(event_receiver: mpsc::UnboundedReceiver<Reply<SnapshotWithEvents>>) -> SessionView` takes its dedicated event-query receiver.
- `set_model_input(&mut self, input: ProviderInput)` retains the latest input exactly. `snapshot(&self, durable: &DurableThread, force_running: bool) -> Snapshot` clones durable boxes and the retained input; its status is `Running` when forced and otherwise the durable status.
- `wait(&mut self, durable, force_running, reply: Reply<Snapshot>)` queues the reply while running and otherwise answers it immediately. `wake(&mut self, durable, force_running)` answers every queued reply with one cloned current snapshot when not running.
- `async receive_event_query(&mut self) -> Option<Reply<SnapshotWithEvents>>` awaits the dedicated receiver. Once it closes, this and subsequent calls remain pending. `answer_event_query(&self, durable, force_running, reply)` sends the current snapshot and cloned durable events.
- `close(&mut self)` rejects every queued wait reply with `ActorError::Closed`.

`ProviderInput`, `Reply`, `Snapshot`, `SnapshotWithEvents`, and `ActorError` retain their actor-channel contracts; `DurableThread` retains its durable-state contract.

For a practical session, creating a snapshot and waking waiters are linear in the cloned boxes and waiter count.