Documentation
¶
Overview ¶
Package judge is the decision adapter's one interface (itd-2609221009495079, spc-2609221011151661 scope 1): a typed judgement, (state, question) → (value, probability), with three question kinds — choose one of N, score on a scale, yes or no. The host's own judgement implements it (Host, at probability 1), and so does the decision model reached through the OpenAI-compatible API adapter (Adapter), so the two are compared like for like and a judgement type is switched between them by configuration alone (router.go), never by its caller.
It sits apart from internal/core/decide, the ADR verb's package: the name is shared, the concern is not.
Like the rest of the core it never prints. It writes only through the recorder its Router is given, which is the lab's pairs file in the machine-scoped store (internal/core/lab), never the repository.
Index ¶
Constants ¶
const ( RouteHost = "host" RouteAdapter = "adapter" )
The routes a receipt names.
const DefaultWindow = 32 << 10
DefaultWindow is the decision model's context, in tokens: the first candidate's 32K (itd-2609221009495079 scope condition 1).
Variables ¶
var ErrHostPending = errors.New("judge: the host's answer is awaited")
ErrHostPending is a host judgement asked out of band: the caller has written the host's request (the drain's request file) and the answer comes back in a later move. A Router passes it through, with its receipt.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
Calls Caller
Creds credential.Source
Target oracle.Target
Options []openaiapi.Option
}
Adapter is the decision model through the one interface: the question is rendered as the host's is, sent to Target through Calls, and the answer is read as a value and a probability. The model cannot abstain, so an answer outside the question's choices, or a probability outside 0 to 1, is no answer at all.
type Answer ¶
Answer is a judgement's answer: one of the question's choices, the probability the answering side gives it, and, from the adapter, the model the provider reported.
type Caller ¶
type Caller interface {
Call(ctx context.Context, creds credential.Source, req oracle.CallRequest, opts ...openaiapi.Option) ([]byte, oracle.CallRecord, error)
}
Caller is one call through the OpenAI-compatible API adapter; *oracle.APIConfig implements it. Its Call admits the target against the allowlist and oracle.denylist again and resolves the key by name, so a target built anywhere is held to adr-2609221009491186 before any call.
type Host ¶
Host is the host's own judgement through the one interface (adr-25): Ask is shown the rendered prompt, the same text the adapter is sent, and returns the host's answer, which is parsed against the question's choices at probability 1. A caller whose host has already answered uses Answered.
func Answered ¶
Answered is a Host whose answer is already in hand: the drain's host has written its answer file, or a page's host has handed its judgement back.
type LogprobAdapter ¶
type LogprobAdapter struct {
Calls Caller
Creds credential.Source
Target oracle.Target
Options []openaiapi.Option
}
LogprobAdapter is the second candidate through the one interface.
type Question ¶
type Question struct {
Type Type
Kind Kind
// Ask is the question in words.
Ask string
// Options are a choose question's options.
Options []string
// Min and Max are a score question's scale, inclusive.
Min, Max int
}
Question is one typed question.
type Receipt ¶
type Receipt struct {
Type Type `json:"type"`
Mode string `json:"mode"`
Route string `json:"route"`
Target string `json:"target,omitempty"`
ModelReported string `json:"model_reported,omitempty"`
Probability float64 `json:"probability"`
StateSHA256 string `json:"state_sha256"`
StateTokens int `json:"state_tokens"`
Fallback string `json:"fallback,omitempty"`
Pair string `json:"pair,omitempty"`
PairSkipped string `json:"pair_skipped,omitempty"`
Note string `json:"note,omitempty"`
}
Receipt is what a judgement's run record carries: the type and its mode, the route that decided, the adapter's target and the model it reported, the probability the deciding side gave, the state's hash and size, why a type turned on fell back to the host, and where a shadow pair went or why it was not kept.
type Router ¶
type Router struct {
// Window is the adapter's window in tokens; DefaultWindow when zero.
Window int
// Diagnostics are the configuration's non-fatal reports, for a front
// door to print: the oracle reader's, and a route naming a type outside
// the registry.
Diagnostics []string
// contains filtered or unexported fields
}
Router routes each judgement type to the host, to the host with the adapter in shadow, or to the adapter.
func Load ¶
Load reads oracle.judgements.<type> through the oracle reader, which refuses a model not on its provider's allowlist (or one oracle.denylist matches) before any call, and returns the Router the repository at repoRoot judges with: the adapter is the API adapter with the key resolved by name from the account's credential store (scored by log-probability where the provider's block marks the model so, candidate), and shadow pairs go to the newest lab minted for the repository. A route to a type outside the registry is a diagnostic.
func NewForTest ¶
func NewForTest(routes map[Type]oracle.Target, adapter func(oracle.Target) Judge, record Recorder) *Router
NewForTest is newRouter, the seam a caller's tests route a type with through a fake adapter and recorder.
func (*Router) Decide ¶
func (r *Router) Decide(ctx context.Context, s State, q Question, host Judge) (Answer, Receipt, error)
Decide answers q over s on the route t's configuration names, with host as the host's judgement. Its error is the host's (ErrHostPending among them) or the question's refusal; an adapter's failure is never an error: in shadow it is recorded in the pair, and turned on it is a fallback to host.
type State ¶
type State struct {
Text string
}
State is what a judgement is made over, after retrieval: the text both implementations are shown.
type Type ¶
type Type string
Type is a judgement type: one judgement-shaped step abcd may route through the adapter. The registry is closed: a type outside it is refused.
const ( RemedyRead Type = "remedy-read" DuplicateMatch Type = "duplicate-match" UnmeetableCriteria Type = "unmeetable-criteria" EligibilityResidual Type = "eligibility-residual" SourceClassification Type = "source-classification" SourceSelection Type = "source-selection" MemoryCheck Type = "memory-check" LedgerCategory Type = "ledger-category" LedgerSeverity Type = "ledger-severity" PrepassOverlap Type = "prepass-overlap" PresentTense Type = "present-tense-advisory" EmbarkLessonRanking Type = "embark-lesson-ranking" )
The judgement types the intent's scope lists. Two steps call the router today: the drain's eligibility-residual, and embark's lesson ranking, one score question per lesson that the host answers with a scores file (dcn-2610300523005947, iss-2610262033055327). Every other type is decided by the host until its step calls the router.