Coverage for src/lexigram/features/hooks.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-26 02:04 +0800

1"""Root hook payload surface for lexigram-features. 

2 

3Defines canonical payload dataclasses for feature-flag lifecycle hook points. 

4Actual hook registration and invocation use the framework's string-keyed 

5``HookRegistryProtocol`` action/filter APIs. 

6""" 

7 

8from __future__ import annotations 

9 

10from dataclasses import dataclass 

11 

12__all__ = [ 

13 "FeatureFlagEvaluatedHook", 

14 "FeatureFlagUpdatedHook", 

15] 

16 

17 

18@dataclass(frozen=True, kw_only=True) 

19class FeatureFlagEvaluatedHook: 

20 """Payload fired when a feature flag is evaluated for a given context. 

21 

22 Attributes: 

23 flag_key: Unique key of the feature flag that was evaluated. 

24 enabled: Resolved boolean result of the evaluation. 

25 """ 

26 

27 flag_key: str 

28 enabled: bool 

29 

30 

31@dataclass(frozen=True, kw_only=True) 

32class FeatureFlagUpdatedHook: 

33 """Payload fired when a feature flag definition is created or updated. 

34 

35 Attributes: 

36 flag_key: Unique key of the feature flag that changed. 

37 """ 

38 

39 flag_key: str