Coverage for src/prosemark/adapters/id_generator_uuid7.py: 100%
5 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-24 18:08 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-24 18:08 +0000
1# Copyright (c) 2024 Prosemark Contributors
2# This software is licensed under the MIT License
4"""UUIDv7-based ID generator implementation."""
6from prosemark.domain.models import NodeId
7from prosemark.ports.id_generator import IdGenerator
10class IdGeneratorUuid7(IdGenerator):
11 """Production ID generator using UUIDv7 for temporal ordering.
13 This implementation leverages the UUIDv7 format to provide:
14 - Globally unique identifiers
15 - Temporal ordering capabilities (newer UUIDs sort after older ones)
16 - Distributed generation without coordination
17 - Compatibility with existing UUID tooling
19 The UUIDv7 format embeds a timestamp in the first 48 bits, enabling
20 natural chronological sorting while maintaining the randomness properties
21 needed for uniqueness across distributed systems.
22 """
24 def new(self) -> NodeId:
25 """Generate a new NodeId using UUIDv7.
27 Returns:
28 A new NodeId with UUIDv7 format
30 """
31 return NodeId.generate()