ExAgent.Session (ExAgent v2.0.0)

View Source

Single-writer coordination of application state and a participant roster.

TurnPolicy uses struct state and controls scheduling/admission. Session enforces membership and lifecycle. A turn computes one complete coordination transition, then checkpoints it once. Change functions should calculate state, not perform external effects expecting transactional rollback.

With Store, successful mutation replies follow save confirmation. Checkpoint errors preserve the new state in memory and block further mutations until checkpoint/1 saves it; the change function is never retried. Restore loads validated conversation data, not processes or arbitrary executable continuations. JSON changes atom keys to strings and does not redact secret content.

Summary

Functions

Retry only the unconfirmed save, without invoking a change function.

Returns a specification to start this module under a supervisor.

Complete a bound terminal run once per lifetime/run using pure host state calculation.

Query a participant's explicitly bound atomic continuation; no agent execution.

Override the actor while preserving the policy scheduling cursor.

Acknowledge a bound local diagnostic explicitly, without running a callback or advancing the turn.

Start a Session with shared_state, policy, participants, session_id, pubsub, metadata, optional trusted application namespace and Store. Namespace must match any Store.scoped/2 descriptor. Live participant refs are supplied by the app within the intended namespace; persisted data never resolves processes. Store errors/incompatible snapshots fail startup rather than starting empty. Additional participants after restore must be added explicitly with join/2. shared_state_codec: MyCodec optionally encodes and restores application structs through ExAgent.Session.StateCodec, after snapshot validation.

Functions

checkpoint(session)

Retry only the unconfirmed save, without invoking a change function.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(session)

complete_turn(session, id, reference, change)

Complete a bound terminal run once per lifetime/run using pure host state calculation.

continuation(session, id)

Query a participant's explicitly bound atomic continuation; no agent execution.

current(session)

end_turn(session, id)

handoff(session, id)

Override the actor while preserving the policy scheduling cursor.

health(session)

join(session, p)

leave(session, id)

participants(session)

pause(session)

read_state(session)

reconcile_turn(session, id, witness)

Acknowledge a bound local diagnostic explicitly, without running a callback or advancing the turn.

resume(session)

start(session)

start_link(opts)

Start a Session with shared_state, policy, participants, session_id, pubsub, metadata, optional trusted application namespace and Store. Namespace must match any Store.scoped/2 descriptor. Live participant refs are supplied by the app within the intended namespace; persisted data never resolves processes. Store errors/incompatible snapshots fail startup rather than starting empty. Additional participants after restore must be added explicitly with join/2. shared_state_codec: MyCodec optionally encodes and restores application structs through ExAgent.Session.StateCodec, after snapshot validation.

status(session)

take_turn(session, id, change)

update_state(session, id, change)