julee.domain.repositories

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

Classes

AssemblyRepository

Handles assembly storage and retrieval operations.

AssemblySpecificationRepository

Handles assembly specification storage and retrieval operations.

BaseRepository

Generic base repository protocol for common CRUD operations.

DocumentPolicyValidationRepository

Handles document policy validation storage and retrieval operations.

DocumentRepository

Handles document storage and retrieval operations.

KnowledgeServiceConfigRepository

Handles knowledge service configuration persistence.

KnowledgeServiceQueryRepository

Handles knowledge service query persistence and retrieval.

PolicyRepository

Handles policy storage and retrieval operations.

Package Contents

class julee.domain.repositories.AssemblyRepository[source]

Bases: julee.domain.repositories.base.BaseRepository[julee.domain.models.Assembly], 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.

class julee.domain.repositories.AssemblySpecificationRepository[source]

Bases: julee.domain.repositories.base.BaseRepository[julee.domain.models.assembly_specification.AssemblySpecification], 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.

class julee.domain.repositories.BaseRepository[source]

Bases: Protocol[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)

async generate_id()[source]

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

Return type:

str

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

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.

async get(entity_id)[source]

Retrieve an entity by ID.

Parameters:

entity_id (str) – Unique entity identifier

Returns:

Entity if found, None otherwise

Return type:

T | None

Implementation Notes

  • Must be idempotent: multiple calls return same result

  • Should handle missing entities gracefully (return None)

  • Loads complete entity with all relationships

async get_many(entity_ids)[source]

Retrieve multiple entities by ID.

Parameters:

entity_ids (list[str]) – List of unique entity identifiers

Returns:

Dict mapping entity_id to entity (or None if not found)

Return type:

dict[str, T | None]

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

Workflow Context

In Temporal workflows, this method is implemented as an activity to ensure batch operations are durably stored and consistent across workflow replays.

async list_all()[source]

List all entities.

Returns:

List of all entities in the repository

Return type:

list[T]

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

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.

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.

async save(entity)[source]

Save an entity.

Parameters:

entity (T) – Complete entity to save

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

class julee.domain.repositories.DocumentPolicyValidationRepository[source]

Bases: julee.domain.repositories.base.BaseRepository[julee.domain.models.policy.DocumentPolicyValidation], 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.

class julee.domain.repositories.DocumentRepository[source]

Bases: julee.domain.repositories.base.BaseRepository[julee.domain.models.Document], 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.

class julee.domain.repositories.KnowledgeServiceConfigRepository[source]

Bases: julee.domain.repositories.base.BaseRepository[julee.domain.models.knowledge_service_config.KnowledgeServiceConfig], 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.

class julee.domain.repositories.KnowledgeServiceQueryRepository[source]

Bases: julee.domain.repositories.base.BaseRepository[julee.domain.models.assembly_specification.KnowledgeServiceQuery], 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.

class julee.domain.repositories.PolicyRepository[source]

Bases: julee.domain.repositories.base.BaseRepository[julee.domain.models.Policy], 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.