Pure, typed prompt composition plan.
Operations are resolved outside this module. The plan applies scoped
start/end/replace semantics independently to instructions, context, and task
sections. Structured model adapters receive the typed plan directly. Legacy
string adapters receive instructions and tasks as text, while context is
enclosed in an escaped <spectre-context trust="data"> boundary.
This preserves Spectre's enforceable guarantee: dynamic context cannot be promoted to instructions, scoped task replacement cannot bypass a policy request, and typed trust survives up to a capable adapter. The legacy marker makes the same distinction explicit but remains text interpreted by a model; Spectre does not claim that any model is immune to semantic jailbreaks.
Summary
Functions
Composes a base task and resolved operations across an outer-to-inner scope path.
Returns the compatibility string supplied to a legacy model adapter.
Returns privacy-safe metadata for a resolved plan.
Returns the typed sections supplied to a structured model adapter.
Types
@type resolution() :: %{ :operation => Spectre.Prompt.Operation.t(), :status => :applied | :skipped | :failed, optional(:content) => String.t(), optional(:reason) => term(), optional(:metadata) => map() }
@type t() :: %Spectre.Prompt.Plan{ context: [Spectre.Prompt.Fragment.t()], examples: [Spectre.Prompt.Fragment.t()], instructions: [Spectre.Prompt.Fragment.t()], metadata: map(), operations: [map()], protected: [Spectre.Prompt.Fragment.t()], rendered: String.t(), task: [Spectre.Prompt.Fragment.t()] }
Functions
@spec compose(String.t(), [resolution()], [term()]) :: {:ok, t()} | {:error, term()}
Composes a base task and resolved operations across an outer-to-inner scope path.
Returns the compatibility string supplied to a legacy model adapter.
Returns privacy-safe metadata for a resolved plan.
@spec sections(t()) :: %{ instructions: [Spectre.Prompt.Fragment.t()], context: [Spectre.Prompt.Fragment.t()], task: [Spectre.Prompt.Fragment.t()] }
Returns the typed sections supplied to a structured model adapter.
Fragment content remains inside this explicit adapter payload and is never copied into plan metadata.