schema_version: 1
case_id: checkpoint-catchup-slow-after-changefeed-resume
ground_truth:
  expected_diagnosis_skill_routes:
  - any_of:
    - ticdc-health-inspection
    - tikv-cdc
  root_cause: The v8.5.7-release.1 storage sink flushed only one hard-coded batch of 4096 events per interval. At roughly 2000 DML/s, each flush advanced checkpoint-ts by only about two seconds, so backlog accumulated even after resolved-ts recovered. A long flush interval amplified the lag. The formal v8.5.7 build writes multiple batches; lowering flush interval is a mitigation.
judge:
  semantic_strategy: undecided
  contract:
    checks:
    - id: time_window_match
      required: true
      description: Actual diagnosis time window matches one allowed case window.
      match: all_of
      rules:
      - source: trace_fact
        matcher: bool_true
        path: time_window_match
    - id: cluster_scope_match
      required: true
      description: Actual diagnosis cluster scope matches expected cluster id.
      match: all_of
      rules:
      - source: trace_fact
        matcher: bool_true
        path: cluster_scope_match
  workflow:
    checks:
    - id: architecture_context_loaded
      weight: 5
      required: true
      description: Architecture context is loaded.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_true
        path: architecture_context_loaded
    - id: misdiagnosis_guardrails_loaded
      weight: 5
      required: true
      description: Misdiagnosis guardrails are loaded.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_true
        path: misdiagnosis_guardrails_loaded
    - id: diagnosis_run_initialized
      weight: 5
      required: true
      description: Diagnosis run is initialized.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_true
        path: diagnosis_run_initialized
    - id: evidence_collection_completed
      weight: 10
      required: true
      description: Evidence collection completes.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_true
        path: evidence_collection_completed
    - id: summary_read_completed
      weight: 5
      required: false
      description: Summary artifact is read when available.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_true
        path: summary_read_completed
    - id: final_answer_emitted
      weight: 0
      required: false
      description: Final answer is emitted.
      match: all_of
      rules:
      - source: workflow_fact
        matcher: bool_true
        path: final_answer_emitted
  execution_contract:
    checks:
    - id: required_workflow_present
      required: true
      description: Required workflow milestones are present.
      match: all_of
      rules:
      - source: workflow_check
        matcher: subset_observed
        paths:
        - architecture_context_loaded
        - misdiagnosis_guardrails_loaded
        - diagnosis_run_initialized
        - evidence_collection_completed
    - id: required_artifacts_present
      required: true
      description: Required evidence artifacts are present.
      match: all_of
      rules:
      - source: artifact_fact
        matcher: subset_observed
        paths:
        - core_evidence_bundle_present
    - id: preferred_channels_minimum_observed
      required: true
      description: At least one preferred evidence channel is observed.
      match: all_of
      rules:
      - source: channel_fact
        matcher: count_gte
        paths:
        - query_or_metric
        - logs
        - events
        threshold: 1
    - id: preferred_channels_all_observed
      required: false
      description: Preferred evidence channels are all observed.
      match: all_of
      rules:
      - source: channel_fact
        matcher: subset_observed
        paths:
        - query_or_metric
        - logs
        - events
  evidence_collection:
    weight: 5
    checks:
    - id: required_artifacts_present
      weight: 4
      required: true
      description: Required evidence artifacts are present and readable.
      match: all_of
      rules:
      - source: artifact_fact
        matcher: subset_observed
        paths:
        - core_evidence_bundle_present
    - id: preferred_channels_minimum_observed
      weight: 0
      required: true
      description: At least the minimum number of preferred evidence channels are observed.
      match: all_of
      rules:
      - source: channel_fact
        matcher: count_gte
        paths:
        - query_or_metric
        - logs
        - events
        threshold: 1
    - id: preferred_channels_all_observed
      weight: 6
      required: false
      description: Preferred evidence channels are all observed.
      match: all_of
      rules:
      - source: channel_fact
        matcher: subset_observed
        paths:
        - query_or_metric
        - logs
        - events
  critical_evidence:
    weight: 30
    checks:
    - id: primary_symptom_evidence_present
      weight: 10
      description: Primary symptom evidence is present in the collected evidence.
      match: any_of
      rules:
      - source: logs
        matcher: keyword_any
        keywords:
        - resolved-ts
        - checkpoint-ts
        - 2 seconds
        - flush
        - backlog
      - source: artifact_json
        artifacts:
        - metrics
        - queries
        - summary_json
        - workspace_report
        matcher: json_text_contains_any
        keywords:
        - resolved-ts
        - checkpoint-ts
        - 2 seconds
        - flush
        - backlog
    - id: root_cause_mechanism_evidence_present
      weight: 10
      description: Root-cause mechanism evidence is present in the collected evidence.
      match: any_of
      rules:
      - source: logs
        matcher: keyword_any
        keywords:
        - '4096'
        - batch
        - storage sink
        - hard-coded
        - events
      - source: artifact_json
        artifacts:
        - metrics
        - queries
        - summary_json
        - workspace_report
        matcher: json_text_contains_any
        keywords:
        - '4096'
        - batch
        - storage sink
        - hard-coded
        - events
    - id: scope_or_timeline_evidence_present
      weight: 10
      description: Throughput and configuration evidence is present in the collected evidence.
      match: any_of
      rules:
      - source: logs
        matcher: keyword_any
        keywords:
        - '2000'
        - DML/s
        - flush-interval
        - 60s
        - 300s
      - source: artifact_json
        artifacts:
        - metrics
        - queries
        - summary_json
        - workspace_report
        matcher: json_text_contains_any
        keywords:
        - '2000'
        - DML/s
        - flush-interval
        - 60s
        - 300s
  evidence_routing:
    weight: 5
    checks:
    - id: specialist_routing_contract
      weight: 3
      required: true
      description: Diagnosis is authored by the analyst with a valid classification and the expected specialist route.
      match: all_of
      rules:
      - source: routing_fact
        matcher: bool_true
        path: diagnosis_analyst_dispatched
      - source: routing_fact
        matcher: bool_true
        path: classification_contract_valid
      - source: routing_fact
        matcher: bool_true
        path: expected_diagnosis_skill_routes_selected
    - id: analysis_patch_valid_json
      weight: 1
      required: true
      description: Analysis patch is valid JSON whenever the patch 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
    - id: analysis_items_shape_valid
      weight: 2
      required: true
      description: Analysis patch items are structurally valid whenever the patch exists.
      match: any_of
      rules:
      - source: routing_fact
        matcher: bool_false
        path: analysis_patch_present
      - source: routing_fact
        matcher: bool_true
        path: analysis_items_shape_valid
    - id: analysis_key_evidence_present
      weight: 2
      required: true
      description: Analysis patch includes key evidence whenever the patch exists.
      match: any_of
      rules:
      - source: routing_fact
        matcher: bool_false
        path: analysis_patch_present
      - source: routing_fact
        matcher: bool_true
        path: analysis_has_key_evidence
    - id: metric_refs_resolvable
      weight: 1
      required: true
      description: Metric references resolve whenever the patch requires them.
      match: any_of
      rules:
      - source: routing_fact
        matcher: bool_false
        path: analysis_patch_present
      - source: routing_fact
        matcher: bool_true
        path: analysis_metric_refs_resolvable
    - id: query_refs_resolvable
      weight: 1
      required: true
      description: Query references resolve whenever the patch requires them.
      match: any_of
      rules:
      - source: routing_fact
        matcher: bool_false
        path: analysis_patch_present
      - source: routing_fact
        matcher: bool_true
        path: analysis_query_refs_resolvable
  diagnosis:
    checks:
    - id: identify_primary_failure_mechanism
      mode: blended
      weight: 3
      required: true
      description: Primary failure mechanism is identified and supported.
      deterministic:
        match: all_of
        rules:
        - source: output_text
          matcher: keyword_any
          keywords:
          - '4096'
          - batch
        - source: output_text
          matcher: keyword_any
          keywords:
          - storage sink
          - flush
        - source: output_text
          matcher: keyword_any
          keywords:
          - checkpoint
          - progress
      semantic:
        id: 1
        title: Primary failure mechanism
        description: The answer identifies the single-batch-per-flush storage-sink limitation.
    - id: explain_causal_chain
      mode: blended
      weight: 3
      required: true
      description: Causal chain is identified and supported.
      deterministic:
        match: all_of
        rules:
        - source: output_text
          matcher: keyword_any
          keywords:
          - DML/s
          - event rate
          - '2000'
        - source: output_text
          matcher: keyword_any
          keywords:
          - 2 seconds
          - slow advance
        - source: output_text
          matcher: keyword_any
          keywords:
          - flush interval
          - backlog
      semantic:
        id: 2
        title: Causal chain
        description: The answer quantitatively links event rate and batch limit to slow checkpoint progress and explains interval amplification.
    - id: recommend_aligned_remediation
      mode: blended
      weight: 3
      required: true
      description: Aligned remediation is identified and supported.
      deterministic:
        match: all_of
        rules:
        - source: output_text
          matcher: keyword_any
          keywords:
          - formal v8.5.7
          - upgrade
          - fixed build
        - source: output_text
          matcher: keyword_any
          keywords:
          - lower
          - reduce
        - source: output_text
          matcher: keyword_any
          keywords:
          - flush interval
      semantic:
        id: 3
        title: Aligned remediation
        description: The answer recommends the multi-batch fixed build and a shorter flush interval as mitigation.
