Skip to main content

SPL (Safe Policy Lisp) evaluator for Agent-Safe capability tokens. 150 lines, zero deps, microseconds.

Project description

Agent-Safe SPL — Python SDK

Python implementation of the SPL (Safe Policy Lisp) evaluator for Agent-Safe capability tokens.

Install

pip install -e .               # core (zero runtime deps)
pip install -e ".[crypto]"     # with Ed25519/Merkle/hash-chain support
pip install -e ".[dev]"        # with test dependencies

Usage

As a library

from spl import parse, verify

policy = parse('(and (= (get req "action") "read") (<= (get req "amount") 100))')
request = {"action": "read", "amount": 50}
env = {
    "vars": {},
    "per_day_count": lambda action, day: 0,
    "crypto": {
        "dpop_ok": lambda: True,
        "merkle_ok": lambda t: True,
        "vrf_ok": lambda d, a: True,
        "thresh_ok": lambda: True,
    },
}

result = verify(policy, request, env)
print("ALLOW" if result["allow"] else "DENY")

As a CLI

python -m spl examples/policies/family_gifts.spl examples/requests/gift_50_niece.json
# → ALLOW

Tests

pip install -e ".[dev]"
pytest tests/ -v

Requirements

  • Python 3.10+
  • Zero runtime dependencies for core evaluator
  • cryptography package optional for real Ed25519 verification

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

agent_safe_spl-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

agent_safe_spl-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file agent_safe_spl-0.1.0.tar.gz.

File metadata

  • Download URL: agent_safe_spl-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agent_safe_spl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 65c5d8b07bc7ae2fb5e01f4c83a2b14c94a52683dd50c3c033602bdee79ef9c8
MD5 93f51c375c3547e17aeaa8b7a29dd91f
BLAKE2b-256 0505b783863e1a880fa465d6551eaabb29930046cbd6b759ee68d2bb23f55eb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_safe_spl-0.1.0.tar.gz:

Publisher: publish.yml on jmcentire/agent-safe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_safe_spl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agent_safe_spl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agent_safe_spl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18ea5f1631979619a9d2712cca372fd640d6ab7aaf9afbadf7bf23a793931955
MD5 be79bec6375de130b97ff950509c5349
BLAKE2b-256 11c7f44d80c9c6a617ab4e62066cf74f29584693304c22d9d5e2af5445dd25a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_safe_spl-0.1.0-py3-none-any.whl:

Publisher: publish.yml on jmcentire/agent-safe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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