# `Squidie.Runtime.RunIndexProjection`
[🔗](https://github.com/dark-trench/squidie/blob/main/lib/squidie/runtime/run_index_projection.ex#L1)

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.

# `anomaly`

```elixir
@type anomaly() :: %{
  :reason =&gt; atom(),
  :entry_type =&gt; atom(),
  optional(:run_id) =&gt; String.t(),
  optional(:workflow) =&gt; String.t(),
  optional(:queue) =&gt; String.t()
}
```

# `run_summary`

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

# `t`

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

# `anomalies`

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

Returns malformed or conflicting index facts discovered during replay.

# `new`

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

Returns a new empty run-index projection.

# `rebuild`

```elixir
@spec rebuild([Squidie.Runtime.DispatchProtocol.Entry.t()]) :: t()
```

Rebuilds a run-index projection from durable journal entries.

# `replay`

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

Replays additional run-index entries into an existing projection.

# `run_ids`

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

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

# `runs`

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

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

# `workflow`

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

Returns the workflow this index projection describes.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
