from __future__ import annotations

from dataclasses import dataclass

from synaptopus.architectures import PolicyDecision


@dataclass(frozen=True)
class CounterState:
    value: int = 0


class IncrementingGenerator:
    def generate(self, state: CounterState) -> int:
        return state.value + 1


class EvenCritic:
    def critique(self, state: CounterState, candidate: int) -> bool:
        return candidate % 2 == 0


class ThresholdCategorizer:
    def categorize(self, state: CounterState, candidate: int) -> str:
        return "high" if candidate >= 2 else "low"


class AcceptEvenHighPolicy:
    def decide(
        self,
        state: CounterState,
        candidate: int,
        critique: bool,
        category: str,
    ) -> PolicyDecision:
        return PolicyDecision(
            accepted=critique and category == "high",
            label="accept" if critique and category == "high" else "reject",
        )
