ALLM.Pipeline.Store.Ecto (allm_pipeline v0.1.0)

Copy Markdown View Source

PostgreSQL implementation of ALLM.Pipeline.Store, and the adapter that ships the package's run/step schemas.

Every callback is a defdelegate onto ALLM.Pipeline.PipelineRun or ALLM.Pipeline.StepLog, which hold the Ecto schemas, the changesets, the serialization rules and the ownership guard. This module is a naming layer: it gives the two schemas one behaviour-shaped front door so a future adapter has a contract to satisfy, without moving a single line of persistence logic out of the modules that own it.

Why delegation, and not a re-implementation

%PipelineRun{} carries a virtual :completion_token minted inside PipelineRun.create/3. defdelegate returns the callee's value untouched, so the owning handle reaches the caller by construction — there is no intermediate struct for it to be dropped from, and no third mint point. An adapter that rebuilt the run from row data instead would return a permanently non-owning handle and break every complete/2 in the system, invisibly to the migration gate. See ALLM.Pipeline.Store's warning.

The repo

Comes from ALLM.Pipeline.Config.repo/0, reached through each schema module's own private repo/0 — this module needs none of its own. Store does not subsume ALLM.Pipeline.Config.repo/0: Metrics and Lock.Advisory read the same handle and sit outside this behaviour entirely.

Tables are contract, not configuration

step_logs and pipeline_runs are inlined in StepLog.build_lineage_tree/1 raw SQL, queried by string from a host app (one that cannot see this package's config), and committees.last_step_log_id is a real Postgres FK. There is no table_prefix option, and the four migrations that own these tables stay in the host.