DocShell.Presentation.ArtifactLimits (DocShell v2.0.0)

Copy Markdown View Source

Bounds portable artifact inputs before profiles are invoked or JSON is decoded.

Per-call keyword overrides are positive finite integers. Defaults bound page bytes, JSON values/depth, AST depth, block/binding/variant counts, profile and descriptor counts/bytes, manifests/projections, and individual/aggregate asset bytes. A caller can explicitly raise or lower them; another applicable site or producer ceiling still wins. No unlimited sentinel is accepted.

Native JSON is walked before canonical encoding. This bounds nesting and aggregate primitive size before the encoder allocates its output. Original manifest bytes are size/depth checked before decoding. These are admission budgets, not a bound on arbitrary work performed by a trusted host adapter.

Summary

Types

t()

Validated resource ceilings for one artifact projection call.

Functions

Checks an observed resource against its admitted ceiling.

Bounds one page's native JSON and AST depth without invoking an adapter.

Bounds native JSON before checking its exact canonical byte size.

Validates closed positive overrides and supplies finite defaults.

Checks document, invocation and original-byte inputs without invoking a profile.

Types

t()

@type t() :: %{required(atom()) => pos_integer()}

Validated resource ceilings for one artifact projection call.

Functions

check(limits, key, observed)

@spec check(t(), atom(), non_neg_integer()) :: :ok | {:error, term()}

Checks an observed resource against its admitted ceiling.

content(value, limits)

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

Bounds one page's native JSON and AST depth without invoking an adapter.

json(value, byte_key, limits)

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

Bounds native JSON before checking its exact canonical byte size.

new(opts \\ [])

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

Validates closed positive overrides and supplies finite defaults.

preflight(content, opts, limits)

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

Checks document, invocation and original-byte inputs without invoking a profile.