"""Entity / AggregateRoot bases — identity-based equality (not attribute-based)."""

from __future__ import annotations

from typing import Any


class Entity:
    """A domain entity: equality + hash by its ``id``, regardless of other fields."""

    id: Any

    def __eq__(self, other: object) -> bool:
        return isinstance(other, type(self)) and getattr(other, "id", None) == self.id

    def __hash__(self) -> int:
        return hash((type(self).__name__, self.id))


class AggregateRoot(Entity):
    """The consistency boundary a repository loads and persists as a whole."""
