Documentation
¶
Overview ¶
Package spawnselection validates direct and roster spawn selectors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
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 ¶
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.
func Challenge ¶
func Challenge(fieldName string, f SpawnSelectionFields, c SpawnSelectionConditions, prev SpawnSelectionFields) ChallengeResult
type ConformanceCase ¶ added in v0.26.0
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 ¶ added in v0.26.0
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 ¶
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.
func Check ¶
func Check(f SpawnSelectionFields, c SpawnSelectionConditions, prev SpawnSelectionFields) SpawnSelectionAvailability
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.