prerequestpolicy

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PolicyDenyOnPattern  = "deny_on_pattern"
	PolicyAllowOnPattern = "allow_on_pattern"
)
View Source
const ID = "pre-request-policy"

ID is the bundled feature plugin id for LLM-backed pre-request admission policy.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(cfg HandlerConfig) (prerequest.Handler, error)

NewHandler builds one policy handler. Tests may pass Prompt directly to avoid filesystem I/O.

func NewHandlers

func NewHandlers(cfg Config) ([]prerequest.Handler, error)

NewHandlers builds sorted pre-request handlers and loads configured prompt files.

Types

type Config

type Config struct {
	PromptDir string          `yaml:"prompt_dir"`
	Handlers  []HandlerConfig `yaml:"handlers"`
}

Config is the plugin-level configuration for chained pre-request policy handlers.

func DecodeConfig

func DecodeConfig(n yaml.Node) (Config, error)

DecodeConfig parses YAML and validates file-local prompt references.

type HandlerConfig

type HandlerConfig struct {
	ID                 string        `yaml:"id"`
	Priority           int           `yaml:"priority"`
	PromptFilename     string        `yaml:"prompt_filename"`
	Prompt             string        `yaml:"-"`
	ModelRoutingString string        `yaml:"model_routing_string"`
	AllowPattern       string        `yaml:"allow_pattern"`
	DenyPattern        string        `yaml:"deny_pattern"`
	Policy             string        `yaml:"policy"`
	DenyMessage        string        `yaml:"deny_message"`
	Timeout            time.Duration `yaml:"-"`
	TimeoutRaw         string        `yaml:"timeout"`
}

HandlerConfig configures one pre-request policy model call.

Jump to

Keyboard shortcuts

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