from __future__ import annotations

from app.core.agent.utils.process_v2.models import V2Intent, V2RouteResult
from app.core.rag.contracts.enums import RagLayer
from app.core.rag.retrieval.session_retriever import RetrievalPlan


class GeneralQaSummaryRetrievalPolicy:
    _LAYERS = [RagLayer.DOCS_DOCUMENT_CATALOG, RagLayer.DOCS_DOC_CHUNKS]

    def supports(self, route: V2RouteResult) -> bool:
        return route.intent == V2Intent.GENERAL_QA

    def resolve(self, route: V2RouteResult) -> RetrievalPlan:
        return RetrievalPlan(
            profile="general_qa_grounded_summary",
            layers=list(self._LAYERS),
            limit=8,
            filters={
                "prefer_path_prefixes": ["docs/architecture/", "docs/"],
                "prefer_like_patterns": ["%readme.md%", "%overview%"],
                "target_doc_hints": list(route.anchors.target_doc_hints),
            },
        )

