{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hurtbybot.com/data/schema.json",
  "title": "Hurt by Bot public incident dataset",
  "type": "object",
  "additionalProperties": true,
  "$defs": {
    "agent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "product",
        "autonomy",
        "approval_bypassed",
        "reversible",
        "recovered"
      ],
      "properties": {
        "product": {
          "type": "string"
        },
        "autonomy": {
          "enum": [
            "human-in-loop",
            "human-on-loop",
            "autonomous",
            "third-party-directed",
            "unknown"
          ]
        },
        "approval_bypassed": {
          "enum": [
            "yes",
            "partial",
            "no",
            "unknown"
          ]
        },
        "reversible": {
          "enum": [
            "yes",
            "partial",
            "no",
            "unknown"
          ]
        },
        "recovered": {
          "enum": [
            "yes",
            "partial",
            "no",
            "unknown"
          ]
        }
      }
    },
    "editorial": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source_checked_date",
        "changes"
      ],
      "properties": {
        "source_checked_date": {
          "type": "string",
          "format": "date",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "applied_date": {
          "type": "string",
          "format": "date",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "changes": {
          "type": "object",
          "propertyNames": {
            "enum": [
              "en",
              "zh",
              "es",
              "pt",
              "fr",
              "de",
              "ja",
              "ko"
            ]
          },
          "additionalProperties": {
            "type": "string",
            "minLength": 1
          },
          "required": [
            "en"
          ]
        }
      }
    },
    "basis": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "severity",
        "translations",
        "source_urls"
      ],
      "properties": {
        "severity": {
          "type": "string",
          "minLength": 1
        },
        "translations": {
          "type": "object",
          "propertyNames": {
            "enum": [
              "en",
              "zh",
              "es",
              "pt",
              "fr",
              "de",
              "ja",
              "ko"
            ]
          },
          "additionalProperties": {
            "type": "string",
            "minLength": 1
          }
        },
        "source_urls": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  },
  "properties": {
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "incidents": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "translations": {
            "type": "object",
            "propertyNames": {
              "enum": [
                "zh",
                "es",
                "pt",
                "fr",
                "de",
                "ja",
                "ko"
              ]
            }
          },
          "severity": {
            "type": "integer",
            "enum": [
              1,
              2,
              3,
              4,
              5,
              0
            ],
            "description": "0 is unrated, outside the ordinal 1..5 scale; never zero harm."
          },
          "severity_slug": {
            "enum": [
              "minor",
              "moderate",
              "serious",
              "severe",
              "catastrophic",
              "unknown"
            ]
          },
          "severity_rated": {
            "type": "boolean"
          },
          "followup_as_of": {
            "anyOf": [
              {
                "type": "string",
                "format": "date",
                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "agent": {
            "anyOf": [
              {
                "$ref": "#/$defs/agent"
              },
              {
                "type": "null"
              }
            ]
          },
          "editorial_correction": {
            "anyOf": [
              {
                "$ref": "#/$defs/editorial"
              },
              {
                "type": "null"
              }
            ]
          },
          "editorial_basis": {
            "anyOf": [
              {
                "$ref": "#/$defs/basis"
              },
              {
                "type": "null"
              }
            ]
          },
          "timeline": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "enum": [
                    "first_report",
                    "response",
                    "lawsuit",
                    "regulatory",
                    "outcome",
                    "update",
                    "statement_note"
                  ]
                },
                "text": {
                  "type": "string"
                }
              },
              "required": [
                "type",
                "text"
              ]
            }
          },
          "system_types": {
            "type": "array",
            "items": {
              "enum": [
                "chatbot",
                "ai-agent",
                "generative-media",
                "recommender",
                "autonomous-vehicle",
                "biometrics",
                "decision-system",
                "robot",
                "llm-tooling",
                "unknown",
                "other"
              ]
            },
            "allOf": [
              {
                "if": {
                  "contains": {
                    "const": "unknown"
                  }
                },
                "then": {
                  "maxItems": 1
                }
              }
            ]
          },
          "sectors": {
            "type": "array",
            "items": {
              "enum": [
                "finance",
                "health",
                "transport",
                "justice",
                "government",
                "employment",
                "education",
                "media",
                "retail",
                "technology",
                "housing",
                "personal",
                "politics",
                "unknown",
                "other"
              ]
            },
            "allOf": [
              {
                "if": {
                  "contains": {
                    "const": "unknown"
                  }
                },
                "then": {
                  "maxItems": 1
                }
              }
            ]
          }
        },
        "required": [
          "id",
          "url",
          "title",
          "summary",
          "severity",
          "severity_slug",
          "severity_rated"
        ],
        "allOf": [
          {
            "if": {
              "properties": {
                "severity": {
                  "const": 0
                }
              },
              "required": [
                "severity"
              ]
            },
            "then": {
              "properties": {
                "severity_rated": {
                  "const": false
                },
                "severity_slug": {
                  "const": "unknown"
                }
              }
            },
            "else": {
              "properties": {
                "severity_rated": {
                  "const": true
                },
                "severity_slug": {
                  "enum": [
                    "minor",
                    "moderate",
                    "serious",
                    "severe",
                    "catastrophic"
                  ]
                }
              }
            }
          }
        ]
      }
    }
  },
  "required": [
    "count",
    "incidents"
  ]
}
