Spectre.Stack.Contract.V2 (Spectre v0.3.0)

Copy Markdown View Source

Mandatory runtime Stack contract for reflective Definition Manifests.

Contract V2 seals two distinct objects: the effective Authority Envelope and the Execution Closure. Existing compiled Stack V1 definitions are accepted only through from_v1/2, which reads and conservatively lowers them without mutating or retaining V1 as the native Manifest contract.

Summary

Functions

Builds Contract V2 for a compiled Agent/Skill and its canonical projection.

Conservatively adapts an immutable Stack Contract V1 definition.

Adapts a V1 Stack or raises with its stable validation reason.

Builds a native Contract V2 from reviewed authority and closure data.

Builds a native Contract V2 or raises.

Returns portable inspection data for the adapted contract.

Returns the mandatory reflective Stack contract version.

Types

t()

@type t() :: %Spectre.Stack.Contract.V2{
  authority: Spectre.Authority.Envelope.t(),
  contract_version: 2,
  execution_closure: Spectre.Execution.Closure.t(),
  source_contract: :native_v2 | :adapted_v1
}

Functions

from_compiled(definition, canonical, opts \\ [])

@spec from_compiled(
  Spectre.Definition.t(),
  Spectre.Definition.Canonical.t(),
  keyword()
) ::
  {:ok, t()} | {:error, term()}

Builds Contract V2 for a compiled Agent/Skill and its canonical projection.

from_v1(stack, opts \\ [])

@spec from_v1(
  Spectre.Stack.Definition.t() | module() | nil,
  keyword()
) :: {:ok, t()} | {:error, term()}

Conservatively adapts an immutable Stack Contract V1 definition.

V1 capability declarations are requests only. Effective grants are their intersection with the explicit :authority_ceiling; omitting the ceiling produces an empty envelope.

from_v1!(stack, opts \\ [])

@spec from_v1!(
  Spectre.Stack.Definition.t() | module() | nil,
  keyword()
) :: t()

Adapts a V1 Stack or raises with its stable validation reason.

new(authority, closure)

@spec new(Spectre.Authority.Envelope.t(), Spectre.Execution.Closure.t()) ::
  {:ok, t()} | {:error, term()}

Builds a native Contract V2 from reviewed authority and closure data.

new!(authority, closure)

Builds a native Contract V2 or raises.

to_data(contract)

@spec to_data(t()) :: map()

Returns portable inspection data for the adapted contract.

version()

@spec version() :: pos_integer()

Returns the mandatory reflective Stack contract version.