Coverage for src / lexigram / contracts / core / identity.py: 0%

15 statements  

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

1"""Identity contracts for the Lexigram framework.""" 

2 

3from __future__ import annotations 

4 

5from enum import StrEnum 

6from typing import Protocol, runtime_checkable 

7 

8 

9class IdStrategy(StrEnum): 

10 """Available ID generation strategies.""" 

11 

12 UUID4 = "uuid4" 

13 UUID7 = "uuid7" 

14 ULID = "ulid" 

15 PREFIXED = "prefixed" 

16 

17 

18@runtime_checkable 

19class IdGeneratorProtocol(Protocol): 

20 """Injectable identity generator.""" 

21 

22 @property 

23 def strategy(self) -> IdStrategy: 

24 """Return the active ID generation strategy.""" 

25 ... 

26 

27 def generate(self) -> str: 

28 """Generate a new unique identifier.""" 

29 ... 

30 

31 def generate_for(self, entity_type: str) -> str: 

32 """Generate a new identifier for a specific entity type.""" 

33 ... 

34 

35 

36__all__ = ["IdGeneratorProtocol", "IdStrategy"]