Pre-release documentation. This guide describes the current product design and evaluation build. Packaging, availability and commercial terms may change before release.
Install and configure
The Python SDK supports Python 3.9 and later and has no required runtime dependencies beyond the standard library. The optional verify extra adds local receipt verification.
pip install avery-rulebook
# Optional offline receipt verification
pip install "avery-rulebook[verify]"
import os
from avery_rulebook import AveryClient
avery = AveryClient(
os.getenv("AVERY_URL", "http://localhost:7171"),
api_key=os.environ["AVERY_TOKEN"],
evidence_scope="evidence",
)Decide and handle every outcome
The Python client returns typed decision objects for the data plane. Control-plane resources such as rulebooks, templates, trust, settings and operations are available as attributes on the same client.
decision = avery.decide(
rulebook="data-handling",
action="customer_record.share",
facts={
"region": "EU",
"purpose": "support",
"partner_approved": True,
},
)
if decision.outcome == "yes":
print("Allowed", decision.envelope.receipt_id)
elif decision.outcome == "needs-review":
review = decision.needs_review
if review is None:
raise RuntimeError("Malformed needs-review response")
raise RuntimeError(
f"Review required: {review.missing_facts}"
)
else:
raise PermissionError(f"Action stopped: {decision.outcome}")Wrap a protected function
Create the hook once, then call it immediately before the protected operation. The returned arguments are the only arguments that may be forwarded because the gateway may have applied obligations or a transform.
guard = avery.gateway.hook(
caller={"agent": "agt_finance_01"},
context={"environment": "production"},
)
def issue_refund(order_id: str, amount: float):
checked = guard(
"payments.issue_refund",
{"order_id": order_id, "amount": amount},
)
result = payments.issue_refund(**checked["args"])
return {"result": result, "receipt_id": checked["receipt_id"]}Operational surfaces
- avery.rulebooks for documents, compilation, review, publication and versions
- avery.templates for framework templates and upgrades
- avery.trust for receipts, ledger activity, analytics and identity
- avery.gateway for explicit pre-action checks
- avery.ops for health, readiness, version and operation status