Expand description
Decision backends — the pure seam (docs/decision-model-proposal.md §3).
A decision (System One) model takes a state plus named, typed
questions and returns typed answers with probabilities, in one parallel
evaluation and with no text generation. Three question types exist:
Question::Noul— yes/no; the answer isp(yes).Question::Choice— one of 2..=255 named options.Question::Score— one of 2..=10 ordered levels, index 0 lowest.
This module holds only what every consumer shares — the questions, the
answers, the request and its Decision, the DecisionBackend trait,
the DEC error domain, and the wire (de)serialization with its answer
validation. It does no I/O. It lives in areev-core so the memory stack
(areev-store, areev-cal, areev-context) can accept a backend without
depending on an LLM or HTTP crate; the adapters (the TypeSafe-shape HTTP
client, Cloudflare, the command backend, LLM emulation) and the provider
chain live in areev_llm::decide, which re-exports everything here under
its original paths.
A decision model may score and order; only code omits, gates, approves or
applies — and code that omits on a probability must check
Decision::calibrated first (proposal §2, rules 1–2).
Every answer is validated on the way OUT of an adapter
(parse_wire_answers, Decision::from_wire): every requested id
present, the type matching the question, probabilities present and
summing to 1 within 1e-2 (then normalized exactly). confidence for
Choice/Score is (n·p_max − 1)/(n − 1) — computed here when a provider
omits it, and always for emulation, so the field means one thing across
providers.
Structs§
- Decide
Request - One decision call.
- Decision
- A validated answer set plus its provenance (proposal §2 rule 4).
- Noul
Criteria - What the two outcomes of a yes/no question mean. Wire keys are
"true"and"false".
Enums§
- Answer
- One typed answer.
- Decide
Error - Every decision-backend failure.
Displayleads with a stableDEC-Ennncode andDecideError::codereturns it; codes are append-only (ERROR_CODES.md). - Question
- One typed question.
Constants§
- CHOICE_
OPTIONS - Option-count bounds for
Question::Choice. - DEFAULT_
DECIDE_ TIMEOUT - The per-call default deadline (
--decide-timeout-ms,AREEV_DECIDE_TIMEOUT_MS): 2000 ms. - SCORE_
LEVELS - Level-count bounds for
Question::Score.
Traits§
- Decision
Backend - The seam. Implementations validate the request (
DEC-E006) and their answers (DEC-E003) and honourreq.deadline.
Functions§
- confidence_
from (n·p_max − 1)/(n − 1): 0 for a uniform distribution, 1 for a certain one. TypeSafe’s formula;nis the option or level count.- parse_
emulated_ answers - The lenient parse for an LLM asked to self-report (
areev_llm’sLlmEmulated): a bare number is accepted as a noul probability, any positive sum renormalizes, level names are accepted as score keys, a named choice with no distribution becomes one-hot, andconfidenceis always recomputed so the field means one thing across providers. A missing id or a type mismatch is stillDEC-E003. - parse_
wire_ answers - Validate and normalize a provider’s
answersobject against the questions that were asked (DEC-E003on any fault). Every requested id must be present with a matching type; answers to ids nobody asked are dropped, as are unknown fields. Probabilities summing within1e-2of 1 are normalized exactly; anything further off is refused. A provider’s ownscoreandconfidenceare kept when present and computed only when absent. - questions_
from_ wire - Parse the wire
questionsobject ({id: question, …}) — the shapeareev decide --questionsand the bindings’decide()take. - questions_
to_ wire - The wire
questionsobject.