Documentation
¶
Overview ¶
Package spec is the shared file contract and execution adapter for virtual models. CLI services and tests load the same Definition values.
Index ¶
Constants ¶
const FormatDecisions scenario.ResponseFormat = "decisions"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
func NewCatalog ¶
func NewCatalog() *Catalog
func (*Catalog) RegisterModels ¶
func (c *Catalog) RegisterModels(name string, f ModelFactory) error
RegisterModels adapts custom Go virtual models, choosers and transform chains. The stable name is serializable; the implementation remains Go code.
type DecisionSpec ¶
type Definition ¶
type Definition struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Kind Kind `json:"kind,omitempty"`
Protocols []scenario.ResponseFormat `json:"protocols,omitempty"`
Mock *vmodel.SharedMockSpec `json:"mock,omitempty"`
Responses map[scenario.ResponseFormat]scenario.Response `json:"responses,omitempty"`
Sequence *SequenceSpec `json:"sequence,omitempty"`
Decision *DecisionSpec `json:"decision,omitempty"`
Transform *TransformSpec `json:"transform,omitempty"`
Builtin string `json:"builtin,omitempty"`
Tags []string `json:"tags,omitempty"`
Expect *scenario.Expect `json:"expect,omitempty"`
Structural *scenario.Expect `json:"structural,omitempty"`
SkipTransitive bool `json:"skip_transitive,omitempty"`
}
Definition keeps identity, protocol selection and assertions identical across every behavior. Exactly one behavior block is selected by kind.
func AllDefinitions ¶
func AllDefinitions() []Definition
AllDefinitions is the migration/export inventory, including opt-in error and usage fixtures and the request-dependent built-in matrix scenarios. It is deliberately not installed into production defaults.
func Decode ¶
func Decode(data []byte) ([]Definition, error)
func DefaultDefinitions ¶
func DefaultDefinitions() []Definition
DefaultDefinitions converts all shipped user-facing models to the common definition. Plain responses are exported as data; transforms keep explicit behavior references so their request-dependent Go logic stays intact.
func FromMock ¶
func FromMock(s vmodel.SharedMockSpec) Definition
func FromSequence ¶
func FromSequence(s vmodel.SequenceConfig) Definition
func Load ¶
func Load(path string) ([]Definition, error)
Load accepts one canonical definition or a list. Identity and kind are explicit.
func (Definition) MarshalJSON ¶
func (d Definition) MarshalJSON() ([]byte, error)
MarshalJSON writes identity once with readable durations. Runtime-only mock identity is restored by Normalize.
func (Definition) MarshalYAML ¶
func (d Definition) MarshalYAML() (any, error)
func (*Definition) Normalize ¶
func (d *Definition) Normalize() error
Normalize validates Go-built and file-built definitions with the same rules.
type Factory ¶
type Factory func(Definition) (scenario.Scenario, error)
Catalog names Go behavior factories explicitly. Factories must create fresh instances so sequence cursors and dynamic callbacks never leak across runs.
type ModelFactory ¶
type ModelFactory func(Definition) (Models, error)
type Models ¶
type Models struct {
Anthropic anthropic.VirtualModel
OpenAI openai.VirtualModel
Decision decision.VirtualModel
}
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is the common service used by the CLI and by scenario adapters.
func New ¶
func New(defs []Definition) (*Runtime, error)
func NewWithCatalog ¶
func NewWithCatalog(defs []Definition, catalog *Catalog) (*Runtime, error)
func (*Runtime) Check ¶
func (r *Runtime) Check(id string, result *check.RoundTripResult) error
Check applies the file's expectations to a native endpoint result. JSON field and raw-body checks work for decisions and recordings as well as chat.
type SequenceSpec ¶
type SequenceSpec struct {
Steps []vmodel.SequenceStep `json:"steps"`
DefaultContent string `json:"default_content,omitempty"`
OnExhaust vmodel.ExhaustPolicy `json:"on_exhaust,omitempty"`
Delay time.Duration `json:"delay,omitempty"`
}
type TransformSpec ¶
type TransformSpec struct {
Builtin string `json:"builtin"`
}
Transform names are registered transforms, not executable expressions.