Spectre.Inference.StreamAdapter.Conformance (Spectre v0.3.3)

Copy Markdown View Source

Adapter-neutral checks for the normalized streaming protocol.

Provider packages pass a portable inference descriptor and deterministic transport messages from an isolated fixture. The runner verifies capability negotiation, open/resume shape, pull-credit discipline, normalized event batches, global provider ordering, UTF-8 reassembly, terminal cardinality, optional cancel or reconcile replies, and mandatory enforcement of the raw transport-chunk and parser-residual bounds. Real network flow control, cancellation, and credentials remain adapter-owned integration tests.

Summary

Functions

Runs the protocol contract over deterministic transport messages.

Types

report()

@type report() :: %{
  capabilities: MapSet.t(atom()),
  transport: :pull | :push,
  transport_requests: non_neg_integer(),
  transport_items: non_neg_integer(),
  ignored_messages: non_neg_integer(),
  events: non_neg_integer(),
  bounds: %{
    max_transport_chunk_bytes: pos_integer(),
    max_parser_residual_bytes: pos_integer()
  },
  bound_checks: %{transport_chunk: :enforced, parser_residual: :enforced},
  terminal: atom() | nil,
  cancel: :not_exercised | :accepted | {:error, atom()},
  reconcile: :not_exercised | atom()
}

Functions

run(adapter, descriptor, messages, opts \\ [])

@spec run(module(), Spectre.Inference.Descriptor.t(), [term()], keyword()) ::
  {:ok, report()} | {:error, term()}

Runs the protocol contract over deterministic transport messages.

Important options are :profile, :adapter_opts, :open_mode (:open or {:resume, cursor}), :require_terminal?, :cancel_after?, :reconcile_provider_request_id, :max_events_per_transport_item, and :max_delta_bytes. :max_transport_chunk_bytes and :max_parser_residual_bytes are mandatory adapter bounds with safe defaults. The adapter must implement StreamAdapter.conformance_fixture/4; the runner supplies an oversized binary and uses the returned fixture to prove both bounds through real handle_transport/2 calls.