ExAgent. Session. StateCodec behaviour
(ExAgent v3.0.0)
View Source
Optional codec for application state at the Session checkpoint boundary.
Stability — Stable.
Configure shared_state_codec: MyCodec on Session.start_link/1. The module
is supplied by the host, never by stored data. encode/1 must return
{:ok, json_data}; decode/1 receives JSON data only after the complete
snapshot and roster have been validated and returns {:ok, application_state}.
Callbacks must be pure and must not include credentials in the persisted data.
The codec module and application structs are never inferred from a snapshot.
Callback failures and errors converting encoded data to JSON produce generic
diagnostics. A checkpoint error still carries the original operation result.
Successful decode still precedes the policy's separate restore validation.
Without a codec, the existing JSON representation remains unchanged.