ExAgent. Session. StateCodec behaviour
(ExAgent v2.2.0)
View Source
Optional codec for application state at the Session checkpoint boundary.
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 return generic errors without exposing the supplied state.
Successful decode still precedes the policy's separate restore validation.
Without a codec, the existing JSON representation remains unchanged.