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

ValidateDocumentUseCase

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:

  1. Generates a unique validation ID

  2. Retrieves the document and policy

  3. Creates and stores the initial validation record

  4. Retrieves all validation queries needed for the policy

  5. Retrieves all knowledge services needed for validation

  6. Registers the document with knowledge services

  7. Executes validation queries and calculates scores

  8. 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:

julee.domain.models.DocumentPolicyValidation

document_policy_validation_repo[source]
document_repo[source]
knowledge_service[source]
knowledge_service_config_repo[source]
knowledge_service_query_repo[source]
now_fn[source]
policy_repo[source]
julee.domain.use_cases.validate_document.logger[source]