recipetest

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	Type      string      `` /* 191-byte string literal not displayed */
	Path      string      `json:"path,omitempty"`
	Value     interface{} `json:"value,omitempty"`
	Regex     string      `json:"regex,omitempty"`
	JsonPath  string      `json:"json_path,omitempty"`
	NodePath  string      `json:"node_path,omitempty"`
	Scope     string      `json:"scope,omitempty"`
	FromState string      `json:"from_state,omitempty"`
	ToState   string      `json:"to_state,omitempty"`
	Status    string      `json:"status,omitempty"`
	Expr      string      `json:"expr,omitempty"`
}

type AssertionResult

type AssertionResult struct {
	Type     string      `json:"type"`
	Passed   bool        `json:"passed"`
	Message  string      `json:"message,omitempty"`
	Expected interface{} `json:"expected,omitempty"`
	Actual   interface{} `json:"actual,omitempty"`
}

type Case

type Case struct {
	ID          string                 `json:"id" validate:"required"`
	Type        string                 `json:"type" validate:"required,oneof=op_case recipe_case integration_case"`
	Target      map[string]interface{} `json:"target,omitempty"`
	Inputs      map[string]interface{} `json:"inputs,omitempty"`
	Mocks       Mocks                  `json:"mocks,omitempty"`
	Assertions  []Assertion            `json:"assertions,omitempty"`
	Evaluations []Evaluation           `json:"evaluations,omitempty"`
	Options     map[string]interface{} `json:"options,omitempty"`
}

type CaseRunResult

type CaseRunResult struct {
	CaseId          string                    `json:"case_id"`
	Status          string                    `json:"status"`
	CaseHash        string                    `json:"case_hash"`
	DurationMs      int64                     `json:"duration_ms"`
	FailureCategory string                    `json:"failure_category,omitempty"`
	FailureReason   string                    `json:"failure_reason,omitempty"`
	Outputs         map[string]interface{}    `json:"outputs,omitempty"`
	Assertions      []AssertionResult         `json:"assertions,omitempty"`
	Evaluations     []EvaluationResult        `json:"evaluations,omitempty"`
	Diagnostics     Diagnostics               `json:"diagnostics,omitempty"`
	Artifacts       map[string]InlineArtifact `json:"artifacts,omitempty"`
}

func RunCase

func RunCase(ctx context.Context, opts HarnessOptions, tenantID string, target TargetRecipe, c Case, exec ExecutionOptions) CaseRunResult

type Diagnostics

type Diagnostics struct {
	MockHits    []MockHit                `json:"mock_hits,omitempty"`
	MockMisses  []MockMiss               `json:"mock_misses,omitempty"`
	Vars        []RenderedVarsDiagnostic `json:"vars,omitempty"`
	Transitions []TransitionDiagnostic   `json:"transitions,omitempty"`
}

type EvalSource

type EvalSource struct {
	Kind           string `json:"kind" validate:"required,oneof=artifact artifact_glob output_path trace"`
	Path           string `json:"path,omitempty"`
	Glob           string `json:"glob,omitempty"`
	OutputPath     string `json:"output_path,omitempty"`
	TraceName      string `json:"trace_name,omitempty"`
	AllowSensitive bool   `json:"allow_sensitive,omitempty"`
}

type Evaluation

type Evaluation struct {
	ID     string                 `json:"id" validate:"required"`
	Type   string                 `json:"type" validate:"required,oneof=text_pattern llm_judge"`
	Mode   string                 `json:"mode,omitempty" validate:"omitempty,oneof=enforce report_only"`
	Source EvalSource             `json:"source" validate:"required"`
	Config map[string]interface{} `json:"config,omitempty"`
}

type EvaluationResult

type EvaluationResult struct {
	Id            string                 `json:"id"`
	Type          string                 `json:"type"`
	Mode          string                 `json:"mode"`
	Passed        bool                   `json:"passed"`
	ErrorCategory string                 `json:"error_category,omitempty"`
	ErrorMessage  string                 `json:"error_message,omitempty"`
	Output        map[string]interface{} `json:"output,omitempty"`
}

type ExecutionOptions

