# Governance

Governance applies policy gates to agent input, output and tool activity. Each organization has a policy catalogue, with assignments at organization, workspace or agent level. Its five categories are input safety, output safety, data protection, tool governance and rate limiting.

Polyant's governance gates automatically return `allow`, `warn` or `block`. The policy assignment determines how the verdict is applied. To add human approval to a workflow, configure the agent to ask a reviewer on a connected channel and wait for a reply before acting.

[Human oversight and approval](https://docs.polyant.ai/admin-panel/human-oversight-and-approval) shows how to set up that step in Slack. The Polyant site describes the [ten governance controls](https://polyant.ai/security/) that come with the managed profiles.

> **Managed services.** The governance engine is available with the Advanced and Ultra plans of Polyant managed services.

## Policy catalogue

The catalogue lists the policies available to the **organization**. It is org-scoped, not deployment-wide and not per-workspace: two organizations on the same engine keep separate catalogues, and every workspace inside one organization draws from its single catalogue. A policy records its name, description, category, severity, gate type, and level. Platform policies marked immutable cannot be edited or deleted.

It is addressed as the organization's own resource (`/api/organizations/{org}/governance/policies`), which is why it is governed by the **organization-tier** permissions rather than the agent-level ones.

The catalogue supports these policy categories:

- `input-safety`
- `output-safety`
- `data-protection`
- `tool-governance`
- `rate-limiting`

Reading the catalogue requires **`org.governance:read`** - which a Viewer holds, since reading the organization's policy list is consistent with a read-everything role. Creating, changing, or removing a mutable policy requires **`org.governance:write`**, which is Admin and above.

The agent-level `agent.governance:read` / `agent.governance:write` pair governs what an *agent* has assigned, not the organization's catalogue. The two are separate keys on purpose: an org-addressed route has no workspace to resolve a workspace-tier permission against, so gating the organization's catalogue on one agent's rights would let a Member reach the whole tenant's policy. See [Roles and permissions](https://docs.polyant.ai/reference/roles#two-tiers-of-permission).

## Governance analytics

The organization's [Monitor](https://docs.polyant.ai/admin-panel/activity) opens with a governance summary of the whole tenant: how often the gates fired over the selected period, with the trend and a comparison by agent. It is collapsed at first, shown only when the period holds events, and needs `org.governance:read`. The decisions themselves are listed in the Monitor below it.

Its tiles (**Total Events**, **Blocked**, **Warned**, **Block Rate**) draw each figure's daily shape and compare it with the previous period of the same length; the block rate moves in points. Through the API the governance overview carries the previous period's figures as `previousPeriod`, and the daily series counts `events`.

The aggregate for one workspace is available from the API (`GET /api/governance/analytics`, `agent.governance:read`); the panel has no separate workspace view. The old workspace address, `/organizations/{org}/workspaces/{ws}/governance`, opens the organization's policy catalogue.

## Apply a policy to the organization or a workspace

A catalogue policy can be applied once for many agents instead of agent by agent. On the organization's **Policy** page (`/organizations/{org}/governance`, the catalogue), the **Where it applies** button on a policy's row (a sliders icon) opens a sheet for one policy with two parts: **Apply to the whole organization**, and one **Apply to workspace {name}** switch per workspace. Each line says where the policy applies now (**Applied to:** the whole organization, named workspaces, a number of agents, or nobody), with its enforcement and a lock icon when it is locked.

For each level the policy is applied to, the sheet sets:

- **Enforcement** - `Block`, `Warn` or `Log`. A policy applied to a level for the first time starts on **Block**, since a rule set for many agents should hold from the start.
- The lock - **Allow a different value in workspaces and agents** on the organization, **Allow a different value for individual agents** on a workspace. It is on by default. Turned off, the levels below can neither switch the policy off nor change its enforcement.

When the organization's assignment is locked, workspaces cannot have a setting of their own for that policy, and the sheet says so.

The workspace's **Policies** page (`/organizations/{org}/workspaces/{ws}/settings/policy`, in its sidebar's *Governance* group) lists the organization's catalogue and, for each policy, whether it applies to that workspace. **Apply** (or **Edit**) opens the same sheet narrowed to the workspace. Every role can read the tab; the panel enables the controls with `org.governance:write`.

The agents below follow the assignment at once: nothing is copied into them, and which assignment applies is worked out each time it is read. Per policy, the most specific level wins (agent over workspace over organization), and a locked organization or workspace assignment stops the walk, so an agent assignment stored under it is kept but not applied. Platform policies sit under all three and are never locked, so an agent can still switch a platform policy off for itself. The runtime gates, the model card, the configuration snapshot and the status checks all read the same resolution, so what is enforced and what is reported cannot differ.

| Route | Permission |
|---|---|
| `GET /api/organizations/{org}/governance/policy-applications` | `org.governance:read` |
| `PUT`, `DELETE /api/organizations/{org}/governance/policies/{policyId}/assignment` | `org.governance:write` |
| `PUT`, `DELETE /api/organizations/{org}/governance/policies/{policyId}/workspaces/{ws}/assignment` | `org.governance:write` |
| `PUT`, `DELETE /api/organizations/{org}/workspaces/{ws}/governance/policies/{policyId}/assignment` | `agent.governance:write` in that workspace |

A `PUT` takes `{ "enforcement": "block", "enabled": true, "locked": false, "configOverride": {...} }`. A write under a lock above answers `409` with `code: "setting_locked"`; removing an assignment that a lock made inactive is always allowed. Every change is recorded in the [management audit log](https://docs.polyant.ai/admin-panel/audit-logs) as an assignment or an unassignment, with its level.

## Assign policies to an agent

Open an agent's **Policy** section, in its *Governance* group, to view the policies in force for it. Each one says where it comes from: **Platform**, **From the organization**, **From the workspace**, or nothing when the agent holds its own assignment. An assignment selects a catalogue policy and can set:

- **Enabled** - whether the policy participates in the agent's pipeline.
- **Enforcement** - `log`, `warn`, or `block`.
- **Configuration override** - agent-specific configuration that supplements the catalogue policy.

Assignments and governance analytics use the same `agent.governance:read` and `agent.governance:write` permissions. A policy can also be assigned platform-wide, in which case it cannot be removed from an individual agent, though the agent can switch it off for itself.

A policy inherited from the organization or the workspace shows its enforcement and state. Changing it on the agent makes an assignment of the agent's own, which starts from the inherited enforcement; **Back to the inherited value** removes it. A locked inherited policy shows **Locked** and its controls are closed (**Locked: it cannot be changed for this agent.**); a save that touches it is refused whole with `409` and `code: "setting_locked"`. An inherited assignment cannot be removed from the agent. A save of several policies is applied whole or not at all.

### Where the events are

The record of which gate actually *fired* is not in this section: it is in the agent's **Monitor** section, under *Activity*, together with the task and webhook runs. The workspace's and the organization's [Monitor](https://docs.polyant.ai/admin-panel/activity) list the same decisions across their agents. Both are a record of what happened rather than configuration, which is why they sit together and away from the rules they came from.

You open Policy to change a rule and Monitor to find out whether one fired - and the second is usually the question you arrive with when something looks wrong.

### Narrowing the event list

An agent's governance events (`GET /api/instances/{slug}/governance/events`) can be filtered by **conversation** (`conversationId`) and, within it, by **turn** (`messageId`) - the assistant message the event was raised on. Input, output and tool-phase events all carry that attribution, which is what makes "what did the gates do on this answer" a question with an answer rather than a scan of a timeline.

Two kinds of conversation are the exception: those driven by the [Room](https://docs.polyant.ai/admin-panel/room) and by webhook triggers. Those paths mint a fresh conversation per cycle and have no stable turn id to stamp on an event before the gates run - the assistant message is persisted, but the id is minted too late. Their events appear in the list and are attributable to the conversation, not to a turn.

## How enforcement works

Each gate runs in one pipeline phase:

- **Input** gates inspect a message before the model is called. A blocking result stops generation.
- **Tool** gates inspect a requested tool call before the tool executes. A blocking result prevents the call.
- **Output** gates inspect the generated response before it is delivered. A blocking result replaces the response with the governance block message.

Room cycles and webhook turns follow the same order as a chat turn: the conversation state a turn's tools wrote is committed after the output gates have checked the reply, and not at all when that check fails with an error.

The gate returns an `allow`, `warn`, or `block` verdict. Assignment enforcement determines how that verdict is applied: `log` records the result while allowing the pipeline to continue, `warn` surfaces a warning, and `block` preserves a blocking verdict.

### When the classifier itself fails

The three semantic gates - prompt injection, PII, topic guardrail - ask a model for a verdict, and they **fail open** on purpose: a broken classifier must not block legitimate traffic.

Failing open used to be indistinguishable from finding nothing. A timeout, a provider error and a model answering outside JSON all arrived as the same empty result, so the agent answered normally, no error was raised, the policy list still said *enabled*, and the only symptom was the **absence** of verdicts - which nothing counts.

Now the three causes are kept apart, and a gate that could not evaluate still allows but **records the allow**, marked as unevaluated and carrying its cause, beside the below-threshold verdicts already persisted. A policy that stopped working is therefore visible as rows rather than as a gap.

A policy that must never let unexamined content through can **fail closed** instead. Turn on **Block when it cannot check** on the policy's assignment in the agent's Policy section, or set `failClosed: true` in the policy's configuration or the assignment's override. With it on and the assignment's enforcement at `block`, a message the classifier could not evaluate - a classifier error, an outage, or a refused provider admission - is blocked rather than let through, and the event says the policy failed closed. Under `log` or `warn` enforcement the setting changes nothing. It is off by default, so every existing policy keeps failing open; turn it on only where blocking during a classifier outage is the lesser harm, since it stops the agent answering for as long as the classifier is down.

The `heavy` tier these gates run on is worth knowing about for the same reason: on a deployment where that model is unavailable in the region, all three stop gating with a single warning line. See [AI Gateway](https://docs.polyant.ai/concepts/ai-gateway#tier-abstraction-not-model-lock-in).

## Output gates and streaming

An enabled output gate requires the engine to buffer the response before delivery. The agent is therefore served non-streamed for that turn, allowing the output gate to redact or block text before any token reaches the client.

Use output gates when a response must be checked before it reaches a channel; use input and tool gates when the risk is in the request or requested action instead.
