Help us shape the future of Go! Take the 2026 Go Developer Survey

guard

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package guard implements deterministic and model-based message policy checks.

Index

Constants

View Source
const (
	DecisionAllow  = "allow"
	DecisionReview = "review"
	DecisionDeny   = "deny"
)

Variables

View Source
var ErrMissingAPIKey = errors.New("guard API key is not configured")

Functions

This section is empty.

Types

type Evaluation

type Evaluation struct {
	Verdict
	Model             string
	ProviderRequestID string
	ResponseID        string
}

Evaluation adds provider evidence to a model verdict.

type Evaluator

type Evaluator interface {
	Evaluate(context.Context, Input) (Evaluation, error)
}

Evaluator checks one message. Errors must fail the caller closed.

type Finding

type Finding struct {
	Code     string
	Decision string
}

Finding is one deterministic high-risk content match.

func Scan

func Scan(text string) []Finding

Scan blocks obvious secrets before any model call. It returns codes only, never matched content.

type HTTP

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

HTTP evaluates messages with strict Structured Outputs and no tools.

func NewHTTP

func NewHTTP(cfg HTTPConfig) (*HTTP, error)

func (*HTTP) Evaluate

func (g *HTTP) Evaluate(ctx context.Context, input Input) (Evaluation, error)

type HTTPConfig

type HTTPConfig struct {
	Endpoint             string
	Model                string
	APIKeyEnv            string
	PromptCacheRetention string
	Client               *http.Client
}

HTTPConfig configures the mandatory Responses API classifier.

type Input

type Input struct {
	Direction   string `json:"direction"`
	Source      string `json:"source"`
	Destination string `json:"destination"`
	Text        string `json:"text"`
	Policy      string `json:"policy"`
}

Input is one direction-specific message policy evaluation.

type Verdict

type Verdict struct {
	Decision    string   `json:"decision"`
	ReasonCode  string   `json:"reason_code"`
	DataClasses []string `json:"data_classes"`
	Explanation string   `json:"explanation"`
}

Verdict is a bounded policy classification. Explanation must not quote text.

Jump to

Keyboard shortcuts

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