julee.domain.models

Domain models for julee.

This package contains all the domain entities and value objects following Clean Architecture principles. These models are framework-independent and contain only business logic.

Re-exports commonly used models for convenient importing:

from julee.domain.models import Document, Assembly, Policy

Submodules

Classes

Assembly

Assembly process that links a specification with input document and

AssemblySpecification

Assembly specification configuration that defines how to assemble

AssemblySpecificationStatus

Status of an assembly specification configuration.

AssemblyStatus

Status of an assembly process.

ContentStream

Wrapper for IO streams that provides proper Pydantic validation.

Document

Complete document entity including content and metadata.

DocumentPolicyValidation

Represents the validation of a document against a policy configuration.

DocumentStatus

Status of a document through the Capture, Extract, Assemble, Publish

KnowledgeServiceConfig

Knowledge service configuration that defines how to interact with

KnowledgeServiceQuery

Knowledge service query configuration for extracting specific data.

Policy

Policy configuration that defines validation and

PolicyStatus

Status of a policy configuration.

Package Contents

class julee.domain.models.Assembly(/, **data)[source]

Bases: pydantic.BaseModel

Assembly process that links a specification with input document and produces an assembled document.

An Assembly represents a specific instance of the document assembly process. It connects an AssemblySpecification (which defines how to assemble) with an input Document (what to assemble from) and produces a single assembled document as output.

classmethod assembled_document_id_must_not_be_empty_if_provided(v)[source]
classmethod assembly_id_must_not_be_empty(v)[source]
classmethod assembly_specification_id_must_not_be_empty(v)[source]
classmethod input_document_id_must_not_be_empty(v)[source]
classmethod workflow_id_must_not_be_empty(v)[source]
assembled_document_id: str | None = None
assembly_id: str = None
assembly_specification_id: str = None
created_at: datetime.datetime | None = None
input_document_id: str = None
status: AssemblyStatus
updated_at: datetime.datetime | None = None
workflow_id: str = None
class julee.domain.models.AssemblySpecification(/, **data)[source]

Bases: pydantic.BaseModel

Assembly specification configuration that defines how to assemble documents of a specific type.

An AssemblySpecification represents a type of document output (like “meeting minutes”, “project report”, etc.) and defines which extractors should be used to collect the necessary data from source documents.

The AssemblySpecification does not contain the template itself - templates will be handled separately during the assembly rendering (or publishing?) phase. This separation allows the same AssemblySpecification definition to be used with different templates over time.

classmethod applicability_must_not_be_empty(v)[source]
classmethod assembly_specification_id_must_not_be_empty(v)[source]
classmethod jsonschema_must_be_valid(v)[source]
classmethod knowledge_service_queries_must_be_valid(v, info)[source]
classmethod name_must_not_be_empty(v)[source]
classmethod version_must_not_be_empty(v)[source]
applicability: str = None
assembly_specification_id: str = None
created_at: datetime.datetime | None = None
jsonschema: dict[str, Any] = None
knowledge_service_queries: dict[str, str] = None
name: str = None
status: AssemblySpecificationStatus
updated_at: datetime.datetime | None = None
version: str = None
class julee.domain.models.AssemblySpecificationStatus[source]

Bases: str, enum.Enum

Status of an assembly specification configuration.

ACTIVE = 'active'
DEPRECATED = 'deprecated'
DRAFT = 'draft'
INACTIVE = 'inactive'
class julee.domain.models.AssemblyStatus[source]

Bases: str, enum.Enum

Status of an assembly process.

CANCELLED = 'cancelled'
COMPLETED = 'completed'
FAILED = 'failed'
IN_PROGRESS = 'in_progress'
PENDING = 'pending'
class julee.domain.models.ContentStream(stream)[source]

Wrapper for IO streams that provides proper Pydantic validation.

This class wraps io.IOBase instances to provide proper Pydantic validation without requiring arbitrary_types_allowed. It ensures that only valid stream objects are accepted while providing a clean interface for stream operations.

read(size=-1)[source]

Read from the underlying stream.

seek(offset, whence=0)[source]

Seek in the underlying stream.

tell()[source]

Get current position in stream.

property stream: io.IOBase

Access the underlying stream.

class julee.domain.models.Document(/, **data)[source]

Bases: pydantic.BaseModel

Complete document entity including content and metadata.

This is the primary domain model that represents a complete document in the CEAP workflow system. Content is provided as a ContentStream for efficient handling of both small and large documents.

The content stream is excluded from JSON serialization - use separate content endpoints for streaming binary data over HTTP.

classmethod content_multihash_must_not_be_empty(v)[source]
classmethod content_type_must_not_be_empty(v)[source]
classmethod document_id_must_not_be_empty(v)[source]
classmethod filename_must_not_be_empty(v)[source]
validate_content_fields(info)[source]

Ensure document has at least content, or content_bytes.

additional_metadata: dict[str, Any] = None
assembly_types: list[str] = None
content: julee.domain.models.custom_fields.content_stream.ContentStream | None = None
content_bytes: bytes | None = None
content_multihash: str = None
content_type: str
created_at: datetime.datetime | None = None
document_id: str
knowledge_service_id: str | None = None
original_filename: str
size_bytes: int = None
status: DocumentStatus
updated_at: datetime.datetime | None = None
class julee.domain.models.DocumentPolicyValidation(/, **data)[source]

Bases: pydantic.BaseModel

Represents the validation of a document against a policy configuration.

