# `Foresight.Reflect.Expand`
[🔗](https://github.com/fosferon/foresight/blob/v0.3.2/lib/foresight/reflect/expand.ex#L1)

The agentic reflect `expand` tool: drill previously retrieved memories up the
hierarchy. `"chunk"` (the default) returns each memory with its provenance and
the neighbouring memories of the same document, the surrounding context a
truncated fact is missing; `"document"` returns the owning document's title and
text. The id list is model-controlled, so it is de-duplicated, filtered to valid
ids and capped before any query runs. `cited_ids/1` lists every memory id an
expansion put in front of the model, for grounding.

# `cited_ids`

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

Every memory id an expansion surfaced: the expanded units and their neighbours.

# `depth`

```elixir
@spec depth(term()) :: String.t()
```

Normalise the tool's `depth` argument; anything but `"document"` is `"chunk"`.

# `expand`

```elixir
@spec expand(module(), String.t(), term(), String.t(), keyword()) :: [map()]
```

Expand `ids` within `bank_id`. Must run inside the caller's tenant scope;
`repo_opts` carries the tenant prefix.

# `max_ids`

```elixir
@spec max_ids() :: pos_integer()
```

Upper bound on memory ids expanded per call.

# `normalize_ids`

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

Unique, well-formed memory ids, at most `max_ids/0` of them, in request order.

---

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