Spectre.Skill.Definition (Spectre v0.3.0)

Copy Markdown View Source

Unified view of compiled and runtime Skill Definitions.

Both origins are backed by Spectre.Definition.Canonical. Runtime input is data-only: it may declare closed prompt fragments, exact Flow routes and registered operation references, but never callbacks, modules or AST.

Summary

Functions

Runs positive/negative applicability examples as an anti-hijack corpus.

Returns normalized structured applicability.

Returns the shared canonical Definition envelope.

Returns true when compiled and runtime sources declare equal behavior.

Validates and wraps an existing canonical Skill Definition.

Lowers a compiled Skill module into the unified Definition view.

Builds a strictly declarative runtime Skill.

Builds a runtime Skill or raises with its stable validation reason.

Returns the registered operation identifiers requested by the Skill.

Returns whether the Definition was compiled or supplied as runtime data.

Returns the Definition's immutable prompt budget.

Returns canonical closed prompt fragments.

Returns the content-addressed exact Definition Ref.

Routes an input inside one Skill and fails closed on ambiguity.

Returns canonical routing rules.

Alias that makes runtime construction explicit at call sites.

Returns origin-neutral semantic IR for equivalence and fixtures.

Fetches one data-driven Work by stable id.

Returns the immutable data-driven Work programs declared by the Skill.

Types

t()

@type t() :: %Spectre.Skill.Definition{
  canonical: Spectre.Definition.Canonical.t(),
  ref: Spectre.Definition.Ref.t()
}

Functions

anti_hijack(definition)

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

Runs positive/negative applicability examples as an anti-hijack corpus.

applicability(definition)

@spec applicability(t()) :: Spectre.Skill.Applicability.t()

Returns normalized structured applicability.

canonical(definition)

@spec canonical(t()) :: Spectre.Definition.Canonical.t()

Returns the shared canonical Definition envelope.

equivalent?(left, right)

@spec equivalent?(t(), t()) :: boolean()

Returns true when compiled and runtime sources declare equal behavior.

from_canonical(canonical)

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

Validates and wraps an existing canonical Skill Definition.

from_compiled(source, opts \\ [])

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

Lowers a compiled Skill module into the unified Definition view.

new(attrs)

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

Builds a strictly declarative runtime Skill.

new!(attrs)

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

Builds a runtime Skill or raises with its stable validation reason.

operation_refs(definition)

@spec operation_refs(t()) :: [term()]

Returns the registered operation identifiers requested by the Skill.

origin(definition)

@spec origin(t()) :: :compiled | :runtime

Returns whether the Definition was compiled or supplied as runtime data.

prompt_budget(definition)

@spec prompt_budget(t()) :: Spectre.Skill.PromptBudget.t()

Returns the Definition's immutable prompt budget.

prompt_fragments(definition)

@spec prompt_fragments(t()) :: [Spectre.Prompt.Fragment.t()]

Returns canonical closed prompt fragments.

ref(definition)

@spec ref(t()) :: Spectre.Definition.Ref.t()

Returns the content-addressed exact Definition Ref.

route(definition, input)

@spec route(t(), Spectre.Input.t() | String.t() | map() | term()) ::
  {:ok, map()} | {:error, term()}

Routes an input inside one Skill and fails closed on ambiguity.

routes(definition)

@spec routes(t()) :: [map()]

Returns canonical routing rules.

runtime(attrs)

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

Alias that makes runtime construction explicit at call sites.

semantic_ir(definition)

@spec semantic_ir(t()) :: map()

Returns origin-neutral semantic IR for equivalence and fixtures.

work(definition, id)

@spec work(t(), term()) :: {:ok, Spectre.Execution.Program.t()} | {:error, term()}

Fetches one data-driven Work by stable id.

works(definition)

@spec works(t()) :: [Spectre.Execution.Program.t()]

Returns the immutable data-driven Work programs declared by the Skill.