Docket.Postgres.Schemas.Run (docket v0.1.0)

Copy Markdown View Source

Row schema for docket_runs.

Columns expose only the fields Postgres needs for identity, claiming, scheduling, inspection, and constraints. state holds all remaining durable run fields and must not be interpreted by hosts.

Operational columns:

  • wake_at — when the run next advances: now means runnable, a future instant means a timer or retry backoff, and nil means claimed, externally parked, poisoned, or terminal.
  • claim_token / claimed_at — execution ownership.
  • tenant_admitted_at — durable windowed sticky-cohort residency. It is independent of the transient claim token and is never set by Legacy.
  • checkpoint_seq — the optimistic commit fence.
  • claim_attempts — consecutive claims consumed by launched execution without committed progress.
  • claim_abandons — consecutive pre-execution claim abandons without committed progress.
  • poisoned_at / poison_reason — paired poison facts, both nil for a healthy run.

tenant_id is a nullable scoping column; nothing requires it.

The changeset is a row codec only. Lifecycle tuple validity (claim pairing, schedule shape, terminal columns) is enforced by the database CHECK constraints, which also bind raw SQL that bypasses changesets.

Summary

Functions

Builds a changeset for inserting or updating a run row.

Types

t()

@type t() :: %Docket.Postgres.Schemas.Run{
  __meta__: term(),
  checkpoint_seq: non_neg_integer(),
  claim_abandons: non_neg_integer(),
  claim_attempts: non_neg_integer(),
  claim_token: Ecto.UUID.t() | nil,
  claimed_at: DateTime.t() | nil,
  finished_at: DateTime.t() | nil,
  graph_hash: String.t() | nil,
  graph_id: String.t() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  latest_checkpoint_type: Docket.Checkpoint.type() | nil,
  poison_reason: String.t() | nil,
  poisoned_at: DateTime.t() | nil,
  run_id: String.t() | nil,
  scope_key: String.t() | nil,
  started_at: DateTime.t() | nil,
  state: binary() | nil,
  status: Docket.Run.durable_status() | nil,
  step: non_neg_integer(),
  tenant_admitted_at: DateTime.t() | nil,
  tenant_id: String.t() | nil,
  updated_at: DateTime.t() | nil,
  wake_at: DateTime.t() | nil
}

Functions

changeset(run \\ %__MODULE__{}, attrs)

@spec changeset(t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()

Builds a changeset for inserting or updating a run row.

tenant_id is never required.