Coverage for src/copytrading_engine/host/self_test/ports.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-11-16 16:55 +0000

1"""Caller-owned interfaces for persistence and deterministic parsing.""" 

2 

3from typing import Protocol 

4 

5from copytrading_engine.host.self_test.model import ( 

6 DestinationOutcome, 

7 ParsedSelfTest, 

8 ParseRejected, 

9 Stage, 

10 SubmitSelfTest, 

11 WorkflowAcceptance, 

12 WorkflowView, 

13) 

14 

15 

16class WorkflowStore(Protocol): 

17 """Operations the workflow service needs from durable storage.""" 

18 

19 async def accept_async(self, command: SubmitSelfTest) -> WorkflowAcceptance: ... 

20 

21 async def get_async(self, command_id: str) -> WorkflowView: ... 

22 

23 async def pending_async(self, limit: int | None = None) -> tuple[str, ...]: ... 

24 

25 async def advance_async( 

26 self, 

27 command_id: str, 

28 expected: Stage, 

29 next_stage: Stage, 

30 outcomes: tuple[DestinationOutcome, ...], 

31 *, 

32 parsed: ParsedSelfTest | None = None, 

33 parse_rejection: ParseRejected | None = None, 

34 ) -> WorkflowView: ... 

35 

36 async def load_command_async(self, command_id: str) -> SubmitSelfTest: ... 

37 

38 async def load_parsed_async(self, command_id: str) -> ParsedSelfTest: ... 

39 

40 async def counts_async(self) -> tuple[int, int, int]: ... 

41 

42 async def trace_anchor_exported_async(self, command_id: str) -> bool: ... 

43 

44 def mark_trace_anchor_exported(self, command_id: str) -> None: ... 

45 

46 

47class SelfTestParser(Protocol): 

48 """A deterministic parser that returns immutable evidence or a domain error.""" 

49 

50 def parse(self, text: str) -> ParsedSelfTest: ...