# gen_durable v0.1.2 - Table of Contents

> Postgres-backed durable FSM engine on top of GenServer.

## Pages

- [gen_durable](readme.md)
- [Performance](performance.md)
- [Specification](gen_durable_spec.md)
- [Implementation plan](gen_durable_plan.md)

## Modules

- Public API
  - [GenDurable](GenDurable.md): Durable FSM engine on top of Postgres + GenServer.
  - [GenDurable.FSM](GenDurable.FSM.md): Behaviour for a durable FSM — or, in its degenerate one-step form, a durable job.
  - [GenDurable.Migration](GenDurable.Migration.md): Library-owned schema migration (Oban-style).
  - [GenDurable.State](GenDurable.State.md): Typed FSM state: an Ecto embedded schema per FSM, encoded to/from jsonb.
Typically defined as a nested `State` module inside the FSM, where it is
adopted by convention (see `GenDurable.FSM`)

- Runtime
  - [GenDurable.Executor](GenDurable.Executor.md): Runs one picked instance to a committed outcome (spec §3/§4).
  - [GenDurable.Reaper](GenDurable.Reaper.md): Periodically returns `executing` rows with an expired lease to `runnable`,
bumping `attempt` (spec §4.3 / §10). This is the at-least-once safety floor for
worker crashes; `handle/2` is intentionally not involved.

  - [GenDurable.Registry](GenDurable.Registry.md): Resolves `{fsm_name, fsm_version}` to an FSM module.
  - [GenDurable.Scheduler](GenDurable.Scheduler.md): Per-queue feeder + executor loop (spec §6). Backpressure-driven: it claims work
from the database into a small in-memory buffer, then spawns at most
`concurrency` supervised Tasks at a time, draining the buffer as slots free.
  - [GenDurable.Supervisor](GenDurable.Supervisor.md): Top-level engine supervisor. Started by the host (Oban-style) as
`{GenDurable, opts}` in their own supervision tree.

- Internals
  - [GenDurable.Context](GenDurable.Context.md): The context handed to `c:GenDurable.FSM.step/2` and `c:GenDurable.FSM.handle/2`.
  - [GenDurable.Outcome](GenDurable.Outcome.md): The five step/handle outcomes from the spec §3, with shape validation.
  - [GenDurable.Queries](GenDurable.Queries.md): Every database statement from spec §10, one function each, as raw SQL.

- Exceptions
  - [GenDurable.Registry.NotFound](GenDurable.Registry.NotFound.md)

