# Roadmap

Where the wire layer stands, what it deliberately leaves out, and the order in which
further operation families would arrive. `docs/design.md` is the canonical spec; this
page is the plan, and it changes more often.

## 1. Delivered in 0.1

The implementation order the release followed, kept because it shows how the layers
depend on each other:

1. Canonical structs and types, including reasoning.
2. Codec behaviour, encoded request, error, capabilities.
3. OpenAI Chat codec with request/response/stream fixtures.
4. Anthropic Messages codec.
5. Gemini GenerateContent codec.
6. Generic OpenAI-compatible configuration.
7. `LlmCall.HTTP` on Finch and the default pool.
8. `LlmCall.JSON` as a behaviour, threaded through the codecs and resolved (with
   `http_opts`, `timeout`) from call option, provider, application environment and
   default. There is no configurable HTTP behaviour.
9. `LlmCall.Client`, `LlmCall.Provider`, and `complete/3`, `execute/2`, `fetch/2`.
10. `LlmCall.SSE`, `LlmCall.Stream` and `stream/3`.
11. The media IR (design §23): `Content.Video`, `Request.modalities`,
    `Capabilities.modalities`, `LlmCall.Media.Request`, `LlmCall.Media.Response`,
    `LlmCall.Operation`, `LlmCall.Media.Capabilities`, the `LlmCall.Media.Codec`
    behaviour, and the public media API.
12. `generate/3` and `poll/3` for the media IR.
13. The conformance suites published from `lib/`, the ban on `@moduledoc false`, and
    the adapter-authoring contract.
14. Provider-hosted tools: the builtin envelope, the `builtin_tools` capability, and
    the codec branches.
15. The media adapters under `LlmCall.Media.Dialect.*`: OpenAI Images, Gemini Imagen
    `predict`, Seedance, MiniMax Hailuo.
16. The OpenAI Responses codec (`POST /v1/responses`) on the HTTP/SSE transport.
17. The `LlmCall.WS` behaviour and `LlmCall.WS.Mint`, and the test servers that
    exercise them.

## 2. Delivered in 0.2

0.2 turned the streaming and validation edges into contract:

- A stream that ends without its protocol terminator is an error, not a synthesized
  stop.
- Header values must be printable ASCII with no leading or trailing whitespace, and
  an offending `api_key` never reaches the error message.
- `:pool_strategy` validates against Finch's own contract instead of accepting
  values Finch does not dispatch on.
- `Request.tools` accepts a `tool_call` module, and `LlmCall.StreamAssembler` bounds
  streamed tool-call arguments with `max_argument_bytes`.

## 3. Delivered in 0.3

Three kinds of change, none of them a new operation family: an authentication family
(a provider can sign what it sends), a fifth reference adapter together with the
binary framing it streams in, and observability for every call.

- `auth: {:sigv4, service: ..., region: ...}` with `credentials:` (a map or a 0-arity
  function) and `region:` client options. The signer runs in the transport, after the
  body is serialized, because the signature covers the bytes that go on the wire. It
  reproduces AWS's published `ListUsers` vector and replays eight request shapes
  signed by botocore — the canonicalisation the published vector cannot reach — and
  adds no runtime dependency.
- `LlmCall.Dialect.Bedrock.Converse`, the fifth reference adapter: text, tool use and
  tool results, with consecutive tool results merged into one user turn because
  Bedrock requires alternating roles.
- The capability boundary is explicit, and now per source: `image_input` and
  `file_input` are `LlmCall.Capabilities.Input` records naming the kinds a codec
  accepts (`inline`, `url`, `uri`, `file`), so a codec that takes bytes but not a URL
  can say so. Conformance derives its sample part from the declaration instead of a
  hard-coded URL image, which is what makes the declaration checkable.
- `{:uri, uri}` is a canonical source for a location only the provider can resolve,
  distinct from a URL the provider fetches. It is what makes Converse's `s3Location`
  reachable.
- Converse carries images and documents inline (`source.bytes`) and from S3
  (`s3Location`), with the media type mapped to Converse's `format` enum and a
  document's `filename` sent as `name`. An `https://` source is refused locally,
  because the service would answer `400`.
- Gemini's media source follows the same rule: `{:uri, _}` reaches `fileData.fileUri`
  for a `gs://` object or a Files API URI, and a URL or bare string is refused. Its
  `fileUri` was never a fetchable URL, so the old acceptance only moved the failure
  to the provider.
- A `{:sigv4, _}` client is refused by the WebSocket connection instead of
  handshaking unsigned.
