from abc import ABC, abstractmethod from afk_developer.backends.models import ( AcceptanceValidationResult, BackendResponse, DiscoveryProposalResult, ResearchProposalResult, TaskExecutionResult, ) from afk_developer.planner.task_model import TaskNode from afk_developer.planner.task_model import DiscoveryContract class ReasonerBackend(ABC): @abstractmethod def complete( self, *, system_prompt: str, user_prompt: str, temperature: float = 0.0, ) -> BackendResponse: """Generate a reasoning response for planning, reflection, or synthesis.""" class CoderBackend(ABC): @abstractmethod def execute_task( self, *, task: TaskNode, project_dir: str, context: str, hitl_mode: bool, max_turns: int, project_name: str = "", ) -> TaskExecutionResult: """Execute one coding task with the provider's agent/tool loop.""" class ResearcherBackend(ABC): @abstractmethod def propose_evidence( self, *, task: TaskNode, project_dir: str, context: str, max_turns: int, project_name: str = "", ) -> ResearchProposalResult: """Propose structured facts without modifying the target or AFK state artifacts.""" def propose_discovery( self, *, task: TaskNode, project_dir: str, contract: DiscoveryContract, context: str, max_turns: int, project_name: str = "", ) -> DiscoveryProposalResult: """Propose local discovery facts for a content-addressed checkpoint. This is deliberately a concrete default during incremental adapter rollout: unsupported providers fail explicitly at runtime instead of becoming abstract-class construction failures in unrelated workflows. """ del task, project_dir, contract, context, max_turns raise NotImplementedError( "The configured researcher does not yet support local discovery checkpoints." ) class ValidatorBackend(ABC): @abstractmethod def validate( self, *, task: TaskNode, project_dir: str, context: str, max_turns: int, project_name: str = "", ) -> AcceptanceValidationResult: """Independently validate a completed task without changing project or Git state.""" class BackendFactory(ABC): @abstractmethod def create_reasoner(self) -> ReasonerBackend: """Create a reasoner backend for the configured role route.""" @abstractmethod def create_coder(self) -> CoderBackend: """Create a coder backend for the configured role route.""" @abstractmethod def create_researcher(self) -> ResearcherBackend: """Create a read-only researcher backend for the configured role route.""" @abstractmethod def create_validator(self) -> ValidatorBackend: """Create a read-only acceptance validator for the configured role route."""