Week 4 - Event Infrastructure: - Create SpaceEventType enum with 18 event types covering space lifecycle, document operations, variables, references, rendering, sync, and cache - Create SpaceEvent dataclass with serialization/deserialization - Create EventBus with sync/async handler support, priority ordering, global handlers, and optional event history - Add event factory functions for common events Week 5 - Event Integration: - Wire EventBus into SpaceService as optional dependency - Emit events for all space operations: - SPACE_CREATED, SPACE_UPDATED, SPACE_DELETED, SPACE_ACTIVATED, SPACE_ARCHIVED - DOCUMENT_ADDED, DOCUMENT_REMOVED, DOCUMENT_MOVED, DOCUMENT_CONTENT_CHANGED - VARIABLE_SET, VARIABLE_DELETED - Create integration tests for event propagation patterns Test coverage: 187 tests total - 43 unit tests for event system - 20 integration tests for event propagation - 124 existing tests continue to pass Capabilities delivered: - CAP-010: SpaceEvent base with type, payload, timestamp - CAP-011: EventBus with in-process publish/subscribe - CAP-012: Event handlers registry with priority support - CAP-013: Change detection via content hash comparison Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
"""
|
|
Event system for Information Spaces.
|
|
|
|
This package provides event-driven architecture for space operations:
|
|
- SpaceEvent: Event dataclass with type, payload, timestamp
|
|
- SpaceEventType: Enum of all event types
|
|
- EventBus: In-process publish/subscribe for space events
|
|
- Event factory functions for common events
|
|
|
|
Events emitted:
|
|
- Space lifecycle: SPACE_CREATED, SPACE_UPDATED, SPACE_DELETED, SPACE_ACTIVATED, SPACE_ARCHIVED
|
|
- Document: DOCUMENT_ADDED, DOCUMENT_UPDATED, DOCUMENT_REMOVED, DOCUMENT_MOVED, DOCUMENT_CONTENT_CHANGED
|
|
- Variable: VARIABLE_SET, VARIABLE_DELETED
|
|
- Reference: REFERENCE_ADDED, REFERENCE_CLEARED
|
|
- Rendering: RENDER_STARTED, RENDER_COMPLETED, RENDER_FAILED
|
|
- Sync: SYNC_STARTED, SYNC_COMPLETED, SYNC_CONFLICT
|
|
- Cache: CACHE_INVALIDATED
|
|
"""
|
|
|
|
from .models import (
|
|
SpaceEvent,
|
|
SpaceEventType,
|
|
space_created_event,
|
|
space_updated_event,
|
|
space_deleted_event,
|
|
document_added_event,
|
|
document_updated_event,
|
|
document_removed_event,
|
|
document_content_changed_event,
|
|
cache_invalidated_event,
|
|
)
|
|
from .bus import (
|
|
EventBus,
|
|
HandlerRegistration,
|
|
get_event_bus,
|
|
reset_event_bus,
|
|
)
|
|
|
|
__all__ = [
|
|
# Event models
|
|
"SpaceEvent",
|
|
"SpaceEventType",
|
|
# Event factories
|
|
"space_created_event",
|
|
"space_updated_event",
|
|
"space_deleted_event",
|
|
"document_added_event",
|
|
"document_updated_event",
|
|
"document_removed_event",
|
|
"document_content_changed_event",
|
|
"cache_invalidated_event",
|
|
# Event bus
|
|
"EventBus",
|
|
"HandlerRegistration",
|
|
"get_event_bus",
|
|
"reset_event_bus",
|
|
]
|