Metadata-Version: 2.4
Name: airiskguard
Version: 0.1.0
Summary: AI Risk Governance Framework — model registry, audit logs, risk dashboards, anomaly detection, regulatory reports, and human review workflows.
Author: airiskguard contributors
License-Expression: MIT
Keywords: ai,audit,compliance,governance,risk,safety
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: aiosqlite>=0.17
Requires-Dist: numpy>=1.21
Requires-Dist: pyyaml>=6.0
Requires-Dist: scikit-learn>=1.0
Requires-Dist: scipy>=1.7
Provides-Extra: all
Requires-Dist: fastapi>=0.68; extra == 'all'
Requires-Dist: flask>=2.0; extra == 'all'
Requires-Dist: httpx>=0.24; extra == 'all'
Requires-Dist: mypy>=1.0; extra == 'all'
Requires-Dist: pytest-asyncio>=0.21; extra == 'all'
Requires-Dist: pytest-cov>=4.0; extra == 'all'
Requires-Dist: pytest>=7.0; extra == 'all'
Requires-Dist: ruff>=0.1.0; extra == 'all'
Requires-Dist: torch>=1.12; extra == 'all'
Requires-Dist: transformers>=4.20; extra == 'all'
Requires-Dist: uvicorn>=0.15; extra == 'all'
Provides-Extra: dev
Requires-Dist: httpx>=0.24; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.68; extra == 'fastapi'
Requires-Dist: uvicorn>=0.15; extra == 'fastapi'
Provides-Extra: flask
Requires-Dist: flask>=2.0; extra == 'flask'
Provides-Extra: transformers
Requires-Dist: torch>=1.12; extra == 'transformers'
Requires-Dist: transformers>=4.20; extra == 'transformers'
Description-Content-Type: text/markdown

# airiskguard

AI Risk Governance Framework — model registry, audit logs, risk dashboards, anomaly detection, regulatory reports, and human review workflows for AI applications.

## Installation

```bash
pip install airiskguard
```

With optional extras:

```bash
pip install airiskguard[fastapi]    # FastAPI integration
pip install airiskguard[flask]      # Flask integration
pip install airiskguard[transformers]  # ML-based hallucination/security detection
pip install airiskguard[dev]        # Development tools
```

## Quick Start

### Decorator Pattern

```python
from airiskguard import risk_guard

@risk_guard(checks=["fraud", "compliance"], model_id="payment-v2")
async def process_payment(tx: dict) -> dict:
    return await engine.process(tx)
```

### Middleware Pattern

```python
from fastapi import FastAPI
from airiskguard.integrations.fastapi import add_risk_guard

app = FastAPI()
add_risk_guard(app, config="airiskguard.yaml")
```

### Direct API

```python
from airiskguard import RiskGuard

guard = RiskGuard()
await guard.initialize()

report = await guard.evaluate(
    input_data={"amount": 500, "user_id": "u123"},
    output_data={"approved": True},
    model_id="my-model",
)
print(report.overall_risk, report.overall_score)
```

## Features

- **Model Registry** — register, version, and manage model lifecycles
- **Audit Log** — immutable SHA-256 hash-chain audit trail
- **Risk Dashboard** — aggregate metrics, trends, and JSON export
- **Anomaly Detection** — IsolationForest + KS drift detection
- **Regulatory Reports** — GDPR, SOX, EU AI Act reports in JSON + HTML
- **Human Review** — threshold-based flagging, approve/reject/escalate workflows
- **Risk Checkers** — fraud, hallucination, compliance, bias, security
- **Framework Integration** — FastAPI, Flask, ASGI, WSGI middleware

## Risk Checkers

| Checker | Detects |
|---------|---------|
| `fraud` | Amount anomaly (z-score), velocity abuse, suspicious patterns |
| `hallucination` | Fabricated URLs, unverifiable citations, contradictions, NLI |
| `compliance` | PII (SSN, email, CC, phone), prohibited content, custom rules |
| `bias` | Disparate impact (4/5ths rule), demographic parity, equalized odds |
| `security` | Prompt injection (~30 patterns), jailbreak (~20 patterns), encoding attacks |

## License

MIT
