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
« 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."""
3from typing import Protocol
5from copytrading_engine.host.self_test.model import (
6 DestinationOutcome,
7 ParsedSelfTest,
8 ParseRejected,
9 Stage,
10 SubmitSelfTest,
11 WorkflowAcceptance,
12 WorkflowView,
13)
16class WorkflowStore(Protocol):
17 """Operations the workflow service needs from durable storage."""
19 async def accept_async(self, command: SubmitSelfTest) -> WorkflowAcceptance: ...
21 async def get_async(self, command_id: str) -> WorkflowView: ...
23 async def pending_async(self, limit: int | None = None) -> tuple[str, ...]: ...
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: ...
36 async def load_command_async(self, command_id: str) -> SubmitSelfTest: ...
38 async def load_parsed_async(self, command_id: str) -> ParsedSelfTest: ...
40 async def counts_async(self) -> tuple[int, int, int]: ...
42 async def trace_anchor_exported_async(self, command_id: str) -> bool: ...
44 def mark_trace_anchor_exported(self, command_id: str) -> None: ...
47class SelfTestParser(Protocol):
48 """A deterministic parser that returns immutable evidence or a domain error."""
50 def parse(self, text: str) -> ParsedSelfTest: ...