spawnselection

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package spawnselection validates direct and roster spawn selectors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(input Input, rosterConfigured bool) error

Validate checks a direct or roster spawn selector. An empty roster file is permitted when rosterConfigured is true, because the entry can be resolved from that configured context.

func ValidateJSON

func ValidateJSON(data []byte, rosterConfigured bool) error

ValidateJSON strictly decodes a selector before applying Validate. It is useful at wire boundaries where misspelled and deferred fields must not be silently ignored.

Types

type ChallengeResult

type ChallengeResult struct {
	FieldName    string
	Status       FieldStatus
	Explanations []string
}

ChallengeResult holds the result of a Challenge call.

type ConformanceCase

type ConformanceCase struct {
	Name             string          `json:"name"`
	Input            json.RawMessage `json:"input"`
	RosterConfigured bool            `json:"rosterConfigured"`
	Valid            bool            `json:"valid"`
	StrictOnly       bool            `json:"strictOnly"`
	ErrorContains    string          `json:"errorContains"`
}

ConformanceCase mirrors a single case in schemas/spawn_selection.conformance.json. The Input is kept as raw JSON so the strict ValidateJSON path sees the exact on-wire keys (including unknown/deferred/misspelled ones) that a raw boundary would. ErrorContains is a substring expected in the evaluator error message for invalid cases; it is empty for valid cases.

func LoadConformanceCases

func LoadConformanceCases(path string) ([]ConformanceCase, error)

LoadConformanceCases reads and parses the shared conformance fixture at path. Both internal/spawnselection tests and external package tests (e.g. internal/mcpserver) use this so fixture loading stays in one place.

type FieldStatus

type FieldStatus struct {
	Enabled   bool
	Required  bool
	Satisfied bool
	Fair      bool
	Reason    *string  // nil when enabled; first blocking reason otherwise
	Reasons   []string // all blocking reasons; empty slice when enabled
	Valid     *bool    // nil = no validator; non-nil = validation result
	Error     string   // non-empty only when Valid != nil && !*Valid
}

FieldStatus mirrors the conformance expectedAvailability shape exactly. Valid and Error are only populated when a named validator is attached to the field and the field is currently enabled and satisfied.

type Input

type Input struct {
	Agent       string `json:"agent"`
	Model       string `json:"model"`
	Backend     string `json:"backend"`
	RosterFile  string `json:"roster_file"`
	RosterEntry string `json:"roster_entry"`
}

Input contains the selector fields accepted by a direct spawn request.

type RuleMetaEntry

type RuleMetaEntry struct {
	Field    string
	RuleType string
	Expr     string
	Reason   string
}

RuleMetaEntry holds metadata about a rule for Challenge output.

type SpawnSelectionAvailability

type SpawnSelectionAvailability struct {
	Agent       FieldStatus
	Backend     FieldStatus
	Model       FieldStatus
	RosterEntry FieldStatus
	RosterFile  FieldStatus
}

SpawnSelectionAvailability holds the availability status for each field.

type SpawnSelectionConditions

type SpawnSelectionConditions struct {
	RosterConfigured bool `json:"rosterConfigured"`
}

SpawnSelectionConditions holds the conditions for SpawnSelection availability checks.

type SpawnSelectionFields

type SpawnSelectionFields struct {
	Agent       *string `json:"agent,omitempty"`
	Backend     *string `json:"backend,omitempty"`
	Model       *string `json:"model,omitempty"`
	RosterEntry *string `json:"rosterEntry,omitempty"`
	RosterFile  *string `json:"rosterFile,omitempty"`
}

SpawnSelectionFields holds the fields for SpawnSelection availability checks.

Jump to

Keyboard shortcuts

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