Skip to main content

Crate decision_cert

Crate decision_cert 

Source
Expand description

Load, verify and apply decision certificates: decision-certificate.v1 (spec/decision-certificate.v1.md), decision-certificate.v1.1 (spec/decision-certificate.v1.1.md) decision-certificate.v1.2 (spec/decision-certificate.v1.2.md), decision-certificate.v1.3 (spec/decision-certificate.v1.3.md), decision-certificate.v1.4 (spec/decision-certificate.v1.4.md) decision-certificate.v1.5 (spec/decision-certificate.v1.5.md) and decision-certificate.v1.6 (spec/decision-certificate.v1.6.md).

Verification canonicalises the JSON value exactly as received (RFC 8785, JCS), never a re-serialised struct, so number formatting can’t drift from the issuer’s. The typed Certificate is read from the same value afterwards, rejecting unknown fields.

A v1.2 certificate also stores the confidence histogram of its threshold split, so a consumer can monitor without labels: Histogram::of bins a window of use-time confidences and shift_score compares it with the stored one. The score is descriptive, a prompt to measure again; it never shows that the bound holds or has failed.

probabilities applies a certificate’s calibration map to a case’s raw scores, for the map kinds v1.2 defines (temperature and dr, MAP_KINDS).

A v1.3 certificate also names the options a consumer automates (automate_options) and reports, per test, the share and error of the answered cases whose answer is one of them (Automated).

A v1.5 certificate also names its tenant and who signed it (Signer: the tenant as operator, or a hosting service for the tenant), and its signature covers the tenant. It is verified with the tenant the consumer expects and that tenant’s moded keys: verify_for_tenant. verify keeps its meaning for v1 to v1.4 and refuses a v1.5 certificate.

A v1.6 certificate is a sequential, anytime-valid measurement over the records of a pre-registered attempt in one flow and environment (sequential). It is verified only on request, with the expected tenant, flow and environment: verify_sequential. verify_for_tenant refuses it, so a consumer that only upgrades the crate never accepts one.

inclusion checks decision-cert-inclusion.v1 (spec/decision-cert-inclusion.v1.md) offline: a bundle showing that a tenant’s transparency log recorded a leaf in a checkpoint its witnesses cosigned (inclusion::verify_bundle), a consistency proof between two checkpoints (inclusion::verify_consistency), and the consumer’s policy for a certificate without a bundle (inclusion::apply_policy).

Re-exports§

pub use challenger::AttemptRole;
pub use sequential::explore_bucket;
pub use sequential::salt_commitment;
pub use sequential::tail_trips;
pub use sequential::Sequential;

Modules§

challenger
decision-certificate.v1.7 (spec/decision-certificate.v1.7.md): the attempt’s role, the champion a challenger runs beside and what it changes (§1.1 to §1.4), the delta budget (§1.5), the checks beyond the schema (§2.5) and promotion (§4.2).
inclusion
decision-cert-inclusion.v1: a tenant’s transparency log, checked offline (spec/decision-cert-inclusion.v1.md).
sequential
decision-certificate.v1.6 (spec/decision-certificate.v1.6.md): the sequential block, the anytime-valid crossing of each class (§1.3), the exploration draw (§1.7) and the checks beyond the schema (§2.7).

Structs§

Audit
Automated
A test’s answered cases whose answer is one of automate_options (v1.3): their share of the test’s n cases, and ucb and realized_band of their error, as the test’s own (descriptive, spec v1.2 §1.2). Null exactly where the test’s are.
Band
CalibrationMap
Certificate
Every field is required; Option fields must be present (as null): a missing field is an error.
Cost
A v1.4 selective_cost certificate’s costs: matrix[label][answered option], in the options’ order, whole numbers in the consumer’s unit (informational), and its largest entry c_max.
DocumentVerdict
The separate results of verify_document. They are never folded into one yes or no: a consumer reads each.
Expiry
A verified certificate’s expiry at the caller’s now (Verified::is_expired).
Histogram
A test’s threshold-split cases per bin of confidence_bins, and the cases the rule abstains on whatever the threshold (unscored, or above the cannot_tell cut). v1.2.
Issuer
Rule
Segment
ShiftScore
Pearson’s chi-square test of homogeneity between the stored histogram and a window’s.
Signer
Who signed a v1.5 certificate: mode operator (the tenant, with its own key; no host), or hosted (a hosting service for the tenant; host is the hosting service’s own key id, ed25519:<16 lowercase hex>).
Split
TrustedKey
A trusted certificate-signing key of one tenant: the base64url raw Ed25519 public key, and the mode it may sign in.
UtcDateTime
The UTC time type of timestamp, Verified::expires_at and Verified::is_expired, re-exported so a caller need not depend on time to name it. A PlainDateTime that is known to be UTC.
Verified
A certificate whose signature verified against a trusted key.
Window

Enums§

CertError
KeyMode
The mode a trusted key may sign in (spec v1.5 §4): Operator (the tenant’s own key, as every key in v1 to v1.4), or Hosted by the hosting service whose own key id is host.

Constants§

