Skip to content

Governance

Governance gives you observability and control over AI agent actions. Define rules that match tool calls, choose whether to observe, warn, or deny, and review everything in a detailed audit log.

Open the Governance page from the dashboard sidebar, or navigate to http://localhost:{port}/governance.

AI coding agents are powerful, but that power comes with risk. An agent might accidentally delete critical files, expose secrets, or make changes you didn’t expect. Governance helps you:

  • Observe all tool calls across all agents in one place
  • Detect risky patterns with regex-based rules
  • Block dangerous operations before they happen (in enforce mode)
  • Audit historical activity for compliance and debugging

Governance has two modes:

ModeBehavior
ObserveRules are evaluated, but deny/warn actions are downgraded to observe. Tool calls are never blocked. Safe for rollout.
EnforceDeny rules block tool calls in real time. Warn rules allow the call but show a warning to the agent.

Rules define what to watch for. Each rule can match on:

  • Tool name — The tool being called (e.g., Bash, Write, * for all)
  • Input pattern — A regex matched against the serialized tool input
  • Path pattern — An fnmatch pattern matched against the file_path field

When a rule matches, it triggers one of four actions:

ActionEffect (Enforce Mode)Effect (Observe Mode)
DenyBlock the tool call, show message to agentLog only (downgraded)
WarnAllow call, warn the agentLog only (downgraded)
ObserveLog onlyLog only
AllowExplicit allow, stop evaluating further rulesAllow

Rules are evaluated in order. The first matching rule wins.

Block destructive shell commands:

id: no-destructive-bash
description: Block rm -rf and similar dangerous commands
enabled: true
tool: Bash
pattern: "rm\\s+-rf|DROP\\s+TABLE|truncate\\s+"
action: deny
message: "This command is blocked by governance policy."

Block writes to .env files:

id: no-env-writes
description: Prevent modification of environment files
enabled: true
tool: Write
path_pattern: "*.env*"
action: deny
message: "Writing to .env files is not allowed."

Observe all file operations:

id: observe-file-ops
description: Log all file system activity
enabled: true
tool: "*"
pattern: "file_path"
action: observe
  1. Go to Governance → Rules
  2. Click Add Rule
  3. Fill in the rule fields:
    • Rule ID — Lowercase with dashes (e.g., no-env-writes)
    • Description — Human-readable explanation
    • Action — Deny, Warn, or Observe
    • Tool name — Which tool to match (* for all)
    • Input pattern — Optional regex
    • Path pattern — Optional fnmatch for file paths
    • Agent message — Shown to the agent on deny/warn
  4. Click Add Rule
  5. Click Save to persist changes

The Audit Log tab shows every governance evaluation. Each event includes:

  • Decision — Allow, Deny, Warn, or Observe
  • Tool — Which tool was called
  • Category — Tool category (filesystem, shell, network, agent, other)
  • Rule — Which rule matched (if any)
  • Session — Link to the full session
  • Time — When the evaluation occurred

Use the filter panel to narrow down events:

  • Decision — Show only allow, deny, warn, or observe events
  • Tool — Filter by tool name (e.g., Bash)
  • Time range — Last hour, 24 hours, 7 days, 30 days, or all time

Click any event to expand it and see full details: agent, session, enforcement mode, evaluation time, matched pattern, and a summary of the tool input.

The top of the Audit Log shows aggregate stats for the last 7 days:

  • Total events
  • Breakdown by decision (Allow, Observe, Warn, Deny)

Use these to quickly understand what’s happening across your agents.

Governance settings are stored in your project’s .oak/config.yaml:

codebase_intelligence:
governance:
enabled: true
enforcement_mode: observe # or "enforce"
log_allowed: false # if true, log allow decisions too (verbose)
retention_days: 30 # how long to keep audit events
rules:
- id: no-destructive-bash
description: Block destructive shell commands
enabled: true
tool: Bash
pattern: "rm\\s+-rf"
action: deny
message: "Blocked by governance policy."
SettingDefaultDescription
enabledfalseWhether governance evaluation is active
enforcement_modeobserveobserve (log only) or enforce (can block)
log_allowedfalseLog allow decisions too (can be verbose)
retention_days30Days to keep audit events before pruning (1–365)
rules[]List of governance rules

Each rule has these fields:

FieldRequiredDescription
idYesUnique identifier (lowercase, dashes only)
descriptionNoHuman-readable description
enabledNoWhether the rule is active (default: true)
toolNoTool name or glob pattern (default: *)
patternNoRegex matched against serialized tool input
path_patternNofnmatch pattern for file paths
actionNoallow, deny, warn, or observe (default: observe)
messageNoMessage shown to agent on deny/warn

Governance automatically categorizes tools for filtering and analysis:

CategoryTools
FilesystemRead, Write, Edit, Glob, Grep
ShellBash
NetworkWebFetch, WebSearch
AgentTask
OtherEverything else

Audit events are automatically pruned based on the retention_days setting. You can also trigger manual pruning:

  1. Go to Governance → Rules
  2. Click the Prune button next to Audit Retention

This removes all events older than the configured retention period.

Governance works with all agents that support the PreToolUse hook:

AgentGovernance Support
Claude CodeFull (deny via hookSpecificOutput)
CursorFull (deny via permission format)
Gemini CLIFull (deny via hookSpecificOutput)
VS Code CopilotFull (deny via hookSpecificOutput)
WindsurfObserve only (no deny hook support)
OpenCodeFull (deny via hookSpecificOutput)
Codex CLIObserve only

Agents that don’t support deny hooks will have deny/warn rules logged but not enforced, even in enforce mode.

Before enabling enforce mode, test your rules against hypothetical tool calls:

  1. Go to Governance → Rules
  2. Find the Test Policy panel
  3. Enter a tool name (e.g., Bash)
  4. Enter tool input as JSON (e.g., {"command": "rm -rf /"})
  5. Click Test

The result shows which rule would match and what action would be taken.

  1. Start with observe mode — Get visibility before enforcement
  2. Review the audit log regularly — Look for unexpected patterns
  3. Use specific patterns — Avoid overly broad rules that block legitimate work
  4. Test rules before enforcing — Use the Test Policy feature
  5. Document your rules — Add clear descriptions so teammates understand the intent
  6. Set reasonable retention — 30 days is a good default; increase if you need longer audit trails