Coverage for src/copytrading_engine/shared/payload_capture.py: 100%

7 statements  

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

1"""The wire-capture vocabulary shared by payload producers and the diagnostics sink.""" 

2 

3from typing import Literal, Protocol 

4 

5from copytrading_engine.shared.model_providers import ModelProvider 

6 

7type JsonValue = bool | int | float | str | list[JsonValue] | dict[str, JsonValue] | None 

8type CaptureKind = Literal["source_event", "model_request", "model_response", "other"] 

9type CaptureStatus = Literal["complete", "incomplete", "missing", "oversize"] 

10type ProviderName = ModelProvider | Literal["other"] 

11 

12 

13class PayloadCapture(Protocol): 

14 """Record one bounded wire payload for diagnostics; never alters the caller's work.""" 

15 

16 def record_payload( 

17 self, 

18 *, 

19 capture_kind: CaptureKind, 

20 workflow_id: str | None, 

21 trace_id: str | None, 

22 destination_id: str | None, 

23 attempt: int | None, 

24 provider: ProviderName, 

25 payload: JsonValue | None, 

26 source_bytes: int | None = None, 

27 max_bytes: int = ..., 

28 status: CaptureStatus = "complete", 

29 ) -> None: ...