ABSTAIN_ALL
abstain_below that abstains on every case (as dk calibrate writes it).
CONTEXT_V1_5
The context string a v1.5 signature’s bytes start with (spec v1.5 §3).
CONTEXT_V1_6
The context string a v1.6 signature’s bytes start with (spec v1.6 §3).
CONTEXT_V1_7
The context string a v1.7 signature’s bytes start with (spec v1.7 §3).
MAP_KINDS
The kinds of calibration map v1.2 defines. A certificate may name another kind; it still verifies, and a consumer that does not apply that kind refuses it (spec v1.2 §4).
MAX_BINS
Most bins a confidence_bins may define.
MAX_C
v1.4’s checks beyond the schema (spec v1.4 §2): cost and pvalue pair with risk; the cost matrix is options x options with a zero diagonal, whole-number entries in [0, c_max], c_max its largest entry, above 0 and at most 10^6, and its off-diagonal entries not all equal; loss_sum and realized_cost are null for the error risks, for an inherited segment and wherever their test answered no case, and otherwise loss_sum is at most c_max * k and realized_cost is exactly loss_sum / (c_max * k), k = floor(coverage * n + 1/2) the answered cases. v1.4: the largest c_max.
MAX_TENANT
The longest tenant (spec v1.5 §2).
SPEC
The spec of a certificate produced by the v1 procedure.
SPECS
Every spec this verifier accepts. v1 and v1.1 have the same fields; v1.2 adds some, v1.3 more, v1.4 more again, v1.5 more again.
SPEC_V1_1
The spec of a certificate produced by the v1.1 procedure (the per-test grid start).
SPEC_V1_2
The spec of a v1.2 certificate: v1.1’s procedure, plus the stored confidence histogram.
SPEC_V1_3
The spec of a v1.3 certificate: v1.2, plus the automated options and their answered share and error per test.
SPEC_V1_4
The spec of a v1.4 certificate: v1.3, plus the cost risk selective_cost.
SPEC_V1_5
The spec of a v1.5 certificate: v1.4, plus tenant and signer, signed over bytes that bind the tenant.
SPEC_V1_6
The spec of a v1.6 certificate: v1.5’s fields, with fixed values for the calibration split, and the sequential block; method confidence_sequence, risk automated_error.
SPEC_V1_7
The spec of a v1.7 certificate: v1.6, plus the attempt’s role (standalone or challenger, with the champion it runs beside) and its delta budget, in sequential.

Functions§

bin_of
The bin of confidence: i with bins[i] <= confidence < bins[i + 1]; the last bin also holds
canonical
The JCS bytes of a JSON value.
certificate_id
chi2_sf
P(X >= x) for X ~ chi-square with df degrees of freedom: the regularised upper incomplete gamma Q(df/2, x/2), by its series below a + 1 and its continued fraction above. 1 for df 0.
confidence
A case’s confidence under map: the largest of its probabilities. None when those are.
key_id
ed25519: + the first 16 hex chars of SHA-256 of the raw public key.
probabilities
The probabilities map gives a case’s raw scores, one per option in score order (spec v1.2 §1):
shift_score
Compare a window’s histogram with the certificate’s (spec §4). The columns are the bins and the unscored count; columns empty in both are dropped. With an empty side or one column left there is nothing to compare: statistic 0, df 0, p-value 1. None when the bin counts differ.
tenant_keys_from_json
Read a tenant’s trusted keys from a JSON object of key id → entry. An entry is a bare base64url string (an operator key, as in a v1 to v1.4 key map), {"key": ..., "mode": "operator"}, or {"key": ..., "mode": "hosted", "host": "ed25519:<16 lowercase hex>"} (spec v1.5 §4). Any other entry, an unknown field, or a host not in that form is refused as CertError::BadKey. The key is checked against its id when a certificate is verified, as in verify.
timestamp
Parse the spec’s timestamp form, YYYY-MM-DDTHH:MM:SSZ, and nothing else.
verify
Verify v against keys (key id → base64url raw public key) and read it.
verify_attempt
Verify v, a decision-certificate.v1.7, for the expected tenant, flow and env (spec v1.7 §4.1), and read it.
verify_attempt_document
verify_document for a v1.7 certificate: verify_attempt with the expected flow and env, the expiry at the caller’s now, and the recomputed id, as separate results.
verify_document
Verify v for the expected tenant exactly as verify_for_tenant does, check its expiry at the caller’s now, and recompute its id, returning the three as separate results.
verify_for_tenant
Verify v for the tenant the consumer expects, against that tenant’s moded keys, and read it (spec v1.5 §4).
verify_promotion
Verify that challenger may replace champion as the certificate a domain automates under (spec v1.7 §4.2), for the expected tenant, flow and env at the caller’s now, and read the challenger.
verify_promotion_document
verify_promotion as separate results: the promotion’s verdict, the challenger’s expiry at now and the challenger’s recomputed id.
verify_sequential
Verify v, a decision-certificate.v1.6, for the expected tenant, flow and env (spec v1.6 §4), and read it.
verify_sequential_document
verify_document for a v1.6 certificate: verify_sequential with the expected flow and env, the expiry at the caller’s now, and the recomputed id, as separate results.

Type Aliases§

TenantKeys
One tenant’s trusted keys: key id → TrustedKey.