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>
92 lines
2.5 KiB
Python
92 lines
2.5 KiB
Python
"""
|
|
Information Spaces package for MarkiTect.
|
|
|
|
This package provides the Information Space abstraction, enabling:
|
|
- First-class space entities with identity, metadata, and lifecycle
|
|
- Event-driven change tracking and notifications
|
|
- Persistent transclusion context with cross-space references
|
|
- HTML rendering with caching and theme support
|
|
- Bidirectional directory synchronization
|
|
- Composable space hierarchies
|
|
|
|
Package Structure:
|
|
- models: Core domain models (InformationSpace, SpaceDocument, SpaceConfig)
|
|
- events: Event system (SpaceEvent, EventBus, handlers)
|
|
- repositories: Data access layer (ISpaceRepository, SqliteSpaceRepository)
|
|
- transclusion: Persistent transclusion context and reference tracking
|
|
- rendering: Space rendering (HTML, themes)
|
|
- sync: Directory synchronization (export, import, bidirectional)
|
|
- services: Business logic (SpaceService)
|
|
- history: Optional git-based version control
|
|
|
|
Usage:
|
|
from markitect.spaces import SpaceService, InformationSpace
|
|
|
|
service = SpaceService()
|
|
space = await service.create_space("my-docs")
|
|
await service.add_document(space, "/intro.md", content="# Intro")
|
|
await service.render(space, output_dir="./html/")
|
|
"""
|
|
|
|
# Phase 1: Foundation
|
|
from .models import (
|
|
InformationSpace,
|
|
SpaceDocument,
|
|
SpaceConfig,
|
|
SpaceMetadata,
|
|
SpaceVariable,
|
|
TransclusionReference,
|
|
SpaceStatus,
|
|
)
|
|
from .services import SpaceService
|
|
from .repositories import (
|
|
ISpaceRepository,
|
|
IDocumentAssociationRepository,
|
|
IVariableRepository,
|
|
IReferenceRepository,
|
|
SqliteSpaceRepository,
|
|
SqliteDocumentRepository,
|
|
SqliteVariableRepository,
|
|
SqliteReferenceRepository,
|
|
initialize_space_tables,
|
|
)
|
|
|
|
# Phase 2: Event System
|
|
from .events import (
|
|
SpaceEvent,
|
|
SpaceEventType,
|
|
EventBus,
|
|
get_event_bus,
|
|
reset_event_bus,
|
|
)
|
|
|
|
__all__ = [
|
|
# Models
|
|
"InformationSpace",
|
|
"SpaceDocument",
|
|
"SpaceConfig",
|
|
"SpaceMetadata",
|
|
"SpaceVariable",
|
|
"TransclusionReference",
|
|
"SpaceStatus",
|
|
# Services
|
|
"SpaceService",
|
|
# Repository Interfaces
|
|
"ISpaceRepository",
|
|
"IDocumentAssociationRepository",
|
|
"IVariableRepository",
|
|
"IReferenceRepository",
|
|
# SQLite Implementations
|
|
"SqliteSpaceRepository",
|
|
"SqliteDocumentRepository",
|
|
"SqliteVariableRepository",
|
|
"SqliteReferenceRepository",
|
|
"initialize_space_tables",
|
|
# Event System
|
|
"SpaceEvent",
|
|
"SpaceEventType",
|
|
"EventBus",
|
|
"get_event_bus",
|
|
"reset_event_bus",
|
|
]
|