Skip to main content

Ritta · mandates

Español · English · Português

Ritta le pone límites a la inteligencia artificial cuando gasta tu plata: vos decís hasta cuánto puede pagar un agente y en qué, cada pago se verifica contra esa regla antes de ejecutarse, y todo queda registrado. La plata nunca pasa por Ritta.

Este repo es la librería open source (Apache 2.0) del mandato: el permiso firmado que dice "este agente puede gastar hasta X, en Y, en nombre de Z". Es compatible con AP2 (Agent Payments Protocol) y se usa con el gateway para pagar con Mercado Pago, Pix y USDC.

pip install ritta
from ritta import Limits, Mandate, Scope, generate_keypair, sign, verify

private_key, public_key = generate_keypair()

mandate = Mandate(
    issuer="did:web:farmacia-central.com.ar",
    subject="agent:compras-01",
    limits=Limits(total=15_000_000, per_operation=5_000_000, currency="ARS"),  # centavos
    scope=Scope(merchants=["MP-123456"], categories=["pharmacy"]),
    hitl_threshold=1_000_000,  # desde $10.000 se pide aprobación humana (lo aplica el gateway)
    state="open",
    expires_in_days=30,
)
token = sign(mandate, private_key)  # SD-JWT firmado con Ed25519

result = verify(
    token,
    public_key,
    amount=120_000,          # en centavos; sale del catálogo del comercio, nunca del modelo
    merchant="MP-123456",
    category="pharmacy",
    remaining=15_000_000,    # saldo sin gastar, lo aporta el ledger del gateway
)
assert result.ok

Si el pago no está autorizado, result.ok es False y result.reason dice por qué: invalid_signature, expired, amount_over_per_operation, amount_over_remaining, merchant_not_allowed, category_not_allowed o malformed.

verify es pura: no usa red ni guarda estado. Misma entrada, misma salida (pasá now= para fijar el reloj).

Las claves se exportan e importan en PEM con ritta.mandates.private_key_to_pem, public_key_to_pem, load_private_key_pem y load_public_key_pem. Nunca guardes una clave privada en el repositorio.

Documentación: ritta.dev. La especificación del formato está en docs/spec-mandate.md.

Estado

Pre-alpha (0.2.0). Etapa 1 del roadmap: ver docs/roadmap.md.

Publicación (mantenedores)

Las versiones se publican en PyPI como ritta solo desde un release de GitHub con tag v* (por ejemplo v0.2.0, que tiene que coincidir con version en pyproject.toml). Lo hace .github/workflows/publish.yml con trusted publishing: no hay tokens de PyPI en los secretos del repo.

Configuración, una sola vez:

  1. En pypi.org, con la cuenta dueña del proyecto: Your account → Publishing → Add a new pending publisher (o, si el proyecto ya existe, Manage → Publishing).
  2. Completar: PyPI project name ritta, owner ritta-io, repository mandates, workflow name publish.yml, environment name pypi.
  3. En GitHub, Settings → Environments del repo ritta-io/mandates: crear el environment pypi (conviene agregar required reviewers para aprobar cada publicación).
  4. Publicar: actualizar version y CHANGELOG.md, mergear a main, y crear el release con tag vX.Y.Z desde la pestaña Releases.

Licencia

Apache 2.0.

Metadata

Release files for ritta 0.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 ritta 0.2.0
File Size Uploaded Provenance Actions
ritta-0.2.0.tar.gz 95.9 kB With provenance Details for ritta-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ritta 0.2.0
File Interpreter ABI Platform Actions
ritta-0.2.0-py3-none-any.whl Python 3 none any Details for ritta-0.2.0-py3-none-any.whl

Total release size: 108.9 kB

Release files / ritta-0.2.0.tar.gz

Download URL ritta-0.2.0.tar.gz
Size 95.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a1680cf1cde7f08100ca0feba947020866c4f24ab08f213d1a3b3337be0e8de5
BLAKE2b-256 checksum
How to use checksums
14d10f35223b2afd06ee03b47bc11ac23eaa98b1857649820825d23a39ddfa3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / ritta-0.2.0-py3-none-any.whl

Download URL ritta-0.2.0-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1eaaae4f7a2a69ffbb6036c0862eb17163ec74a903858ded7f5a85e0e1d25261
BLAKE2b-256 checksum
How to use checksums
8da042a2796b473a76e01a96b21b8b475586aa6badf17b783efeb69a686372a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for ritta 0.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ritta-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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