guardrail

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package guardrail provides output validation guardrails for AI agent responses.

Guardrails enforce contracts on agent output — reject, retry, or constrain responses based on structural, lexical, or semantic rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BannedWordsGuardrail

type BannedWordsGuardrail struct {
	// contains filtered or unexported fields
}

BannedWordsGuardrail validates that output does not contain any banned words.

@sk-task guardrails#T2.1: BannedWordsGuardrail — output must not contain banned words (AC-005)

func NewBannedWordsGuardrail

func NewBannedWordsGuardrail(words ...string) *BannedWordsGuardrail

NewBannedWordsGuardrail creates a BannedWordsGuardrail with the given banned words.

func (*BannedWordsGuardrail) Validate

func (g *BannedWordsGuardrail) Validate(output string) error

type ContainsGuardrail

type ContainsGuardrail struct {
	// contains filtered or unexported fields
}

ContainsGuardrail validates that output contains all required substrings.

@sk-task guardrails#T1.1: ContainsGuardrail — output must contain all substrings (AC-004)

func NewContainsGuardrail

func NewContainsGuardrail(substrings ...string) *ContainsGuardrail

NewContainsGuardrail creates a ContainsGuardrail requiring the given substrings.

func (*ContainsGuardrail) Validate

func (g *ContainsGuardrail) Validate(output string) error

type Guardrail

type Guardrail interface {
	Validate(output string) error
}

Guardrail validates an output string and returns an error if validation fails.

@sk-task guardrails#T1.1: Guardrail interface for output validation (AC-001)

type JSONSchemaGuardrail

type JSONSchemaGuardrail struct {
	// contains filtered or unexported fields
}

JSONSchemaGuardrail validates that output is valid JSON matching a JSON Schema (draft-07).

@sk-task guardrails#T2.2: JSONSchemaGuardrail — output must be valid JSON matching schema (AC-006)

func NewJSONSchemaGuardrail

func NewJSONSchemaGuardrail(schemaStr string) (*JSONSchemaGuardrail, error)

NewJSONSchemaGuardrail creates a JSONSchemaGuardrail with the given JSON Schema string. Returns error if the schema is invalid.

func (*JSONSchemaGuardrail) Validate

func (g *JSONSchemaGuardrail) Validate(output string) error

type LengthGuardrail

type LengthGuardrail struct {
	// contains filtered or unexported fields
}

LengthGuardrail validates that output length is within the specified bounds.

@sk-task guardrails#T1.1: LengthGuardrail — output length in bounds (AC-003)

func NewLengthGuardrail

func NewLengthGuardrail(min, max int) *LengthGuardrail

NewLengthGuardrail creates a LengthGuardrail with the given min/max bounds.

func (*LengthGuardrail) Validate

func (g *LengthGuardrail) Validate(output string) error

type RegexGuardrail

type RegexGuardrail struct {
	// contains filtered or unexported fields
}

RegexGuardrail validates that output matches a given regular expression.

@sk-task guardrails#T1.1: RegexGuardrail — output must match regex (AC-002)

func NewRegexGuardrail

func NewRegexGuardrail(pattern string) (*RegexGuardrail, error)

NewRegexGuardrail creates a RegexGuardrail. Returns error if pattern is invalid.

func (*RegexGuardrail) Validate

func (g *RegexGuardrail) Validate(output string) error

Jump to

Keyboard shortcuts

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