Whenever you're ready, walk me through how you'd approach this.
Finish two dataclasses that represent permission groups and groups, then complete two methods in a service class that loads the permission groups and checks whether a user has permission for a single operation and database combination, including recursively held groups.
Implement the task in Python with clear handling for duplicate memberships, missing references, cyclic group relationships, and repeated loads. Preserve deterministic behavior and make the permission lookup safe to call repeatedly. Add focused tests for direct permissions, nested groups, denied access, malformed references, and cycles.