services/session/session
Session state — pure state transformer for conversation context. Moved from core/session/ to services/session/ (Stage 2C).
Types
pub type Session {
Session(
session_id: String,
persona: String,
history: List(message.Message),
persisted_message_count: Int,
turn_count: Int,
)
}
Constructors
-
Session( session_id: String, persona: String, history: List(message.Message), persisted_message_count: Int, turn_count: Int, )
Values
pub fn end_and_fork(
conn: sqlight.Connection,
session: Session,
source: String,
persona: String,
reason: String,
) -> Result(#(Session, String), String)
End the current session and create a new one linked via parent_session_id.
pub fn generate_session_key(source: String) -> String
Generate a unique session key with source and ISO8601 timestamp.
pub fn load(
conn: sqlight.Connection,
session_key: String,
source: String,
persona: String,
) -> Result(Session, String)
Load a session from the database, or create it if it doesn’t exist.
pub fn new(session_id: String, persona: String) -> Session
Create a new in-memory session with an id and persona.
pub fn persist(
conn: sqlight.Connection,
session: Session,
) -> Result(Session, String)
Persist new messages since last save and bump the updated_at timestamp.