from __future__ import annotations import hashlib def deterministic_audit_selected(record_id: str, rate: float, minimum_counter: int = 0) -> bool: """Stable sampling: the same record always gets the same audit decision.""" if minimum_counter > 0: return True value = int(hashlib.sha256(record_id.encode()).hexdigest()[:12], 16) / float(16**12) return value < rate