Skip to main content

Open-source policy-as-code runtime for AI agent guardrails, capability control, tool call governance, MCP tool governance, and auditable runtime policy

Project description

Brane Core

Brane Core is an open-source policy-as-code runtime for AI agent guardrails. It governs tool calls, model calls, MCP tools, database queries, memory, retrieval, file access, secrets, and other agent actions before they execute.

Use Brane when you need runtime control for production AI agents: tool call governance, MCP tool governance, tenant isolation, read-only database policies, refund limits, high-risk action blocking, and audit-ready decision traces.

Brane lets a developer declare capabilities, write central Python policies, intercept agent actions, allow or deny those actions, and inspect local audit events.

This alpha is intentionally small: sync Python callables, local memory/JSONL audit, and allow/deny policy decisions.

Why Brane

Most agent guardrails focus on prompts or model outputs. Brane focuses on what the agent does.

An AI agent action can issue a refund, run SQL, call an external API, invoke an MCP tool, write memory, read a secret, open a file, call a model, or delegate to another agent. Brane evaluates policy at that action boundary:

Capability + AgentAction + PolicyContext -> Policy -> Decision

That makes Brane useful as:

  • AI agent guardrails
  • AI agent safety
  • Capability control for AI agents
  • Policy control for AI agents
  • Policy-as-code for AI agents
  • Tool call governance for AI agents
  • MCP tool governance
  • Runtime control for agent actions
  • Auditable allow/deny decisions for production agents

Install

pip install -e .

Quickstart

import brane

runtime = brane.Runtime(
    agent_id="support-agent",
    environment="prod",
    audit_path=".brane/audit/events.jsonl",
)

@runtime.capability(name="refund_customer", type="tool", risk="high")
def refund_customer(customer_id: str, amount_usd: float):
    return {"status": "refunded", "amount_usd": amount_usd}

@runtime.before_capability("refund_customer")
def refund_policy(ctx):
    if ctx.arg("amount_usd") > 100:
        return brane.deny("Refund above $100 requires approval")
    return brane.allow()

refund_customer("cus_123", 50)
refund_customer("cus_123", 500)

The second call raises brane.CapabilityDeniedError and writes an audit event with the action id, capability, policy, decision, and outcome.

Answer Guides

These guides explain Brane in the category language search engines and AI agents look for:

Decorator Capabilities

Use @runtime.capability(...) when you own the Python function.

@runtime.capability(name="send_email", type="tool", risk="medium")
def send_email(to: str, body: str):
    return {"status": "sent"}

Brane registers the capability and returns an enforcing wrapper. The original function is available as send_email.__brane_original__ for adapter code that needs direct execution after creating an explicit InterceptRequest.

Wrapper Capabilities

Use runtime.wrap_capability(...) when the function comes from another package or framework.

def web_search(query: str):
    return {"results": []}

safe_web_search = runtime.wrap_capability(
    web_search,
    name="web_search",
    type="tool",
    risk="low",
)

Policy Decorators

Policies receive a PolicyContext. They can inspect the normalized action, capability metadata, runtime metadata, input arguments, output, tenant, principal, environment, effect, side effects, and scopes.

@runtime.before_capability("*", priority=0)
def tenant_boundary(ctx):
    input_tenant = ctx.arg("tenant_id")
    if input_tenant and ctx.tenant_id and input_tenant != ctx.tenant_id:
        return brane.deny("Cross-tenant action blocked")
    return brane.allow()

before_capability policies run before execution when the interception request stage is before_capability. after_capability policies run after execution when the request stage is after_capability.

Audit Logs

Use audit_path for JSONL audit:

runtime = brane.Runtime(
    agent_id="support-agent",
    audit_path=".brane/audit/events.jsonl",
)

Or use an in-memory sink for tests and demos:

audit = brane.InMemoryAuditSink()
runtime = brane.Runtime(agent_id="support-agent", audit=audit)

Supported alpha outcomes:

  • denied_before_execution
  • executed
  • denied_after_execution
  • execution_failed

Run Examples

python agents/support_refund_agent.py
python agents/enterprise_ops_agent.py
python agents/planner_driven_agent.py

The planner-driven example is the clearest alpha demo: a fake planner emits runtime action plans, a generic executor routes them through Brane, and central policies block large refunds, cross-tenant actions, billing ledger reads, and unsafe customer-visible emails.

Alpha Limitations

  • Sync callables only
  • Allow/deny only
  • Local audit only
  • No approvals yet
  • No cloud yet
  • No LangGraph adapter yet
  • No async yet
  • No secret broker yet

Project details


Download files

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

Source Distribution

brane_core-0.1.0a2.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

brane_core-0.1.0a2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file brane_core-0.1.0a2.tar.gz.

File metadata

  • Download URL: brane_core-0.1.0a2.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brane_core-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 7d3cc2eaa7e72130d994bab548d4e7438cafc20ccfdb729cac49b779263fba8a
MD5 3e273dea45f89423ab7611edd4fcd1cc
BLAKE2b-256 af86668b4ae79df483dfa2195338ed6e71d27eabb81b7e2365486564e21644b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for brane_core-0.1.0a2.tar.gz:

Publisher: publish.yml on MembraneLabs/brane-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brane_core-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: brane_core-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brane_core-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 d07d0f29c66fb6ecfd49e5d4a50d8010b25f636f5b3c461987be9536ddcb51e7
MD5 5e4f161b32963c9ea198462279a643b1
BLAKE2b-256 ea9d76324e8dc1f9e8d9fe8a9f9b3962c6f38bd0f370c9450f819628f0ae8583

See more details on using hashes here.

Provenance

The following attestation bundles were made for brane_core-0.1.0a2-py3-none-any.whl:

Publisher: publish.yml on MembraneLabs/brane-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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