StatifierPersistence.Ecto (StatifierPersistence v0.6.0)

Copy Markdown View Source

Compile-time Ecto configuration on the host's own module (ADR-0002).

A host declares its persistence module once:

defmodule MyApp.Persistence do
  use StatifierPersistence.Ecto, repo: MyApp.Repo
end

and gets, with zero further options: the resolved configuration readable via MyApp.Persistence.__statifier_persistence__/1, and three Ecto schema modules - MyApp.Persistence.Chart, MyApp.Persistence.Position, MyApp.Persistence.Run - over the statifier_charts / statifier_positions / statifier_runs tables with UXID string primary keys (chart_ / pos_ / run_ prefixes).

Every knob is compile-time, on this use, never in application env (ADR-0002 decision 3), and the migrations helper consumes the same resolved configuration so schemas and DDL cannot disagree. See StatifierPersistence.Ecto.Config for the options (:key, :table_prefix, :tables, :prefix, :blob_type).

The engine identity columns (content_hash, session_id, run_id) are stored verbatim as strings and are never touched by the configured key scheme - ADR-0002 decision 1.

The runs schema also carries metadata, the optional opaque map of host identities ADR-0006 grants, as a jsonb column (V02 of the migrations helper). It holds identities only, never personal data: :blob_type does not reach it, so anything filed there is at rest in the clear no matter how the blob columns are configured.

:blob_type reaches exactly three columns - identity_blob, chart_blob, position_blob - and nothing else: a host wanting encryption at rest for those payload columns passes a custom Ecto.Type or Ecto.ParameterizedType there and gets it applied with zero further wiring. The identity and lookup columns (content_hash, session_id, run_id, status, failure) stay plain text regardless - the identity guard and the unique indexes depend on reading them back verbatim, and metadata stays jsonb regardless for the same reason: it is the column a host queries (ADR-0006 decision 3).