Skip to main content

Module decision

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.
SopDecisionSpec
The [decision] table of an SOP.toml.
SystemOneClient
HTTP client for any /v1/systemone endpoint. Point base_url at https://api.typesafe.ai for Jev or at a local laya-serve for Laya.
Usage

Enums§

Answer
GateOnError
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§

DecisionModel
Seam for the decision call. The daemon injects SystemOneClient; tests inject a scripted model.

Functions§

decide
Ask model about event for sop and 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 in rationale.
decide_without_model
Resolve spec when 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, and unless_decided must name a step that asks a question.