Skip to main content

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, 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

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

enforra-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

enforra-0.1.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

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

Hashes for enforra-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8edb29ee5a322b7bddbdde2b7e8b056dad16328d2e07a80871d742a45d0cdad8
MD5 d69c2c18194af7ec84c0dbff29510742
BLAKE2b-256 444c66f37a0e59d42949f5f87671695b04baeb68ef358d9add2da5ea8f34efd9

See more details on using hashes here.

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

Hashes for enforra-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5daf119a9d70934c995b1b9614f6f118d401b0eebf600f3283959fb83da7da5a
MD5 b699c86c5568bad0c8c343eeda9566d2
BLAKE2b-256 d639b1d86958013c960dd409110672d17cac18c978fc9f165fef16e898b63a5b

See more details on using hashes here.

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