AgentBlueprintProtocol.Bounds (Agent Blueprint Protocol v0.1.0)

Copy Markdown View Source

Parse ceilings for the bounded JSON decoder — resource-exhaustion guards, distinct from the eight operational ceilings an artifact declares.

Every field is a positive integer. maximum/0 is the immutable profile ceiling. new/1 derives a tighter profile: an override may only lower a field, never raise it, so a portable input can never widen a host's parse limits.

fieldmeaning
bytesmaximum total input size
depthmaximum structural nesting
membersmaximum members in one object
itemsmaximum items in one array
nodesmaximum total value nodes
stringmaximum byte length of one string value
keymaximum byte length of one object key
number_lexememaximum byte length of one number's source lexeme

Parse ceilings are decoder limits — the profile authorizes nothing.

Summary

Functions

Validate and normalize a Bounds struct, or build one from an overrides map.

The immutable profile maxima.

A tighter profile from overrides. Each override key must be known and its value a positive integer no greater than the corresponding maximum (tighten-only). Omitted fields keep their maximum.

Types

error()

@type error() :: :unknown_bound | {:ceiling, atom()}

t()

@type t() :: %AgentBlueprintProtocol.Bounds{
  bytes: pos_integer(),
  depth: pos_integer(),
  items: pos_integer(),
  key: pos_integer(),
  members: pos_integer(),
  nodes: pos_integer(),
  number_lexeme: pos_integer(),
  string: pos_integer()
}

Functions

coerce(bounds)

@spec coerce(t() | map()) :: {:ok, t()} | {:error, error()}

Validate and normalize a Bounds struct, or build one from an overrides map.

A struct is re-validated field-by-field, not trusted: a directly-constructed %Bounds{} carrying a super-maximum (or non-positive) ceiling is rejected, so the tighten-only invariant holds no matter how the struct was made.

maximum()

@spec maximum() :: t()

The immutable profile maxima.

new(overrides)

@spec new(map()) :: {:ok, t()} | {:error, error()}

A tighter profile from overrides. Each override key must be known and its value a positive integer no greater than the corresponding maximum (tighten-only). Omitted fields keep their maximum.