pig/session_store
Durable session storage types for atomic agent-state transitions.
Types
The durable transcript, its current commit head, and persisted settings.
pub type Session {
Session(
head: option.Option(String),
messages: List(message.Message),
inference_settings: option.Option(provider.InferenceSettings),
)
}
Constructors
-
Session( head: option.Option(String), messages: List(message.Message), inference_settings: option.Option(provider.InferenceSettings), )
A durable, idempotently identifiable session transition.
pub type SessionCommit {
SessionCommit(
id: String,
parent: option.Option(String),
delta: SessionDelta,
)
}
Constructors
-
SessionCommit( id: String, parent: option.Option(String), delta: SessionDelta, )
An atomic change to a durable session.
pub type SessionDelta {
MessagesAppended(
first: message.Message,
rest: List(message.Message),
)
InferenceSettingsChanged(settings: provider.InferenceSettings)
}
Constructors
-
MessagesAppended( first: message.Message, rest: List(message.Message), )Append one or more messages to the durable transcript.
-
InferenceSettingsChanged(settings: provider.InferenceSettings)Replace the durable inference settings.
Errors returned while loading or committing a durable session.
pub type SessionError {
Unavailable(message: String)
Corrupt(message: String)
ParentConflict(
expected: option.Option(String),
actual: option.Option(String),
)
InvalidCommit(message: String)
}
Constructors
-
Unavailable(message: String)The store could not be reached or complete an operation.
-
Corrupt(message: String)Stored data is corrupt, including a commit ID reused with different contents.
-
ParentConflict( expected: option.Option(String), actual: option.Option(String), )A commit’s expected parent does not match the session’s current head.
-
InvalidCommit(message: String)The proposed commit is invalid and cannot be stored.
A synchronous durable store bound to one logical session.
pub type SessionStore {
SessionStore(
load: fn() -> Result(Session, SessionError),
commit: fn(SessionCommit) -> Result(Session, SessionError),
)
}
Constructors
-
SessionStore( load: fn() -> Result(Session, SessionError), commit: fn(SessionCommit) -> Result(Session, SessionError), )
Values
pub fn new_commit(
parent: option.Option(String),
first: message.Message,
rest: List(message.Message),
) -> SessionCommit
Create a message commit with a fresh opaque ID and its expected parent.
pub fn new_settings_commit(
parent: option.Option(String),
settings: provider.InferenceSettings,
) -> SessionCommit
Create an inference-settings commit with a fresh opaque ID and its expected parent.