Spectre.Inference.Stream (Spectre v0.3.3)

Copy Markdown View Source

One-shot, pull-driven inference stream.

The handle is intentionally process-free: it carries only logical fences plus a bearer token used to authorize attach and control operations. The live session is resolved through a unique Registry. It is an ephemeral capability, not a durable or persistable continuation. Recovery returns a replacement handle with a fresh epoch.

Delta events are provisional. Only the terminal %Spectre.Result{} has passed the normal post-processing and canonical Run commit.

Summary

Functions

Waits for the committed terminal Run result without exposing deltas.

Cancels the current stream attempt. The operation is idempotent.

Commits restart-based steering and returns a replacement Enumerable.

Types

t()

@opaque t()

Functions

await_result(stream, timeout \\ :timer.minutes(5))

@spec await_result(t(), timeout()) :: {:ok, Spectre.Result.t()} | {:error, term()}

Waits for the committed terminal Run result without exposing deltas.

When no Enumerable has claimed the handle, this call becomes its one authoritative consumer and drains provider events internally. When an Enumerable is already active, it only waits for that consumer's terminal result. Repeated calls are idempotent for the session's retention window.

cancel(stream, reason \\ :user_requested)

@spec cancel(t(), term()) :: :ok | {:error, term()}

Cancels the current stream attempt. The operation is idempotent.

steer(stream, input, opts \\ [])

@spec steer(t(), term(), keyword()) :: {:ok, t()} | {:error, term()}

Commits restart-based steering and returns a replacement Enumerable.

The current stream never follows the successor epoch; it terminates with :superseded when the Instance accepts the command.