{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.bayanatlabs.com/research/arabic-preference-calibration-kit/v0.1/schema.json",
  "title": "Arabic preference pair (pairs.jsonl), Arabic Preference Calibration Kit v0.1",
  "type": "object",
  "required": ["pair_id", "prompt_variety", "target_variety", "messages", "response_a", "response_b", "gates", "criterion_scores", "gold", "rationale_en", "rubric_version"],
  "properties": {
    "pair_id": { "type": "string" },
    "prompt_variety": { "type": "string", "description": "Variety the user wrote in, e.g. msa, gulf_saudi, egyptian, levantine, gulf_saudi_code_switched." },
    "target_variety": { "enum": ["mirror_user", "msa"], "description": "Register policy for the reply." },
    "domain": { "type": "string" },
    "context": { "type": ["object", "null"], "properties": { "lang": { "type": "string" }, "text": { "type": "string" } } },
    "messages": { "type": "array", "items": { "type": "object", "required": ["role", "content"], "properties": { "role": { "enum": ["user", "assistant", "system"] }, "content": { "type": "string" } } } },
    "response_a": { "type": "string" },
    "response_b": { "type": "string" },
    "gates": {
      "type": "object",
      "properties": {
        "a": { "$ref": "#/$defs/gates" },
        "b": { "$ref": "#/$defs/gates" }
      }
    },
    "criterion_scores": {
      "type": "object",
      "properties": {
        "a": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/scores" }] },
        "b": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/scores" }] }
      }
    },
    "gold": {
      "type": "object",
      "required": ["outcome", "strength", "reason_codes"],
      "properties": {
        "outcome": { "enum": ["A", "B", "tie", "both_unacceptable", null] },
        "strength": { "enum": ["significantly_better", "slightly_better", "none", null] },
        "reason_codes": { "type": "array", "items": { "type": "string" } }
      }
    },
    "gold_rewrite": { "type": "string", "description": "Corrected response for both_unacceptable pairs; a supervised fine-tuning example." },
    "rationale_en": { "type": "string" },
    "tests": { "type": "string" },
    "response_source": { "type": "object" },
    "kit": { "type": "string" },
    "version": { "type": "string" },
    "rubric_version": { "type": "string" },
    "synthetic": { "type": "boolean" }
  },
  "$defs": {
    "gates": { "type": "object", "properties": { "safety": { "enum": ["pass", "fail"] }, "accuracy": { "enum": ["pass", "fail"] } } },
    "scores": {
      "type": "object",
      "properties": {
        "instruction_following": { "type": ["integer", "null"], "minimum": 0, "maximum": 4 },
        "dialect_fit": { "type": ["integer", "null"], "minimum": 0, "maximum": 4 },
        "register": { "type": ["integer", "null"], "minimum": 0, "maximum": 4 },
        "cultural_fit": { "type": ["integer", "null"], "minimum": 0, "maximum": 4 },
        "language_quality": { "type": ["integer", "null"], "minimum": 0, "maximum": 4 }
      }
    }
  }
}
