Expand description
Classifier (SPEC.md §8B) — the contract for a JUDGMENT, as Tool
is the contract for an ACTION. A System One model takes a state plus
pre-declared, typed questions and returns calibrated answers with no free
text. It has no messages, no tool calling and no streaming, so it never
enters the client loop.
A classifier INTERPRETS; it never AUTHORISES. Schema validity is not
correctness: a decision can be confidently wrong. Numeric limits,
permission checks and allowlists stay in code. Nothing here is a security
control. Ported from golang/classifier.go.
Structs§
- Choice
Answer - One option from the offered set, with a probability for every offered option.
- Choice
Question - One option from a named set (1..255).
criteria[id]must say what picking it would MEAN — the encoding obligation is the caller’s (ADR 0021). - Classifier
- The whole seam: one verb. Cheap to clone.
- Classifier
Error - A classifier failure. The text is the shared cross-port message.
- Classifier
Options - Classifier options (§8B); mirrors §8
ClientOptionswherever it makes sense. - Classifier
Usage - The wire’s usage block.
cost: Nonemeans the backend did not say — NOT zero. - Decision
- One answer per question, keyed by the caller’s keys.
- Eval
Context - What a call carries besides state and questions: cancellation, and the
call name a
Taperecords under. - Noul
Answer - The probability that a statement holds. No confidence: the number is the answer.
- Noul
Criteria - Labels the true and false cases of a noul question.
Nonecriteria is ABSENT on the wire;Some(default)is{"false":"","true":""}. - Noul
Question - The probability that a statement holds (0..1).
- Recorded
Decision - One entry of the
staticcorpus, keyed on the canonical request AND the state. - Score
Answer - A rating against the ordered rubric; may fall between levels.
- Score
Question - A rating against an ORDERED rubric of 2..10 levels (never sorted).
Enums§
- Classifier
Backend - Whose endpoint answers: sets base URL + model + key env AS A UNIT.
- Classifier
Style - Selects the backend (§8B Backends).
- Decision
Answer - One typed answer, discriminated by the wire’s
type. - Question
- One pre-declared question. The set is closed.
Constants§
- DEFAULT_
CLASSIFIER_ API_ KEY_ ENV - The NAME of the env var holding the credential.
- DEFAULT_
CLASSIFIER_ BASE_ URL - The System One endpoint base.
- DEFAULT_
CLASSIFIER_ BATCH_ CONCURRENCY - How many states
evaluate_batchhas in flight at once. - DEFAULT_
CLASSIFIER_ MODEL - The floating alias. Pin it once thresholds are tuned.
- DEFAULT_
CLASSIFIER_ TIMEOUT_ MS - Bounds one request in ms (a classifier has no loop to bound).
- MAX_
CHOICE_ OPTIONS - Client-side cap on a choice’s named options.
- MAX_
SCORE_ LEVELS - METRIC_
CLASSIFIER_ EVALUATE - MetricEvent
eventvalues this module emits into the §8on_metricsink. - METRIC_
CLASSIFIER_ WARNING - MIN_
SCORE_ LEVELS - Bounds of a score rubric.
- NEAR_
UNIFORM_ TOLERANCE - ABSOLUTE tolerance on max|p - 1/n|, compared INCLUSIVELY.
- OPENROUTER_
CLASSIFIER_ API_ KEY_ ENV - OPENROUTER_
CLASSIFIER_ BASE_ URL - The OpenRouter pairing. The model id differs from TypeSafe’s own spelling.
- OPENROUTER_
CLASSIFIER_ MODEL
Functions§
- canonical_
json - Canonical JSON in Go
encoding/jsonform (SetEscapeHTML(false)): keys sorted bytewise, compact, Go string escaping and Go float formatting. - canonical_
request - The bytes the byte-identity claim covers:
model+questions, keys sorted recursively, arrays never reordered, compact,<>&'"and non-ASCII raw.stateis deliberately NOT here (numbers do not canonicalise). - choice_
over - Build a choice from any (name, description) pairs — tools, skills, agents.
- create_
classifier - Build a classifier, applying the §8B defaults and rejecting a style whose required option is missing before any call is made.
- degenerate_
criteria - The §8B degenerate predicate: every value empty, every value its own key, or every value identical (n >= 2). A single-option choice never is.
- near_
uniform max_i |p_i - 1/n| <= 0.05over the map AS RETURNED; n == 1 is uniform, an empty map is not a distribution (false).- with_
call_ name - Name the next evaluation for a tape (
"triage","plan").
Type Aliases§
- Evaluate
Fn - The host’s own evaluation (
style: Custom). - Questions
- Questions keyed by the CALLER’s keys (never transmitted as content).