Serializable session snapshot persisted by session stores.
A snapshot carries its own :version, and that is the field that matters
most. Once a snapshot exists on someone's disk the shape is no longer free to
change, and a record that does not say which shape it is leaves no way to read
an old one except guessing. migrate/1 is the only supported way to turn a
loaded term back into a snapshot, so every store gets the same handling
whether it wrote the term yesterday or a year ago.
:id and :actor exist for the same reason. A snapshot without them can be
restored but not attributed, which is enough for a single user resuming their
own terminal and not enough for anything that holds sessions on behalf of
more than one person. :actor is opaque to Condukt: a host puts whatever
identifies the owner in it and gets it back untouched.
A session that keeps a journal also records which runs the snapshot holds
and the outcomes of its recent request ids, with put_runs/3, read back
with runs/1. They are not struct fields: a term with a field an older
build has never seen is one that build cannot decode with
:erlang.binary_to_term(binary, [:safe]), which would cost it the whole
snapshot. They sit under a string key instead, encoded on their own, so an
older build reads the snapshot and drops them on its next save, which
forgets the stored request outcomes. A store that writes snapshots field by
field must keep that entry too; Condukt.SessionStore.Conformance checks it.
Summary
Functions
The snapshot version this build writes.
Brings a loaded term up to the current version.
Builds a snapshot, stamping the version and timestamps.
Records the newest run the snapshot's messages include, and the stored outcomes of recent request ids, newest first.
Returns {last_run_id, requests} as recorded by put_runs/3, or
{nil, []} for a snapshot without them or whose record cannot be read.
Functions
The snapshot version this build writes.
Brings a loaded term up to the current version.
Returns {:ok, snapshot} or {:error, reason}. Version 1 had no version
field at all, so a struct without one is read as version 1 rather than
rejected: those snapshots are on real disks and refusing them would lose
conversations that are otherwise intact.
Builds a snapshot, stamping the version and timestamps.
:created_at is preserved when given, so a session that has been persisted
before keeps the moment it started rather than the moment it was last saved.
Records the newest run the snapshot's messages include, and the stored outcomes of recent request ids, newest first.
Returns {last_run_id, requests} as recorded by put_runs/3, or
{nil, []} for a snapshot without them or whose record cannot be read.