specvalidation

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package specvalidation owns the shared structural grant/session contract. It has no dependency on the CRDs or access manager, so both admission and platform request boundaries can use it without an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModeError

func ModeError(mode *string, boundary Boundary) error

func TeamIDField

func TeamIDField(path *field.Path, value string) *field.Error

TeamIDField validates a stable identifier without normalizing persisted data. Request boundaries trim their input before calling the same predicate.

func ValidDecision

func ValidDecision(value string) bool

func ValidSideEffect

func ValidSideEffect(value string) bool

func ValidTrust

func ValidTrust(value string) bool

Types

type Boundary

type Boundary uint8

Boundary preserves the existing contracts: admission permits legacy wildcard grants and empty side-effect lists; platform apply requires explicit intent.

const (
	Admission Boundary = iota
	Apply
)

type Grant

type Grant struct {
	ServerName         string
	Subject            Subject
	Mode               *string
	MaxTrust           string
	ExpiresAt          *time.Time
	AllowedSideEffects []string
	ToolRules          []ToolRule
	PrimitiveRules     []PrimitiveRule
}

type PrimitiveRule

type PrimitiveRule struct{ Kind, Pattern, Decision string }

type Result

type Result []violation

Result retains Kubernetes field causes and the existing platform error text.

func ValidateGrant

func ValidateGrant(spec Grant, boundary Boundary, now time.Time) Result

ValidateGrant does not default or mutate the input. Normalization belongs to the platform request boundary; admission validates the submitted spec as-is.

func ValidatePrimitiveRules

func ValidatePrimitiveRules(rules []PrimitiveRule) Result

ValidatePrimitiveRules checks resource, prompt and skill rules. It is shared by admission, platform apply and `server validate`, so every entry point agrees on what a valid rule is.

func ValidateSession

func ValidateSession(spec Session, boundary Boundary) Result

func (Result) FieldErrors

func (r Result) FieldErrors() field.ErrorList

func (Result) FirstError

func (r Result) FirstError() error

func (Result) Messages

func (r Result) Messages() []string

Messages returns the human-readable text of each violation.

type SecretKeyRef

type SecretKeyRef struct{ Name, Key string }

type Session

type Session struct {
	ServerName             string
	Subject                Subject
	ConsentedTrust         string
	UpstreamTokenSecretRef *SecretKeyRef
}

type Subject

type Subject struct{ HumanID, AgentID, TeamID string }

type ToolRule

type ToolRule struct{ Name, Decision, RequiredTrust string }

Jump to

Keyboard shortcuts

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