Module decision
Expand description
Decision-model gating for SOP dispatch.
A “System One” decision model (TypeSafe Jev, or the Jev-compatible open-weights
Laya served locally) answers typed questions about a state instead of
generating text. An SOP opts in with a [decision] table in SOP.toml; for
each event that already matched one of its triggers, dispatch asks the model:
- gate (
noul): should this event start this SOP at all? - mode (
choice): which of the author-listed execution modes fits this run?
The model can only choose among what the author wrote down. It never adds a
trigger, never picks a mode outside modes, and never removes a step-level
requires_confirmation or checkpoint gate (those are resolved per step,
independently of the run’s mode). Every failure path falls back to the
strictest listed mode, so an outage or a low-confidence answer adds human
supervision rather than removing it.
Structs§
- Answers
- SopDecision
- Outcome of consulting the model for one (SOP, event) pair.
- SopDecision
Spec - The
[decision]table of anSOP.toml. - System
OneClient - HTTP client for any
/v1/systemoneendpoint. Pointbase_urlathttps://api.typesafe.aifor Jev or at a locallaya-servefor Laya. - Usage
Enums§
- Answer
- Gate
OnError - What the gate does when the model cannot answer (network, HTTP, malformed).
- Question
- One typed question. Only the two shapes dispatch needs are modeled.
Traits§
- Decision
Model - Seam for the decision call. The daemon injects
SystemOneClient; tests inject a scripted model.
Functions§
- decide
- Ask
modelabouteventforsopand resolve the answer against the SOP’s[decision]spec. Never errors: every model failure resolves to the spec’s fail-closed outcome with the failure inrationale. - decide_
without_ model - Resolve
specwhen its model alias is not configured: the same fail-closed outcome as an unreachable model. - models_
from_ config - Build a client for every
[decision_models.<alias>]entry with a known endpoint (provider defaults applied). An entry without one, or whose client cannot be built, is logged and left out, so SOPs selecting it dispatch fail-closed. - part_
steps - Step numbers of the SOP’s conditional parts (steps with
decide). - validate_
parts - Validate the step-level decision fields (
decide,unless_decided) against the SOP: a part needs a[decision]model to ask, andunless_decidedmust name a step that asks a question.