Skip to main content

ActAuth (Python)

Part of LoopEngine — a runtime for defining and running AI agents through a transparent ReAct loop — handling rule-based permission gating (allow/ask/deny) with human-approval hooks. Works standalone too, no dependency on LoopEngine itself.

Reference implementation of the rule engine, scoped resolution, conditions, and audit log. See the root README for the product pitch and rule format; this file only covers what's specific to the Python package.

Install

pip install -e ".[dev]"

Quickstart

python examples/quickstart.py
import asyncio
from actauth import AuditLog, Gate, Scope

async def main():
    gate = Gate.from_config(
        "examples/actauth.yml",
        audit_log=AuditLog("actauth-audit.jsonl"),
    )
    scope = Scope(tenant="beta-fintech", environment="production", agent="payments-agent")
    result = await gate.evaluate("send_refund", {"amount": 5000}, scope)
    print(result.decision, result.reason)

asyncio.run(main())

Run the tests

pytest

Project layout

src/actauth/
  models.py       Decision, Scope, Rule, EvaluationResult
  conditions.py   safe {field, op, value} evaluator, no eval()
  rules.py        RuleSet — loads YAML, resolves scope + conditions
  audit.py        AuditLog — append-only JSONL
  approvers.py    Approver interface, ConsoleApprover, SlackApprover
  gate.py         Gate — ties the above together
examples/
  actauth.yml     example rule set
  quickstart.py   runnable end-to-end demo
tests/

Status

Rule engine, scoping, conditions, audit log, and SlackApprover are real and tested. No agent-SDK adapter yet.

ConsoleApprover

The default Approver — a blocking terminal prompt, useful for local dev and for exercising the full ask pipeline without standing up Slack:

from actauth import Gate
from actauth.approvers import ConsoleApprover

gate = Gate.from_config("actauth.yml", approver=ConsoleApprover())
# this is also the default if you omit `approver`

result = await gate.evaluate("send_refund", {"amount": 900}, scope)
# prints scope/tool/args/reason, then blocks on `approve? [y/N]`

SlackApprover

from actauth.approvers import SlackApprover

approver = SlackApprover(
    bot_token=os.environ["SLACK_BOT_TOKEN"],
    channel="#approvals",
    signing_secret=os.environ["SLACK_SIGNING_SECRET"],
)

# wire your own route for the Slack app's Interactivity Request URL:
@app.post("/slack/interactions")
async def slack_interactions(request):
    raw_body = await request.body()
    await approver.handle_interaction(
        raw_body.decode(),
        request.headers["x-slack-request-timestamp"],
        request.headers["x-slack-signature"],
    )
    return Response(status_code=200)

request_approval() posts an interactive Approve/Deny message and resolves when handle_interaction() is called with the matching click — verified against Slack's request signature, timing out (deny) after timeout_seconds (default 5 minutes) if nobody responds.

Download files

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

Source Distribution

actauth-0.0.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

actauth-0.0.4-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file actauth-0.0.4.tar.gz.

File metadata

  • Download URL: actauth-0.0.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.8

File hashes

Hashes for actauth-0.0.4.tar.gz
Algorithm Hash digest
SHA256 7fdb711dbd0539f289fe7dd5dc5865e7cf58a98014ca39f3749bd9c62ce81dec
MD5 bd2cf756a7c61ec76d95025264f0480a
BLAKE2b-256 b6de2e97608ca3898b16dac9d59f8ac6f7593e6f62e17f43035416db1724f058

See more details on using hashes here.

File details

Details for the file actauth-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: actauth-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.8

File hashes

Hashes for actauth-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6f2c109efe8198f43451d4d3e26f62dbdebc20b75a6b70d9abec091d9995df3a
MD5 7efee63456c56ce7bc6927fdfc2bf844
BLAKE2b-256 49a7a59074f96b37b533f7e853e472952f1edd18515ea35c93ecf65f5ee8ae74

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 Sentry Error logging StatusPage Status page