Metadata-Version: 2.4
Name: aigp-client
Version: 1.0.0
Summary: Universal AIGP (AI Governance Protocol) client — consent-based runtime AI governance
Project-URL: Homepage, https://github.com/evanerwee/aigp-protocol
Project-URL: Documentation, https://github.com/evanerwee/aigp-protocol/tree/main/spec
Project-URL: Repository, https://github.com/evanerwee/aigp-protocol
Author-email: Evan Erwee <evan@erwee.com>
License: Proprietary
Keywords: ai,aigp,bedrock,governance,llm,protocol
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.11
Requires-Dist: httpx>=0.25.0
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Requires-Dist: respx; extra == 'dev'
Description-Content-Type: text/markdown

# aigp-client

Universal AI Governance Protocol (AIGP) client — RFC-010 implementation.

## Install

```bash
pip install aigp_client-1.0.0-py3-none-any.whl
```

Or in `requirements.txt`:
```
aigp-client @ file:///app/wheels/aigp_client-1.0.0-py3-none-any.whl
```

## Usage

```python
from aigp_client import AigpClient

client = AigpClient(
    gov_url="https://www.cyber-ai-gov.com",
    app_id="MY_APP",
    hmac_secret="your-shared-secret",
    mode="REPORT",  # or "ENFORCE"
)

# Heartbeat (run as background task)
await client.heartbeat()

# Pre-invocation check
decision = await client.check("my_use_case", "model-id", user_id="user@example.com")
if decision.denied:
    raise Exception(f"Blocked: {decision.reason}")

# Post-invocation record
await client.record(
    use_case="my_use_case", model_id="model-id",
    input_tokens=500, output_tokens=200,
    duration_ms=1200, user_id="user@example.com",
)
```

## Use Cases Config

Instead of hardcoding use cases, ship an `aigp-use-cases.json` alongside your app:

```json
{
  "app_id": "MY_APP",
  "use_cases": [
    {"id": "chat", "description": "General AI chat"},
    {"id": "analysis", "description": "Data analysis"}
  ]
}
```

The client auto-discovers this file at:
- `./aigp-use-cases.json`
- `/app/aigp-use-cases.json`

Or pass explicitly:
```python
client = AigpClient(..., use_cases_file="/path/to/aigp-use-cases.json")
```

## Modes

| Mode | Behavior | When GOV_APP unreachable |
|------|----------|--------------------------|
| `REPORT` | Log all, allow all | Allow (fail-open) |
| `ENFORCE` | Check policies, block violations | Deny (fail-closed) |

## Protocol (RFC-010)

| Message | Endpoint | Purpose |
|---------|----------|---------|
| REGISTER | `GET /api/v1/register/{app_id}` | Heartbeat + declare use cases |
| REQUEST | `POST /api/v1/request` | Pre-invocation policy check |
| RECORD | `POST /api/v1/record` | Post-invocation telemetry |

All messages are HMAC-SHA256 signed with headers:
- `X-AIGP-Signature: hmac-sha256={sig}`
- `X-AIGP-Timestamp: {iso_timestamp}`
- `X-AIGP-App-Id: {app_id}`

## Docker Integration

```dockerfile
COPY wheels/ /app/wheels/
RUN pip install /app/wheels/aigp_client-1.0.0-py3-none-any.whl
COPY aigp-use-cases.json /app/aigp-use-cases.json
```

## Build

```bash
cd HELPERS/aigp-client
make wheel    # → dist/aigp_client-1.0.0-py3-none-any.whl
make test     # run tests
```

## Version

`1.0.0` — Initial release. Single source of truth for all Deloitte Cyber apps.
