# `PhoenixAI.Store.Memory.Pipeline`
[🔗](https://github.com/franciscpd/phoenix-ai-store/blob/v0.1.0/lib/phoenix_ai/store/memory/pipeline.ex#L1)

Orchestrates memory strategy execution for a conversation's message list.

The pipeline:
1. Extracts pinned messages (role: :system or pinned: true)
2. Sorts strategies by priority (lower = runs first)
3. Applies each strategy sequentially on non-pinned messages
4. Re-injects pinned messages at the beginning (in original order)
5. Returns `{:ok, filtered_messages}`

## Presets

    Pipeline.preset(:default)     # SlidingWindow last: 50
    Pipeline.preset(:aggressive)  # TokenTruncation max_tokens: 4096
    Pipeline.preset(:summarize)   # Summarization + SlidingWindow

**Note on pinned message ordering:** Pinned messages (role: :system or pinned: true)
are always placed at the beginning of the output list, regardless of their original
position. This is intentional — LLMs expect system instructions at the start of the
message list. If you need a pinned message at a specific position, consider injecting
it manually after the pipeline runs.

# `strategy_entry`

```elixir
@type strategy_entry() :: {module(), keyword()}
```

# `t`

```elixir
@type t() :: %PhoenixAI.Store.Memory.Pipeline{strategies: [strategy_entry()]}
```

# `new`

```elixir
@spec new([strategy_entry()]) :: t()
```

Creates a new pipeline from a list of `{strategy_module, opts}` tuples.

# `preset`

```elixir
@spec preset(:default | :aggressive | :summarize) :: t()
```

Returns a preset pipeline configuration.

# `run`

```elixir
@spec run(t(), [map()], map(), keyword()) :: {:ok, [map()]} | {:error, term()}
```

Runs the pipeline against a list of messages.

Pinned messages (system messages and messages with `pinned: true`) are
extracted before strategies run and re-injected at the beginning of the
result in their original order.

---

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