schema_version: 1
case_id: ttl-row-processing-in-premium-cluster-during-sql-tail-latency-incident-window
ground_truth:
  root_cause: Correctly recognizing TTL activity in this incident window requires querying the real TiDB TTL counters instead of inferring from slow-query or generic log absence.
judge:
  semantic_strategy: undecided
  contract:
    checks:
    - id: cluster_scope_match
      required: true
      description: Actual diagnosis cluster scope matches the expected 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
  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
    - 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: 5
    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: 3
      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
  diagnosis:
    supporting:
      weight: 0
      checks:
      - id: ttl_json_output_present
        weight: 1
        description: The answer includes the TTL JSON payload.
        match: all_of
        rules:
        - source: output_text
          matcher: keyword_any
          keywords:
          - ttl_activity_present
    semantic:
      enabled: false
      checks:
      - id: 1
        weight: 1
        title: unused
        description: unused
        required: false
    hard_checks:
    - id: output_cluster_id_matches_reference
      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_window_start_matches_reference
      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
      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: evidence_sufficient_matches_reference
      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: ttl_activity_present_matches_reference
      description: Output JSON ttl_activity_present matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: ttl_activity_present
        reference_output_id: reference_answer
        reference_path: ttl_activity_present
    - id: ttl_insert_rows_delta_matches_reference
      description: Output JSON ttl_insert_rows_delta matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: signals.ttl_insert_rows_delta
        reference_output_id: reference_answer
        reference_path: signals.ttl_insert_rows_delta
    - id: ttl_processed_expired_rows_delta_matches_reference
      description: Output JSON ttl_processed_expired_rows_delta matches the runtime reference.
      match: all_of
      rules:
      - source: output_json
        matcher: json_path_equals_reference
        path: signals.ttl_processed_expired_rows_delta
        reference_output_id: reference_answer
        reference_path: signals.ttl_processed_expired_rows_delta
  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_cluster_id_matches_reference
    description: Output JSON cluster_id matches the runtime reference.
  - id: output_window_matches_reference
    description: Output JSON window.start and window.end match the runtime reference.
  - id: output_evidence_sufficient_matches_reference
    description: Output JSON evidence_sufficient matches the runtime reference.
  - id: output_ttl_activity_matches_reference
    description: Output JSON ttl_activity_present and signal values match the runtime reference.
