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.3.0.tar.gz (10.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.3.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agent_safe_spl-0.3.0.tar.gz
Algorithm Hash digest
SHA256 50dedd7c1f15d2cda080063a4590dc572258aa4a54435fd41f015e60279afa50
MD5 cdc578ac56cf826f7ca342d8991b80f3
BLAKE2b-256 c994fc3a2651b97df115d617ed59a7f83fbafa65b6fecf105b64456a3795ac97

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_safe_spl-0.3.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.3.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for agent_safe_spl-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0d6d29f7de6c492e978330e5c68f74786ea42761aaf771e4f9ba8e95c51bb10
MD5 fcde8457aad99228d89e8b11a073997f
BLAKE2b-256 8d617a841ac2cb944acddc7ec06e750c03654777e7b5caa26e4605f69d1ea121

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_safe_spl-0.3.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