feat(spaces): implement Phase 2 Event System
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>
This commit is contained in:
@@ -3,14 +3,55 @@ 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 handlers and registration
|
||||
- Event factory functions for common events
|
||||
|
||||
Events emitted:
|
||||
- SPACE_CREATED, SPACE_UPDATED, SPACE_DELETED
|
||||
- DOCUMENT_ADDED, DOCUMENT_UPDATED, DOCUMENT_REMOVED
|
||||
- RENDER_COMPLETED, SYNC_COMPLETED
|
||||
- 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
|
||||
"""
|
||||
|
||||
# Events will be implemented in Phase 2
|
||||
__all__ = []
|
||||
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",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user