Metadata-Version: 2.4
Name: maigp-server
Version: 5.0.0
Summary: MAIGP Governance Server — Mediated AI Governance Protocol engine (scope envelopes, circuit breakers, delegation)
Project-URL: Homepage, https://github.com/owner-spec/aigp-protocol
Project-URL: Repository, https://github.com/owner-spec/aigp-protocol
Author-email: Evan Erwee <evan@erwee.com>
License: Proprietary
Keywords: agentic,ai,aigp,circuit-breaker,governance,maigp,mediated,protocol,scope-envelope
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Requires-Python: <3.14,>=3.11
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Description-Content-Type: text/markdown

# aigp-server — AIGP Governance Engine

Reference governance server for the AI Governance Protocol (AIGP) v4.0. Provider-based architecture with jurisdictional AI governance.

## Install

```bash
pip install aigp-server
```

## What It Does

The governance server evaluates AI requests against 5 jurisdictional rule engines in strict priority order:

```
IHL (RFC-027) → EU AI Act (RFC-028) → AU Strategy (RFC-029) → Japan Act (RFC-030) → Universal (RFC-031)
```

First DENY wins. 35 governance rules total.

## Quick Start

```python
from aigp_server import GovernanceEngine, AigpRouter, ServerConfig

# Configure
config = ServerConfig(
    storage={"provider": "memory"},       # or "dynamodb"
    mode="REPORT",                        # REPORT (fail-open) or ENFORCE (fail-closed)
)
components = config.build()

# Create engine + router
engine = GovernanceEngine(components.store, components.scope_mgr, components.circuit_breaker, mode="REPORT")
router = AigpRouter(engine, hmac_secret="your-secret")

# Declare jurisdictional context
await engine.declare_universal_context("my-app", {"active": True, "principles": "ALL"})

# Handle requests (framework-agnostic — returns (status_code, response_dict))
status, resp = await router.handle_tool_request(headers, body)
```

## Jurisdictional Governance (v4.0)

| Route | Method | RFC |
|-------|--------|-----|
| `/api/v1/context/declare` | POST | RFC-027 (IHL) |
| `/api/v1/regulatory/declare` | POST | RFC-028 (EU AI Act) |
| `/api/v1/african/declare` | POST | RFC-029 (AU Strategy) |
| `/api/v1/japanese/declare` | POST | RFC-030 (Japan Act) |
| `/api/v1/universal/declare` | POST | RFC-031 (Universal) |

Each has a corresponding GET endpoint: `/api/v1/{context}/{app_id}`

## Rule Engines

| File | Rules | Scope |
|------|:-----:|-------|
| `ihl_rules.py` | 6 | Non-derogable IHL protections |
| `euai_rules.py` | 7 | Risk classification, conformity, FRIA |
| `au_rules.py` | 6 | Data sovereignty, cultural preservation |
| `jp_rules.py` | 6 | Innovation enablement, safety, transparency |
| `universal_rules.py` | 10 | Baseline: human authority, accountability, non-discrimination |

## Provider Architecture

```
aigp_server/
├── governance_engine.py     Core engine — 5-layer evaluation
├── routes.py                Framework-agnostic HTTP handlers
├── ihl_rules.py             RFC-027
├── euai_rules.py            RFC-028
├── au_rules.py              RFC-029
├── jp_rules.py              RFC-030
├── universal_rules.py       RFC-031
├── hmac_auth.py             HMAC-SHA256 request signing
├── config.py                Provider configuration
├── providers/
│   ├── storage/             memory, dynamodb
│   ├── scope/               ScopeEnvelopeManager, CircuitBreakerService
│   ├── enforcement/         bedrock, azure, gcp adapters
│   ├── pii/                 regex, presidio, comprehend
│   ├── key_store/           local, kms, vault
│   └── consent/             Tier-aware tokenization
```

## Agentic Governance Handlers

| Handler | Purpose | Decision |
|---------|---------|----------|
| `handle_tool_request` | Per-tool CHECK | ALLOW / DENY |
| `handle_plan_submit` | Plan approval | APPROVED / REJECTED |
| `handle_step_complete` | Budget decrement | recorded |
| `handle_escalate` | Human escalation | Creates pending task |
| `handle_delegate` | Agent-to-agent scoping | Scope narrowing |
| `handle_memory_write` | Classification check | ALLOW / DENY |

## Implementing Your Own

This is a **reference implementation**. To build your own governance server:

1. `pip install aigp-server` for the engine + rules
2. Wire `AigpRouter` handlers into your HTTP framework (FastAPI, Flask, Express, etc.)
3. Implement `StorageProviderBase` for your database
4. Deploy behind your own infrastructure

The `aigp-client` SDK (all 8 languages) talks to any server implementing the AIGP HTTP contract.

## License

Proprietary — © 2025-2026 Evan Erwee. All rights reserved.