type ExecutionOptions struct {
	Mode             string `json:"mode,omitempty" validate:"omitempty,oneof=isolated"`
	Timeout          string `json:"timeout,omitempty"`
	ArtifactMode     string `json:"artifact_mode,omitempty" validate:"omitempty,oneof=none inline"`
	ArtifactMaxBytes int64  `json:"artifact_max_bytes,omitempty" validate:"omitempty,gte=1"`
	EvaluationMode   string `json:"evaluation_mode,omitempty" validate:"omitempty,oneof=enforce report_only"`
}

type HarnessOptions

type HarnessOptions struct {
	Resolver   TargetResolver
	Deps       coreops.ServiceDependencies2
	CELOptions template.CELOptionsProvider
	WorkRoot   string
}

type InlineArtifact

type InlineArtifact struct {
	ContentBase64 string `json:"content_base64"`
	SizeBytes     int64  `json:"size_bytes"`
	Truncated     bool   `json:"truncated"`
}

type Issue

type Issue struct {
	Code    string `json:"code"`
	Field   string `json:"field,omitempty"`
	Message string `json:"message"`
}

type MockBehavior

type MockBehavior struct {
	Mode        string            `json:"mode" validate:"required,oneof=return fail passthrough record_passthrough replay"`
	Outputs     map[string]any    `json:"outputs,omitempty"`
	Artifacts   map[string]string `json:"artifacts,omitempty"`
	Error       *TestError        `json:"error,omitempty"`
	CassetteKey string            `json:"cassette_key,omitempty"`
}

type MockHit

type MockHit struct {
	NodePath string `json:"node_path"`
	Op       string `json:"op"`
	Mode     string `json:"mode"`
}

type MockMiss

type MockMiss struct {
	NodePath string `json:"node_path"`
	Op       string `json:"op"`
	Reason   string `json:"reason"`
}

type Mocks

type Mocks struct {
	Ops []OpMock `json:"ops,omitempty" validate:"omitempty,dive"`
}

type OpMock

type OpMock struct {
	Match    OpMockMatch  `json:"match" validate:"required"`
	Behavior MockBehavior `json:"behavior" validate:"required"`
}

type OpMockMatch

type OpMockMatch struct {
	NodePath string `json:"node_path,omitempty"`
	Op       string `json:"op,omitempty"`
}

type RenderedVarsDiagnostic added in v0.0.11

type RenderedVarsDiagnostic struct {
	NodePath string                 `json:"node_path"`
	Scope    string                 `json:"scope"`
	Vars     map[string]interface{} `json:"vars"`
}

type RuntimeConfig

type RuntimeConfig struct {
	Policy           TestPolicy
	ArtifactMode     string
	ArtifactMaxBytes int64
	EvaluationMode   string
}

type TargetRecipe

type TargetRecipe struct {
	Mode     string `json:"mode" validate:"required,oneof=inline_recipe recipe_selector"`
	Selector string `json:"selector,omitempty"`
	Format   string `json:"format,omitempty" validate:"omitempty,oneof=yaml json"`
	Content  string `json:"content,omitempty"`
}

type TargetResolver

type TargetResolver interface {
	ResolveRecipeTarget(ctx context.Context, tenantID string, target TargetRecipe) (*recipecore.Recipe, string, []Issue, []Issue)
}

type TestError

type TestError struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type TestPolicy

type TestPolicy struct {
	Mode                 string
	RequireMocks         bool
	BlockedOps           map[string]struct{}
	AllowedOnlyNodePath  string
	RequiredDependencies map[string]struct{}
}

type TransitionDiagnostic added in v0.0.11

type TransitionDiagnostic struct {
	FromState  string                 `json:"from_state,omitempty"`
	ToState    string                 `json:"to_state,omitempty"`
	Expression string                 `json:"expression,omitempty"`
	Result     bool                   `json:"result"`
	Selected   bool                   `json:"selected,omitempty"`
	Payload    map[string]interface{} `json:"payload,omitempty"`
}

type ValidationResult

type ValidationResult struct {
	Valid    bool    `json:"valid"`
	CaseHash string  `json:"case_hash"`
	Errors   []Issue `json:"errors,omitempty"`
	Warnings []Issue `json:"warnings,omitempty"`
}

func ValidateCase

func ValidateCase(ctx context.Context, opts HarnessOptions, tenantID string, target TargetRecipe, c Case) ValidationResult

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL