from __future__ import annotations

from ai_orchestrator.schemas.workflow_models import CriticResult, EvaluationSummary, ValidationSummary


class EvaluatorAgent:
    def evaluate(
        self,
        *,
        goal: str,
        repo_context: dict,
        validation_result: ValidationSummary,
        critic_result: CriticResult,
    ) -> EvaluationSummary:
        issues = list(critic_result.issues)
        if not validation_result.valid:
            issues.extend(f"Failed validation check: {name}" for name in validation_result.failed_checks)

        key_modules = repo_context.get("key_modules", [])
        if "architecture" in goal.lower() and not key_modules:
            issues.append("Repository grounding did not identify key modules for an architecture-sensitive task.")

        return EvaluationSummary(passed=not issues, issues=issues)
