"""Support helpers for case-evaluation payload builder facades."""

from __future__ import annotations

from collections.abc import Mapping
from typing import Any

from ace_lite.benchmark.case_evaluation_namespace_lookup import (
    lookup_case_evaluation_value,
)


def lookup_case_evaluation_payload_value(
    namespace: Mapping[str, Any],
    key: str,
) -> Any:
    return lookup_case_evaluation_value(
        namespace,
        key,
        error_prefix="case-evaluation payload input",
    )


ROW_ARGUMENT_NAMES = (
    "case",
    "expected",
    "top_k",
    "recall_hit",
    "precision",
    "first_hit_rank",
    "hit_at_1",
    "reciprocal_rank",
    "utility",
    "task_success_hit",
    "task_success_config",
    "task_success_failed_checks",
    "noise",
    "dependency_recall",
    "memory_latency_ms",
    "index_latency_ms",
    "repomap_latency_ms",
    "repomap_worktree_seed_count",
    "repomap_subgraph_seed_count",
    "repomap_seed_candidates_count",
    "repomap_cache_hit",
    "repomap_precompute_hit",
    "augment_latency_ms",
    "skills_latency_ms",
    "source_plan_latency_ms",
    "latency_ms",
    "chunk_hit_at_k",
    "chunks_per_file_mean",
    "chunk_budget_used",
    "retrieval_context_chunk_count",
    "retrieval_context_coverage_ratio",
    "retrieval_context_char_count_mean",
    "contextual_sidecar_parent_symbol_chunk_count",
    "contextual_sidecar_parent_symbol_coverage_ratio",
    "contextual_sidecar_reference_hint_chunk_count",
    "contextual_sidecar_reference_hint_coverage_ratio",
    "retrieval_context_pool_chunk_count",
    "retrieval_context_pool_coverage_ratio",
    "chunk_contract_fallback_count",
    "chunk_contract_skeleton_chunk_count",
    "chunk_contract_fallback_ratio",
    "chunk_contract_skeleton_ratio",
    "chunk_cache_contract_present",
    "chunk_cache_contract_fingerprint_present",
    "chunk_cache_contract_metadata_aligned",
    "chunk_cache_contract_file_count",
    "chunk_cache_contract_chunk_count",
    "unsupported_language_fallback_count",
    "unsupported_language_fallback_ratio",
    "subgraph_payload_enabled",
    "subgraph_seed_path_count",
    "subgraph_edge_type_count",
    "subgraph_edge_total_count",
    "robust_signature_count",
    "robust_signature_coverage_ratio",
    "graph_prior_chunk_count",
    "graph_prior_coverage_ratio",
    "graph_prior_total",
    "graph_seeded_chunk_count",
    "graph_transfer_count",
    "graph_hub_suppressed_chunk_count",
    "graph_hub_penalty_total",
    "graph_closure_enabled",
    "graph_closure_boosted_chunk_count",
    "graph_closure_coverage_ratio",
    "graph_closure_anchor_count",
    "graph_closure_support_edge_count",
    "graph_closure_total",
    "topological_shield_enabled",
    "topological_shield_mode",
    "topological_shield_report_only",
    "topological_shield_max_attenuation",
    "topological_shield_shared_parent_attenuation",
    "topological_shield_adjacency_attenuation",
    "topological_shield_attenuated_chunk_count",
    "topological_shield_coverage_ratio",
    "topological_shield_attenuation_total",
    "topological_shield_attenuation_per_chunk",
    "graph_source_provider_loaded",
    "graph_source_projection_fallback",
    "graph_source_edge_count",
    "graph_source_inbound_signal_chunk_count",
    "graph_source_inbound_signal_coverage_ratio",
    "graph_source_centrality_signal_chunk_count",
    "graph_source_centrality_signal_coverage_ratio",
    "graph_source_pagerank_signal_chunk_count",
    "graph_source_pagerank_signal_coverage_ratio",
    "skills_selected_count",
    "skills_token_budget",
    "skills_token_budget_used",
    "skills_token_budget_utilization_ratio",
    "skills_budget_exhausted",
    "skills_skipped_for_budget_count",
    "skills_route_latency_ms",
    "skills_hydration_latency_ms",
    "skills_metadata_only_routing",
    "skills_precomputed_route",
    "skills_manifest_metadata_only_selected_count",
    "skills_manifest_body_scan_selected_count",
    "skills_selected_matched_count_mean",
    "skills_selected_signal_count_mean",
    "skills_selected_priority_mean",
    "candidate_rows_materialized_count",
    "candidate_chunks_materialized_count",
    "source_plan_candidate_chunks_materialized_count",
    "skills_markdown_bytes_loaded",
    "plan_replay_cache_enabled",
    "plan_replay_cache_hit",
    "plan_replay_cache_stale_hit_safe",
    "chunk_stage_miss",
    "validation_tests",
    "validation_probe_enabled",
    "validation_probe_status",
    "validation_probe_executed_count",
    "validation_probe_issue_count",
    "validation_branch_case",
    "validation_branch_candidate_count",
    "validation_branch_rejected_count",
    "validation_branch_selection_present",
    "validation_branch_patch_artifact_present",
    "validation_branch_archive_present",
    "validation_branch_parallel",
    "validation_branch_winner_passed",
    "validation_branch_winner_regressed",
    "validation_branch_winner_score",
    "validation_branch_winner_after_issue_count",
    "agent_loop_observed",
    "agent_loop_enabled",
    "agent_loop_attempted",
    "agent_loop_actions_requested",
    "agent_loop_actions_executed",
    "agent_loop_stop_reason",
    "agent_loop_replay_safe",
    "agent_loop_last_policy_id",
    "agent_loop_last_action_reason",
    "agent_loop_request_more_context_count",
    "agent_loop_request_source_plan_retry_count",
    "agent_loop_request_validation_retry_count",
    "agent_loop_validation_findings_refine_applied",
    "agent_loop_validation_findings_refine_focus_path_count",
    "source_plan_validation_feedback_present",
    "source_plan_validation_feedback_status",
    "source_plan_validation_feedback_issue_count",
    "source_plan_validation_feedback_probe_status",
    "source_plan_validation_feedback_probe_issue_count",
    "source_plan_validation_feedback_probe_executed_count",
    "source_plan_validation_feedback_selected_test_count",
    "source_plan_validation_feedback_executed_test_count",
    "source_plan_failure_signal_origin",
    "source_plan_failure_signal_present",
    "source_plan_failure_signal_status",
    "source_plan_failure_signal_issue_count",
    "source_plan_failure_signal_probe_status",
    "source_plan_failure_signal_probe_issue_count",
    "source_plan_failure_signal_probe_executed_count",
    "source_plan_failure_signal_selected_test_count",
    "source_plan_failure_signal_executed_test_count",
    "source_plan_failure_signal_has_failure",
    "source_plan_evidence_card_count",
    "source_plan_file_card_count",
    "source_plan_chunk_card_count",
    "source_plan_validation_card_present",
    "source_plan_evidence_summary",
    "source_plan_graph_closure_preference_enabled",
    "source_plan_graph_closure_bonus_candidate_count",
    "source_plan_graph_closure_preferred_count",
    "source_plan_granularity_preferred_count",
    "source_plan_focused_file_promoted_count",
    "source_plan_packed_path_count",
    "source_plan_chunk_retention_ratio",
    "source_plan_packed_path_ratio",
    "notes_hit_ratio",
    "profile_selected_count",
    "capture_triggered",
    "ltm_selected_count",
    "ltm_attribution_count",
    "ltm_graph_neighbor_count",
    "ltm_plan_constraint_count",
    "ltm_feedback_signal_counts",
    "ltm_attribution_scope_counts",
    "ltm_attribution_preview",
    "feedback_enabled",
    "feedback_reason",
    "feedback_event_count",
    "feedback_matched_event_count",
    "feedback_boosted_count",
    "feedback_boosted_paths",
    "multi_channel_rrf_enabled",
    "multi_channel_rrf_applied",
    "multi_channel_rrf_granularity_count",
    "multi_channel_rrf_pool_size",
    "multi_channel_rrf_granularity_pool_ratio",
    "graph_lookup_enabled",
    "graph_lookup_reason",
    "graph_lookup_guarded",
    "graph_lookup_boosted_count",
    "graph_lookup_weight_scip",
    "graph_lookup_weight_xref",
    "graph_lookup_weight_query_xref",
    "graph_lookup_weight_symbol",
    "graph_lookup_weight_import",
    "graph_lookup_weight_coverage",
    "graph_lookup_candidate_count",
    "graph_lookup_pool_size",
    "graph_lookup_query_terms_count",
    "graph_lookup_normalization",
    "graph_lookup_guard_max_candidates",
    "graph_lookup_guard_min_query_terms",
    "graph_lookup_guard_max_query_terms",
    "graph_lookup_query_hit_paths",
    "graph_lookup_scip_signal_paths",
    "graph_lookup_xref_signal_paths",
    "graph_lookup_symbol_hit_paths",
    "graph_lookup_import_hit_paths",
    "graph_lookup_coverage_hit_paths",
    "graph_lookup_max_inbound",
    "graph_lookup_max_xref_count",
    "graph_lookup_max_query_hits",
    "graph_lookup_max_symbol_hits",
    "graph_lookup_max_import_hits",
    "graph_lookup_max_query_coverage",
    "graph_lookup_boosted_path_ratio",
    "graph_lookup_query_hit_path_ratio",
    "native_scip_loaded",
    "native_scip_document_count",
    "native_scip_definition_occurrence_count",
    "native_scip_reference_occurrence_count",
    "native_scip_symbol_definition_count",
    "policy_profile",
    "graph_transfer_per_seed_ratio",
    "router_enabled",
    "router_mode",
    "router_arm_set",
    "router_arm_id",
    "router_confidence",
    "router_shadow_arm_id",
    "router_shadow_source",
    "router_shadow_confidence",
    "router_online_bandit_requested",
    "router_experiment_enabled",
    "router_online_bandit_active",
    "router_is_exploration",
    "router_exploration_probability",
    "router_fallback_applied",
    "router_fallback_reason",
    "router_online_bandit_reason",
    "docs_enabled_flag",
    "docs_hit",
    "hint_inject",
    "embedding_enabled",
    "embedding_runtime_provider",
    "embedding_strategy_mode",
    "embedding_semantic_rerank_applied",
    "embedding_similarity_mean",
    "embedding_similarity_max",
    "embedding_rerank_ratio",
    "embedding_cache_hit",
    "embedding_fallback",
    "parallel_time_budget_ms",
    "embedding_time_budget_ms",
    "chunk_semantic_time_budget_ms",
    "xref_time_budget_ms",
    "parallel_docs_timed_out",
    "parallel_worktree_timed_out",
    "embedding_time_budget_exceeded",
    "embedding_adaptive_budget_applied",
    "chunk_semantic_time_budget_exceeded",
    "chunk_semantic_fallback",
    "chunk_guard_enabled",
    "chunk_guard_mode",
    "chunk_guard_reason",
    "chunk_guard_report_only",
    "chunk_guard_filtered_count",
    "chunk_guard_filter_ratio",
    "chunk_guard_pairwise_conflict_count",
    "chunk_guard_pairwise_conflict_density",
    "chunk_guard_fallback",
    "chunk_guard_expectation",
    "xref_budget_exhausted",
    "slo_downgrade_signals",
    "decision_trace",
    "evidence_insufficiency",
)

