AI Governance Control SDK  ·  PyPI: aigc  ·  v0.3.3

AIGC enforces governance over every AI model invocation, before and after the call. Policy-driven authorization, cryptographic audit artifacts, risk scoring, and a four-point gate system. Runs in your own infrastructure. No vendor lock-in.

Why AIGC

AI models make no guarantees by default. When your application calls a model, what policy governs that call? Who authorized it? What was the output allowed to contain? How do you prove it hours or weeks later?

AIGC (AI Governance Control) answers every one of those questions by sitting in the path of every invocation. It checks authorization before the call, validates output after it, scores risk, signs the evidence, and produces an immutable audit artifact. All of that runs in a single synchronous pipeline you own and deploy.

AIGC does not orchestrate, host, or own your model calls. You keep all of that. AIGC wraps your existing code with verifiable governance.

1
entry point: enforce_invocation()
4
gate insertion points
10
interactive labs
// core guarantee

Every AI model invocation in your system produces a signed, timestamped audit artifact with SHA-256 checksums of both input and output. No call goes unrecorded.

The enforcement pipeline

A single call to enforce_invocation() runs every governance check in deterministic order. No step is skipped; no check is optional unless your policy explicitly allows it.

load_policy()
Loads your YAML policy, resolves extends composition, validates against JSON Schema DSL.
run_custom_gates() → evaluate_guards()
Custom pre_authorization gates fire. Then AST-based guards expand conditional policy rules.
validate_role() + validate_preconditions()
Role membership verified. Input checked against typed constraints: type, pattern, enum, min/max.
validate_tool_constraints()
Tool usage validated against policy-defined budgets and allowed surfaces.
validate_schema() + validate_postconditions()
Output validated against JSON Schema. All postcondition assertions must pass.
compute_risk_score() → generate_audit_artifact()
Factor-based risk score computed. Signed audit artifact produced with SHA-256 checksums.
enforcement.py · single entry point
from aigc import enforce_invocation

result = enforce_invocation({
    'policy_file':      'policies/my_policy.yaml',
    'input':            {'prompt': user_prompt},
    'output':           {'response': model_response},
    'context':          {'session_id': session_id},
    'model_provider':   'openai',
    'model_identifier': 'gpt-4o',
    'role':             'analyst',
})

# result.audit_artifact  (signed, immutable)
# result.risk_score      (numeric risk score)
# result.passed          (True if all checks passed)

Governance in two phases

AIGC's split enforcement separates authorization (before the call) from validation (after the output). Fail fast on policy violations without paying for an unnecessary model invocation.

Phase A: Pre-Call

Pre-Authorization

Before your code calls the model, AIGC validates the request against policy. Policy violations stop the call entirely. No tokens consumed, no latency wasted.

  • Role validation: is this caller permitted?
  • Precondition checks: does input meet typed constraints?
  • Tool constraints: are allowed tools declared?
  • Custom gates at pre_authorization & post_authorization
Phase B: Post-Call

Output Validation

After the model returns, AIGC validates the output before it reaches your application. Output violating policy is rejected. It never reaches your application.

  • JSON Schema validation: does output match expected shape?
  • Postcondition assertions: do semantic guarantees hold?
  • Custom gates at pre_output & post_output
  • Risk score computed and audit artifact signed

Immutable audit artifacts

Every invocation produces a structured audit record signed with HMAC-SHA256. Input and output are checksummed separately. The artifact is yours. AIGC writes it to your storage, your log stream, your audit database.

Sample audit artifact · audit_schema v1.4
{
  "artifact_id":       "inv_01J8RKT...",
  "timestamp":         "2025-11-14T09:22:41.337Z",
  "policy_version":    "1.2.0",
  "model_provider":    "openai",
  "model_identifier": "gpt-4o",
  "role":              "analyst",
  "input_checksum":   "sha256:e3b0c44298fc...",
  "output_checksum":  "sha256:a665a45920422...",
  "risk_score":       0.12,
  "risk_mode":        "risk_scored",
  "passed":           true,
  "signature":        "hmac-sha256:f4c3b9..."
}

