PostgreSQL-backed checkpointer using Ecto.
Assumes the lang_ex_checkpoints table has been created via
LangEx.Migration. See LangEx.Migration for setup instructions.
State is encoded with LangEx.Checkpoint.Serializer, so structs, atoms,
and tuples survive the round-trip exactly.
Large state values (above :blob_threshold bytes, default 16KB) are
stored once per (thread_id, content_hash) in lang_ex_checkpoint_blobs
and referenced from the checkpoint row — a value that never changes
between super-steps (e.g. a big tool catalog) is written once per thread
instead of into every checkpoint. Requires migration V3. Set
blob_threshold: :infinity in the config to store everything inline.
Config
The :repo key must point to an Ecto.Repo module:
config = [repo: MyApp.Repo, thread_id: "thread-1"]
LangEx.Checkpointer.Postgres.save(config, checkpoint)
Summary
Functions
@spec prune(keyword(), keyword()) :: {:ok, non_neg_integer()}
Deletes checkpoints created before the given DateTime, across all
threads. Returns {:ok, deleted_count}. Run periodically (e.g. from
a scheduled job) to enforce a retention window:
LangEx.Checkpointer.Postgres.prune([repo: MyApp.Repo],
older_than: DateTime.add(DateTime.utc_now(), -30, :day)
)