Skip to main content

govern

A policy enforcement layer that sits between AI agents and the infrastructure they act on.

The design decision

Most agent-guardrail prototypes expose an audit() function the agent is supposed to call before doing something dangerous. That only works if the agent cooperates — which is exactly the assumption you cannot make. It's a logging convention, not a control.

govern wraps the client, the tool function, or the subprocess call instead. The agent doesn't get a choice about whether policy runs, because govern owns the only path to the resource.

Policy itself is data — a YAML file a customer can edit, review, and commit — not if statements in Python.

Install

pip install govern-agent
# or from source:
pip install -e .

Try it

govern demo                  # scripted agent hitting a production policy
govern init                  # write govern.yaml into the current repo
govern policy                # show the active policy
govern check s3:DeleteBucket prod-billing --env production
govern log --blocked-only

Use it

import boto3, govern

govern.init(agent_id="cost-optimizer", environment="production")

s3 = govern.guard(boto3.client("s3"), service="s3")
s3.list_buckets()                          # allowed
s3.delete_bucket(Bucket="prod-billing")    # raises PolicyViolation

Three interception points:

# 1. wrap a client — method calls become "<service>:<Operation>"
client = govern.guard(some_sdk_client, service="k8s")

# 2. decorate a tool the agent can call
@govern.guarded("db:DropTable", resource=lambda a, k: k["table"])
def drop_table(table): ...

# 3. replace subprocess.run
govern.run("terraform apply -auto-approve")

Policy

version: 1
default_effect: deny

rules:
  - id: deny-destructive-prod
    effect: deny
    severity: critical
    description: Never let an agent destroy production resources.
    actions: ["*:Delete*", "*:Destroy*", "*:Terminate*"]
    resources: ["*"]
    environments: ["production", "prod"]

Matching is glob-based across three fields (actions, resources, environments). Precedence is deny > require_approval > allow; anything matching no rule falls through to default_effect. Policy is discovered like .gitGOVERN_POLICY env var, then govern.yaml walking up from cwd, then the bundled default.

Modes

  • enforce (default) — denied actions raise PolicyViolation
  • monitor — nothing is blocked, but everything that would have been is flagged in the audit log and session summary

Monitor mode is how you get a new customer to say yes: run it for a week, show them what their agents actually tried to do, then turn on enforce.

Approvals

govern.init("migration-bot", "production", approval=govern.prompt_approval)

Any rule with effect: require_approval calls the handler. The default handler denies, since there's usually no human attached to an agent run.

Audit log

Every decision is appended as JSONL to .govern/audit.jsonl (override with GOVERN_AUDIT_LOG). An unwritable log never takes the agent down.

Status

v0.1.0 prototype. The API is intentionally small so the core idea can move without breaking the surface.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

govern_agent-0.1.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

govern_agent-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file govern_agent-0.1.0.tar.gz.

File metadata

  • Download URL: govern_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for govern_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b9c0d6349a13e53db303737f07674d29e69d9bd862889a7106021cd7c05db21
MD5 714d821bd7f74f6562463582d9f10b30
BLAKE2b-256 96e47dbb832d6ddf7b102a0ab03c1518d58b907601596eb76a649343ad357547

See more details on using hashes here.

File details

Details for the file govern_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: govern_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for govern_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 003dcc062fdeefa83ffdba871830904238afe568c03eed725c113dbfabead914
MD5 cc535c70fbdbda8ccfa14bd5ab371f0a
BLAKE2b-256 bbe00ecfc82fe6f918c986d11c26c7616081d525f38ae28e285a9b04825a4a0c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page