Skip to content

DecGuardReliability testing for probabilistic AI decisions.

Define decision contracts, test behavioral invariants, detect regressions, and gate unreliable model versions before production.

$ pip install decguard
$ decguard test decguard.yaml --all

refund_request (choice)
PASS  min_accuracy   1.000 ≥ 0.9
PASS  max_ece        0.139 ≤ 0.15
PASS  min_coverage   0.727 ≥ 0.5
PASS  option_order   0 / 33 violating
PASS  whitespace     0 / 22 violating

PASS: all gates hold
Condensed output of the refund example

One contract, every check ​

A Decision Contract describes the decision and what "reliable" means for it. Every command reads the same file.

yaml
schema_version: "0.1"

decision:
  name: refund_request
  description: How should this customer refund request be handled?
  type: choice
  options: [refund, reject, review]

backend:                   # Jev through OpenRouter; or mock, http, a plugin
  provider: systemone
  model: typesafe/jev-1.13
  url: https://openrouter.ai/api/alpha/decisions
  bearer_token_env: OPENROUTER_API_KEY

dataset: cases.jsonl

evaluation:
  probability_tolerance: 0.02   # Jev rounds probabilities to two decimals

requirements:              # violated -> FAIL, exit 1
  min_accuracy: 0.9
  max_ece: 0.1

properties:                # decguard fuzz / decguard test --all
  option_order:
    max_tv_distance: 0.03
CommandQuestion it answers
decguard testDoes the model meet its accuracy, calibration and coverage gates on the golden dataset?
decguard fuzzDoes the answer stay stable when irrelevant details of the input change?
decguard diffIs the candidate version worse than the one it replaces?
decguard checkIs the deployed model still calibrated on real traffic, in every segment?
decguard runGiven this confidence, should the application accept, abstain, fall back or ask a human?

Exit codes are the interface: 0 pass, 1 a reliability gate failed, 2 the run could not be evaluated. Start with the quickstart, or read what DecGuard is first.

Released under the Apache-2.0 License.