Skip to main content

archytan-lite (Python)

Fail-closed Python client for the Archytan Lite authorization gate — see high-archy.tech.

pip install archytan-lite

Run the gate

This package is the client; the gate runs as a Docker image on your own infrastructure. The quickstart starts one and walks through a signed ALLOW, a BLOCK and a single-use capability in about a minute, checking every answer as it goes:

curl -fsSLO https://raw.githubusercontent.com/High-ArchyTech-Solutions/archytan-lite-community/main/quickstart/quickstart.sh
bash quickstart.sh

Examples, JSON Schemas, release notes and issues live in archytan-lite-community.

The rule this client enforces

Only an HTTP 200 whose body has decision == "ALLOW", and a receipt whose Ed25519 signature verifies against the gate's public key, and a receipt that describes this request counts as authorized.

Everything else is denied: a non-200, a timeout, a refused connection, a malformed body, a signature that doesn't verify, a receipt for some other action, the gate process being dead.

Nothing here raises for a denial. A denial arrives as allowed=False, never as an exception — an exception is something a caller can forget to catch, and a forgotten except around an authorization check fails open.

Use

from uuid import uuid4
from archytan_lite import authorize, redeem_capability

result = authorize(
    url="http://archytan-lite:8421",
    token=CALLER_TOKEN,
    gate_public_key_hex=GATE_PUBLIC_KEY,   # the hex `keygen` printed
    action="invoice.delete",
    actor={"uid": "user_1"},               # see "Roles" below
    resource={"type": "invoice", "id": "inv_7"},
    idempotency_key=str(uuid4()),
)
if not result.allowed:
    raise PermissionError(result.reason)

authorize_async and redeem_capability_async are the async forms. They share their decision logic with the sync versions rather than reimplementing it — two copies is how a sync path and an async path end up disagreeing about what "authorized" means, with only one of them audited.

Roles

Omit actor["role"] when the gate runs credential-bound roles. In that mode your role is a property of your credential, resolved server-side, and a role asserted in the request that disagrees with it is treated as an escalation attempt and refused. The receipt comes back carrying the role the gate resolved.

Send actor["role"] only against a gate configured with a single shared token, which has no other way to learn one. When you do send it, this client checks the receipt agrees with it.

Capabilities

When the gate has capabilities enabled, an ALLOW carries a single-use grant scoped to exactly one action on one resource, expiring in seconds. Holding it is not permission to act — spend it immediately before acting:

spent = redeem_capability(
    url="http://archytan-lite:8421",
    token=CALLER_TOKEN,
    capability_token=result.capability.token,
    action="invoice.delete",
    resource={"type": "invoice", "id": "inv_7"},
)
if not spent.redeemed:
    raise PermissionError(spent.reason)   # expired, out of scope, or already spent

delete_invoice("inv_7")

A second redemption of the same capability is refused, so an actuator cannot be driven to act twice on one authorization.

AI agent frameworks

pip install "archytan-lite[langchain]"

ArchytanGuardedTool wraps a function so an agent cannot reach it without the gate authorizing the call and the capability being spent first:

from archytan_lite.integrations.langchain import ArchytanGuardedTool

delete_invoice_tool = ArchytanGuardedTool(
    name="delete_invoice",
    description="Permanently delete an invoice by id.",
    action="invoice.delete",
    resource_type="invoice",
    func=really_delete_invoice,          # reached only after ALLOW + redemption
    gate_url="http://archytan-lite:8421",
    caller_token=AGENT_TOKEN,
    gate_public_key_hex=GATE_PUBLIC_KEY,
    actor_uid="agent-invoices",
)

It is a LangChain BaseTool, which LangGraph and CrewAI both accept, so one integration covers all three.

A denial returns an explanation to the agent rather than raising, because a raised exception inside an agent loop is usually swallowed and retried — the agent should be told it was refused, in text it can reason about, so it stops rather than loops.

What this cannot do for you: nothing stops your code from importing the underlying function and calling it directly. The wrapper makes the guarded path the easy one and the unguarded path a deliberate act; it is not a sandbox.

Contract siblings

This client, clients/node/index.js, and the authorize() helper in testing/failclosed/failclosed_test.go are the same contract in three languages. If you change the decision logic in one, change it in the others.

How it checks a receipt

The gate signs intent_hash, not the fields printed beside it. So before trusting the signature, this client recomputes intent_hash from the receipt's fields plus the idempotency key it sent, reproducing Go's encoding/json output exactly (HTML escapes, U+2028/U+2029, control characters, raw UTF-8 for everything else), and pinned to clients/testdata/intent_vectors.json, which is generated from the Go code. Without that step an intermediary could pair a genuine signature with rewritten fields. verify_receipt(receipt, gate_public_key_hex, idempotency_key) exposes the same check for a stored receipt; verify_receipt_signature alone does not prove the fields were signed.

Metadata

Release files for archytan-lite 2.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for archytan-lite 2.0.3
File Size Uploaded
archytan_lite-2.0.3.tar.gz 17.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for archytan-lite 2.0.3
File Interpreter ABI Platform
archytan_lite-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / archytan_lite-2.0.3.tar.gz

Download URL archytan_lite-2.0.3.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fd5c1b298a62a22e24ad38e073b4127a5bd9882b31fd92c2e0341bcd5b186b59
BLAKE2b-256 checksum
How to use checksums
690d36117d2de6a2847eeecc5f6a090da7a1d9a5c409e9b57ff1302db8c488ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / archytan_lite-2.0.3-py3-none-any.whl

Download URL archytan_lite-2.0.3-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
453e4c210e2dd51880f56260addf806dd6288fffbfb17c4a5c4c9cefca67d28c
BLAKE2b-256 checksum
How to use checksums
184183dfdc2f7f70d935f3ca7076f3d7ddbbcf1a9ac9a0422517cf632ad25c2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

2.1.1

2 release files

2.1.0

2 release files

This release

2.0.3 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page