kcode-k1-chat-thread-session-actor 0.2.4

Concrete asynchronous session actor for one durable K1 chat thread
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
# K1 chat-thread session actor

## Public contract

- `open(adapter: Adapter, key: impl Into<String>, session: Session, kmap: Arc<K1AccessKmap>, web_search: WebSearchAction) -> Result<Handle, String>` recovers one durable thread, spawns its serialized actor, and returns its established command handle.
- `Handle` retains the actor-channel contract. In particular, `snapshot()` retains its existing live snapshot, while `snapshot_with_events()` returns that same snapshot together with cloned durable events in recorded order.

The actor owns FIFO commands, Codex turn effects, managed runtime model-usage lifecycle, stage acknowledgements, restart generations, and teardown. It subscribes to the active runtime key before provider inference and persists correlated usage records in actor order. The WebSearch task leaf owns live search tasks and cancellation epochs; the session-view leaf owns snapshots, retained provider input, event queries, and waiters. The actor neither aggregates, deduplicates, prices, nor exposes usage as chat boxes.

Durable state exclusively owns canonical Agent Response, Agent Message, Tool Call, Tool Message and Tool Result transitions; persistence; fresh-thread replay; same-thread delta input; authorization; synchronous action dispatch; restart; and success-only prepared frontiers. This package owns no persistence format, authorization policy, native tool implementation, HTTP, migration, daemon composition, deployment, or public facade.

For a practical session, `open` performs synchronous recovery and actor setup; it is not yet benchmarked.