A DocumentPolicyValidation tracks the complete lifecycle of validating a document against policy criteria. It includes:

  1. Initial validation: Document is scored against policy validation queries

  2. Optional transformation: If policy includes transformation queries and initial validation fails, transformations are applied

  3. Re-validation: Transformed document is re-scored against policy criteria

  4. Final determination: Pass/fail based on final validation scores

The validation process supports both validation-only policies and policies that include transformations for document quality improvement.

classmethod error_message_must_be_valid(v)[source]
classmethod input_document_id_must_not_be_empty(v)[source]
classmethod policy_id_must_not_be_empty(v)[source]
classmethod post_transform_scores_must_be_valid(v)[source]
classmethod transformed_document_id_must_be_valid(v)[source]
classmethod validation_scores_must_be_valid(v)[source]
completed_at: datetime.datetime | None = None
error_message: str | None = None
input_document_id: str = None
passed: bool | None = None
policy_id: str = None
post_transform_validation_scores: list[tuple[str, int]] | None = None
started_at: datetime.datetime | None = None
status: DocumentPolicyValidationStatus
transformed_document_id: str | None = None
validation_id: str = None
validation_scores: list[tuple[str, int]] = None
class julee.domain.models.DocumentStatus[source]

Bases: str, enum.Enum

Status of a document through the Capture, Extract, Assemble, Publish pipeline.

ASSEMBLED = 'assembled'
ASSEMBLY_SPECIFICATION_IDENTIFIED = 'assembly_specification_identified'
CAPTURED = 'captured'
EXTRACTED = 'extracted'
FAILED = 'failed'
PUBLISHED = 'published'
REGISTERED = 'registered'
class julee.domain.models.KnowledgeServiceConfig(/, **data)[source]

Bases: pydantic.BaseModel

Knowledge service configuration that defines how to interact with an external knowledge/AI service.

A KnowledgeServiceConfig represents a service endpoint that can store documents and execute queries against them. This could be an AI service, vector database, search engine, or any other service that can analyze documents and answer questions about them.

classmethod description_must_not_be_empty(v)[source]
classmethod knowledge_service_id_must_not_be_empty(v)[source]
classmethod name_must_not_be_empty(v)[source]
classmethod service_api_must_be_valid(v)[source]
created_at: datetime.datetime | None = None
description: str = None
knowledge_service_id: str = None
name: str = None
service_api: ServiceApi = None
updated_at: datetime.datetime | None = None
class julee.domain.models.KnowledgeServiceQuery(/, **data)[source]

Bases: pydantic.BaseModel

Knowledge service query configuration for extracting specific data.

A KnowledgeServiceQuery represents a specific extraction operation that can be performed against a knowledge service. It defines which knowledge service to use and what prompt to send for data extraction.

When executed, the relevant section of the AssemblySpecification’s JSON schema will be passed along with the prompt to ensure the knowledge service response conforms to the expected structure and validation requirements.

The mapping between queries and schema sections is handled by the AssemblySpecification’s knowledge_service_queries field.

Examples of query_metadata usage:

For Anthropic services:

query_metadata = {
    "model": "claude-sonnet-4-5",
    "max_tokens": 4000,
    "temperature": 0.1
}

For OpenAI services:

query_metadata = {
    "model": "gpt-4",
    "temperature": 0.2,
    "top_p": 0.9
}

For custom services:

query_metadata = {
    "endpoint": "custom-model-v2",
    "timeout": 30,
    "retries": 3
}
classmethod knowledge_service_id_must_not_be_empty(v)[source]
classmethod name_must_not_be_empty(v)[source]
classmethod prompt_must_not_be_empty(v)[source]
classmethod query_id_must_not_be_empty(v)[source]
assistant_prompt: str | None = None
created_at: datetime.datetime | None = None
knowledge_service_id: str = None
name: str = None
prompt: str = None
query_id: str = None
query_metadata: dict[str, Any] | None = None
updated_at: datetime.datetime | None = None
class julee.domain.models.Policy(/, **data)[source]

Bases: pydantic.BaseModel

Policy configuration that defines validation and transformation criteria for documents.

A Policy represents a set of quality criteria that documents must meet. It includes validation scores that are calculated using knowledge service queries, and optional transformation queries that can be applied to improve document quality before re-validation.

The policy operates in two modes:

  1. Validation-only: Calculates scores and passes/fails based on criteria

  2. Validation with transformation: Calculates scores, applies transformations, then re-calculates scores for final pass/fail

classmethod description_must_not_be_empty(v)[source]
classmethod policy_id_must_not_be_empty(v)[source]
classmethod title_must_not_be_empty(v)[source]
classmethod transformation_queries_must_be_valid(v)[source]
classmethod validation_scores_must_be_valid(v)[source]
classmethod version_must_not_be_empty(v)[source]
created_at: datetime.datetime | None = None
description: str = None
property has_transformations: bool

Check if this policy includes transformation queries.

Returns True if transformation queries are defined and non-empty.

property is_validation_only: bool

Check if this policy operates in validation-only mode.

Returns True if no transformation queries are defined or if the transformation queries list is empty.

policy_id: str = None
status: PolicyStatus
title: str = None
transformation_queries: list[str] | None = None
updated_at: datetime.datetime | None = None
validation_scores: list[tuple[str, int]] = None
version: str = None
class julee.domain.models.PolicyStatus[source]

Bases: str, enum.Enum

Status of a policy configuration.

ACTIVE = 'active'
DEPRECATED = 'deprecated'
DRAFT = 'draft'
INACTIVE = 'inactive'