Skip to main content
Attesta uses Python Protocol classes (structural sub-typing) to define the interfaces for its pluggable components. Any class that implements the required methods is accepted — no inheritance or registration needed. All protocols are decorated with @runtime_checkable, so you can use isinstance() checks at runtime.

RiskScorer

Assigns a continuous risk score in [0.0, 1.0] to an action.

Import

Required Methods

Implementing a Custom Scorer

Built-in Scorers

Attesta ships with several ready-to-use scorers in attesta.core.risk:
Python

Renderer

The UI/UX layer that presents gates, challenges, and status messages to the human operator. All methods are async.

Import

Required Methods

Implementing a Custom Renderer

Built-in Renderers

Python Attesta auto-detects the best renderer at runtime. If rich is installed and stdin is a TTY (interactive session), TerminalRenderer is used. Otherwise, Python falls back to _DefaultRenderer (auto-approve). In TypeScript, non-interactive mode defaults to deny unless you provide a renderer. You can always override behavior by passing an explicit renderer.

AuditLogger

Persists approval records for compliance and forensic analysis.

Import

Required Methods

Implementing a Custom Audit Logger

Built-in Audit Logger

The built-in AuditLogger in attesta.core.audit writes SHA-256 hash-chained entries to a JSONL file. See the Audit Trail concept page for details on the hash chain and verification.
Python

ChallengeProtocol

Defines a verification challenge that can be presented to an operator. This protocol is used internally by challenge implementations and is less commonly implemented by end users.

Import

Required Methods

Implementing a Custom Challenge

The ChallengeProtocol.present() method is async. Even if your challenge implementation is synchronous, you must declare it as an async method (or wrap it) to satisfy the protocol.

Protocol Compliance Checking

All Attesta protocols are @runtime_checkable, so you can verify compliance at runtime:
Python
Runtime isinstance() checks with @runtime_checkable protocols only verify that the required methods and properties exist on the object. They do not validate signatures, return types, or the async nature of methods. Use a type checker like mypy or pyright for full static verification.