Spectre.Inference.Constraints (Spectre v0.3.0)

Copy Markdown View Source

Hard limits and soft preferences attached to one inference request.

Constraint merging is monotonic: a handler may strengthen a flow constraint, but cannot widen privacy, cost, latency, or minimum-capability limits.

Summary

Functions

Builds constraints from flow contributions followed by call-site options.

Merges a stronger layer into an existing constraint set.

Types

t()

@type t() :: %Spectre.Inference.Constraints{
  context_tokens: non_neg_integer() | nil,
  max_attempts: pos_integer() | nil,
  maximum_cost_tier: :low | :medium | :high | nil,
  maximum_latency_ms: pos_integer() | nil,
  maximum_output_tokens: pos_integer() | nil,
  minimum_level: term(),
  preferred_level: term(),
  privacy: :cloud_allowed | :private_cloud_only | :local_only | atom(),
  risk: :low | :medium | :high | atom(),
  strict?: boolean(),
  structured_output?: boolean()
}

Functions

from_options(opts, flow_constraints \\ [])

@spec from_options(
  keyword(),
  [Spectre.Flow.Constraint.t()]
) :: t()

Builds constraints from flow contributions followed by call-site options.

merge(base, stronger)

@spec merge(t(), t() | map() | keyword()) :: t()

Merges a stronger layer into an existing constraint set.

new(constraints)

@spec new(t() | map() | keyword() | nil) :: t()