julee.domain.use_cases.validate_document¶
Use case logic for document validation within the Capture, Extract, Assemble, Publish workflow.
This module contains use case classes that orchestrate business logic while remaining framework-agnostic. Dependencies are injected via repository instances following the Clean Architecture principles.
Attributes¶
Classes¶
Use case for validating documents against policies. |
Module Contents¶
- class julee.domain.use_cases.validate_document.ValidateDocumentUseCase(document_repo, knowledge_service_query_repo, knowledge_service_config_repo, policy_repo, document_policy_validation_repo, knowledge_service, now_fn)[source]¶
Use case for validating documents against policies.
This class orchestrates the business logic for document validation within the Capture, Extract, Assemble, Publish workflow while remaining framework-agnostic. It depends only on repository protocols, not concrete implementations.
In workflow contexts, this use case is called from workflow code with repository stubs that delegate to Temporal activities for durability. The use case remains completely unaware of whether it’s running in a workflow context or a simple async context - it just calls repository methods and expects them to work correctly.
Architectural Notes:
This class contains pure business logic with no framework dependencies
Repository dependencies are injected via constructor (dependency inversion)
All error handling and compensation logic is contained here
The use case works with domain objects exclusively
Deterministic execution is guaranteed by avoiding non-deterministic operations
- async validate_document(document_id, policy_id)[source]¶
Validate a document against a policy and return the validation result.
This method orchestrates the core validation workflow:
Generates a unique validation ID
Retrieves the document and policy
Creates and stores the initial validation record
Retrieves all validation queries needed for the policy
Retrieves all knowledge services needed for validation
Registers the document with knowledge services
Executes validation queries and calculates scores
Determines pass/fail and updates validation record
- Parameters:
document_id (str) – ID of the document to validate
policy_id (str) – ID of the policy to validate against
- Returns:
DocumentPolicyValidation with validation results
- Raises:
ValueError – If required entities are not found or invalid
RuntimeError – If validation processing fails
- Return type: