Skip to main content

Crate reliakit_decide

Crate reliakit_decide 

Source
Expand description

Deterministic, zero-dependency decision engine for agents and control logic.

reliakit-decide answers one question well: given the current signals, which action should I take? It scores each candidate action with utility-based reasoning and picks the best — deterministically, with no floating point and no third-party dependencies. Reasoner::decide allocates nothing; Reasoner::rank and Reasoner::explain allocate only the result they return. The same signals always produce the same decision, so the choice is reproducible and testable.

It is not a language model and does not understand text; it decides what to do, not what to say. In an agent it is the fast, explainable “judgment” layer next to a model that generates language.

§Model

  • A Score is a fixed-point value in 0.0..=1.0 (stored as 0..=10_000).
  • A Curve maps a raw signal to a score (e.g. “low health” → high score).
  • A Consideration is one signal run through a curve.
  • An Action multiplies its considerations together (product-veto: any near-zero consideration vetoes the action) to get a utility.
  • A Reasoner holds the candidate actions and selects the best.

§Example

use reliakit_decide::{Action, Curve, Reasoner, Score};

// A bot chooses between fleeing and fighting based on its health.
let health = Score::from_ratio(20, 100); // 20% health

let mut brain = Reasoner::new();
brain.add(Action::new("flee").consider(Curve::Inverse, health)); // strong when health is low
brain.add(Action::new("fight").consider(Curve::Linear, health)); // strong when health is high

let choice = brain.decide().unwrap();
assert_eq!(choice.id, "flee"); // low health -> flee wins

§no_std

The crate is no_std-compatible (default-features = false) and always requires alloc. The default std feature currently adds nothing beyond core + alloc.

Structs§

Action
A candidate decision: the value returned if chosen, plus the considerations that score it.
Consideration
A single weighted input: a raw signal run through a Curve.
Contribution
One line of an explanation: a consideration’s label and the score it produced for the chosen action.
Decision
The outcome of a decision: the chosen id and the utility it won with.
Explanation
Why an action was chosen: its id, final utility, and the per-consideration breakdown (in declaration order) that produced it.
Policy
A persistent table of learned weights, one per key, nudged by feedback.
Reasoner
Holds candidate Actions and selects among them by utility.
Score
A fixed-point score in the inclusive range 0.0..=1.0, stored as an integer in 0..=10_000 (steps of 0.0001).

Enums§

Curve
Maps a raw input signal (already a Score) to a contribution score.