defaults:
  component: process_v2_retrieval_policy_resolver

cases:
  - id: general-overview-grounded
    route:
      routing_domain: GENERAL
      intent: GENERAL_QA
      subintent: SUMMARY
      user_query: "Что это за сервис?"
      normalized_query: "что это за сервис"
      anchors:
        target_doc_hints: []
        endpoint_paths: []
    expected:
      plan:
        profile: general_qa_grounded_summary
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          prefer_path_prefixes: [docs/architecture/, docs/]

  - id: general-does-not-become-docs-summary
    route:
      routing_domain: GENERAL
      intent: GENERAL_QA
      subintent: SUMMARY
      user_query: "Дай общий обзор, включая /health"
      normalized_query: "дай общий обзор включая /health"
      anchors:
        endpoint_paths: ["/health"]
        target_doc_hints: ["docs/api/health-endpoint.md"]
        matched_aliases: ["api"]
    expected:
      plan:
        profile: general_qa_grounded_summary
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8

  - id: find-files-with-target-hint
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: FIND_FILES
      user_query: "Покажи файл про health endpoint"
      normalized_query: "покажи файл про health endpoint"
      anchors:
        endpoint_paths: ["/health"]
        target_doc_hints: ["docs/api/health-endpoint.md"]
    expected:
      plan:
        profile: file_lookup
        layers: [D1_DOCUMENT_CATALOG, D3_ENTITY_CATALOG]
        limit: 12
        filters:
          target_doc_hints: ["docs/api/health-endpoint.md"]
          path_prefixes: [docs/api/]
          prefer_like_patterns: ["%health-endpoint.md%"]

  - id: find-files-endpoint-only
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: FIND_FILES
      user_query: "Где описан /send?"
      normalized_query: "где описан /send"
      anchors:
        endpoint_paths: ["/send"]
        target_doc_hints: []
    expected:
      plan:
        profile: file_lookup
        layers: [D1_DOCUMENT_CATALOG, D3_ENTITY_CATALOG]
        limit: 12
        filters:
          path_prefixes: [docs/api/, docs/]
          prefer_like_patterns: ["%/send%"]

  - id: find-files-entities-and-domain
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: FIND_FILES
      user_query: "В каком документе описан ManualSendWorker?"
      normalized_query: "в каком документе описан manualsendworker"
      anchors:
        entity_names: ["ManualSendWorker"]
        matched_aliases: ["manual send"]
        process_domain: "messaging"
        process_subdomain: "manual_send"
        target_doc_hints: []
    expected:
      plan:
        profile: file_lookup
        layers: [D1_DOCUMENT_CATALOG, D3_ENTITY_CATALOG]
        limit: 12
        filters:
          metadata.domain: messaging
          metadata.subdomain: manual_send
          prefer_path_prefixes: [docs/domains/, docs/, docs/logic/]
          prefer_like_patterns: ["%manualsendworker%", "%manual send%", "%messaging%", "%manual_send%"]

  - id: docs-summary-api-endpoint-health
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Объясни /health"
      normalized_query: "объясни /health"
      target_terms: ["health", "/health"]
      anchors:
        endpoint_paths: ["/health"]
        target_doc_hints: ["docs/api/health-endpoint.md"]
    expected:
      plan:
        profile: docs_summary_api_endpoint
        layers: [D1_DOCUMENT_CATALOG, D2_FACT_INDEX, D0_DOC_CHUNKS]
        limit: 8
        filters:
          target_doc_hints: ["docs/api/health-endpoint.md"]
          path_prefixes: [docs/api/, docs/]
          prefer_path_prefixes: [docs/api/, docs/]

  - id: docs-summary-architecture
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Как устроена архитектура сервиса?"
      normalized_query: "как устроена архитектура сервиса"
      anchors:
        file_names: ["docs/architecture/runtime-manager.md"]
        target_doc_hints: ["docs/architecture/runtime-manager.md"]
        matched_aliases: ["architecture"]
    expected:
      plan:
        profile: docs_summary_architecture
        layers: [D1_DOCUMENT_CATALOG, D5_RELATION_GRAPH, D0_DOC_CHUNKS]
        limit: 8
        filters:
          target_doc_hints: ["docs/architecture/runtime-manager.md"]
          prefer_path_prefixes: [docs/architecture/, docs/]

  - id: docs-summary-logic-flow
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Опиши workflow отправки уведомлений"
      normalized_query: "опиши workflow отправки уведомлений"
      anchors:
        matched_aliases: ["workflow"]
        process_domain: "notifications"
        process_subdomain: "delivery_loop"
        target_doc_hints: []
    expected:
      plan:
        profile: docs_summary_logic_flow
        layers: [D4_WORKFLOW_INDEX, D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          metadata.domain: notifications
          metadata.subdomain: delivery_loop
          prefer_path_prefixes: [docs/logic/, docs/architecture/, docs/]

  - id: docs-summary-domain-entity
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Что такое RuntimeManager?"
      normalized_query: "что такое runtimemanager"
      anchors:
        entity_names: ["RuntimeManager"]
        process_domain: "runtime"
    expected:
      plan:
        profile: docs_summary_domain_entity
        layers: [D3_ENTITY_CATALOG, D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          metadata.domain: runtime
          prefer_path_prefixes: [docs/domains/, docs/, docs/api/]
          prefer_like_patterns: ["%runtimemanager%", "%runtime%"]

  - id: docs-summary-generic-weak-signals
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Дай краткое summary документации"
      normalized_query: "дай краткое summary документации"
      anchors:
        target_doc_hints: []
        endpoint_paths: []
        entity_names: []
        matched_aliases: []
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          prefer_path_prefixes: [docs/]

  - id: docs-summary-generic-conflicting-signals
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Как связан /health и RuntimeManager?"
      normalized_query: "как связан /health и runtimemanager"
      anchors:
        endpoint_paths: ["/health"]
        entity_names: ["RuntimeManager"]
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8

  - id: find-files-stays-file-lookup-on-mixed-signals
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: FIND_FILES
      user_query: "Найди документ по architecture runtime manager"
      normalized_query: "найди документ по architecture runtime manager"
      anchors:
        entity_names: ["RuntimeManager"]
        matched_aliases: ["architecture"]
        file_names: ["docs/architecture/runtime-manager.md"]
    expected:
      plan:
        profile: file_lookup
        layers: [D1_DOCUMENT_CATALOG, D3_ENTITY_CATALOG]
        limit: 12
        filters:
          path_prefixes: [docs/architecture/]

  - id: resolver-survives-partial-empty-anchors
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Что там по docs?"
      normalized_query: "что там по docs"
      anchors:
        entity_names: []
        file_names: [""]
        endpoint_paths: []
        target_doc_hints: []
        matched_aliases: []
        process_domain:
        process_subdomain:
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8

  - id: find-files-file-name-priority
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: FIND_FILES
      user_query: "Покажи документ manual-send"
      normalized_query: "покажи документ manual-send"
      anchors:
        file_names: ["docs/workflows/manual-send.md"]
        matched_aliases: ["manual send"]
        target_doc_hints: []
    expected:
      plan:
        profile: file_lookup
        layers: [D1_DOCUMENT_CATALOG, D3_ENTITY_CATALOG]
        limit: 12
        filters:
          path_prefixes: [docs/workflows/]
          prefer_like_patterns: ["%docs/workflows/manual-send.md%", "%manual send%"]

  - id: conflict-api-hint-vs-workflow-metadata
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Опиши flow для /health в notification loop"
      normalized_query: "опиши flow для /health в notification loop"
      anchors:
        endpoint_paths: ["/health"]
        target_doc_hints: ["docs/api/health-endpoint.md"]
        matched_aliases: ["workflow"]
        process_domain: "notifications"
        process_subdomain: "delivery_loop"
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          target_doc_hints: ["docs/api/health-endpoint.md"]
          metadata.domain: notifications
          metadata.subdomain: delivery_loop
          path_prefixes: [docs/api/, docs/]

  - id: conflict-file-name-vs-architecture-alias
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Объясни architecture для notification loop"
      normalized_query: "объясни architecture для notification loop"
      anchors:
        file_names: ["docs/logic/notification-loop.md"]
        matched_aliases: ["architecture"]
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          prefer_path_prefixes: [docs/architecture/, docs/, docs/logic/]
          prefer_like_patterns: ["%docs/logic/notification-loop.md%", "%architecture%"]

  - id: conflict-hint-vs-entity-soft-signals
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Что делает /send и ManualSendWorker?"
      normalized_query: "что делает /send и manualsendworker"
      anchors:
        endpoint_paths: ["/send"]
        target_doc_hints: ["docs/api/send-endpoint.md"]
        entity_names: ["ManualSendWorker"]
        matched_aliases: ["manual send"]
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          target_doc_hints: ["docs/api/send-endpoint.md"]
          path_prefixes: [docs/api/, docs/]
          prefer_like_patterns: ["%send-endpoint.md%", "%/send%", "%manualsendworker%", "%manual send%"]

  - id: metadata-only-find-files
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: FIND_FILES
      user_query: "Найди документы по notifications delivery loop"
      normalized_query: "найди документы по notifications delivery loop"
      anchors:
        process_domain: "notifications"
        process_subdomain: "delivery_loop"
    expected:
      plan:
        profile: file_lookup
        layers: [D1_DOCUMENT_CATALOG, D3_ENTITY_CATALOG]
        limit: 12
        filters:
          path_prefixes: [docs/]
          metadata.domain: notifications
          metadata.subdomain: delivery_loop
          prefer_path_prefixes: [docs/, docs/domains/, docs/logic/]

  - id: metadata-only-generic-summary
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Дай summary по notifications delivery loop"
      normalized_query: "дай summary по notifications delivery loop"
      anchors:
        process_domain: "notifications"
        process_subdomain: "delivery_loop"
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          metadata.domain: notifications
          metadata.subdomain: delivery_loop
          prefer_path_prefixes: [docs/]
          prefer_like_patterns: ["%notifications%", "%delivery_loop%"]

  - id: metadata-domain-entity-with-alias
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Объясни компонент billing"
      normalized_query: "объясни компонент billing"
      anchors:
        matched_aliases: ["component"]
        process_domain: "billing"
    expected:
      plan:
        profile: docs_summary_domain_entity
        layers: [D3_ENTITY_CATALOG, D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          metadata.domain: billing
          prefer_path_prefixes: [docs/domains/, docs/, docs/api/]
          prefer_like_patterns: ["%component%", "%billing%"]

  - id: alias-only-api
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Объясни api health"
      normalized_query: "объясни api health"
      anchors:
        matched_aliases: ["api endpoint"]
    expected:
      plan:
        profile: docs_summary_api_endpoint
        layers: [D1_DOCUMENT_CATALOG, D2_FACT_INDEX, D0_DOC_CHUNKS]
        limit: 8
        filters:
          path_prefixes: [docs/api/, docs/]
          prefer_like_patterns: ["%api endpoint%"]

  - id: alias-only-architecture
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Расскажи про architecture"
      normalized_query: "расскажи про architecture"
      anchors:
        matched_aliases: ["architecture"]
    expected:
      plan:
        profile: docs_summary_architecture
        layers: [D1_DOCUMENT_CATALOG, D5_RELATION_GRAPH, D0_DOC_CHUNKS]
        limit: 8
        filters:
          prefer_path_prefixes: [docs/architecture/, docs/]
          prefer_like_patterns: ["%architecture%"]

  - id: partial-only-endpoint-path
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Что делает /status?"
      normalized_query: "что делает /status"
      anchors:
        endpoint_paths: ["/status"]
    expected:
      plan:
        profile: docs_summary_api_endpoint
        layers: [D1_DOCUMENT_CATALOG, D2_FACT_INDEX, D0_DOC_CHUNKS]
        limit: 8
        filters:
          path_prefixes: [docs/api/, docs/]
          prefer_like_patterns: ["%/status%"]

  - id: partial-only-target-doc-hint
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Объясни notification loop"
      normalized_query: "объясни notification loop"
      anchors:
        target_doc_hints: ["docs/logic/notification-loop.md"]
    expected:
      plan:
        profile: docs_summary_logic_flow
        layers: [D4_WORKFLOW_INDEX, D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          target_doc_hints: ["docs/logic/notification-loop.md"]
          prefer_path_prefixes: [docs/logic/, docs/architecture/, docs/]

  - id: generic-neutral-with-nonsemantic-hint
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Дай общий summary intro docs"
      normalized_query: "дай общий summary intro docs"
      anchors:
        target_doc_hints: ["docs/intro/overview.md"]
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          target_doc_hints: ["docs/intro/overview.md"]
          prefer_path_prefixes: [docs/]

  - id: generic-neutral-weak-mixed-aliases
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: SUMMARY
      user_query: "Нужен общий summary про architecture component"
      normalized_query: "нужен общий summary про architecture component"
      anchors:
        matched_aliases: ["architecture", "component"]
    expected:
      plan:
        profile: docs_summary_generic
        layers: [D1_DOCUMENT_CATALOG, D0_DOC_CHUNKS]
        limit: 8
        filters:
          prefer_path_prefixes: [docs/architecture/, docs/, docs/domains/, docs/api/]

  - id: find-files-hard-priority-with-multiple-hints
    route:
      routing_domain: DOCS
      intent: DOC_EXPLAIN
      subintent: FIND_FILES
      user_query: "Найди документы по /health и runtime manager"
      normalized_query: "найди документы по /health и runtime manager"
      anchors:
        endpoint_paths: ["/health"]
        entity_names: ["RuntimeManager"]
        matched_aliases: ["architecture"]
        target_doc_hints:
          - "docs/api/health-endpoint.md"
          - "docs/architecture/runtime-manager.md"
    expected:
      plan:
        profile: file_lookup
        layers: [D1_DOCUMENT_CATALOG, D3_ENTITY_CATALOG]
        limit: 12
        filters:
          target_doc_hints:
            - "docs/api/health-endpoint.md"
            - "docs/architecture/runtime-manager.md"
          path_prefixes: [docs/api/, docs/architecture/]
          prefer_like_patterns: ["%health-endpoint.md%", "%runtime-manager.md%"]
