{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agrodt.github.io/agrotool-knowledge-portal/schemas/v3/component_state_events.schema.json",
  "title": "PublicComponentStateEventsV3",
  "type": "array",
  "items": {
    "type": "object",
    "allOf": [
      { "$ref": "../v1/common.schema.json#/$defs/recordMetadata" },
      {
        "type": "object",
        "required": [
          "component_state_event_id",
          "component_id",
          "line",
          "state_kind",
          "state_value",
          "event_date",
          "observed_at",
          "date_precision",
          "version_applicability",
          "evidence_class",
          "evidence_hierarchy_version",
          "assertion_status",
          "conflict_event_ids",
          "evidence_summary_ids",
          "source_ids",
          "derivation_method",
          "derivation_version",
          "limitations"
        ],
        "properties": {
          "component_state_event_id": {
            "type": "string",
            "pattern": "^CSE[A-Z0-9_-]{1,60}$"
          },
          "component_id": {
            "type": "string",
            "pattern": "^CMP[A-Z0-9_-]{1,61}$"
          },
          "line": { "$ref": "#/$defs/systemLine" },
          "state_kind": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "state_value": {
            "enum": [
              "described",
              "announced",
              "available",
              "tested",
              "quality_checked",
              "reported",
              "supported",
              "mixed",
              "not_supported",
              "contested",
              "deprecated",
              "superseded",
              "withdrawn"
            ]
          },
          "event_date": { "type": "string", "format": "date" },
          "observed_at": { "type": "string", "format": "date" },
          "date_precision": { "enum": ["day", "month", "year"] },
          "version_applicability": {
            "$ref": "../v3/component_mappings.schema.json#/$defs/versionApplicability"
          },
          "evidence_class": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "evidence_hierarchy_version": {
            "type": "string",
            "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
          },
          "assertion_status": {
            "enum": ["source_asserted", "computation_result", "candidate"]
          },
          "conflict_event_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^CSE[A-Z0-9_-]{1,60}$"
            },
            "uniqueItems": true
          },
          "evidence_summary_ids": {
            "allOf": [
              { "$ref": "../v1/common.schema.json#/$defs/evidenceIds" },
              { "type": "array", "minItems": 1 }
            ]
          },
          "source_ids": {
            "allOf": [
              { "$ref": "../v1/common.schema.json#/$defs/sourceIds" },
              { "type": "array", "minItems": 1 }
            ]
          },
          "derivation_method": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "derivation_version": { "type": "string", "minLength": 1 },
          "limitations": {
            "$ref": "../v1/common.schema.json#/$defs/localizedText"
          }
        }
      }
    ],
    "unevaluatedProperties": false
  },
  "$defs": {
    "systemLine": {
      "enum": ["scientific_model", "software", "data", "validation"]
    }
  }
}
