Skip to main content

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, and log_only
  • Support observe mode via mode: observe or observe_only: true
  • Write local JSONL audit events with redacted args and context
  • Provide a sync, typed EnforraClient.run_tool(...) API

Supported Policy Fields

  • version
  • mode
  • observe_only
  • defaults.decision
  • policies[].id
  • policies[].priority
  • policies[].match.agent
  • policies[].match.tool
  • policies[].decision
  • policies[].conditions

Supported Condition Operators

  • eq
  • neq
  • gt
  • gte
  • lt
  • lte
  • contains
  • not_contains

Conditions can be expressed as:

  • A flat list where every condition must pass
  • all groups
  • any groups
  • Combined all and any groups

Observe Mode

In observe mode, matched block and require_approval decisions are shadowed to an effective decision of allow. The audit log includes:

  • enforcement_mode
  • observed_decision
  • effective_decision
  • shadow
  • observe_mode

Development

python3 -m pytest

Metadata

Release files for enforra 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enforra 0.1.0
File Size Uploaded
enforra-0.1.0.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for enforra 0.1.0
File Interpreter ABI Platform
enforra-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / enforra-0.1.0.tar.gz

Download URL enforra-0.1.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8edb29ee5a322b7bddbdde2b7e8b056dad16328d2e07a80871d742a45d0cdad8
BLAKE2b-256 checksum
How to use checksums
444c66f37a0e59d42949f5f87671695b04baeb68ef358d9add2da5ea8f34efd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release files / enforra-0.1.0-py3-none-any.whl

Download URL enforra-0.1.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5daf119a9d70934c995b1b9614f6f118d401b0eebf600f3283959fb83da7da5a
BLAKE2b-256 checksum
How to use checksums
d639b1d86958013c960dd409110672d17cac18c978fc9f165fef16e898b63a5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page