Skip to main content

Module compliance_score

Module compliance_score 

Source
Expand description

Phase 19.1 – compliance scoring on top of ComplianceReport.

Productizes the existing crate::operator_report::ComplianceReport into a user-facing 0..=1000 score with weighted factors:

FactorMax pointsSignal
Deny rate300denies / total_observed
Revocation rate300revoked_caps / observed_caps (or flag)
Velocity anomaly rate150anomaly_windows / total_windows
Policy coverage150lineage + checkpoint rates (averaged)
Attestation freshness100age of latest attestation vs. staleness

Weights sum to 1000. Each factor produces a 0..=max deduction; the final score is 1000 - total_deductions, clamped to [0, 1000].

This module is additive: it consumes a ComplianceReport without modifying its fields. Callers who already materialize a compliance report reuse its figures verbatim.

Structs§

ComplianceFactor
Per-factor deduction detail (0..=max points).
ComplianceFactorBreakdown
Full factor breakdown for a compliance score.
ComplianceScore
Final compliance score for an agent over a window.
ComplianceScoreConfig
Options controlling scoring thresholds. Defaults match the roadmap’s 19.1 acceptance targets (zero denies in 1000 calls -> >900; any revoked cap -> <500).
ComplianceScoreInputs
Observed compliance inputs that are not carried by ComplianceReport.

Constants§

COMPLIANCE_SCORE_MAX
Maximum possible compliance score.
DEFAULT_ATTESTATION_STALENESS_SECS
Default staleness threshold (seconds) beyond which the attestation freshness factor is fully deducted. Ninety days mirrors the default receipt-retention window in crate::receipt_store::RetentionConfig.
WEIGHT_ATTESTATION_FRESHNESS
Weight for the attestation-freshness factor.
WEIGHT_DENY_RATE
Weight (maximum-deducted points) for the deny-rate factor.
WEIGHT_POLICY_COVERAGE
Weight for the policy-coverage factor.
WEIGHT_REVOCATION
Weight for the revocation factor.
WEIGHT_VELOCITY_ANOMALY
Weight for the velocity-anomaly factor.

Functions§

compliance_factor_breakdown
Build the per-factor breakdown without wrapping it in a score.
compliance_score
Compute the weighted compliance score for an agent.