schema_version: 1
case_id: read-pool-cpu-scope-compare-in-premium-cluster-during-latest-window
ground_truth:
  root_cause: >-
    Correctly answering this ad-hoc case requires keeping the scope distinction
    between a single TiKV instance peak unified-read-pool CPU value and the
    cluster-total peak value across the same window, without confusing the
    aggregate sum for a single-node measurement.
judge:
  semantic_strategy: undecided
  contract:
    checks:
    - id: cluster_scope_match
      required: true
      description: Actual diagnosis cluster scope matches the expected logical cluster id.
      match: all_of
      rules:
      - source: trace_fact
        matcher: bool_true
        path: cluster_scope_match
  workflow:
    checks:
    - id: final_answer_emitted
      weight: 0
      required: true
      description: Final answer is emitted for the ad-hoc query.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_true
        path: final_answer_emitted
    - id: collect_evidence_not_used
      weight: 0
      required: true
      description: This ad-hoc case must not invoke collect_evidence.py.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_false
        path: collect_evidence_invoked
  execution_contract:
    checks:
    - id: required_workflow_present
      required: true
      description: The minimal ad-hoc workflow is present.
      match: all_of
      rules:
      - source: workflow_check
        matcher: subset_observed
        paths:
        - final_answer_emitted
        - collect_evidence_not_used
    - id: required_report_present
      required: true
      description: Workspace diagnosis report is present.
      match: all_of
      rules:
      - source: artifact_fact
        matcher: subset_observed
        paths:
        - diagnosis_report_present
    - id: query_or_metric_channel_observed
      required: true
      description: At least one query or metric evidence channel is observed.
      match: all_of
      rules:
      - source: channel_fact
        matcher: count_gte
        paths:
        - query_or_metric
        threshold: 1
  evidence_collection:
    weight: 6
    checks:
    - id: required_report_present
      weight: 2
      required: true
      description: Workspace diagnosis report is present and readable.
      match: all_of
      rules:
      - source: artifact_fact
        matcher: subset_observed
        paths:
        - diagnosis_report_present
    - id: query_or_metric_channel_observed
      weight: 2
      required: true
      description: Query or metric evidence is observed for this ad-hoc request.
      match: all_of
      rules:
      - source: channel_fact
        matcher: count_gte
        paths:
        - query_or_metric
        threshold: 1
  critical_evidence:
    weight: 80
    checks:
    - id: read_pool_metric_present
      weight: 6
      required: true
      description: Evidence includes unified read pool CPU metrics.
      match: any_of
      rules:
      - source: artifact_json
        artifacts:
        - metrics
        - workspace_report
        matcher: json_text_contains_any
        keywords:
        - tikv_unified_read_pool_cpu
    - id: output_cluster_id_matches_reference
      weight: 6
      required: true
      description: Output JSON cluster_id matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: cluster_id
        reference_output_id: reference_answer
        reference_path: cluster_id
    - id: output_metrics_cluster_id_matches_reference
      weight: 6
      required: true
      description: Output JSON metrics_cluster_id matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: metrics_cluster_id
        reference_output_id: reference_answer
        reference_path: metrics_cluster_id
    - id: output_window_start_matches_reference
      weight: 5
      required: true
      description: Output JSON window.start matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: window.start
        reference_output_id: reference_answer
        reference_path: window.start
    - id: output_window_end_matches_reference
      weight: 5
      required: true
      description: Output JSON window.end matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: window.end
        reference_output_id: reference_answer
        reference_path: window.end
    - id: output_evidence_sufficient_matches_reference
      weight: 5
      required: true
      description: Output JSON evidence_sufficient matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: evidence_sufficient
        reference_output_id: reference_answer
        reference_path: evidence_sufficient
    - id: output_peak_instance_node_matches_reference
      weight: 12
      required: true
      description: Output JSON peak_instance_node matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: peak_instance_node
        reference_output_id: reference_answer
        reference_path: peak_instance_node
    - id: output_peak_instance_cpu_matches_reference
      weight: 17
      required: true
      description: Output JSON peak_instance_read_pool_cpu_cores matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: peak_instance_read_pool_cpu_cores
        reference_output_id: reference_answer
        reference_path: peak_instance_read_pool_cpu_cores
    - id: output_cluster_total_peak_matches_reference
      weight: 18
      required: true
      description: Output JSON cluster_total_peak_read_pool_cpu_cores matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: cluster_total_peak_read_pool_cpu_cores
        reference_output_id: reference_answer
        reference_path: cluster_total_peak_read_pool_cpu_cores
  diagnosis:
    supporting:
      weight: 0
      checks:
      - id: structured_json_output_present
        weight: 1
        description: The answer includes the expected structured JSON payload.
        match: all_of
        rules:
        - source: output_text
          matcher: keyword_any
          keywords:
          - peak_instance_node
          - peak_instance_read_pool_cpu_cores
          - cluster_total_peak_read_pool_cpu_cores
    semantic:
      enabled: false
      checks:
      - id: 1
        weight: 1
        title: unused
        description: unused
        required: false
    hard_checks:
    - id: output_peak_instance_node_matches_reference
      description: Output JSON peak_instance_node matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: peak_instance_node
        reference_output_id: reference_answer
        reference_path: peak_instance_node
    - id: output_peak_instance_cpu_matches_reference
      description: Output JSON peak_instance_read_pool_cpu_cores matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: peak_instance_read_pool_cpu_cores
        reference_output_id: reference_answer
        reference_path: peak_instance_read_pool_cpu_cores
    - id: output_cluster_total_peak_matches_reference
      description: Output JSON cluster_total_peak_read_pool_cpu_cores matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: cluster_total_peak_read_pool_cpu_cores
        reference_output_id: reference_answer
        reference_path: cluster_total_peak_read_pool_cpu_cores
  evidence_routing:
    weight: 0
    checks:
    - id: analysis_patch_valid_when_present
      weight: 0
      required: true
      description: Analysis patch is only required to be valid when it exists.
      match: any_of
      rules:
      - source: routing_fact
        matcher: bool_false
        path: analysis_patch_present
      - source: routing_fact
        matcher: bool_true
        path: analysis_patch_valid_json
  critical:
  - id: output_peak_instance_node_matches_reference
    description: Output JSON peak_instance_node matches the runtime reference.
  - id: output_peak_instance_cpu_matches_reference
    description: Output JSON peak_instance_read_pool_cpu_cores matches the runtime reference.
  - id: output_cluster_total_peak_matches_reference
    description: Output JSON cluster_total_peak_read_pool_cpu_cores matches the runtime reference.
