Combine, override, or compose multiple risk scoring strategies with Composite, Max, and Fixed scorers
While the DefaultRiskScorer handles most use cases, Attesta provides three additional scorer types that let you combine, override, or compose scoring strategies. All scorers implement the same RiskScorer protocol and can be used interchangeably.
The CompositeRiskScorer combines multiple scorers by computing a weighted average of their scores. Weights are normalized internally, so they do not need to sum to 1.0.
The MaxRiskScorer runs multiple scorers and takes the maximum score across all of them. This is the most conservative strategy — if any scorer considers an action risky, the overall score reflects that.
from attesta.core.risk import ( DefaultRiskScorer, MaxRiskScorer,)# Your custom domain scorerclass ComplianceScorer: def score(self, context) -> float: if "pii" in str(context.arguments).lower(): return 0.9 # PII operations are always high risk return 0.1# If either scorer flags the action, the higher score winsconservative = MaxRiskScorer( scorers=[DefaultRiskScorer(), ComplianceScorer()])
Defense in depth — Multiple independent scorers act as safety nets
Compliance overlays — A compliance scorer can veto the default scorer’s low rating
Red lines — Ensure certain patterns always trigger high-risk regardless of other factors
MaxRiskScorer is deliberately conservative. If you combine it with a scorer that returns high values for common operations, you may cause excessive approval friction. Monitor your approval rates after deployment.
The FixedRiskScorer always returns the same pre-configured score, regardless of the action context. While simple, it has several practical applications.
During incident response, you can swap to FixedRiskScorer(0.85) to force multi-party approval on all agent actions while you investigate. Return to the default scorer once the incident is resolved.
You can nest scorers to build sophisticated policies:
from attesta.core.risk import ( DefaultRiskScorer, CompositeRiskScorer, MaxRiskScorer, FixedRiskScorer,)# Layer 1: Blend default + domain scorerblended = CompositeRiskScorer( scorers=[ (DefaultRiskScorer(), 2.0), (ComplianceScorer(), 1.0), ])# Layer 2: Take the max of blended score and a risk floorfinal = MaxRiskScorer( scorers=[blended, FixedRiskScorer(0.2)])# No action can score below 0.2, and compliance concerns always raise the score