decision

package
v1.261006.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MPL-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package decision holds virtual models for the decisions endpoint (POST {base}/decisions, see .design/decision-protocol.md): typed questions about a piece of state in, calibrated answers out.

The wire shape follows Jev, the only published decisions API (OpenAI's is unpublished): a request carries "model", "state" and "questions" keyed by caller-chosen ids; each question has a "type" and "criteria":

choice  criteria: {"option": "description", ...}   -> choice + probabilities + confidence
score   criteria: ["lowest level", ..., "highest"]  -> score + legend + probabilities + confidence
noul    (instructions only)                         -> noul (probability the statement is true)

The response is {"model", "answers": {id: {"type", ...}}, "usage"}.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func First

func First(_ []byte, _ string, _ int) int

First always picks index 0: the first choice option, the lowest score level, and "true" for noul. Predictable for routing demos and dry-runs.

func RegisterDefaults

func RegisterDefaults(r *Registry)

RegisterDefaults registers the user-facing decision demo models:

decision-first   always the first option (confidence 1)
decision-stable  input-hashed choice, reproducible (confidence 0.8)

func Stable

func Stable(input []byte, id string, n int) int

Stable hashes state+id: the same input always gets the same pick, different inputs spread across the options.

Types

type Chooser

type Chooser func(input []byte, id string, n int) int

Chooser picks an index in [0, n) for one question. input is the request's state and id the question id, so a chooser can be input-stable but independent of the model name.

type MockModel

type MockModel struct {
	vmodel.BaseMockModel
	// contains filtered or unexported fields
}

MockModel is a deterministic, in-memory decision model.

func NewMockModel

func NewMockModel(cfg *MockModelConfig) *MockModel

NewMockModel builds a MockModel from cfg.

func (*MockModel) HandleDecision

func (m *MockModel) HandleDecision(body []byte) ([]byte, error)

HandleDecision implements VirtualModel.

type MockModelConfig

type MockModelConfig struct {
	ID          string
	Name        string
	Description string
	Choose      Chooser
	// Confidence is the probability mass on the picked option/level (and the
	// noul probability when it picks "true"); the rest is split evenly. Zero
	// means 1 (certain).
	Confidence float64
}

MockModelConfig configures a MockModel.

type Registry

Registry holds decision virtual models.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty decision registry.

type RequestError

type RequestError struct{ Message string }

RequestError marks a client-side problem (HTTP 400) as opposed to a model failure.

func (*RequestError) Error

func (e *RequestError) Error() string

type VirtualModel

type VirtualModel interface {
	vmodel.VirtualModel
	// HandleDecision answers one decisions request body (already known to be
	// valid JSON) with a JSON response body. An unanswerable request returns
	// *RequestError.
	HandleDecision(body []byte) ([]byte, error)
}

VirtualModel is the decisions sub-interface: the base identity plus one request/response method over JSON.

Jump to

Keyboard shortcuts

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