Documentation
¶
Overview ¶
Package decide asks typed questions about a run (2.0 W3, #175): yes/no, score and choice. Every Oracle answers the same questions; Guarded wraps a model-backed one so that any error, timeout or unanswered question falls back to the questions' own heuristics. Callers never see an error.
Index ¶
Constants ¶
const Timeout = 2500 * time.Millisecond
Timeout bounds a model-backed oracle's answer (spec §5 W3: 2.5 s, then the heuristic).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Answer ¶
type Answer struct {
P float64 // YesNo: P(yes)
Score float64 // Score: 0-based level, probability-weighted
Choice string // Choice: the most likely option
Probs map[string]float64 // Choice and Score: the distribution, when known
Confidence float64 // Choice and Score: 0..1, when known
Source string // "heuristic", "llm" or "jev"
}
Answer is one typed answer.
type CallView ¶
type CallView struct {
Tool string `json:"tool"`
Args string `json:"args,omitempty"`
Result string `json:"result,omitempty"`
IsError bool `json:"is_error,omitempty"`
}
CallView is one tool call and, once it ran, its result.
type CompleteFunc ¶
CompleteFunc is one small-model call (compact.SummarizeFunc's shape).
type Heuristic ¶
type Heuristic struct{}
Heuristic is the default Oracle: each question's Heuristic, no model.
type Jev ¶
Jev is the TypeSafe System One oracle. The state goes to a third party: the client redacts it before it is sent.
type LLM ¶
type LLM struct {
Complete CompleteFunc
Workspace string
}
LLM asks the small model and reads a JSON object back. No backend at 2.0 sets a provider JSON mode, so the JSON is required by the prompt and parsed leniently: the first {...} in the reply. The small model may be a remote provider, so the state is redacted first, as for Jev: secrets, and file paths (workspace-relative inside Workspace, <path> elsewhere).
type Oracle ¶
type Oracle interface {
Ask(ctx context.Context, state string, qs []Question) (map[string]Answer, error)
}
Oracle answers questions about state, a JSON document (State.String) or plain text. The map holds the questions it could answer.
func Guarded ¶
Guarded asks primary under Timeout. On an error it answers from the questions' heuristics, and a question primary left unanswered gets its heuristic answer too. It never returns an error. use names the caller in the stats ("ballot", "gate", "route", "prune"); logf (nil: none) gets one line per failed call. A nil primary is the heuristic alone and is not counted in the stats.
func New ¶
func New(mode string, complete CompleteFunc, use, workspace string, logf func(string)) Oracle
New returns the oracle the config's `oracle` key names, Guarded for use: "llm" asks the small model through complete, "jev" asks TypeSafe (key from TYPESAFE_API_KEY or ~/.celeste/typesafe.key), anything else is the heuristic. A missing key or small model logs once and gives the heuristic. workspace is the run's: paths inside it are sent workspace-relative, every other path as <path> (jev.RedactPaths). logf may be nil.
type Question ¶
type Question struct {
ID string
Kind Kind
Text string // what to decide; may name fields of the state in `backticks`
// YesNo: optional criteria for yes and no.
True, False string
// Score: the ordered level descriptions, 2 to 10. Answer.Score is the
// 0-based level.
Levels []string
// Choice: option → description ("" for none).
Options map[string]string
// Heuristic answers without a model. Nil, or ok == false, is no opinion.
Heuristic func(State) (Answer, bool)
}
Question is one typed question.
type State ¶
type State struct {
Goal string `json:"goal,omitempty"`
Latest string `json:"latest_user_message,omitempty"`
Turns []TurnView `json:"recent_turns,omitempty"`
Call *CallView `json:"pending_call,omitempty"`
Text string `json:"text,omitempty"`
}
State is what the oracle sees: the goal, the latest user message, the recent turns, and free text for questions about one string (routing). Every string is redacted (jev.RedactAll: secrets and file paths) before it leaves the machine.
func ParseState ¶
ParseState reads a State back. Text that is not a JSON object becomes State.Text.