# `CommBus.Protocol.Pipeline`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

ALF pipeline that assembles a conversation and adapts it into a protocol packet.

# `alf_components`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

# `assemble_prompt`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec assemble_prompt(
  CommBus.Protocol.Pipeline.State.t(),
  keyword()
) :: CommBus.Protocol.Pipeline.State.t()
```

Pipeline stage that runs prompt assembly on the context's conversation and
entries, attaching the assembly result to the context.

# `build_packet`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec build_packet(
  CommBus.Protocol.Pipeline.State.t(),
  keyword()
) :: CommBus.Protocol.Pipeline.State.t()
```

Pipeline stage that invokes the protocol adapter to convert the assembled
context into a protocol packet.

# `call`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec call(any(), Keyword.t()) :: any() | [any()] | nil
```

```elixir
@spec call(any(), Keyword.t()) :: reference()
```

# `cast`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

# `components`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec components() :: [map()]
```

# `finalize_result`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec finalize_result(
  CommBus.Protocol.Pipeline.State.t(),
  keyword()
) :: {:ok, CommBus.Protocol.Packet.t()} | {:error, term()}
```

Pipeline stage that extracts the final result from the pipeline state,
returning either the assembled packet or an error.

# `flow`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec flow(map(), list(), Keyword.t()) :: Enumerable.t()
```

# `run`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec run(
  CommBus.Protocol.Context.t() | tuple(),
  keyword()
) :: {:ok, CommBus.Protocol.Packet.t()} | {:error, term()}
```

Executes the ALF assembly pipeline: validates the context, assembles the
prompt, builds a protocol packet, validates it, and returns the result.

## Parameters

  - `input` — A `%CommBus.Protocol.Context{}` struct, or a tuple of
    `{conversation, entries}` or `{conversation, entries, opts}`.
  - `opts` — Keyword options: `:adapter` (protocol adapter module,
    defaults to `CommBus.Protocol.LlmCoreAdapter`).

## Returns

`{:ok, %CommBus.Protocol.Packet{}}` on success or `{:error, reason}` on failure.

# `start`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec start() :: :ok
```

# `start`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec start(list()) :: :ok
```

# `started?`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec started?() :: true | false
```

# `stop`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec stop() :: :ok | {:exit, {atom(), any()}}
```

# `stream`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec stream(Enumerable.t(), Keyword.t()) :: Enumerable.t()
```

# `validate_context`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec validate_context(
  CommBus.Protocol.Pipeline.State.t(),
  keyword()
) :: CommBus.Protocol.Pipeline.State.t()
```

Pipeline stage that validates the context has a valid conversation and entry list.
Returns the state unchanged if valid, or sets an error result if invalid.

# `validate_packet`
[🔗](https://github.com/fosferon/comm_bus/blob/v0.1.0/{path}#L{line})

```elixir
@spec validate_packet(
  CommBus.Protocol.Pipeline.State.t(),
  keyword()
) :: CommBus.Protocol.Pipeline.State.t()
```

Pipeline stage that validates the assembled packet's structure, checking
message format, sections, and token usage.

---

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