Skip to main content

Risk Engine

The Risk Engine produces a numerical score (0.0 to 1.0) and a categorical risk level for every memory operation. This assessment is computed before the Policy Engine runs, so policy rules can branch on risk_score and risk_level. The current scorer is memproof-baseline-v1.

Risk Factors

Each operation is evaluated across up to five factors. Every factor produces a contribution value between 0.0 and 1.0.
1

Operation Type

Different operation types carry different inherent risk. Read operations are low-risk; destructive operations are higher.
2

PII Detection

Content is scanned against regex patterns for personally identifiable information. If PII is detected, a factor with contribution 0.60 is added.Detected patterns include: Social Security numbers, email addresses, credit card numbers, and phone numbers.
3

Secrets Detection

Content is scanned for embedded credentials and secrets. If a secret is detected, a factor with contribution 0.70 is added.Detected patterns include: API key assignments, bearer tokens, and keys matching the sk- prefix pattern.
4

Source Trust

The context.source field is compared against a set of trusted sources: langgraph, openai_sessions, and mcp.
5

Scope Anomaly

If the tenant_id or project_id is missing from the operation scope, a factor with contribution 0.70 is added. This flags operations that lack proper organizational context.

Scoring Formula

The final score is computed in two steps: Step 1: Weighted average
Step 2: Floor boost from maximum factor
The floor boost ensures that a single high-risk factor (like a detected secret at 0.70) cannot be diluted below 80% of its contribution by low-risk factors. The final score is clamped to a maximum of 1.0.
The floor boost is a deliberate design choice. A memory operation that contains an API key should never score “low risk” just because all other factors are clean.

Worked Example

Consider a remember operation from a trusted source (langgraph) that contains an email address:
Result: score = 0.48, level = medium.

Risk Levels

The score maps to one of four risk levels using configurable thresholds: Thresholds can be customized in the policy YAML under risk_thresholds:

Content Flags

In addition to the scored risk assessment, the Risk Engine produces boolean content flags that are passed to the Policy Engine as condition fields:
These map directly to the content.contains_pii and content.contains_secret fields available in policy rule conditions.

How Risk Feeds Into Policy

The RiskAssessment and content flags are passed to the Policy Engine as part of the evaluation context. Policy rules can use any combination of risk data:

RiskAssessment Model

Every operation response includes the full risk assessment:
Each RiskFactor in the factors list includes:
Use the factors list in logging and dashboards to understand exactly why an operation scored the way it did.