DETAIL_ARGUMENT_NAMES = (
    "top_candidates",
    "included_candidate_paths",
    "included_candidate_globs",
    "excluded_candidate_paths",
    "excluded_candidate_globs",
    "relevant_candidate_paths",
    "noise_candidate_paths",
    "candidate_matches",
    "top_chunks",
    "expected_hits",
    "chunk_hits",
    "validation_tests",
    "source_plan_evidence_summary",
    "source_plan_card_summary",
    "source_plan_failure_signal_summary",
    "memory_latency_ms",
    "index_latency_ms",
    "repomap_latency_ms",
    "repomap_worktree_seed_count",
    "repomap_subgraph_seed_count",
    "repomap_seed_candidates_count",
    "repomap_cache_hit",
    "repomap_precompute_hit",
    "augment_latency_ms",
    "skills_latency_ms",
    "source_plan_latency_ms",
    "retrieval_context_chunk_count",
    "retrieval_context_coverage_ratio",
    "retrieval_context_char_count_mean",
    "contextual_sidecar_parent_symbol_chunk_count",
    "contextual_sidecar_parent_symbol_coverage_ratio",
    "contextual_sidecar_reference_hint_chunk_count",
    "contextual_sidecar_reference_hint_coverage_ratio",
    "chunk_contract_fallback_count",
    "chunk_contract_skeleton_chunk_count",
    "chunk_contract_fallback_ratio",
    "chunk_contract_skeleton_ratio",
    "chunk_cache_contract_present",
    "chunk_cache_contract_fingerprint_present",
    "chunk_cache_contract_metadata_aligned",
    "chunk_cache_contract_file_count",
    "chunk_cache_contract_chunk_count",
    "unsupported_language_fallback_count",
    "unsupported_language_fallback_ratio",
    "subgraph_payload_enabled",
    "subgraph_payload",
    "subgraph_seed_path_count",
    "subgraph_edge_type_count",
    "subgraph_edge_total_count",
    "subgraph_seed_paths",
    "subgraph_edge_counts",
    "skills_selected_count",
    "skills_token_budget",
    "skills_token_budget_used",
    "skills_token_budget_utilization_ratio",
    "skills_budget_exhausted",
    "skills_skipped_for_budget_count",
    "skills_payload",
    "skills_metadata_only_routing",
    "skills_route_latency_ms",
    "skills_hydration_latency_ms",
    "plan_replay_cache_enabled",
    "plan_replay_cache_hit",
    "plan_replay_cache_stale_hit_safe",
    "plan_replay_cache_payload",
    "chunk_stage_miss",
    "slo_downgrade_signals",
    "parallel_time_budget_ms",
    "embedding_time_budget_ms",
    "chunk_semantic_time_budget_ms",
    "xref_time_budget_ms",
    "chunk_guard_mode",
    "chunk_guard_reason",
    "chunk_guard_candidate_pool",
    "chunk_guard_signed_chunk_count",
    "chunk_guard_filtered_count",
    "chunk_guard_retained_count",
    "chunk_guard_pairwise_conflict_count",
    "chunk_guard_pairwise_conflict_density",
    "chunk_guard_max_conflict_penalty",
    "chunk_guard_payload",
    "chunk_guard_report_only",
    "chunk_guard_fallback",
    "chunk_guard_expectation",
    "robust_signature_count",
    "robust_signature_coverage_ratio",
    "graph_prior_chunk_count",
    "graph_prior_coverage_ratio",
    "graph_prior_total",
    "graph_seeded_chunk_count",
    "graph_transfer_count",
    "graph_transfer_per_seed_ratio",
    "graph_hub_suppressed_chunk_count",
    "graph_hub_penalty_total",
    "topological_shield_enabled",
    "topological_shield_mode",
    "topological_shield_report_only",
    "topological_shield_max_attenuation",
    "topological_shield_shared_parent_attenuation",
    "topological_shield_adjacency_attenuation",
    "topological_shield_attenuated_chunk_count",
    "topological_shield_coverage_ratio",
    "topological_shield_attenuation_total",
    "topological_shield_attenuation_per_chunk",
    "graph_source_provider_loaded",
    "graph_source_projection_fallback",
    "graph_source_edge_count",
    "graph_source_inbound_signal_chunk_count",
    "graph_source_inbound_signal_coverage_ratio",
    "graph_source_centrality_signal_chunk_count",
    "graph_source_centrality_signal_coverage_ratio",
    "graph_source_pagerank_signal_chunk_count",
    "graph_source_pagerank_signal_coverage_ratio",
    "graph_closure_enabled",
    "graph_closure_boosted_chunk_count",
    "graph_closure_coverage_ratio",
    "graph_closure_anchor_count",
    "graph_closure_support_edge_count",
    "graph_closure_total",
    "multi_channel_rrf_enabled",
    "multi_channel_rrf_applied",
    "multi_channel_rrf_granularity_count",
    "multi_channel_rrf_pool_size",
    "multi_channel_rrf_granularity_pool_ratio",
    "graph_lookup_enabled",
    "graph_lookup_reason",
    "graph_lookup_guarded",
    "graph_lookup_boosted_count",
    "graph_lookup_weight_scip",
    "graph_lookup_weight_xref",
    "graph_lookup_weight_query_xref",
    "graph_lookup_weight_symbol",
    "graph_lookup_weight_import",
    "graph_lookup_weight_coverage",
    "graph_lookup_candidate_count",
    "graph_lookup_pool_size",
    "graph_lookup_query_terms_count",
    "graph_lookup_normalization",
    "graph_lookup_guard_max_candidates",
    "graph_lookup_guard_min_query_terms",
    "graph_lookup_guard_max_query_terms",
    "graph_lookup_query_hit_paths",
    "graph_lookup_scip_signal_paths",
    "graph_lookup_xref_signal_paths",
    "graph_lookup_symbol_hit_paths",
    "graph_lookup_import_hit_paths",
    "graph_lookup_coverage_hit_paths",
    "graph_lookup_max_inbound",
    "graph_lookup_max_xref_count",
    "graph_lookup_max_query_hits",
    "graph_lookup_max_symbol_hits",
    "graph_lookup_max_import_hits",
    "graph_lookup_max_query_coverage",
    "graph_lookup_boosted_path_ratio",
    "graph_lookup_query_hit_path_ratio",
    "source_plan_graph_closure_preference_enabled",
    "source_plan_graph_closure_bonus_candidate_count",
    "source_plan_graph_closure_preferred_count",
    "source_plan_granularity_preferred_count",
    "source_plan_focused_file_promoted_count",
    "source_plan_packed_path_count",
    "source_plan_packed_path_ratio",
    "source_plan_chunk_retention_ratio",
    "source_plan_packing_reason",
)


__all__ = [
    "DETAIL_ARGUMENT_NAMES",
    "ROW_ARGUMENT_NAMES",
    "lookup_case_evaluation_payload_value",
]
