Skip to main content

Module decide

Module decide 

Source
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:

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§

DecideRequest
One decision call.
Decision
A validated answer set plus its provenance (proposal §2 rule 4).
NoulCriteria
What the two outcomes of a yes/no question mean. Wire keys are "true" and "false".

Enums§

Answer
One typed answer.
DecideError
Every decision-backend failure. Display leads with a stable DEC-Ennn code and DecideError::code returns 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§

DecisionBackend
The seam. Implementations validate the request (DEC-E006) and their answers (DEC-E003) and honour req.deadline.

Functions§

confidence_from
(n·p_max − 1)/(n − 1): 0 for a uniform distribution, 1 for a certain one. TypeSafe’s formula; n is the option or level count.
parse_emulated_answers
The lenient parse for an LLM asked to self-report (areev_llm’s LlmEmulated): 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, and confidence is always recomputed so the field means one thing across providers. A missing id or a type mismatch is still DEC-E003.
parse_wire_answers
Validate and normalize a provider’s answers object against the questions that were asked (DEC-E003 on 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 within 1e-2 of 1 are normalized exactly; anything further off is refused. A provider’s own score and confidence are kept when present and computed only when absent.
questions_from_wire
Parse the wire questions object ({id: question, …}) — the shape areev decide --questions and the bindings’ decide() take.
questions_to_wire
The wire questions object.