extension

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package extension adapts the Sentinel engine as a Forge extension.

Index

Constants

View Source
const ExtensionDescription = "Composable AI evaluation and testing framework with persona-aware scoring"

ExtensionDescription is the human-readable description.

View Source
const ExtensionName = "sentinel"

ExtensionName is the name registered with Forge.

View Source
const ExtensionVersion = "0.1.0"

ExtensionVersion is the semantic version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DisableRoutes prevents HTTP route registration.
	DisableRoutes bool `json:"disable_routes" mapstructure:"disable_routes" yaml:"disable_routes"`

	// DisableMigrate prevents auto-migration on start.
	DisableMigrate bool `json:"disable_migrate" mapstructure:"disable_migrate" yaml:"disable_migrate"`

	// BasePath is the URL prefix for all sentinel routes.
	BasePath string `json:"base_path" mapstructure:"base_path" yaml:"base_path"`

	// DefaultModel is the LLM model to use when not specified per-suite.
	DefaultModel string `json:"default_model" mapstructure:"default_model" yaml:"default_model"`

	// Temperature is the default sampling temperature.
	Temperature float64 `json:"temperature" mapstructure:"temperature" yaml:"temperature"`

	// PassThreshold is the minimum score to consider a test case passed.
	PassThreshold float64 `json:"pass_threshold" mapstructure:"pass_threshold" yaml:"pass_threshold"`

	// RegressionThreshold is how far below the current baseline a metric
	// may fall before a run counts as regressed. Default 0.05.
	RegressionThreshold float64 `json:"regression_threshold" mapstructure:"regression_threshold" yaml:"regression_threshold"`

	// Concurrency is the number of parallel evaluation workers.
	Concurrency int `json:"concurrency" mapstructure:"concurrency" yaml:"concurrency"`

	// ShutdownTimeout is the maximum time to wait for graceful shutdown.
	ShutdownTimeout time.Duration `json:"shutdown_timeout" mapstructure:"shutdown_timeout" yaml:"shutdown_timeout"`

	// GroveDatabase is the name of a grove.DB registered in the DI container.
	// When set, the extension resolves this named database and auto-constructs
	// the appropriate store based on the driver type (pg/sqlite/mongo).
	// When empty and WithGroveDatabase was called, the default (unnamed) DB is used.
	GroveDatabase string `json:"grove_database" mapstructure:"grove_database" yaml:"grove_database"`

	// DashboardAppID is the app the dashboard reads and writes when the
	// signed-in principal carries no app_id claim. Nothing populates that
	// claim today, so a deployment that wants the dashboard sets this. There
	// is no default: with neither, every dashboard request is refused,
	// because an empty app id matches every app in every store.
	DashboardAppID string `json:"dashboard_app_id" mapstructure:"dashboard_app_id" yaml:"dashboard_app_id"`

	// RequireConfig requires config to be present in YAML files.
	// If true and no config is found, Register returns an error.
	RequireConfig bool `json:"-" yaml:"-"`
}

Config holds the Sentinel extension configuration. Fields can be set programmatically via ExtOption functions or loaded from YAML configuration files (under "extensions.sentinel" or "sentinel" keys).

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the Sentinel extension.

type ExtOption

type ExtOption func(*Extension)

ExtOption configures the Sentinel Forge extension.

func WithBasePath

func WithBasePath(path string) ExtOption

WithBasePath sets the URL prefix for all sentinel routes.

func WithConfig

func WithConfig(cfg Config) ExtOption

WithConfig sets the extension configuration.

func WithDisableMigrate

func WithDisableMigrate() ExtOption

WithDisableMigrate disables auto-migration on start.

func WithDisableRoutes

func WithDisableRoutes() ExtOption

WithDisableRoutes disables HTTP route registration.

func WithEngineOption

func WithEngineOption(opt engine.Option) ExtOption

WithEngineOption passes an engine option directly.

func WithExtension

func WithExtension(x plugin.Extension) ExtOption

WithExtension registers a Sentinel extension (lifecycle hooks).

func WithGroveDatabase

func WithGroveDatabase(name string) ExtOption

WithGroveDatabase sets the name of the grove.DB to resolve from the DI container. The extension will auto-construct the appropriate store backend (postgres/sqlite/mongo) based on the grove driver type. Pass an empty string to use the default (unnamed) grove.DB.

func WithRequireConfig

func WithRequireConfig(require bool) ExtOption

WithRequireConfig requires config to be present in YAML files. If true and no config is found, Register returns an error.

func WithScorer

func WithScorer(d scorer.Descriptor, f scorer.Factory) ExtOption

WithScorer registers a scorer the dashboard can offer for a run. Use it for the LLM scorers, which need the application's LLMClient.

func WithStore

func WithStore(s store.Store) ExtOption

WithStore sets the evaluation store.

func WithTarget

func WithTarget(name, description string, t target.Target) ExtOption

WithTarget registers a named target, so the dashboard can start a run against it. Without one, runs can only be started from Go.

type Extension

type Extension struct {
	*forge.BaseExtension
	// contains filtered or unexported fields
}

Extension adapts Sentinel as a Forge extension.

func New

func New(opts ...ExtOption) *Extension

New creates a Sentinel Forge extension with the given options.

func (*Extension) API

func (e *Extension) API() *api.API

API returns the API handler.

func (*Extension) Engine

func (e *Extension) Engine() *engine.Engine

Engine returns the underlying Sentinel engine. This is nil until Register is called.

func (*Extension) Handler

func (e *Extension) Handler() http.Handler

Handler returns the HTTP handler for all API routes.

func (*Extension) Health

func (e *Extension) Health(ctx context.Context) error

Health implements forge.Extension.

func (*Extension) Register

func (e *Extension) Register(fapp forge.App) error

Register implements forge.Extension. It initializes the engine, builds the API, and optionally registers HTTP routes.

func (*Extension) RegisterContractContributor

func (e *Extension) RegisterContractContributor(
	disp *dispatcher.Dispatcher,
	reg dashcontract.Registry,
	wreg dashcontract.WardenRegistry,
) error

RegisterContractContributor implements dashboard.ContractContributorAware: it registers the sentinel contract contributor the React shell reads.

func (*Extension) RegisterRoutes

func (e *Extension) RegisterRoutes(router forge.Router)

RegisterRoutes registers all Sentinel API routes into a Forge router.

func (*Extension) Start

func (e *Extension) Start(ctx context.Context) error

Start begins the Sentinel engine and runs auto-migration if enabled.

func (*Extension) Stop

func (e *Extension) Stop(ctx context.Context) error

Stop gracefully shuts down the Sentinel engine.

Directories

Path Synopsis
Package contract wires Sentinel into the Forge dashboard's contract path.
Package contract wires Sentinel into the Forge dashboard's contract path.

Jump to

Keyboard shortcuts

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