{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "HeyData outcome labels (Example schema; each deal publishes its own)",
  "type": "object",
  "required": [
    "session_id",
    "task_category",
    "outcome"
  ],
  "properties": {
    "session_id": {
      "type": "string",
      "description": "Capture session id from the delivery manifest"
    },
    "task_category": {
      "type": "string",
      "examples": [
        "picking",
        "packing",
        "returns",
        "repair",
        "prep"
      ]
    },
    "outcome": {
      "type": "object",
      "description": "One outcome per session, joined from the business's own records",
      "oneOf": [
        {
          "properties": {
            "type": {
              "const": "fulfilment"
            },
            "result": {
              "enum": [
                "fulfilled_correctly",
                "mis_pick",
                "short_pick",
                "damaged"
              ]
            },
            "source": {
              "const": "order_record"
            }
          }
        },
        {
          "properties": {
            "type": {
              "const": "return_disposition"
            },
            "result": {
              "enum": [
                "restock",
                "refurbish",
                "liquidate",
                "dispose",
                "refund_only"
              ]
            },
            "source": {
              "const": "returns_record"
            }
          }
        },
        {
          "properties": {
            "type": {
              "const": "ticket_resolution"
            },
            "result": {
              "enum": [
                "resolved",
                "escalated",
                "reopened"
              ]
            },
            "source": {
              "const": "support_ticket"
            }
          }
        },
        {
          "properties": {
            "type": {
              "const": "qa_check"
            },
            "result": {
              "enum": [
                "pass",
                "fail"
              ]
            },
            "defect_code": {
              "type": "string"
            },
            "source": {
              "const": "qa_record"
            }
          }
        }
      ]
    },
    "segments": {
      "type": "array",
      "description": "Action segments labelled by vetted experts",
      "items": {
        "type": "object",
        "required": [
          "start_s",
          "end_s",
          "action"
        ],
        "properties": {
          "start_s": {
            "type": "number"
          },
          "end_s": {
            "type": "number"
          },
          "action": {
            "type": "string",
            "examples": [
              "reach",
              "grasp",
              "scan",
              "place",
              "inspect"
            ]
          }
        }
      }
    },
    "quality_rating": {
      "type": "integer",
      "minimum": 1,
      "maximum": 5,
      "description": "Expert rating of the clip's usefulness"
    },
    "agreement": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Inter-annotator agreement for the segments, where two experts labelled the clip"
    }
  }
}
