ai-safe2-framework

AI SAFE² Core Gateway v3.0

North-south runtime enforcement for the AI SAFE² v3.1 framework

AI SAFE² Component Plane

Framework Home Cross-Pillar Governance AISM NEXUS Dashboard
Previous: ← Scanner Related: NEXUS MCP Agent-to-Tool Profile

Gateway evidence and technology contribution

Gateway action-risk routing scores are separate from organizational AISM maturity and the Technology Contribution Profile. Record provider, tool, and agent-to-agent boundaries separately. A mediated provider request does not establish containment of direct tool or delegated paths. Use the validation guide to test interception, authorization, actuation, outage, revocation, and legitimate utility before claiming runtime effectiveness.

Version and Conformance Boundary

The current gateway implementation is Gateway v3.0. AI SAFE² v3.1 did not silently rename this component.

“Core Gateway” is the north-south provider proxy. “NEXUS Sovereign Gateway” is the separate NEXUS component’s gateway scaffold and follows the NEXUS source version. These names and version numbers identify different components. See the component version map.

The gateway remains a compatible reference component for the north-south enforcement plane because the v3.1 release primarily changes protocol governance and the MCP agent-to-tool profile. Existing v3.0 gateway audit evidence therefore retains its v3.0 component identity until a separately tested gateway release changes that identity.

This distinction is intentional:


Architecture

Client / Agent
      |
      v
HeartbeatMonitor       hard stop on invalid liveness state
      |
RateLimiter            per-identity request limits
      |
ProviderAdapter        normalized provider boundary
      |
RiskScorer             action x sensitivity x history
      |
HITLCircuitBreaker     AUTO / MEDIUM / HIGH / CRITICAL
      |
ImmutableAuditLog      HMAC-SHA256 chained evidence
      |
Provider Dispatch      Anthropic / OpenAI / Gemini / Ollama / OpenRouter
      |
ResponseScanner        outbound exfiltration and injection checks
      |
      v
Client Response

Enforcement Components

Component Function
HeartbeatMonitor Validates liveness state and activates safe mode on invalid conditions
RateLimiter Bounds request volume per identity
ProviderAdapter Normalizes provider requests while preserving the original upstream payload
RiskScorer Computes the gateway risk vector used for HITL routing
HITLCircuitBreaker Applies tiered human authorization requirements
ImmutableAuditLog Produces HMAC-chained audit evidence and detects tampering
ResponseScanner Inspects upstream output before return to the caller
SafeMode Blocks normal traffic until operator-controlled recovery

v3.1 Enforcement-Plane Model

Plane Primary component/path Gateway role
North-south Gateway Primary reference enforcement component
East-west NEXUS Gateway may carry/record NEXUS context but is not the primary A2A governance layer
Agent-to-tool CP.5.MCP + NEXUS MCP adapter/toolkit Gateway is not a substitute for MCP-specific authorization/profile enforcement

The gateway therefore should not be used as evidence that MCP-14 through MCP-19 are implemented. Those controls must be evaluated on the actual agent-to-tool path.


Quick Start

Dependencies

python3 -m pip install fastapi uvicorn httpx pyyaml requests

Required secrets

export AUDIT_CHAIN_KEY="$(openssl rand -hex 32)"
export OPERATOR_DEACTIVATION_KEY="$(openssl rand -hex 16)"

Set the credential for the selected provider, for example:

export ANTHROPIC_API_KEY="..."
# export OPENAI_API_KEY="..."
# export GEMINI_API_KEY="..."
# export OPENROUTER_API_KEY="..."

Run

uvicorn gateway.main:app --host 127.0.0.1 --port 8080

Provider Support

Provider Credential/config
Anthropic ANTHROPIC_API_KEY
OpenAI OPENAI_API_KEY
Gemini GEMINI_API_KEY
Ollama local endpoint, normally no API key
OpenRouter OPENROUTER_API_KEY

All providers pass through the same gateway policy stages; provider adapters handle upstream-specific transport details.


NEXUS Relationship

The gateway contains compatibility hooks for NEXUS context and can record NEXUS-related identity/delegation evidence when present.

That does not make the gateway the NEXUS implementation. NEXUS remains the CSI reference path for east-west governance and the v3.1 agent-to-tool adapter contract.

See NEXUS for the current implementation boundary.


Audit Provenance

Gateway audit records intentionally identify the gateway component version that created them. Existing Gateway v3.0 evidence should remain v3.0 evidence.

The audit-chain genesis anchor must not be changed merely because the framework version advances. Doing so would break verification of prior chained records.

A future Gateway v3.1 release should define and test an explicit evidence migration/versioning policy rather than silently rewriting the v3.0 anchor.


Safe Mode

Safe mode blocks governed traffic until explicitly deactivated by the authorized operator path.

Typical triggers include:

The safety path remains outside ordinary model authority.


Framework References


🔗 Navigation

Framework Home Cross-Pillar Governance AISM NEXUS Scanner Dashboard

AI SAFE² v3.1 framework · Gateway v3.0 component · Cyber Strategy Institute