EventBus allows external code to subscribe to lifecycle events emitted during the Attesta approval pipeline. Events are fired at key points — risk scoring, trust computation, challenge issuance, approval decisions, and audit logging — enabling integrations like webhooks, metrics, and custom logging.
EventType
TheEventType enum defines all lifecycle events emitted during the approval pipeline.
Import
Values
| Member | Value | Description |
|---|---|---|
RISK_SCORED | "risk_scored" | Emitted after the risk scorer produces a score. |
TRUST_COMPUTED | "trust_computed" | Emitted after the trust engine computes a trust score. |
CHALLENGE_ISSUED | "challenge_issued" | Emitted when a challenge is presented to the operator. |
CHALLENGE_COMPLETED | "challenge_completed" | Emitted when the operator completes a challenge. |
APPROVED | "approved" | Emitted when an action is approved. |
DENIED | "denied" | Emitted when an action is denied. |
ESCALATED | "escalated" | Emitted when timeout policy escalates an action. |
AUDIT_LOGGED | "audit_logged" | Emitted after an entry is written to the audit log. |
Event
A single lifecycle event emitted by the pipeline.Import
Fields
| Field | Type | Default | Description |
|---|---|---|---|
type | EventType | (required) | The kind of lifecycle event. |
timestamp | float | time.time() | Unix timestamp when the event was created. |
data | dict[str, Any] | {} | Arbitrary payload data associated with the event. |
Example
EventBus
Publish/subscribe event bus for pipeline lifecycle events. Thread-safe. Supports both sync and async handlers. Errors in handlers are caught and logged — they never break the pipeline.Import
Constructor
EventBus takes no constructor arguments. All state is managed internally.
on()
Subscribe a synchronous callback to an event type. Can be used as a decorator or called directly.Signature
| Parameter | Type | Description |
|---|---|---|
event_type | EventType | The event type to subscribe to. |
callback | EventHandler | None | The handler function. If None, returns a decorator. |
async_on()
Subscribe an async callback to an event type. Works identically toon() but for async handlers.
Signature
| Parameter | Type | Description |
|---|---|---|
event_type | EventType | The event type to subscribe to. |
callback | Callable | None | The async handler function. If None, returns a decorator. |
off()
Remove a callback from an event type’s subscription list.Signature
| Parameter | Type | Description |
|---|---|---|
event_type | EventType | The event type to unsubscribe from. |
callback | EventHandler | The handler to remove. |
emit()
Emit an event to all registered synchronous handlers. Errors in handlers are caught and logged.Signature
async_emit()
Emit an event to both sync and async handlers. Sync handlers are called first, then async handlers are awaited.Signature
clear()
Remove all handlers for all event types.Integration with Attesta
Pass anEventBus to the Attesta constructor to receive pipeline lifecycle events:
Webhooks
Send HTTP notifications for pipeline events
Audit Trail
Every event is also recorded in the audit log