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)

Pass traceparent= (the W3C header value of the current trace) to any of the four calls and the gate logs its trace and span ids beside the decision, so the decision shows up next to your trace in your APM. A value that isn't a valid version-00 traceparent isn't sent, so it can't cause a refusal.

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.

Version 2 receipts

Gates since Archytan Lite 2.4 mint version 2 receipts, which also sign what each decision was made under: the SHA-256 of the gate's policy and callers files, the credential that asked (caller_id), the resource's tenant, the gate's mode and whether observe mode turned a refusal into an ALLOW, the caller's W3C trace id, and the receipt's id, instance, trace id and time. This client verifies both versions, each under its own signature tag, and refuses a receipt that claims a version it doesn't know, a v1 receipt that carries any v2 field, and a v2 receipt with any field changed. Clients older than 2.1 refuse v2 receipts, so upgrade them before the gate (or run the gate with ARCHYTAN_LITE_RECEIPT_VERSION=1 until you have).

Pass expected_policy_sha256= (the hex SHA-256 of the policy file you expect the gate to run) and an ALLOW is accepted only if the receipt says the gate decided under exactly that policy; a v1 receipt, which records no policy, is refused. Name the tenant on the request (resource={"type": ..., "id": ..., "tenant_id": ...}) and a v2 receipt for any other tenant is refused too.

Client 2.2 adds holds, for gate 2.9 and later; against an older gate it behaves exactly as 2.1 did.

Holds: waiting for a person to approve

Archytan Lite 2.9 can hold an action until a person approves it. A policy that holds an action makes the gate answer HTTP 202 with decision: "HOLD" instead of an ALLOW. For a caller that means: nothing may happen yet. authorize returns that as a denied result with held=True:

AuthorizeResult(allowed=False, held=True, reason="held_for_approval",
                hold=Hold(hold_id=..., expires_at=...), receipt=<the signed HOLD receipt>)

allowed stays False until a verified approval arrives. A 202 only counts as a hold if its receipt verifies under your idempotency key, says HOLD and matches your request; any other 202 is an ordinary denial with held=False.

To wait for the answer, call wait_for_hold (or wait_for_hold_async) with the same arguments as authorize plus max_wait (seconds, default 60) and poll_interval (seconds, default 2):

from archytan_lite import wait_for_hold, redeem_capability

result = wait_for_hold(
    url=URL, token=CALLER_TOKEN, gate_public_key_hex=GATE_PUBLIC_KEY,
    action="invoice.refund", actor={"uid": "user_1"},
    resource={"type": "invoice", "id": "inv_7"},
    idempotency_key=key, max_wait=300,
)
if not result.allowed:
    ...  # result.held is True here when nobody answered in time
spent = redeem_capability(
    url=URL, token=CALLER_TOKEN, capability_token=result.capability.token,
    action="invoice.refund", resource={"type": "invoice", "id": "inv_7"},
)

It polls GET /v1/holds/{id} with your token until the hold is no longer open or the deadline passes (the earlier of max_wait and the hold's expiry plus two seconds), then repeats the authorize call once to collect. A failed poll is retried until the deadline, and it never raises for gate behavior.

An approval returns allowed=True with the resolution receipt (receipt, which names the approver), the HOLD receipt (hold_receipt) and a capability. It is checked differently from an ordinary ALLOW: the HOLD receipt must verify and match your request, and the resolution must be signed under the key "hold:" + hold_receipt["receipt_id"], name the same action and resource, and come with a capability. Anything else is a denial.

The capability's lifetime starts when you collect it (30 seconds by default), not when the person approved, so redeem it right away. If the approval was not collected in time the gate answers 410 and you need a new request with a new idempotency key.

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.2.0

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.2.0
File Size Uploaded Provenance Actions
archytan_lite-2.2.0.tar.gz 29.6 kB Without provenance Details for archytan_lite-2.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 49.9 kB

Release files / archytan_lite-2.2.0.tar.gz

Download URL archytan_lite-2.2.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1aa402b66b6e773acb6d458a59b3dd9bb54e1c24a818782fe0241d00e3826498
BLAKE2b-256 checksum
How to use checksums
5477e0eef7de13fbe66ffbe5a7480cb9589de63037d98c3bde8a42f196747336
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.2.0-py3-none-any.whl

Download URL archytan_lite-2.2.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e6a8c1a16536094d8a090d1064088ccda2a9b5a0871b9d49ea1b362b8a93a7c
BLAKE2b-256 checksum
How to use checksums
c12ff3242ea409145c21729537898bbc34f1f96e401a853c30b70373ee117e77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for archytan-lite 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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