ExAgent.Session.Snapshot (ExAgent v3.0.0)

View Source

JSON checkpoint of coordination data. Version 3 adds bounded continuation references; unbound sessions still write v2, and valid v1/v2 data remains readable.

Stability — Stable.

Custom Stores use serialize/1, deserialize/1 and validate/2 for the snapshots supplied by the Session. Decoding is data-only. The Session restores the policy explicitly supplied by the host. Custom policies opt in with ExAgent.Session.TurnPolicy.snapshot/1 and ExAgent.Session.TurnPolicy.restore_snapshot/3. Participant refs and live processes stay in the runtime. JSON preserves application strings.

Summary

Functions

Decode stored JSON as a validated Session snapshot.

Encode a Session snapshot as portable JSON for a Store.

Validate a snapshot and check its session ID against the storage key.

Types

t()

@type t() :: %ExAgent.Session.Snapshot{
  continuations: term(),
  current: term(),
  metadata: term(),
  participants: term(),
  policy_mod: term(),
  policy_state: term(),
  policy_version: term(),
  revision: term(),
  saved_at: term(),
  seq: term(),
  session_id: term(),
  shared_state: term(),
  status: term(),
  version: term()
}

Functions

deserialize(binary)

@spec deserialize(binary()) :: {:ok, t()} | {:error, term()}

Decode stored JSON as a validated Session snapshot.

serialize(snapshot)

@spec serialize(t()) :: binary()

Encode a Session snapshot as portable JSON for a Store.

validate(snapshot, expected_id)

@spec validate(t(), String.t()) :: {:ok, t()} | {:error, term()}

Validate a snapshot and check its session ID against the storage key.