{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://u22a8.ai/schemas/samples.schema.json",
  "title": "Training Sample",
  "description": "Schema for a single line in a training JSONL file. Each line has a 'content' field and zero or more trait fields with quality values.",
  "type": "object",
  "required": ["content"],
  "properties": {
    "content": {
      "description": "The sample content. A string for plain text (the common case). Structured content (URL, image) uses an object with a 'type' discriminator.",
      "oneOf": [
        {
          "type": "string",
          "minLength": 1,
          "description": "Plain text content."
        },
        {
          "type": "object",
          "required": ["type"],
          "description": "Structured content (future extension).",
          "properties": {
            "type": {
              "type": "string",
              "enum": ["url", "image"],
              "description": "Content type discriminator."
            }
          },
          "allOf": [
            {
              "if": { "properties": { "type": { "const": "url" } } },
              "then": {
                "required": ["type", "url"],
                "properties": {
                  "type": { "const": "url" },
                  "url": { "type": "string", "format": "uri" }
                },
                "additionalProperties": false
              }
            },
            {
              "if": { "properties": { "type": { "const": "image" } } },
              "then": {
                "required": ["type"],
                "properties": {
                  "type": { "const": "image" },
                  "url": { "type": "string", "format": "uri" },
                  "path": { "type": "string" },
                  "base64": { "type": "string" }
                },
                "additionalProperties": false
              }
            }
          ]
        }
      ]
    }
  },
  "additionalProperties": {
    "description": "Trait field — the key is the field name (mapped to a trait in model.yaml), the value is a quality indicator.",
    "oneOf": [
      {
        "type": "string",
        "enum": [
          "positive", "negative",
          "good", "yes", "high", "strong", "excellent",
          "fair", "moderate", "mixed", "medium",
          "poor", "no", "low", "weak", "bad"
        ],
        "description": "Quality label."
      },
      {
        "type": "number",
        "minimum": 0,
        "maximum": 1,
        "description": "Numeric quality value in [0, 1]."
      }
    ]
  }
}
