Coverage for src/prosemark/ports/compile/service.py: 100%
12 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-30 23:09 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-30 23:09 +0000
1"""Contract definition for CompileServicePort.
3This module defines the port interface for the compile service,
4following hexagonal architecture principles.
5"""
7from abc import ABC, abstractmethod
9from prosemark.domain.compile.models import CompileRequest, CompileResult
10from prosemark.domain.models import NodeId
13class CompileServicePort(ABC):
14 """Port interface for compile operations.
16 This port defines the contract for compiling node subtrees
17 into concatenated text output.
18 """
20 @abstractmethod
21 def compile_subtree(self, request: CompileRequest) -> CompileResult:
22 """Compile a node and all its descendants into plain text.
24 Args:
25 request: The compile request with target node and options
27 Returns:
28 CompileResult containing the concatenated content and statistics
30 Raises:
31 NodeNotFoundError: If the specified node_id doesn't exist
32 CompileError: If compilation fails for any other reason
34 """
35 ...
38class NodeNotFoundError(Exception):
39 """Raised when the specified node cannot be found."""
41 def __init__(self, node_id: NodeId) -> None:
42 self.node_id = node_id
43 super().__init__(f'Node not found: {node_id}')
46class CompileError(Exception):
47 """Base exception for compilation errors."""