SHA-256 Checksums

Input and output are checksummed independently. Tampering with either is detectable without re-running the model.

HMAC-SHA256 Signing

The full artifact is signed using HMAC-SHA256 with constant-time verification. Verification does not require the original model call.

AuditLineage

Chain-of-custody lineage links related invocations. Correlate a downstream call to the upstream artifact that authorized it.

RiskHistory

Per-role and per-session risk histories track pattern drift: a model that passes policy today but is trending toward violation thresholds.

Custom enforcement gates

Need to check a blocklist, call your OPA policy server, or log to a SIEM before a call proceeds? EnforcementGates are your injection points. No forking required.

custom_gate.py · example gate
from aigc import EnforcementGate, GateContext

class BlocklistGate(EnforcementGate):
    insertion_point = "pre_authorization"

    def check(self, ctx: GateContext) -> None:
        prompt = ctx.invocation["input"]["prompt"]
        if is_blocked(prompt):
            raise GateViolation(
                "Prompt matches blocklist"
            )

Four insertion points

pre_authorization
Fires before role/precondition checks. Fail fast before any validation work.
post_authorization
After authorization passes, before output validation begins.
pre_output
Before schema and postcondition checks. Ideal for PII scanning.
post_output
After all checks pass, before the audit artifact is finalized.

Factor-based risk scoring

Every invocation receives a numeric risk score derived from weighted policy factors. Three modes let you tune governance intensity per role, per model, or per call context.

strict

Any risk score above threshold blocks the call. Zero tolerance. Use for regulated outputs, financial decisions, or medical contexts.

risk_scored

Risk score is computed and recorded in the audit artifact. The call is allowed, but the score is visible for downstream filtering or alerting.

warn_only

Risk is surfaced as a warning in the artifact, never as a block. Use for observability during rollout, before switching to strict mode.

Try AIGC in the browser

Ten interactive labs walk you through every AIGC capability. No model API key required for the core labs.

Lab 01
Risk Scoring

Test factor-based risk scoring. Adjust weights and modes, see how scores shift with different inputs, and watch enforcement outcomes change in real time.

Open lab →
Lab 02
Signing & Verification

Generate HMAC-SHA256 signed audit artifacts and verify them. Tamper with fields to observe how signature validation fails.

Open lab →
Lab 03
Audit Chain

Build and inspect multi-invocation audit chains. Trace AuditLineage: see how downstream calls link back to the upstream artifact that authorized them.

Open lab →
Lab 04
Policy Composition

Use the extends DSL to compose policies from a base. See how role sets narrow (never widen) and how ambiguous merges are rejected.

Open lab →
Lab 05
Loaders & Versioning

Test policy loading, versioning, and schema validation. See how the loader resolves extends chains and validates against the JSON Schema DSL.

Open lab →
Lab 06
Custom Gates

Write and register custom EnforcementGates at all four insertion points. See gate failures propagate and observe how gates access full invocation context.

Open lab →
Lab 07
Compliance Dashboard

View a live compliance summary across multiple invocations. Check pass/fail rates, risk distributions, and artifact counts by role.

Open lab →
Lab 08
Governed Knowledge Base

Apply governance to a RAG-style knowledge base. Enforce source constraints and validate retrieved content against postconditions before returning to the user.

Open lab →
Lab 09
Governed vs. Ungoverned

Side-by-side comparison: run the same prompt through a governed and an ungoverned path. See exactly what governance catches, and what slips through without it.

Open lab →
Lab 10
Split Enforcement Explorer

Step through Phase A and Phase B hands-on. Trigger pre-call failures, watch output rejections, and see how split enforcement avoids unnecessary model costs.

Open lab →

Get started in minutes

