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.2.1.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.2.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_safe_spl-0.2.1.tar.gz
  • Upload date:
  • Size: 10.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.2.1.tar.gz
Algorithm Hash digest
SHA256 5b345439e5f35a00ce6bc21daebdec04ba6a342e598eda7a221d775fc1b38d83
MD5 fcbd007bd33d04c5e7943da154718926
BLAKE2b-256 354c98af3ccc240d727e994ec7895bdaa5a5d4c449743daed2d1007060f71508

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: agent_safe_spl-0.2.1-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.7

File hashes

Hashes for agent_safe_spl-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 069fbc6582064de94ac1dd28efa490ef218c31a530cb6b34a544fd002298c87d
MD5 9503e981dd62d9c5beb0544ff654cafd
BLAKE2b-256 9ebf29025781bc580f9297e78463274e1b415aab5ff815bf67f11c7ecd82d9d8

See more details on using hashes here.

Provenance

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