```python
"""Count the hits a key stream scores on a direct-mapped cache."""


def slot_hits(keys: list, slots: int) -> int:
    """Replay a stream of integer cache keys against a direct-mapped cache.

    Args:
        keys: A list of integer cache keys to process.
        slots: The number of slots in the cache (must be a positive integer).

    Returns:
        The total number of cache hits.

    Raises:
        ValueError: If slots is not a positive integer or any key is not an integer.
    """
    if not isinstance(slots, int) or isinstance(slots, bool) or slots <= 0:
        raise ValueError("slots must be a positive integer")

    if not isinstance(keys, list):
        raise ValueError("keys must be a list")

    for key in keys:
        if not isinstance(key, int) or isinstance(key, bool):
            raise ValueError("all keys must be integers")

    held = [None] * slots
    hits = 0

    for key in keys:
        slot_index = key % slots
        if slot_index < 0:
            slot_index += slots

        if held[slot_index] == key:
            hits += 1
        else:
            held[slot_index] = key

    return hits
```