Skip to main content

Governance Gateway — Policy-as-Code

A policy engine that evaluates a request against the tenant's active policies and returns allow, deny, or escalate (human-in-the-loop).

Where policies are enforced — the boundary​

SurfaceEnforced?
POST /v1/governance/evaluateOn request — returns the verdict; the caller decides what to do with it
Orchestrator workflows (/v1/orchestrator/*)Inline — every inference step and tool execution is gated with evaluate_and_gate; a deny stops the step, an escalate pauses the workflow for HITL; outputs get a PII post-check
Memory operations (/v1/stores/* write / retrieve / delete)Not gated. Policies are not consulted on the memory path. If you call the memory API directly, enforcement is yours: evaluate first, then act

"Every request passes through the gateway" is true for orchestrated workflows and not for the raw memory API. Reports state this as policy_enforcement_scope under DORA Art 9.

Policy types​

TypeDescriptionExample Config
rate_limitMax operations per time window{"max_requests": 600, "window_seconds": 60}
model_allowlistRestrict which LLM models can be used{"models": ["gpt-4o", "claude-3.5-sonnet"]}
content_filterBlock queries/outputs matching regex patterns{"patterns": ["password", "secret"], "check_fields": ["query", "output"]}
data_scopeRestrict which stores can be accessed{"allowed_stores": ["default", "production"]}
token_budgetCap tokens per request{"max_tokens_per_request": 10000}
hitl_requiredRequire human approval for operations{"operations": ["delete", "inference"]}
pii_guardDetect PII patterns in outputs{"patterns": ["\\b\\d{3}-\\d{2}-\\d{4}\\b"]}

Actions​

ActionBehavior
denyVerdict denied. Orchestrator: the step is stopped. /evaluate: allowed: false.
escalateVerdict escalated. Orchestrator: the workflow pauses for HITL approval. /evaluate: allowed: false.
log_onlyAllow, but record the match in the evaluation log.
allowExplicitly allow (overrides lower-priority denials).

Evaluation flow​

  1. Request arrives with operation (e.g. write, retrieve, inference) and context
  2. All enabled policies are loaded, ordered by priority (lower number = higher priority)
  3. Each policy is evaluated against the context
  4. Per-policy result is logged to governance_evaluation_log
  5. If any policy returns denied or escalated, the result is not allowed; webhooks fire for denials and escalations
# Evaluate policies against a request
curl -X POST https://api.grafomem.com/v1/governance/evaluate \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"operation": "inference",
"context": {
"model_id": "gpt-3.5-turbo",
"query": "What is the password?",
"tokens": 500
}
}'

Response:

{
"allowed": false,
"evaluations": [
{"policy_name": "Model Allowlist", "result": "denied", "detail": "Model 'gpt-3.5-turbo' not in allowlist"},
{"policy_name": "Content Filter", "result": "denied", "detail": "Content filter match in 'query': pattern 'password'"}
],
"summary": {"total": 3, "allowed": 1, "denied": 2, "escalated": 0, "logged": 0}
}

API reference​

Policy CRUD​

MethodPathDescription
POST/v1/governance/policiesCreate a new policy
GET/v1/governance/policiesList all policies
GET/v1/governance/policies/{id}Get a single policy
PUT/v1/governance/policies/{id}Update a policy
DELETE/v1/governance/policies/{id}Delete a policy

Evaluation & Monitoring​

MethodPathDescription
POST/v1/governance/evaluateEvaluate all policies against a request
POST/v1/governance/seed-defaultsSeed default policies (rate limit + PII guard)
GET/v1/governance/statsSummary statistics
GET/v1/governance/policy-typesList available policy types with config schemas
GET/v1/governance/logsEvaluation log (filterable by policy_id, result)

Default policies​

When you call POST /v1/governance/seed-defaults, two policies are created:

  1. Default Rate Limit — 600 requests per minute, action: deny
  2. PII Output Guard — Detects SSN, credit card, and IBAN patterns in outputs, action: log_only

Portal UI​

The Governance tab in the Cloud Portal provides:

  • Stats dashboard — active policies, total evaluations, denied, escalated
  • Create policy form — name, type picker, action selector, JSON config editor
  • Policy table — with ✓ON/✕OFF toggles and delete buttons
  • Test evaluation panel — simulate requests and see which policies fire, color-coded results
  • Evaluation logs — time, policy, operation, result, detail