# `Runic.Workflow.FactResolver`
[🔗](https://github.com/zblanco/runic/blob/main/lib/workflow/fact_resolver.ex#L1)

Runtime resolver that hydrates `FactRef` structs via a Store adapter.

Maintains a process-local cache to avoid repeated store round-trips.
The cache lives in the Worker process memory and is cleared on Worker stop.

# `t`

```elixir
@type t() :: %Runic.Workflow.FactResolver{
  cache: %{optional(term()) =&gt; term()},
  store: {module(), term()}
}
```

# `new`

```elixir
@spec new({module(), term()}) :: t()
```

Creates a new FactResolver backed by the given store tuple.

# `preload`

```elixir
@spec preload(t(), [term()]) :: t()
```

Batch-loads a list of fact hashes into the resolver's cache.

Hashes already present in the cache are skipped. Returns an updated
resolver with the newly loaded values in its cache.

# `resolve`

```elixir
@spec resolve(Runic.Workflow.Fact.t() | Runic.Workflow.FactRef.t(), t()) ::
  {:ok, Runic.Workflow.Fact.t()} | {:error, term()}
```

Resolves a Fact or FactRef to a full Fact with its value.

- Full `Fact` structs with a value are returned as-is (passthrough).
- `FactRef` structs are resolved by checking the cache first, then
  falling back to the store's `load_fact/2`.

Returns `{:ok, %Fact{}}` or `{:error, reason}`.

# `resolve!`

```elixir
@spec resolve!(Runic.Workflow.Fact.t() | Runic.Workflow.FactRef.t(), t()) ::
  Runic.Workflow.Fact.t()
```

Like `resolve/2` but raises on error.

---

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