Skip to content

events

diapason.core.events

Thread-safe pub/sub event bus for inter-primitive telemetry.

Extends IPW's EventRecorder into a full publish/subscribe system so that any primitive can emit events (e.g. INFERENCE_END) and any other primitive can react without direct coupling.

Event dataclass

A single event published on the bus.

EventBus

Thread-safe publish/subscribe event bus.

Subscribers are called synchronously in registration order within the publishing thread. An optional record_history flag retains all published events for later inspection (useful in tests/telemetry).

history property

Return a copy of all recorded events (empty if recording is off).

clear_history()

Discard all recorded events.

publish(event_type, data=None)

Create and dispatch an event to all subscribers.

Returns the published Event instance.

subscribe(event_type, callback)

Register callback to be called whenever event_type is published.

unsubscribe(event_type, callback)

Remove callback from listeners for event_type.

EventType

Bases: str, Enum

Supported event categories.

get_event_bus(*, record_history=False)

Return the module-level EventBus singleton, creating it if needed.

reset_event_bus()

Replace the singleton with a fresh instance (for tests).