Coverage for app / services / rules / __init__.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-10-31 11:21 +0000

1""" 

2The rule vocabulary — what a governance rule can ask, and what it can do. 

3 

4Three registries make up the grammar, each one class per entry: 

5 

6``operators`` How two values are compared (``gt``, ``matches``, ``has_any``…). 

7``fields`` What a condition can ask about (``prompt``, ``prompt_tokens``, 

8 ``pii_detected``…), including how to resolve it from an 

9 invocation's context. 

10``actions`` What a matched rule does (``block``, ``redact_pii``, 

11 ``cost_cap``…), and the parameters each one takes. 

12 

13``catalogue`` serves all three over the API so the visual rule builder is 

14driven by the same definitions the engine evaluates against, and 

15``conditions`` is the single matcher every rule type goes through. 

16 

17``app.services.rule_engine`` remains the entry point for evaluating rules 

18against an invocation; this package is the vocabulary it evaluates *with*. 

19""" 

20 

21from app.services.rules import actions, catalogue, conditions, fields, operators, pii 

22from app.services.rules.actions import ( 

23 ActionOutcome, 

24 ActionParam, 

25 BlockDecision, 

26 TextAction, 

27) 

28from app.services.rules.conditions import all_conditions_match, condition_matches 

29from app.services.rules.fields import Phase 

30from app.services.rules.operators import ValueType 

31from app.services.rules.pii import detect_pii, filter_pii 

32 

33__all__ = [ 

34 "ActionOutcome", 

35 "ActionParam", 

36 "BlockDecision", 

37 "Phase", 

38 "TextAction", 

39 "ValueType", 

40 "actions", 

41 "all_conditions_match", 

42 "catalogue", 

43 "condition_matches", 

44 "conditions", 

45 "detect_pii", 

46 "fields", 

47 "filter_pii", 

48 "operators", 

49 "pii", 

50]