# decision-cert
The open specification for **decision certificates** (`decision-certificate.v1.1`, and v1 before it), a Rust crate that
verifies and applies them, and the conformance fixtures every implementation must agree on.
## Try it in one line
Verify a signed example certificate with the published Python package
([`demo/`](demo/README.md) says what the example is):
<!-- quickstart -->
```bash
uvx decision-cert verify <(curl -sL https://raw.githubusercontent.com/zer07labs/decision-cert/main/demo/example/certificate.json) --keys <(curl -sL https://raw.githubusercontent.com/zer07labs/decision-cert/main/demo/example/trusted-keys.json)
```
It prints the certificate id (`sha256:d0547d97…`) and exits 0. CI runs this line.
## What a decision certificate is
A model answers a decision (approve or decline, route A or B) and gives each answer a confidence.
A decision certificate records how that model's answers were **measured** on labelled cases:
- which labelled cases were used (by hash, never the cases themselves);
- the confidence threshold below which the model abstains;
- the share of cases it answers at that threshold;
- an upper bound on the error rate of the answered cases, at a stated confidence level;
- since v1.2, how the calibration cases' confidences were spread, so a consumer can notice without
labels when the cases it sees have moved away from them.
Whoever ran the measurement signs the certificate (Ed25519 over the RFC 8785 canonical JSON bytes),
and its id is `sha256:` of those bytes. Anyone holding the signer's public key can check that the
record is intact and who produced it.
**Certificates describe a measured process, never guarantee an outcome.** The bound holds only
while future cases are exchangeable with the calibration cases. It says nothing about any single
decision, about label quality or fairness, or about populations that were never sampled. That is
why certificates expire. [`docs/certificates.md`](docs/certificates.md) lists what a certificate
claims and what it does not.
## Verify one
```rust
use decision_cert::verify;
let cert: serde_json::Value = serde_json::from_str(&std::fs::read_to_string("cert.json")?)?;
let keys = serde_json::from_str(&std::fs::read_to_string("trusted-keys.json")?)?; // key id -> base64url public key
let v = verify(&cert, &keys)?; // schema, trusted key, signature
let threshold = v.threshold_for(Some("north")); // segment threshold, else the top-level one
let expired = v.is_expired(decision_cert::UtcDateTime::now()); // re-measure after expires_at
// v1.2: compare recent cases' confidences with the stored histogram
// (None for a case unscored or above rule.cannot_tell_above)
use decision_cert::{shift_score, Histogram};
if let (Some(bins), Some(stored)) = (v.confidence_bins(), v.histogram_for(Some("north"))) {
let window = Histogram::of(bins, recent_confidences).expect("confidences in [0, 1]");
let p = shift_score(stored, &window).expect("same bins").p_value; // small: measure again
}
// v1.2: apply the certificate's calibration map (temperature or dr) to a case's raw scores
let answered = v.confidence(&raw_scores).is_some_and(|c| c >= threshold);
```
`verify` rejects a certificate that does not match the schema (unknown fields included), is signed
by a key not in `keys`, or whose signature does not verify. It returns the certificate id, the typed
certificate and its expiry.
## Layout
| Path | What |
|---|---|
| [`spec/`](spec/) | [`decision-certificate.v1.7.md`](spec/decision-certificate.v1.7.md) (**frozen** 2026-12-04: challenger attempts beside a champion, release trains, the delta budget across attempts, promotion), [`decision-certificate.v1.6.md`](spec/decision-certificate.v1.6.md) (**frozen** 2026-11-30: a sequential measurement per flow and environment), [`decision-cert-inclusion.v1.md`](spec/decision-cert-inclusion.v1.md), the transparency-log sidecar (**frozen** 2026-11-17), [`decision-certificate.v1.5.md`](spec/decision-certificate.v1.5.md) (**frozen** 2026-11-17), [`decision-certificate.v1.4.md`](spec/decision-certificate.v1.4.md) and [`decision-certificate.v1.3.md`](spec/decision-certificate.v1.3.md) (**frozen** 2026-11-12), [`decision-certificate.v1.2.md`](spec/decision-certificate.v1.2.md) (**frozen** 2026-11-08), [`decision-certificate.v1.1.md`](spec/decision-certificate.v1.1.md) (**frozen** 2026-11-08), [`decision-certificate.v1.md`](spec/decision-certificate.v1.md) (**frozen** 2026-10-25), and a JSON Schema for each |
| [`rust/`](rust/) | the `decision-cert` crate: `verify`, `canonical`, `certificate_id`, `key_id`, segment thresholds, expiry, the v1.2 calibration maps (`probabilities`, `confidence`) and shift score, and `inclusion`, the verifier for the transparency-log inclusion proofs ([`spec/decision-cert-inclusion.v1.md`](spec/decision-cert-inclusion.v1.md): `verify_bundle`, `verify_consistency`, `apply_policy`) |
| [`wasm/`](wasm/) | the npm package `decision-cert`: the crate compiled to WebAssembly for Node.js (`verifyDocument`, `verifySequentialDocument`, `verifyAttemptDocument`, `verifyPromotionDocument`, `certificateId`, `verifyBundle` and the rest of the inclusion checks), with [`wasm/conformance.cjs`](wasm/conformance.cjs), which runs every fixture set through it |
| [`python/`](python/) | a pure-Python verifier (`decision_cert`), a port of the crate that passes the same fixtures, the inclusion verifier included |
| [`fixtures/`](fixtures/) | conformance fixtures: signed certificates with their canonical bytes, ids and expected verdicts, plus `mutations/schema_invalid.json`, schema-invalid certificates a verifier must reject; v1 at the top level, v1.1 in `fixtures/v1.1/`, v1.2 in `fixtures/v1.2/`, v1.3 in `fixtures/v1.3/`, v1.4 in `fixtures/v1.4/`, v1.5 in `fixtures/v1.5/`; v1.6 in `fixtures/v1.6/`, with its counting vectors in `fixtures/v1.6-counting/`; v1.7 in `fixtures/v1.7/`, with its promotion vectors in `fixtures/v1.7-promotion/` |
| [`interop/c2sp/`](interop/c2sp/) | an independent check of the inclusion fixtures' checkpoints with the Go C2SP libraries (CI job `c2sp-interop`) |
| [`docs/certificates.md`](docs/certificates.md) | how a certificate is issued, verified and applied |
| [`docs/credit-approval.md`](docs/credit-approval.md) | a profile: one certificate per credit-approval deployment, with the label-free drift alarm and an audit sample for selective labels |
| [`docs/method.md`](docs/method.md) | the method explained: how the threshold is chosen, what the claim is, what the numbers describe, and the limits |
| [`docs/model-risk.md`](docs/model-risk.md) | what a certificate gives a model validation (SR 11-7 headings), and what it does not |
| [`docs/evidence-pack.md`](docs/evidence-pack.md) | the evidence pack format (`decision-evidence-pack.v1`): one tenant's certificates, trusted keys and measured cases with a hashed manifest, and `verify-pack`, which checks one |
| [`plans/`](plans/) | the public roadmap |
v1 to v1.5 are frozen, and verifiers accept all six. v1 and v1.1 have the same fields; v1.1
changes one step of the issuing procedure (each test starts the threshold grid on its own cases) and
clarifies the text. v1.2 keeps v1.1's procedure and adds fields under its own `spec` value: the
confidence histogram for monitoring without labels. It also defines a second calibration map kind,
`dr`, refitted on a few labels from a shifted population. v1.3
adds to v1.2 the options a consumer decides automatically, with each test's answered share and
error among them (descriptive: the bound still covers every answered case), and binds each case's
`cannot_tell` value in `data_hash`. v1.4 adds to v1.3 a cost
risk, `selective_cost`: from a consumer's cost matrix, it bounds the expected cost of the answered
cases instead of their error rate (equal costs stay v1's error test). v1.5 adds to v1.4 the `tenant`
a certificate is issued for, bound into its signature, and a `signer` that says whether the tenant
signed it or a hosting service signed it for the tenant; a v1.5 certificate is verified for an
expected tenant (`verify_for_tenant`). Issuers write v1.2 unless asked for v1.3, v1.4 or v1.5. A frozen spec's fields never change meaning, and
verifiers reject unknown fields. Corrections to frozen text go in [`spec/ERRATA.md`](spec/ERRATA.md), never in the text.
From the command line, in Rust or Python (exit 0 verified and unexpired, 1 rejected or expired,
2 usage or file error):
```bash
cargo install decision-cert --features cli
decision-cert verify cert.json --keys trusted-keys.json [--now 2026-11-07T00:00:00Z]
pip install decision-cert
python -m decision_cert verify cert.json --keys trusted-keys.json
```
Both CLIs also check the inclusion documents ([`decision-cert-inclusion.v1`](spec/decision-cert-inclusion.v1.md))
against a tenant's log trust configuration, printing the same JSON verdict line (exit 0 accepted, 1
refused with the spec's error name, 2 unreadable or a malformed configuration).
```bash
decision-cert verify-bundle bundle.json --trust log-trust.json
decision-cert verify-consistency consistency.json --trust log-trust.json
python -m decision_cert verify-bundle bundle.json --trust log-trust.json
```
The issuer's side (`certify --leaf-out`, `python -m decision_cert bundle` and `log backfill`), and the
reference log and witness (`log init`, `append`, `checkpoint`, `prove`, `consistency`, `witness cosign`),
are in
[`docs/certificates.md`](docs/certificates.md#recording-it-in-the-tenants-log).
Or in Python:
```python
from decision_cert import loads, verify
v = verify(loads(open("cert.json").read()), loads(open("trusted-keys.json").read()))
v.id, v.threshold_for("north"), v.is_expired(datetime.now(UTC))
```
## Install
```toml
# Cargo.toml
decision-cert = "0.1"
```
```bash
pip install decision-cert # Python 3.12+, depends on rfc8785 and cryptography only
npm install decision-cert # Node.js: the Rust crate compiled to WebAssembly
```
Releases are tagged `vX.Y.Z` on `main` and published from CI
([`.github/workflows/release.yml`](.github/workflows/release.yml)). A git pin still works for
unreleased commits:
```toml
decision-cert = { git = "https://github.com/zer07labs/decision-cert", rev = "<sha>" }
```
Working on this repository:
```bash
cd rust && cargo test --all-features # unit tests + the conformance suite over ../fixtures
cd python && uv sync && uv run pytest # the Python verifier, incl. agreement with the crate
```
## In Node.js, or offline
The npm package `decision-cert` is the Rust crate compiled to WebAssembly
([`wasm/`](wasm/), [`wasm/npm/README.md`](wasm/npm/README.md)), so a service in Node.js and an auditor
on a machine with no network run the same check, with the same verdicts:
```js
const { verifyDocument } = require("decision-cert");
const r = verifyDocument(certText, "acme-bank", trustedKeysText, "2026-11-19T00:00:00Z");
r.verification; // { verdict: "accepted", certificate_id, ... } or { verdict: "refused", error: "WrongTenant", message }
r.expiry; // { now, expires_at, expired } when accepted, else null
r.certificate_id;
```
It reads no clock and calls no network service: the caller passes the time to check expiry at, so
the same certificate, keys and time give the same three results anywhere. The verification, the
expiry and the id are separate results, never one yes or no. A refusal carries the crate's
`CertError` variant name (`Invalid`, `UntrustedKey`, `BadKey`, `BadSignature`, `WrongTenant`,
`KeyMode`); relay the name, since `WrongTenant`'s message names the certificate's tenant. The inclusion
checks (`verifyBundle`, `verifyConsistency`, `applyPolicy`) return the CLI's verdict lines.
An auditor can check the package before relying on it: CI runs every fixture set (v1 to v1.5 with
their mutations, and inclusion-v1) through the WebAssembly build and compares each verdict with the
crate's, and each release records the SHA-256 of `decision_cert_bg.wasm` in its workflow log, checked
again after installing the published version from npm. Offline, with the repository and an installed
copy:
```bash
sha256sum node_modules/decision-cert/decision_cert_bg.wasm
node wasm/conformance.cjs node_modules/decision-cert fixtures
```
In Rust the same call is `decision_cert::verify_document(&cert, tenant, &keys, now)`, which returns a
`DocumentVerdict` with the same three results.
## Writing another verifier
A verifier in any language must agree with the Rust crate on every file in `fixtures/`: the
canonical bytes, the certificate id and the verdict ([`fixtures/README.md`](fixtures/README.md)).
The Rust crate is the reference; where a
verifier disagrees with it, the verifier is wrong or the spec needs an erratum.
[`docs/conformance.md`](docs/conformance.md) is the procedure; [`spec/ERRATA.md`](spec/ERRATA.md)
holds dated clarifications of the frozen text.
## The issuer
The reference issuer (the tool that runs the measurement and signs the certificate) is
`decision_cert.issue`, an optional extra of the Python package, so the verifier keeps its two
dependencies:
```bash
pip install 'decision-cert[issue]' # adds numpy, scipy, jsonschema, PyYAML
python -m decision_cert.issue keygen --out operator.pem
python -m decision_cert.issue certify --predictions preds.jsonl --data labelled.jsonl \
--domain-dir my-domain --backend my-model --key operator.pem --audit full-label
```
[`docs/certificates.md`](docs/certificates.md) describes the inputs, the output and the refusals.
The issuer also generates the reference fixtures
([`python/tools/gen_positive_fixtures.py`](python/tools/gen_positive_fixtures.py)).
## Contributing and security
See [`CONTRIBUTING.md`](CONTRIBUTING.md), [`SECURITY.md`](SECURITY.md) and
[`CHANGELOG.md`](CHANGELOG.md).
## Licence
Apache-2.0, see [`LICENSE`](LICENSE).