Syntropy.Retention
(syntropy v0.3.0)
Copy Markdown
Data retention policy for replay read models.
The policy decides how long replay data (run envelopes, runtime events, lattice snapshots, structural recommendations, task runs) is kept when persistence is enabled:
"infinite"— never purge (default)"days7"— purge rows older than seven days, on boot and hourly"session"— purge all replay data when the runtime boots
Config-like tables (webhooks, API tokens, knowledge, runtime settings) and billing data (usage records) are never purged.
The applied policy is persisted in runtime_settings and survives
restarts. Without persistence there is nothing to purge, so the policy is
informational only.
Summary
Functions
Validates and applies a retention policy.
Effective retention policy: the persisted setting when present, otherwise
the environment-seeded default (SYNTROPY_RETENTION_POLICY).
Purges replay data according to the given policy and returns per-table
deletion counts. Purge failures never raise; they are observed through
PersistenceHealth and reported as an empty count map.
Retention posture for the API and the platform cockpit.
Types
@type policy() :: String.t()
@type purge_counts() :: %{required(String.t()) => non_neg_integer()}
Functions
Validates and applies a retention policy.
The policy is written through to runtime_settings (best effort) and also
applied to the Application environment so persistence-disabled runtimes
keep the value for the life of the node.
@spec policies() :: [policy()]
@spec policy() :: policy()
Effective retention policy: the persisted setting when present, otherwise
the environment-seeded default (SYNTROPY_RETENTION_POLICY).
@spec purge(policy(), :recorder | :direct) :: purge_counts()
Purges replay data according to the given policy and returns per-table
deletion counts. Purge failures never raise; they are observed through
PersistenceHealth and reported as an empty count map.
announce controls how the retention_purged event is emitted:
:recorder goes through the running EventRecorder; :direct persists
the event row directly, for boot-time purges that run before the recorder
hydrates.
@spec purge_after_days() :: pos_integer()
@spec report() :: map()
Retention posture for the API and the platform cockpit.