Local-first capability policy runtime for AI agents
Project description
Brane Core
Brane Core is a local-first capability policy runtime for Python agent tools. It lets a developer declare capabilities, write central policies, intercept tool calls, allow or deny actions, and inspect local audit events.
This alpha is intentionally small: sync Python callables, local memory/JSONL audit, and allow/deny policy decisions.
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.
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_executionexecuteddenied_after_executionexecution_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brane_core-0.1.0a0.tar.gz.
File metadata
- Download URL: brane_core-0.1.0a0.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b000021ef50e085731a9878dc7f3f878b8b3a6755d77df277d1aa0023d9a9f0
|
|
| MD5 |
c5eca3faa44c718077cc30f324015723
|
|
| BLAKE2b-256 |
4a0aa2fe1af09ebb61e53f6a9fb1609d7fd9eda5b7581f06773631801f6aaca0
|
Provenance
The following attestation bundles were made for brane_core-0.1.0a0.tar.gz:
Publisher:
publish.yml on MembraneLabs/brane-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brane_core-0.1.0a0.tar.gz -
Subject digest:
8b000021ef50e085731a9878dc7f3f878b8b3a6755d77df277d1aa0023d9a9f0 - Sigstore transparency entry: 1458817948
- Sigstore integration time:
-
Permalink:
MembraneLabs/brane-core@df6b4d6656a2f1d46d2625ff685026266fcdd9e4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MembraneLabs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df6b4d6656a2f1d46d2625ff685026266fcdd9e4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file brane_core-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: brane_core-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab0516c53f12fc124927ac1fe107d30b9168885eefffefcd53a1df207955d2ca
|
|
| MD5 |
8e3c846519f5107d9ed108ebe86a9b8b
|
|
| BLAKE2b-256 |
8e124885c5ce3a30088f3f47148fb67179c3baad2d8e8978f458af33dfe46dea
|
Provenance
The following attestation bundles were made for brane_core-0.1.0a0-py3-none-any.whl:
Publisher:
publish.yml on MembraneLabs/brane-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brane_core-0.1.0a0-py3-none-any.whl -
Subject digest:
ab0516c53f12fc124927ac1fe107d30b9168885eefffefcd53a1df207955d2ca - Sigstore transparency entry: 1458818092
- Sigstore integration time:
-
Permalink:
MembraneLabs/brane-core@df6b4d6656a2f1d46d2625ff685026266fcdd9e4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MembraneLabs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df6b4d6656a2f1d46d2625ff685026266fcdd9e4 -
Trigger Event:
workflow_dispatch
-
Statement type: