Coverage for src/copytrading_engine/parsing/contracts.py: 100%
19 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"""Validated parser inputs and typed records crossing storage boundaries."""
3from dataclasses import dataclass
4from datetime import date, datetime
5from typing import Protocol
7from copytrading_engine.parsing.diagnostics import ValidationIssue
8from copytrading_engine.parsing.history import PastCall
9from copytrading_engine.shared.raw_message import RawMessage
10from copytrading_engine.shared.signals import StockSignal
13@dataclass(frozen=True, slots=True)
14class ExtractionJob:
15 key: str
16 raw: RawMessage
17 attempts: int
18 workflow_id: str
19 trace_id: str
22@dataclass(frozen=True, slots=True)
23class DestinationIdentity:
24 message_id: str
25 account_id: str
26 destination_id: str
27 configuration_revision: str
28 workflow_id: str
29 trace_id: str
30 attempt: int = 0
33@dataclass(frozen=True, slots=True)
34class DestinationRegistration:
35 account_id: str
36 configuration_revision: str
39@dataclass(frozen=True, slots=True)
40class RequestReservation:
41 key: str
42 expected_attempts: int
43 day: date
44 daily_limit: int
45 retry_at: datetime
48@dataclass(frozen=True, slots=True)
49class PendingSignal:
50 key: str
51 signal: StockSignal
52 seq: int
55class ExtractionStore(Protocol):
56 async def next(self, now: datetime) -> ExtractionJob | None: ...
57 async def reserve(self, request: RequestReservation) -> bool: ...
58 async def finish(self, key: str, result: StockSignal) -> None: ...
59 async def past_calls(self, channel_id: str, before: str) -> tuple[PastCall, ...]: ...
60 async def diagnose(
61 self,
62 key: str,
63 attempt: int,
64 at: datetime,
65 reason: str,
66 issues: tuple[ValidationIssue, ...],
67 ) -> None: ...