Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-rag/src/lexigram/ai/rag/pipeline/base.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-25 07:19 +0800

1"""Base protocol and interfaces for pipeline stages.""" 

2 

3from __future__ import annotations 

4 

5from typing import Protocol 

6 

7from lexigram.ai.rag.pipeline.types import PipelineContext 

8 

9 

10class PipelineStageProtocol(Protocol): 

11 """Protocol for pipeline stages. 

12 

13 Each stage processes the context and returns an updated context. 

14 Stages should be independent and idempotent where possible. 

15 """ 

16 

17 async def process(self, context: PipelineContext) -> PipelineContext: 

18 """Process the pipeline context. 

19 

20 Args: 

21 context: The current pipeline context 

22 

23 Returns: 

24 Updated pipeline context 

25 

26 Raises: 

27 Exception: If stage processing fails and error strategy is FAIL_FAST 

28 """ 

29 ... 

30 

31 @property 

32 def name(self) -> str: 

33 """Get the stage name. 

34 

35 Returns: 

36 Name of the stage 

37 """ 

38 ...