Attesta class is the recommended high-level entry point for production use. It holds shared defaults for risk scoring, rendering, audit logging, and trust that are applied to every gate created from the instance.
Constructor
Parameters (Python)
Parameters (TypeScript)
Recognized Policy Keys
from_config()
Class method that loads configuration from a YAML file. This is the recommended way to create anAttesta instance in production.
Config Format Detection
from_config() auto-detects two configuration formats:
Rich format (preferred) — contains policy:, risk:, or trust: top-level sections:
attesta.yaml (rich format)
attesta.yaml (legacy format)
When using the rich format,
from_config() automatically initializes a TrustEngine, domain-aware risk scorer, AuditLogger, and TerminalRenderer (if rich is installed) based on the configuration sections. You do not need to wire these up manually.Signature
Returns: A fully configured
Attesta instance.
Raises:
FileNotFoundErrorif the config file does not exist.TypeErrorif the file does not contain a top-level mapping.ImportErrorifpyyamlis not installed (install withpip install attesta[yaml]).
gate() Method
Decorator factory that creates gated functions using this instance’s defaults. Supports the same three calling styles as the module-level@gate.
Parameters
All parameters from the module-level@gate are supported. Per-gate values override instance defaults. The following parameters are resolved from the instance if not explicitly provided:
evaluate() Method
The primary entry point for framework integrations. Runs the full approval pipeline for anActionContext and returns an ApprovalResult. Unlike the @gate decorator, this method does not raise AttestaDenied — the caller is responsible for checking the verdict.
Signature
Returns: An
ApprovalResult containing the verdict, risk assessment, challenge result, and audit entry ID.
The
evaluate() method is async. In synchronous code, use asyncio.run(attesta.evaluate(ctx)) or the @gate decorator which handles the async bridging automatically.policy Property
Returns a shallow copy of the active policy dictionary. Useful for inspecting the resolved configuration.Python
Signature
CoreAttesta (Orchestrator)
TheCoreAttesta class (importable as from attesta import CoreAttesta) is the low-level orchestrator that executes the full approval pipeline for a single action. Each @gate decorator creates one internally. You rarely need to use it directly.
Pipeline Steps
Theevaluate() method on CoreAttesta executes these steps in order:
- Merge hints — Extra
risk_hintsare merged intoctx.hints - Risk scoring — The risk scorer produces a 0-1 score and risk level
- Trust adjustment — If a trust engine is configured, the score is adjusted based on agent history (CRITICAL actions are never downgraded)
- Challenge selection — The risk level is mapped to a challenge type via the challenge map
- Verification — The challenge is presented through the renderer
- Minimum review time — Enforces
min_review_secondswithasyncio.sleep - Build result — Constructs the
ApprovalResult - Audit — Logs the result via the audit logger
- Update trust — Records the outcome in the trust engine
Python