Reference Omni.Session.Store adapter using plain files on disk.
Designed for local development, single-node deployments, and as a
worked example of the adapter contract. Writes assume a single writer
per session id — safe within a single Omni.Session process, which
serialises writes through its mailbox, but not across nodes or
unrelated processes opening the same id. For multi-node deployments,
implement a custom adapter against a shared store such as Postgres
or S3.
Each session lives in its own directory with two files:
<base_path>/
<session_id>/
nodes.jsonl # tree nodes, one JSON-encoded node per line
session.json # path, cursors, state fields, timestampsnodes.jsonl is append-only when save_tree/4 is called with a
:new_node_ids hint; otherwise it's rewritten from the full node set.
session.json is a single merged file written by both save_tree and
save_state — the two callbacks write disjoint keys, so the merge is
read-modify-write with no conflict resolution.
Configuration
:base_path— required. Absolute paths are used verbatim. Relative paths require:otp_app(see below) and are resolved viaApplication.app_dir/2.:otp_app— optional. When set together with a relative:base_path, the adapter resolves the absolute base viaApplication.app_dir(otp_app, base_path). This is CWD-independent and remains stable across the BEAM lifetime, unlike paths derived fromFile.cwd!/0which can shift under code reloading orcd.
Examples:
# Absolute — used as-is
{Omni.Session.Store.FileSystem, base_path: "/var/data/sessions"}
# Relative under :my_app's priv directory
{Omni.Session.Store.FileSystem, base_path: "priv/sessions", otp_app: :my_app}Passing a relative :base_path without :otp_app raises
ArgumentError on first use — silent CWD-dependent storage is a
foot-gun the adapter refuses to enable.
Encoding
| Field | Encoding |
|---|---|
node message, usage | Omni.Codec.encode/1 |
path | JSON array of integers |
cursors | JSON array of [parent_id, child_id] pairs |
title, system | plain JSON string or null |
model | [provider_string, model_id] |
opts | Omni.Codec.encode_term/1 wrapper |
created_at, updated_at | ISO8601 strings |