Squidie.Runtime.RunIndexProjection (squidie v0.1.2)

Copy Markdown View Source

Rebuildable projection over a workflow's run-index journal.

Run-index entries are lookup facts, not execution state. They let the Jido-native runtime rebuild "which runs exist for this workflow?" from the journal boundary without scanning storage adapter internals.

Duplicate entries for the same run are idempotent when they carry the same workflow and timestamp. Conflicting or malformed persisted entries are kept as anomalies so callers can surface index drift without losing the valid portion of the read model.

Summary

Functions

Returns malformed or conflicting index facts discovered during replay.

Returns a new empty run-index projection.

Rebuilds a run-index projection from durable journal entries.

Replays additional run-index entries into an existing projection.

Returns indexed run ids in the same deterministic order as runs/1.

Returns indexed run summaries ordered by index timestamp and run id.

Returns the workflow this index projection describes.

Types

anomaly()

@type anomaly() :: %{
  :reason => atom(),
  :entry_type => atom(),
  optional(:run_id) => String.t(),
  optional(:workflow) => String.t(),
  optional(:queue) => String.t()
}

run_summary()

@type run_summary() :: %{
  run_id: String.t(),
  workflow: String.t(),
  indexed_at: DateTime.t(),
  queue: String.t()
}

t()

@type t() :: %Squidie.Runtime.RunIndexProjection{
  anomalies: [anomaly()],
  runs: %{optional(String.t()) => run_summary()},
  workflow: String.t() | nil
}

Functions

anomalies(run_index_projection)

@spec anomalies(t()) :: [anomaly()]

Returns malformed or conflicting index facts discovered during replay.

new(workflow \\ nil)

@spec new(String.t() | nil) :: t()

Returns a new empty run-index projection.

rebuild(entries)

Rebuilds a run-index projection from durable journal entries.

replay(projection, entries)

@spec replay(t(), [Squidie.Runtime.DispatchProtocol.Entry.t()]) :: t()

Replays additional run-index entries into an existing projection.

run_ids(projection)

@spec run_ids(t()) :: [String.t()]

Returns indexed run ids in the same deterministic order as runs/1.

runs(run_index_projection)

@spec runs(t()) :: [run_summary()]

Returns indexed run summaries ordered by index timestamp and run id.

workflow(run_index_projection)

@spec workflow(t()) :: String.t() | nil

Returns the workflow this index projection describes.