Skip to main content

MAIGP (Mediated AI Governance Protocol) client — consent-based runtime AI governance

Project description

aigp-client

Universal AI Governance Protocol (AIGP) client v4.0 — consent-based runtime AI governance with jurisdictional enforcement.

Install

pip install aigp-client

Quick Start

from aigp_client import AigpClient

client = AigpClient("https://your-gov-server.com", "my-app", "hmac-secret")

# Declare governance context (once at startup)
client.declare_universal_context({"active": True, "principles": "ALL"})

# Every AI call: CHECK → invoke → RECORD
decision = await client.check("chat", "claude-4")
# ... invoke your model ...
await client.record(use_case="chat", model_id="claude-4", input_tokens=500, output_tokens=200, duration_ms=1200)

One-Line Governance

from aigp_client import govern

aigp = govern("https://gov-server.com", "my-app", "secret")
result = await aigp.wrap(my_ai_function)  # CHECK + RECORD automatic

Jurisdictional Governance (v4.0)

Declare which legal frameworks govern your AI system:

from aigp_client import (
    AigpClient, HumanitarianContext, RegulatoryContext,
    AfricanContext, JapaneseContext,
)

client = AigpClient("https://gov.example.com", "my-app", "secret")

# Universal baseline (RFC-031) — all apps should declare this
client.declare_universal_context({"active": True, "principles": "ALL", "accountability_required": True})

# EU AI Act (RFC-028)
client.declare_regulatory_context(RegulatoryContext(
    active=True, framework="EU_AI_ACT", risk_classification="HIGH_RISK",
    deployer_jurisdiction="DE",
))

# Japan AI Promotion Act (RFC-030)
client.declare_japanese_context(JapaneseContext(
    active=True, governance_framework="JAPAN_AI_PROMOTION_ACT",
    sector="HEALTHCARE", innovation_priority=True,
))

# AU Continental AI Strategy (RFC-029)
client.declare_african_context(AfricanContext(
    active=True, governance_framework="AU_CONTINENTAL_AI_STRATEGY",
    member_state="KE", ubuntu_principle=True,
))

# IHL — conflict zones (RFC-027)
client.declare_humanitarian_context(HumanitarianContext(
    active=True, legal_regime="IHL_GCIV", conflict_classification="NIAC",
    operating_authority="ICRC",
))

All subsequent CHECK requests are evaluated against declared contexts. Priority: IHL → EU → AU → Japan → Universal.

User Feedback (RFC-026)

await client.feedback(request_id="req-123", session_id="ses-abc",
                      rating="thumbs_up", pseudonym_id="user-hash")

Multi-Agent Delegation

from aigp_client import SessionContext, DelegationToken

session = SessionContext(user_id="coordinator@company.com")
child = session.child(scope=["search_only"])

token = DelegationToken(issuer="coordinator", delegate="worker",
                        allowed_models=["claude-4"], max_tokens=10000)
encoded = token.encode("shared-secret")

Token Tracking

from aigp_client import TokenAccumulator

tokens = TokenAccumulator()
tokens.add_from_usage({"prompt_tokens": 500, "completion_tokens": 200})  # OpenAI
tokens.add_from_usage({"inputTokens": 300, "outputTokens": 150})          # Bedrock
print(f"Total: {tokens.total_input} in, {tokens.total_output} out")

Full Lifecycle Trace

from aigp_client import TraceBuilder

tb = TraceBuilder(request_id="req-1")
tb.start(1); tb.end(1, attributes={"user_id": "user@co.com"})  # Identity
tb.start(3); tb.end(3, attributes={"decision": "ALLOW"})        # CHECK
tb.start(9); tb.end(9, attributes={"model": "claude-4"})        # Invoke
tb.add_tool_span("search_docs", duration_ms=45)                  # Tool
tb.start(14); tb.end(14)                                         # RECORD
spans, summary = tb.build()
await client.trace(trace_id=tb.trace_id, spans=spans, summary=summary)

Tool Governance

from aigp_client import ToolGovernance

tg = ToolGovernance(client=client)
decision = await tg.check_tool("execute_sql", params={"query": "SELECT *"})

Modes

Mode Behavior When server unreachable
REPORT Log all, allow all Allow (fail-open)
REPORT-TRACE Log + stage-level spans Allow (fail-open)
ENFORCE Check policies, block violations Deny (fail-closed)

Supported Languages

Python TypeScript Go Java C# Rust Ruby Swift

All 8 SDKs have: declareHumanitarianContext, declareRegulatoryContext, declareAfricanContext, declareJapaneseContext, declareUniversalContext.

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maigp_client-5.0.0.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maigp_client-5.0.0-py3-none-any.whl (44.4 kB view details)

Uploaded Python 3

File details

Details for the file maigp_client-5.0.0.tar.gz.

File metadata

  • Download URL: maigp_client-5.0.0.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for maigp_client-5.0.0.tar.gz
Algorithm Hash digest
SHA256 be250e65a5a8c119c759d1c521ff5af866def7b918c2a7e9b5418576900275d8
MD5 f873449be9c3cff0d0b32ed1b7349042
BLAKE2b-256 9b526282be10821d8cb3eb861a12b516f72414e2c2c3593fb5e81072fcd06195

See more details on using hashes here.

File details

Details for the file maigp_client-5.0.0-py3-none-any.whl.

File metadata

  • Download URL: maigp_client-5.0.0-py3-none-any.whl
  • Upload date:
  • Size: 44.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for maigp_client-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9799d9812735bfc6f6da3ad0df9fc1815f1cf7032b647ea09d30a15e91254f79
MD5 14cb44826b0731a25d3b927b380f19e7
BLAKE2b-256 e5700b31e605c4e67aab93d8de28c31e6d5598f41f334652bf62636183deda93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page