julee.domain.repositories ========================= .. py:module:: julee.domain.repositories .. autoapi-nested-parse:: Repository protocols for julee domain. This module exports all repository protocol interfaces for the Capture, Extract, Assemble, Publish workflow, following the Clean Architecture patterns established in the Fun-Police framework. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/julee/domain/repositories/assembly/index /autoapi/julee/domain/repositories/assembly_specification/index /autoapi/julee/domain/repositories/base/index /autoapi/julee/domain/repositories/document/index /autoapi/julee/domain/repositories/document_policy_validation/index /autoapi/julee/domain/repositories/knowledge_service_config/index /autoapi/julee/domain/repositories/knowledge_service_query/index /autoapi/julee/domain/repositories/policy/index Classes ------- .. autoapisummary:: julee.domain.repositories.AssemblyRepository julee.domain.repositories.AssemblySpecificationRepository julee.domain.repositories.BaseRepository julee.domain.repositories.DocumentPolicyValidationRepository julee.domain.repositories.DocumentRepository julee.domain.repositories.KnowledgeServiceConfigRepository julee.domain.repositories.KnowledgeServiceQueryRepository julee.domain.repositories.PolicyRepository Package Contents ---------------- .. py:class:: AssemblyRepository Bases: :py:obj:`julee.domain.repositories.base.BaseRepository`\ [\ :py:obj:`julee.domain.models.Assembly`\ ], :py:obj:`Protocol` Handles assembly storage and retrieval operations. This repository manages Assembly entities within the Capture, Extract, Assemble, Publish workflow. Each Assembly produces a single assembled document. Inherits common CRUD operations (get, save, generate_id) from BaseRepository. .. py:class:: AssemblySpecificationRepository Bases: :py:obj:`julee.domain.repositories.base.BaseRepository`\ [\ :py:obj:`julee.domain.models.assembly_specification.AssemblySpecification`\ ], :py:obj:`Protocol` Handles assembly specification storage and retrieval operations. This repository manages AssemblySpecification entities within the Capture, Extract, Assemble, Publish workflow. Specifications define how to assemble documents of specific types, including JSON schemas and knowledge service query configurations. Inherits common CRUD operations (get, save, generate_id) from BaseRepository. .. py:class:: BaseRepository Bases: :py:obj:`Protocol`\ [\ :py:obj:`T`\ ] Generic base repository protocol for common CRUD operations. This protocol defines the common interface shared by all domain repositories in the system. It uses generics to provide type safety while eliminating code duplication. Type Parameter: T: The domain entity type (must extend Pydantic BaseModel) .. py:method:: generate_id() :async: Generate a unique entity identifier. This operation is non-deterministic and must be called from workflow activities, not directly from workflow code. :returns: Unique entity ID string .. rubric:: Implementation Notes - Must generate globally unique identifiers - May use UUIDs, database sequences, or distributed ID generators - Should be fast and reliable - Failure here should be rare but handled gracefully .. rubric:: Workflow Context In Temporal workflows, this method is implemented as an activity to ensure the generated ID is durably stored and consistent across workflow replays. .. py:method:: get(entity_id) :async: Retrieve an entity by ID. :param entity_id: Unique entity identifier :returns: Entity if found, None otherwise .. rubric:: Implementation Notes - Must be idempotent: multiple calls return same result - Should handle missing entities gracefully (return None) - Loads complete entity with all relationships .. py:method:: get_many(entity_ids) :async: Retrieve multiple entities by ID. :param entity_ids: List of unique entity identifiers :returns: Dict mapping entity_id to entity (or None if not found) .. rubric:: Implementation Notes - Must be idempotent: multiple calls return same result - Should handle missing entities gracefully (return None for missing) - Implementations may optimize with batch operations or fall back to individual get() calls - Keys in returned dict correspond exactly to input entity_ids - Missing entities have None values in the returned dict .. rubric:: Workflow Context In Temporal workflows, this method is implemented as an activity to ensure batch operations are durably stored and consistent across workflow replays. .. py:method:: list_all() :async: List all entities. :returns: List of all entities in the repository .. rubric:: Implementation Notes - Must be idempotent: multiple calls return same result - Returns empty list if no entities exist - Should return entities in a consistent order (e.g., by ID) - For large datasets, consider pagination at the use case level .. rubric:: Workflow Context In Temporal workflows, this method is implemented as an activity to ensure the list operation is durably stored and consistent across workflow replays. .. rubric:: Default Implementation Base protocol provides a default that returns empty list. Repository implementations should override this method as needed. .. note:: This default implementation returns empty list to avoid breaking existing repositories. Specific repositories should implement proper list_all() functionality as needed. .. py:method:: save(entity) :async: Save an entity. :param entity: Complete entity to save .. rubric:: Implementation Notes - Must be idempotent: saving same entity state is safe - Should update the updated_at timestamp - Must save complete entity with all relationships - Handles both new entities and updates to existing ones .. py:class:: DocumentPolicyValidationRepository Bases: :py:obj:`julee.domain.repositories.base.BaseRepository`\ [\ :py:obj:`julee.domain.models.policy.DocumentPolicyValidation`\ ], :py:obj:`Protocol` Handles document policy validation storage and retrieval operations. This repository manages DocumentPolicyValidation entities within the Capture, Extract, Assemble, Publish workflow. These entities track the complete lifecycle of validating documents against policies, including initial validation scores, transformation results, and final outcomes. Inherits common CRUD operations (get, save, generate_id) from BaseRepository. .. py:class:: DocumentRepository Bases: :py:obj:`julee.domain.repositories.base.BaseRepository`\ [\ :py:obj:`julee.domain.models.Document`\ ], :py:obj:`Protocol` Handles document storage and retrieval operations. This repository manages the core document storage and metadata operations within the Capture, Extract, Assemble, Publish workflow. Inherits common CRUD operations (get, save, generate_id) from BaseRepository. The save method handles both content and metadata storage atomically. .. py:class:: KnowledgeServiceConfigRepository Bases: :py:obj:`julee.domain.repositories.base.BaseRepository`\ [\ :py:obj:`julee.domain.models.knowledge_service_config.KnowledgeServiceConfig`\ ], :py:obj:`Protocol` Handles knowledge service configuration persistence. This repository manages knowledge service metadata and configuration storage within the Capture, Extract, Assemble, Publish workflow. External service operations are handled separately by the service layer. Inherits common CRUD operations (get, save, generate_id) from BaseRepository. .. py:class:: KnowledgeServiceQueryRepository Bases: :py:obj:`julee.domain.repositories.base.BaseRepository`\ [\ :py:obj:`julee.domain.models.assembly_specification.KnowledgeServiceQuery`\ ], :py:obj:`Protocol` Handles knowledge service query persistence and retrieval. This repository manages the storage and retrieval of KnowledgeServiceQuery domain objects within the Capture, Extract, Assemble, Publish workflow. These queries define how to extract specific data using external knowledge services during assembly. Inherits common CRUD operations (get, save, generate_id) from BaseRepository. .. py:class:: PolicyRepository Bases: :py:obj:`julee.domain.repositories.base.BaseRepository`\ [\ :py:obj:`julee.domain.models.Policy`\ ], :py:obj:`Protocol` Handles policy storage and retrieval operations. This repository manages Policy entities within the Capture, Extract, Assemble, Publish workflow. Policies define validation criteria and optional transformations for documents in the quality assurance process. Inherits common CRUD operations (get, save, generate_id) from BaseRepository.