aigc v0.3.3, available on PyPI
pip install aigc
v0.2.x · legacy
Original enforcement engine. Superseded by v0.3.3 audit schema and split enforcement.
v0.3.3 · current stable
Split enforcement, audit schema v1.4, AuditLineage, ProvenanceGate, RiskHistory, policy composition with extends.
v0.9.0 · AEGIS beta on develop
GovernanceSession, workflow CLI (init / lint / doctor / trace / export), adapter layer for Bedrock, A2A, and OpenAI Agents. Renamed to AEGIS on release.
quickstart.py · governed invocation in 10 lines
from aigc import enforce_invocation

result = enforce_invocation({
    'policy_file':      'policies/basic.yaml',
    'input':            {'prompt': 'Summarize this document.'},
    'output':           {'response': model_response},
    'context':          {'request_id': 'req-001'},
    'model_provider':   'anthropic',
    'model_identifier': 'claude-3-5-sonnet',
    'role':             'analyst',
})

if result.passed:
    print(result.audit_artifact['artifact_id'])
    # → 'inv_01J8RKT...'
basic.yaml · minimal policy
policy_version: "1.0.0"
roles:
  - analyst
risk:
  mode:      risk_scored
  threshold: 0.8
pre_conditions:
  required:
    - field: prompt
      type:  string
post_conditions:
  required:
    - field: response
      type:  string
◈ v0.9.0 Beta, source-only on develop

Workflow governance is coming.

v0.9.0 adds multi-step workflow governance. A GovernanceSession wraps a series of invocations in a deterministic lifecycle. Every state transition is audited. Sessions can pause for approval, fail safely, and produce a final workflow artifact that correlates all constituent invocation artifacts.

The SDK will be renamed to AEGIS (Auditable Enforcement and Governance for Intelligent Systems) on release. The PyPI package aigc remains supported.

◈ Follow develop on GitHub →

Session lifecycle

  • Context manager: __exit__ never suppresses exceptions
  • Clean exit from non-terminal state → auto-finalizes as INCOMPLETE
  • Exception exit → FAILED artifact emitted, then re-raises
  • SessionPreCallResult is single-use. Replay attacks are rejected.
v0.9.0 · GovernanceSession usage (preview)
from aigc import AIGC

governance = AIGC()

# open_session() is always instance-scoped
with governance.open_session(
    policy_file="policies/review.yaml",
) as session:

    # Phase A: pre-call authorization
    pre = session.enforce_step_pre_call({
        "policy_file":      "policies/review.yaml",
        "input":            {"prompt": prompt},
        "output":           {},
        "context":          {"caller_id": "demo"},
        "model_provider":   "anthropic",
        "model_identifier": "claude-sonnet-4-6",
        "role":             "ai-assistant",
    })

    # You call the model
    response = your_model_client.call(prompt)

    # Phase B: post-call validation + audit
    session.enforce_step_post_call(pre, {"result": response})

    session.complete()

# Workflow artifact on session.workflow_artifact after __exit__
# Source: github.com/nealsolves/aigc/tree/develop

aigc workflow init

Scaffold a governed workflow from minimal, standard, or regulated-high-assurance starter profiles. No hand-authored DSL required on the default path.

aigc workflow lint

Validate your workflow manifest and policy composition before deployment. Surface constraint violations before they become runtime failures.

aigc workflow doctor

Diagnose a failed workflow session. Identifies the exact transition, gate, or constraint that caused failure, with specific steps to fix it.

aigc workflow export

Export workflow and invocation artifacts in operator or full-audit mode. Correlate invocation checksums back to their session context.

Start governing your AI today.

AIGC works alongside your existing AI infrastructure. No hosted service, no vendor lock-in. One Python package, one entry point, one audit artifact per call.

AIGC → AEGIS: The SDK will be renamed to AEGIS (Auditable Enforcement and Governance for Intelligent Systems) when v0.9.0 is released. The PyPI package aigc will remain supported.