Skip to content

feat: implement risk engine (guard, factors, and client integration)#3

Open
abiorh-claw wants to merge 1 commit intomainfrom
feat/risk-engine
Open

feat: implement risk engine (guard, factors, and client integration)#3
abiorh-claw wants to merge 1 commit intomainfrom
feat/risk-engine

Conversation

@abiorh-claw
Copy link
Contributor

Description

Implements the Risk Engine (Phase 1 & 2) for OmniClaw.
This system evaluates transactions based on risk factors (velocity, amount, new recipient) and assigns a Risk Score (0-100).

  • Low Risk (0-20): Auto-Approved
  • Medium Risk (20-80): Flagged → Creates 'Payment Intent' for HITL Review
  • High Risk (80-100): Blocked

Key Features

  • RiskGuard: Aggregates factors and enforces thresholds.
  • RiskFactors:
    • AmountFactor: Exponential risk scaling for large amounts.
    • VelocityFactor: Checks transaction frequency spikes.
    • NewRecipientFactor: Higher risk for unknown addresses.
  • Client Integration: pay() now catches RiskFlaggedError and automatically creates a pending PaymentIntent instead of failing.
  • Trust-Awareness: Risk thresholds are dynamically adjusted based on ERC-8004 Trust Scores (if available).

Changes

  • Added src/omniclaw/risk/guard.py and factors.py.
  • Updated OmniClawClient.pay() to handle risk exceptions.
  • Added examples/test_risk.py for verification.
  • Added spec docs/specs/002_risk_engine.md.

Verification

  • Ran examples/test_risk.py locally. Confirmed Allow, Flag (Intent Creation logic simulated), and Block scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant