Coverage for src / lexigram / contracts / observability / audit.py: 0%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-15 18:57 +0800

1"""Audit verifier scheduler protocol (audit types moved to contracts/audit/).""" 

2 

3from __future__ import annotations 

4 

5from typing import Any, Protocol, runtime_checkable 

6 

7from lexigram.contracts.audit.types import AuditEntry 

8 

9__all__ = ["AuditEntry", "AuditVerifierSchedulerProtocol"] 

10 

11 

12@runtime_checkable 

13class AuditVerifierSchedulerProtocol(Protocol): 

14 """Protocol for registering and scheduling the audit verifier task. 

15 

16 Implementations are provided by the ``lexigram-sql`` package and registered 

17 in the DI container. Extension packages (e.g. ``lexigram-admin``) resolve 

18 this protocol from the container rather than importing concrete DB types. 

19 """ 

20 

21 def register_handler(self, task_provider: Any) -> None: 

22 """Register the audit verifier handler with a task provider. 

23 

24 Args: 

25 task_provider: A task provider that accepts ``register_handler``. 

26 """ 

27 ... 

28 

29 def schedule( 

30 self, 

31 task_provider: Any, 

32 *, 

33 audit_table: str = "audit_log", 

34 key: bytes | None = None, 

35 ) -> str | None: 

36 """Schedule the periodic audit verifier job. 

37 

38 Args: 

39 task_provider: A task provider/scheduler with ``schedule_job``. 

40 audit_table: Name of the audit table to verify. 

41 key: HMAC key used for checksum verification. 

42 

43 Returns: 

44 Job ID returned by the scheduler, or ``None``. 

45 """ 

46 ...