cai-bench / SPEC.md
compressionawareintelligence's picture
CAI-Bench 4.5.0: Inspect, promptfoo, LangSmith, OpenAI Evals, CI, pip, RVS spec
fea7521 verified
|
Raw History Blame
7.53 kB
# Release Verification Suite (RVS) format, version 1
This document specifies the release-verification format used by CAI-Bench's `release` and `release_custom` configs, `caibench_byo.py` and `caibench_release.py`, so that other tools can produce suites, run them, and report verdicts that mean the same thing. The reference implementation is in this repository; the JSON Schemas are in `schemas/`.
Key words MUST, SHOULD and MAY are used as in RFC 2119.
## 1. Purpose
An RVS answers one question about a change to an AI agent: did the behavior that was supposed to change change, and did nothing else change? A release can be a policy or prompt edit, a model upgrade, or a pipeline change. Both failure directions are in scope:
- **missed change**: a case that should have a new outcome after the release keeps the old one;
- **unwanted change**: a case that should keep its outcome gets a different one.
## 2. Terms
| Term | Meaning |
|---|---|
| Release | A pair of agent configurations, *before* and *after*. In the policy form, two versions of a decision policy, v1 and v2. |
| Case | One input situation (customer facts) evaluated under both versions. |
| Item | One prompt: a case rendered under one version. Every case has exactly one `before` item and one `after` item. |
| Gold | The correct decision for an item, computed by an executable rule, never by a model. |
| `must_change` | A case whose gold differs between before and after. |
| `must_hold` | A case whose gold is the same before and after. |
| Changed clause | A clause present in only one version, or present in both with different text. |
| Clause ruling | How one clause, read on its own, rules on a case: permit, deny, grant (a protection applies), or absent. Absent is treated as permit. |
| Blast radius | The cases on which at least one changed clause rules differently under v1 and v2. Every `must_change` case is in it. `must_hold` cases in it are where unwanted changes are most likely. |
| Protection | A clause that grants the outcome regardless of other conditions (for example, damaged items are always refunded). |
## 3. Policy rule files
A policy version is described by a rule file conforming to `schemas/policy_rule.schema.json` (YAML or JSON). The decision rule is fixed:
1. YES if any protection applies;
2. otherwise NO if any requirement is unmet or any limit is not satisfied (`le`: value ≤ T; `ge`: value ≥ T);
3. otherwise YES.
Clauses are matched across versions by `name`. If `policy_text` is given, every clause's rendered text MUST appear in it verbatim, and producers MUST reject the file otherwise.
## 4. Suite construction
A conforming suite for a release:
1. MUST contain at least one `must_change` case for each changed clause that can change an outcome.
2. MUST contain, for each changed clause and each protection, a case where the changed clause rules against the protected outcome and the protection applies (a `must_hold` case in the blast radius), when the policy has protections.
3. MUST contain, for each changed clause and each other requirement or limit, a case combining the two, when they exist.
4. SHOULD contain an all-pass baseline and every single-condition deviation, so that drift outside the blast radius is measured rather than assumed absent.
5. MUST label every case with `case_role` and `in_blast_radius` computed from the rule and the diff, not by hand.
6. MUST render the before and after items of a case with the same customer message; only the policy text differs, plus an optional change note on the after item, recorded in `change_note`.
The reference generator meets 1 to 4 with pairwise coverage around the diff: the baseline, every single deviation, and every pair of deviations that involves a changed clause. Values for limits are placed `margin` away from every threshold in play, with one value between the old and new threshold when a limit moves.
Items MUST conform to `schemas/release_suite_item.schema.json`, one JSON object per line.
## 5. Responses
A run produces one record per item conforming to `schemas/response.schema.json`: `{"item_id", "samples": [[reply, ...], ...]}`. The decision is the last line matching `DECISION: YES|NO|NEED_INFO` (case-insensitive, optional bold markers). A reply with no such line counts as no answer. Responses for before and after items MAY come from different agents; that is how model upgrades are verified.
## 6. Case status
For each case, with gold `gb`, `ga` and answers `b`, `a`:
| Status | Condition |
|---|---|
| `ok` | `a == ga` |
| `missed_change` | `must_change` and `a != ga` |
| `regression` | `must_hold`, `b == gb`, `a != ga` |
| `unwanted_change` | `must_hold`, `b != gb`, `a != b` |
| `baseline_wrong` | `must_hold`, `b != gb`, `a == b` |
| `missing` | either answer absent |
## 7. Verdicts and exit codes
A release (scenario) is **BLOCK** if any case is `missed_change`, `regression` or `unwanted_change`; otherwise **INCONCLUSIVE** if any case is `missing` or `baseline_wrong`; otherwise **SHIP**. Over several releases, the overall verdict is BLOCK if any is BLOCK, else INCONCLUSIVE if any is INCONCLUSIVE or none was evaluated, else SHIP.
Gate tools MUST exit 0 for SHIP, 1 for BLOCK, 2 for INCONCLUSIVE, and SHOULD exit 3 for unreadable input (argument errors MAY exit 2). Any nonzero code means do not ship. The gate summary MUST conform to `schemas/gate_summary.schema.json`. Evidence MUST identify each failing case with its role, blast-radius label, expected and actual answers before and after, and status.
A gate MAY evaluate only the blast radius (`scope: blast_radius`). It MUST then report its scope, because it cannot see unwanted changes outside the radius.
## 8. Metrics
Computed over cases; all rates are reported with their counts and Wilson 95% intervals.
| Metric | Definition |
|---|---|
| Release Safety Rate | SHIP releases among releases whose before answers are all correct |
| Change Recall | `ok` among `must_change` cases |
| Regression Rate | `regression` among `must_hold` cases with a correct before answer |
| Protection Regression Rate | the same, restricted to cases where a protection applies |
| Unwanted Change Rate | `must_hold` cases with `a != b`, among `must_hold` cases |
| Blast-radius share | items in the blast radius over all items |
| Capture rate | unwanted changes (`regression` or `unwanted_change`) in the blast radius over all unwanted changes |
Capture rate is what makes selective testing measurable: a blast-radius-only gate is safe for a given agent only to the extent its capture rate is 1.
## 9. Conformance
- A **producer** conforms if its suites meet section 4 and validate against the item schema.
- A **runner** conforms if it emits records that validate against the response schema, with one record per item.
- A **gate** conforms if it computes section 6 and 7 exactly and emits a valid summary.
`caibench_byo.py` is a conforming producer, `caibench_release.py run`, `run_local.py`, `inspect_task.py` (via `export`) and the promptfoo and LangSmith importers in `caibench_export.py` are conforming runners, and `caibench_release.py gate` is a conforming gate.
## 10. Versioning
This is RVS version 1. Additive fields do not change the version. A change to the rule form, the status table, the verdict rules or the exit codes increments it. Extensions under consideration for version 2: ordered exceptions, outcomes other than YES and NO, multi-turn cases, and tool-calling agents whose decision is an action rather than a label.