- `Usage` carries Bedrock's prompt-cache token counters.
- `provider_options.bedrock` lands at the top level of the Converse request instead
  of inside `additionalModelRequestFields`, and the canonical envelope keys are
  reserved. That is what makes `guardrailConfig`, `performanceConfig`,
  `requestMetadata` and `promptVariables` reachable;
  `additionalModelRequestFields` is written nested, as it appears on the wire.
- `LlmCall.EventStream` decodes `application/vnd.amazon.eventstream`, the framing
  `ConverseStream` answers with: length prefixes, typed headers, CRC-32 over both the
  prelude and the message, and a truncation check at end of body. The test frames are
  generated by `@smithy/eventstream-codec` rather than by hand, so the decoder is
  checked against an implementation it shares no code with.
- `ConverseStream`: the same codec serves `/converse` and `/converse-stream`, maps
  `messageStart`, `contentBlock*`, `messageStop` and `metadata` onto the IR stream
  events, and reports an `exception` frame as a provider error. Usage arrives after
  `messageStop`, so the terminator is flushed at end of body and a stream that never
  reaches `messageStop` is an `:invalid_response`.

Not in it, and deliberately: signed WebSocket or bidirectional streaming, credential
resolution (still a non-goal, design §4), and internationalised hosts (refused with a
punycode hint).

## 4. Further operation families

0.1 ships two operation families — completion (`LlmCall.Codec`) and media generation
with its long-running operations (`LlmCall.Media.Codec`) — plus the Responses
WebSocket transport. Further families follow the same rule as design §25.3.1: **a new
operation is a new IR plus a codec behaviour**, and never a new field on `Request`.
Adding one is therefore additive and does not disturb the IR contract.

### 4.1 What a family costs

A codec is small; the fixed cost per family is what surrounds it, and it multiplies per
provider:

- the canonical request/response/capabilities structs;
- a codec behaviour, an adapter macro and a conformance suite;
- one adapter, fixture set and wire-fact verification per provider;
- client entry points, documentation and CHANGELOG surface.

The suite cost scales with the family's wire surface, not with its importance. An
embedding suite covers shapes, vector dimensions, usage and errors — no stream, no
operation state machine, no asset hop — so it is a fraction of the media suite. The
Bedrock codec is the recent data point: about 300 lines of codec, one fixture set and
one conformance line, against a signer that took as long as the codec itself — which
is why it is an auth family and not an operation family.

That cost model is the reason the order below exists: breadth is the wrong thing to buy
first. The library's claim is a verifiable wire contract, not "every model in every
modality"; a full-client library already occupies that ground.

### 4.2 Prerequisite: parameterise the family

Completion and media are currently two hand-written pipelines: two behaviours, two
adapter macros, two conformance skeletons, two client surfaces. Writing a third and
fourth family by hand multiplies that plumbing. Before family #3, one refactor turns
"a family" into a parameterised mechanism — codec behaviour, adapter macro, conformance
skeleton, client entry points — with media as its first instance. That is a
reorganisation, not a feature, and it belongs in a 0.x minor.

### 4.3 Order and verdict

| Operation | Canonical shape | New family | Demand | Plan |
| --- | --- | --- | --- | --- |
| Embeddings | `{model, input, dimensions?}` → vectors + usage | yes, small | highest: a conversation library is almost always paired with a vector store | next minor, with rerank |
| Rerank | `{model, query, documents, top_n?}` → ordered scores | shares the vector family | medium, narrow vendor set | next minor |
| Speech | text in, media bytes out | media-shaped | medium-low | 0.3 |
| Transcription | bytes in, text and segments out; needs the multipart boundary the transport deliberately does not own (design §23.7) | yes | medium | 0.3, once that boundary has a design |
| OCR | image or file in, text out | **no**: `Content.Image` and `Content.File` in a chat request already express it for every multimodal codec | low | documentation; a dedicated endpoint only on demand |
| Evaluation | "answer named questions about this text/JSON" | **no**: it is an upper-layer abstraction built on chat or structured output, not a provider endpoint | low | never in core |

Rerank is the first family the signing work pays for twice: Bedrock's rerank endpoint
takes the same `{:sigv4, ...}` declaration and the same client, so the family's cost
there is the codec alone. That is the concrete argument for the auth seam having been
the right one to build before a third operation family.

### 4.4 Criteria for adding a family

A family enters the core only when all three hold:

1. its canonical shape is expressible without `provider_options`;
2. at least two providers need it — a single-vendor endpoint belongs in the
   application, not in a protocol library;
3. someone carries the per-provider adapter and verification cost, and the conformance
   suite for the family is written in the same change.
