Skip to main content

Module actor

Module actor 

Source
Expand description

SessionActor — owns THE Runtime + ConversationState for one conversation and runs its turn machine (PLAN-phase2 §2.5).

Every method body is moved from an existing reactor site (TUI dispatch.rs Abort/Submit/StreamingInput, stream_handler.rs event-queue + stream arms, tui/mod.rs teardown, cmd/chat.rs post-turn); the presentation halves stay client-side and are fed by the envelopes this actor emits. Each StreamEvent is forwarded to clients BEFORE the actor acts on it, so a client sees the same order it sees today.

Invariants:

  • Runtime::clone() resets TTL latches. The actor clones it only for driver stream-start (Prepared→Started) and compaction. The stream-start clone shares the original’s TTL atomics via share_ttl_latches so a redundant 1h→5m downgrade notice per driver turn is avoided. The compaction clone is read-only+discarded and needs no sharing.
  • emit is the ONLY seq increment site.
  • Detach never touches stream/cancel; only End (and Cancel) stop a turn.

Structs§

SessionActor
SessionTask
The tokio task. SessionTask::run is the reactor loop.

Constants§

DEFAULT_PARK_GRACE

Functions§

idle_end_grace
SYNAPS_DAEMON_IDLE_END_GRACE_SECS: how long a ZERO-turn session with no clients lingers before it ends (F18). Default 5 s — long enough for a client that disconnected mid-reconnect, short enough that open-and-close does not pin a Runtime for a minute.
park_grace
SYNAPS_DAEMON_PARK_GRACE_SECS: never → None (Parked disabled); n → n seconds after the last detach once idle; default 60.
parked_evict_after
SYNAPS_DAEMON_PARKED_EVICT_SECS: how long a PARKED session stays in the daemon’s map before it is evicted (EndReason::Evicted). Its state is on disk; --continue <id> rebuilds it exactly as after a daemon restart. The row only exists so --attach <id> / the adopt banner can find it quickly. Default 1 h; never → keep forever.
prompt_abandon_timeout
SYNAPS_DAEMON_PROMPT_ABANDON_SECS: how long a pending host confirmation on a NON-driver session survives after the LAST client detaches before it is fail-closed answered None (deny) so can_park() can proceed. This bounds the resource pin from an ABANDONED prompt WITHOUT punishing a transient disconnect (SSH drop, sleep, wifi): a re-attach before expiry cancels it and the user answers the prompt normally. Default 1 h — generous enough that a human coming back from lunch still answers; never/0/off → None = disabled = pure pre-#112 behaviour (a prompt survives detach forever).

Type Aliases§

ActiveStream
The in-flight response stream (tui/stream_handler.rs ActiveStream).