Serializable session envelope for running an agent across requests.
A session is data. It stores the agent spec, request history, hibernated snapshots, pending review requests, and the latest result/error. It does not own processes or runtime capabilities.
Summary
Functions
Increments the durable session revision.
Removes active lease ownership from a session.
Builds a new session from a copied, safe snapshot and lineage data.
Normalizes an existing session, keyword list, or map.
Returns the most recent session snapshot, if one exists.
Merges snapshot evidence without adding duplicate snapshot ids.
Builds a durable session from keyword or map attributes.
Builds a durable session and raises if the attributes are invalid.
Records typed cancellation evidence and marks the session as cancelled.
Records a durable in-run checkpoint while lease ownership stays active.
Records a session error and marks the session as failed.
Adds active lease ownership to a running session.
Adds a request and marks the session as running.
Adds a completed turn result and updates semantic agent state.
Adds a snapshot and marks the session as hibernated.
Returns the Zoi schema for a durable session.
Returns the current durable session schema version.
Starts durable session data for an agent specification.
Returns the possible durable session statuses.
Types
@type status() ::
:new | :running | :hibernated | :waiting | :finished | :cancelled | :error
@type t() :: %Jidoka.Session.Data{ agent_id: binary(), error: nil | nil | any(), lease: nil | nil | term(), lineage: nil | nil | term(), metadata: map(), pending_reviews: [term()], requests: [term()], result: nil | nil | term(), revision: integer(), schema_version: integer(), session_id: binary(), snapshots: [term()], spec: term(), status: (((((:new | :running) | :hibernated) | :waiting) | :finished) | :cancelled) | :error }
Functions
Increments the durable session revision.
Removes active lease ownership from a session.
@spec fork(t(), Jidoka.Snapshot.t(), Jidoka.Session.Lineage.t(), keyword()) :: {:ok, t()} | {:error, term()}
Builds a new session from a copied, safe snapshot and lineage data.
Normalizes an existing session, keyword list, or map.
@spec latest_snapshot(t()) :: Jidoka.Snapshot.t() | nil
Returns the most recent session snapshot, if one exists.
@spec merge_snapshots([Jidoka.Snapshot.t()], [Jidoka.Snapshot.t()]) :: [ Jidoka.Snapshot.t() ]
Merges snapshot evidence without adding duplicate snapshot ids.
Builds a durable session from keyword or map attributes.
Builds a durable session and raises if the attributes are invalid.
@spec put_cancellation(t(), Jidoka.Cancellation.t() | term()) :: t()
Records typed cancellation evidence and marks the session as cancelled.
@spec put_durable_checkpoint(t(), Jidoka.Snapshot.t()) :: t()
Records a durable in-run checkpoint while lease ownership stays active.
Records a session error and marks the session as failed.
@spec put_lease(t(), Jidoka.Session.Lease.t()) :: t()
Adds active lease ownership to a running session.
@spec put_request(t(), Jidoka.Turn.Request.t()) :: t()
Adds a request and marks the session as running.
@spec put_result(t(), Jidoka.Turn.Result.t()) :: t()
Adds a completed turn result and updates semantic agent state.
@spec put_snapshot(t(), Jidoka.Snapshot.t()) :: t()
Adds a snapshot and marks the session as hibernated.
@spec schema() :: Zoi.schema()
Returns the Zoi schema for a durable session.
@spec schema_version() :: pos_integer()
Returns the current durable session schema version.
@spec start( Jidoka.Agent.Spec.t(), keyword() ) :: {:ok, t()} | {:error, term()}
Starts durable session data for an agent specification.
@spec statuses() :: [status()]
Returns the possible durable session statuses.