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

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_safe_spl-0.2.0.tar.gz
  • Upload date:
  • Size: 10.8 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.0.tar.gz
Algorithm Hash digest
SHA256 6fd4d2661c5980794510e6bca0964109708c1baf5d84b80f2d4c8204d5937c8c
MD5 f334772739f4d9e75cea45a5d2b89e9d
BLAKE2b-256 a061b9c7a5713ec067abf77fc5eb617e549a88fb3d73618b2183a1886da9d35a

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for agent_safe_spl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca05aee2209829e8d8ebb36d70ecb4c1d5d381b416c6ec13fff604ce19ac8539
MD5 19e45a0ec75a36ed18a231ef10a62811
BLAKE2b-256 8f2101c25c32afd61134fa93d53d81062385de3f06965e24aaad10310ef3adab

See more details on using hashes here.

Provenance

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