Skip to main content
Every time a gated function is called, Attesta’s DefaultRiskScorer evaluates the action across 5 independent factors and produces a weighted composite score between 0.0 and 1.0. This score determines which challenge the human operator must complete before execution proceeds.

The 5 Scoring Factors

The final score is the weighted sum of individual factor scores:
All factor scores are clamped to the [0.0, 1.0] range before weighting. The final composite score is also clamped, ensuring it never exceeds 1.0.

Factor 1: Function Name (weight: 0.30)

The scorer extracts the verb from the function name and classifies it into one of three tiers.

Destructive Verbs — score 0.95

These verbs indicate irreversible or highly impactful operations:

Mutating Verbs — score 0.55

These verbs modify state but are typically reversible:

Read Verbs — score 0.10

These verbs indicate read-only operations with minimal risk:
If the verb does not match any category, a default mid-range score is assigned.

Factor 2: Arguments (weight: 0.25)

The scorer scans all argument values (converted to strings) for patterns that indicate sensitive or dangerous content.

Sensitive Patterns

Each detected pattern contributes to the argument score. Multiple matches compound the risk.
Arguments containing production or .env in any position will significantly elevate the risk score. This is by design — accidentally targeting production environments is one of the most common causes of AI agent incidents.
Python

Factor 3: Docstring (weight: 0.20)

The scorer inspects the function’s docstring for keywords that signal risk.

High-Risk Keywords — score 0.85

Caution Keywords — score 0.50

If multiple keywords match, the highest score wins.

Factor 4: Hints (weight: 0.15)

Callers can supply explicit risk hints to influence the score. Hints come in two forms:

Boolean Hints

Each boolean hint set to True adds 0.30 to the hint score (cumulative, clamped to 1.0).

Numeric Hints

Numeric hints are scaled as min(value / 10000, 1.0) * 0.8:
Use boolean hints for categorical flags like production, affects_pii, or requires_backup. Use numeric hints for quantities like affected_rows, file_count, or dollar_amount.

Factor 5: Novelty (weight: 0.10)

The novelty factor captures how familiar a particular function call is. The first invocation of any gated function is treated as highest novelty; the score decreases linearly with subsequent calls. The formula is:
This means the novelty score starts at 0.9 for the first call and linearly decreases to 0.1 by the 10th call, remaining at 0.1 thereafter.
Novelty tracking is per-function, per-session. A new session resets all novelty counters.

Worked Example

Consider a function delete_user("usr_123", env="production") with docstring "Permanently remove a user account." called for the first time, with no hints: A score of 0.72 maps to risk level HIGH, which triggers a quiz challenge.

Custom Scorers

DefaultRiskScorer covers general-purpose use cases. For domain-specific scoring, you can use a CompositeRiskScorer to blend the default scorer with custom logic, or replace it entirely with your own implementation.

Risk Levels

See how scores map to LOW, MEDIUM, HIGH, and CRITICAL

Risk Scorers

Combine or replace scorers with Composite, Max, and Fixed