Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AI Governance

Cowboy constrains what an agent can do through several independent mechanisms. They overlap deliberately: a command rejected by one layer is not relied upon to be caught by another.

LayerWhereWhat it does
Approvalsbridge / Redishold outbound messages for a human reaction
Egress allowlistsecrets proxyrestrict HTTP methods and destinations, inject credentials
Sheepdogseccomp sandboxenforce file/network/exec rules at the syscall level

This page summarizes how they are configured. There is no runtime rule engine or FilterAction-style API in the harness — governance is the sum of the mechanisms below. Command, path, and syscall enforcement is done by sheepdog at the kernel boundary (see below), not by a separate string-matching filter layer.

Approvals (human in the loop)

For outbound messages that should not be sent autonomously, the bridge approval protocol holds a message until a human reacts to a notification. Configure it per bridge:

services.cowboy.bridges.discord.approval = {
  required = true;
  notify = "discord";
  notify_channel = "<channel-id>";
  timeout = 3600;
};

Approval state is tracked in Redis hashes and resolved from human reactions. See Approvals & Outbox for the full protocol.

Egress allowlist (secrets proxy)

In the managed proxy deployment, network rules route HTTP through the proxy and the agent uses placeholder provider credentials. Local and ordinary Docker launches hold credentials instead. With egress control enabled, GET, HEAD and OPTIONS pass the method gate; every other method needs an allowed destination or receives HTTP 403. TRACE receives HTTP 403 everywhere, whatever the allowlist or egress setting, because a server that echoes it would return the injected credential. Allowed requests can still change external state or disclose readable data. See Security Model.

services.cowboy.secretsProxy = {
  enable = true;
  domainMappings = {
    "api.anthropic.com" = {
      secretPath = "/run/agenix/anthropic-key";
      headerName = "x-api-key";
    };
  };
  # Extra write-allowed domains. Domains in domainMappings are implicitly
  # write-allowed.
  allowedWriteDomains = [ "github.com" "api.github.com" "*.githubusercontent.com" ];

  # Prefer an exact grant when a whole host does not need write access.
  allowedWriteRoutes = [ {
    scheme = "https";
    hostname = "api.example.com";
    port = 443;
    path = "/v1/messages";
    methods = [ "POST" ];
    contentTypes = [ "application/json" ];
    queryPolicy = "forbid";
  } ];
  # Networks the proxy refuses to connect to. Setting this replaces the
  # default (link-local, which holds most clouds' metadata services, and AWS's
  # IPv6 metadata address), so keep those entries. This adds the home LAN.
  deniedNetworks = [ "169.254.0.0/16" "fe80::/10" "fd00:ec2::254/128" "192.168.0.0/16" ];
  # Empty means any destination not denied. When non-empty, only these
  # networks are reachable. Deny wins over allow.
  allowedNetworks = [ ];
};

allowedWriteRoutes is additive with the backward-compatible allowedWriteDomains list. Each structured entry is exact: it has no hostname wildcards and a write must match its scheme, destination hostname, explicit port, normalized path, method, and media type. queryPolicy = "forbid" rejects any query string; "allow" permits arbitrary query parameters. The proxy fails startup on malformed policy and refuses ambiguous paths (including raw, encoded, or double-encoded dot segments and encoded separators), rather than letting an upstream server normalize them into a different route. Content type parameters such as charset do not affect the media-type comparison.

Because every domainMappings key is still implicitly copied to allowedWriteDomains for compatibility, use allowedWriteRoutes for hosts that are not also credential mappings when route-level narrowing is required.

The proxy connects from the host’s network namespace, so these two options bound what an agent reaches from the host. By default, only link-local and AWS’s IPv6 metadata address are refused. Loopback and private networks stay reachable, so agents can use local services and each other. The proxy judges the address a name resolves to and the peer it actually connected to. Routes in passthroughPorts and sshDestinations bypass the proxy and this policy.

The allowlist enforcement lives in the mitmproxy addon (proxy/addon.py); write methods, legacy wildcard-domain checks, exact structured route checks and the destination policy are implemented there. See Security Model.

Sheepdog (seccomp sandbox)

Sheepdog enforces file, network, and exec rules at the syscall level rather than by string matching. Rules are verb-granular — Bash, Read, Edit, Create, Delete, and Connect — and resolve to allow or deny, with optional runtime-granted exceptions (lazy permissions) taking precedence over baked-in denies.

services.cowboy.sheepdog = {
  enable = true;
  lazyPerms = true;   # allow runtime permission grants
};

services.cowboy.agents.alice.sheepdog = {
  extraDeny  = [ "Read(/home/alice/workspace/credentials/**)" ];
  extraAllow = [ "Bash(make)" ];
  extraBlockedSyscalls = [ "keyctl" ];
  extraReadonlyPaths   = [ "/home/alice/workspace/vendor" ];
  extraMaskedPaths     = [ "/proc/interrupts" ];
};

Each extra* option adds to a shipped baseline. The baseline already lets the agent read, edit, create and delete under its own home directory (/home/alice here), which is where managed tools run, and blocks the sandbox-escape syscalls and /proc paths.

Setting deny, allow, blockedSyscalls, readonlyPaths or maskedPaths instead replaces that baseline. Evaluation fails if a replacement drops a shipped deny rule, blocked syscall, masked path or read-only path that is not named in dropBaseline. A replacement allow list that drops shipped rules is only a warning, but every dropped rule is a tool or path the agent loses.

Sheepdog is Linux-only. See crates/sheepdog/src/policy.rs and modules/options/sheepdog.nix.

See also

Plan state is advisory

The agent can call update_plan_state to record an objective, tasks, blockers and the next step. Each task is pending, in progress or completed. Updates replace the supplied fields, keep at most one task in progress and record an update timestamp.

The state is saved as plan_state.json in the session directory and loaded on resume. Each update_plan_state result echoes the whole plan, including up to eight tasks, and the model reads its current plan there. While such a result is in the conversation, the model’s transient context packet leaves the plan out and says where it is. Once compaction has removed the result, the packet carries the plan instead. The packet is added to the conversation when its content changes, and the latest one is current. For controlled experiments the plan_packet launch setting changes this: append puts every changed plan in a new packet and keeps the older ones, and rewrite does the same but keeps only the latest packet. Neither echoes the plan in the result. The default is transcript, the behaviour described above.

The first wake after at least an hour without a model request, when the prompt cache has likely expired, adds a note with the plan. The note asks the agent to check the plan against what is left and to update it if it is stale. See Compaction.

This is a memory aid, not an approval gate. Plan state does not restrict the tool list, impose a read-only planning phase or enforce that actions follow the listed tasks. Use bridge approvals and host policy for enforced controls.