Local-first Python SDK for Enforra OSS tool-call enforcement.
Project description
enforra
Local-first Python SDK for Enforra OSS.
Install
From this repository:
python3 -m pip install -e ".[dev]"
Usage
from enforra import EnforraClient
client = EnforraClient(
policy_path="policies/starter/support-agent.yaml",
audit_path=".enforra/audit.jsonl",
agent="support-agent",
)
result = client.run_tool(
tool_name="stripe.refund",
args={"amount": 75, "customer_id": "cus_123"},
handler=lambda: {"refund_id": "ref_123", "status": "succeeded"},
context={"environment": "production"},
)
Features
- Load local YAML policies with
version: 1 - Evaluate
allow,block,require_approval, andlog_only - Support observe mode via
mode: observeorobserve_only: true - Write local JSONL audit events with redacted args and context
- Provide a sync, typed
EnforraClient.run_tool(...)API
Supported Policy Fields
versionmodeobserve_onlydefaults.decisionpolicies[].idpolicies[].prioritypolicies[].match.agentpolicies[].match.toolpolicies[].decisionpolicies[].conditions
Supported Condition Operators
eqneqgtgteltltecontainsnot_contains
Conditions can be expressed as:
- A flat list where every condition must pass
allgroupsanygroups- Combined
allandanygroups
Observe Mode
In observe mode, matched block and require_approval decisions are shadowed to an effective
decision of allow. The audit log includes:
enforcement_modeobserved_decisioneffective_decisionshadowobserve_mode
Development
python3 -m pytest
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
enforra-0.1.0.tar.gz
(13.7 kB
view details)
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
enforra-0.1.0-py3-none-any.whl
(12.1 kB
view details)
File details
Details for the file enforra-0.1.0.tar.gz.
File metadata
- Download URL: enforra-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8edb29ee5a322b7bddbdde2b7e8b056dad16328d2e07a80871d742a45d0cdad8
|
|
| MD5 |
d69c2c18194af7ec84c0dbff29510742
|
|
| BLAKE2b-256 |
444c66f37a0e59d42949f5f87671695b04baeb68ef358d9add2da5ea8f34efd9
|
File details
Details for the file enforra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: enforra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5daf119a9d70934c995b1b9614f6f118d401b0eebf600f3283959fb83da7da5a
|
|
| MD5 |
b699c86c5568bad0c8c343eeda9566d2
|
|
| BLAKE2b-256 |
d639b1d86958013c960dd409110672d17cac18c978fc9f165fef16e898b63a5b
|