Skip to main content
The 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 an Attesta 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)
Legacy flat format — a simple key-value dict without structured sections:
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:
  • FileNotFoundError if the config file does not exist.
  • TypeError if the file does not contain a top-level mapping.
  • ImportError if pyyaml is not installed (install with pip 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:
The trust_engine is always inherited from the Attesta instance and cannot be overridden per-gate. This ensures consistent trust tracking across all gates.

evaluate() Method

The primary entry point for framework integrations. Runs the full approval pipeline for an ActionContext 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

Returns: A copy of the internal policy dict. Modifying the returned dict does not affect the instance.

CoreAttesta (Orchestrator)

The CoreAttesta 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

The evaluate() method on CoreAttesta executes these steps in order:
  1. Merge hints — Extra risk_hints are merged into ctx.hints
  2. Risk scoring — The risk scorer produces a 0-1 score and risk level
  3. Trust adjustment — If a trust engine is configured, the score is adjusted based on agent history (CRITICAL actions are never downgraded)
  4. Challenge selection — The risk level is mapped to a challenge type via the challenge map
  5. Verification — The challenge is presented through the renderer
  6. Minimum review time — Enforces min_review_seconds with asyncio.sleep
  7. Build result — Constructs the ApprovalResult
  8. Audit — Logs the result via the audit logger
  9. Update trust — Records the outcome in the trust engine
Python