{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pollinationtech.com/open/pollination-observation.schema.json",
  "title": "PollinationTech Open Observation",
  "description": "Experimental vendor-neutral record for pollination-related observations, events, measurements, provenance, biological context, permissions, and links to related observations.",
  "type": "object",
  "required": [
    "schema_version",
    "record_id",
    "observed_at",
    "observation_type",
    "measurement_level",
    "source",
    "location",
    "measurements",
    "provenance"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "0.2.0"
    },
    "record_id": {
      "type": "string",
      "minLength": 3,
      "description": "Stable unique identifier within the publishing system."
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "observation_type": {
      "type": "string",
      "enum": [
        "environment",
        "bloom_stage",
        "pollinator_presence",
        "flower_visitation",
        "pollen_transfer",
        "reproductive_outcome",
        "agricultural_outcome",
        "colony_state",
        "hive_activity",
        "intervention"
      ]
    },
    "measurement_level": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5,
      "description": "0 environment; 1 presence/activity; 2 visitation; 3 pollen transfer; 4 reproductive outcome; 5 agricultural outcome."
    },
    "source": {
      "type": "object",
      "required": [
        "system_name",
        "source_type"
      ],
      "properties": {
        "system_name": {
          "type": "string"
        },
        "organization": {
          "type": "string"
        },
        "source_type": {
          "type": "string",
          "enum": [
            "sensor",
            "human_observation",
            "computer_vision",
            "acoustics",
            "radar",
            "weather_service",
            "remote_sensing",
            "laboratory",
            "farm_record",
            "model",
            "other"
          ]
        },
        "device_id": {
          "type": "string"
        },
        "software_version": {
          "type": "string"
        },
        "method_uri": {
          "type": "string",
          "format": "uri"
        }
      },
      "additionalProperties": true
    },
    "location": {
      "type": "object",
      "required": [
        "latitude",
        "longitude"
      ],
      "properties": {
        "latitude": {
          "type": "number",
          "minimum": -90,
          "maximum": 90
        },
        "longitude": {
          "type": "number",
          "minimum": -180,
          "maximum": 180
        },
        "accuracy_m": {
          "type": "number",
          "minimum": 0
        },
        "elevation_m": {
          "type": "number"
        },
        "field_id": {
          "type": "string"
        },
        "apiary_id": {
          "type": "string"
        },
        "privacy_precision": {
          "type": "string",
          "enum": [
            "exact",
            "100m",
            "1km",
            "10km",
            "region",
            "withheld"
          ]
        },
        "geometry_uri": {
          "type": "string",
          "format": "uri",
          "description": "Optional external geometry or feature URI for field, polygon, transect, raster cell, or region."
        },
        "coordinate_reference_system": {
          "type": "string",
          "default": "EPSG:4326"
        }
      },
      "additionalProperties": false
    },
    "biological_context": {
      "type": "object",
      "properties": {
        "crop_common_name": {
          "type": "string"
        },
        "plant_scientific_name": {
          "type": "string"
        },
        "pollinator_common_name": {
          "type": "string"
        },
        "pollinator_scientific_name": {
          "type": "string"
        },
        "colony_id": {
          "type": "string"
        },
        "bloom_stage": {
          "type": "string",
          "enum": [
            "pre_bloom",
            "first_bloom",
            "early_bloom",
            "peak_bloom",
            "late_bloom",
            "petal_fall",
            "post_bloom",
            "unknown"
          ]
        },
        "flower_unit": {
          "type": "string",
          "description": "Flower, inflorescence, head, tree, transect, or other observational unit."
        }
      },
      "additionalProperties": true
    },
    "measurements": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "variable",
          "value"
        ],
        "properties": {
          "variable": {
            "type": "string"
          },
          "value": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "unit": {
            "type": "string"
          },
          "method": {
            "type": "string"
          },
          "aggregation": {
            "type": "string",
            "enum": [
              "instantaneous",
              "mean",
              "median",
              "sum",
              "count",
              "min",
              "max",
              "rate",
              "classification",
              "other"
            ]
          },
          "interval_seconds": {
            "type": "number",
            "minimum": 0
          },
          "uncertainty": {
            "type": "number",
            "minimum": 0
          },
          "confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "quality_flag": {
            "type": "string",
            "enum": [
              "raw",
              "validated",
              "estimated",
              "modeled",
              "flagged",
              "missing"
            ]
          },
          "sensor_depth_cm": {
            "type": "number"
          },
          "sampling_interval_seconds": {
            "type": "number",
            "minimum": 0
          },
          "detection_limit": {
            "type": "number"
          },
          "reference_frame": {
            "type": "string"
          },
          "classification_label": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "environment": {
      "type": "object",
      "properties": {
        "temperature_c": {
          "type": "number"
        },
        "relative_humidity_pct": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "wind_speed_m_s": {
          "type": "number",
          "minimum": 0
        },
        "precipitation_mm": {
          "type": "number",
          "minimum": 0
        },
        "growing_degree_days": {
          "type": "number",
          "minimum": 0
        },
        "gdd_base_c": {
          "type": "number"
        }
      },
      "additionalProperties": true
    },
    "intervention": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "actor": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "provenance": {
      "type": "object",
      "required": [
        "created_at",
        "publisher"
      ],
      "properties": {
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "publisher": {
          "type": "string"
        },
        "source_record_id": {
          "type": "string"
        },
        "derived_from": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "processing_notes": {
          "type": "string"
        },
        "license": {
          "type": "string"
        },
        "attribution": {
          "type": "string"
        },
        "source_uri": {
          "type": "string",
          "format": "uri"
        },
        "processing_software": {
          "type": "string"
        },
        "processing_version": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "permissions": {
      "type": "object",
      "properties": {
        "access": {
          "type": "string",
          "enum": [
            "public",
            "restricted",
            "private"
          ]
        },
        "redistribution": {
          "type": "string",
          "enum": [
            "allowed",
            "with_attribution",
            "restricted",
            "prohibited",
            "unknown"
          ]
        },
        "commercial_use": {
          "type": "string",
          "enum": [
            "allowed",
            "restricted",
            "prohibited",
            "unknown"
          ]
        },
        "location_redaction_required": {
          "type": "boolean"
        },
        "purpose_restrictions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    "links": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "rel",
          "href"
        ],
        "properties": {
          "rel": {
            "type": "string"
          },
          "href": {
            "type": "string",
            "format": "uri"
          }
        },
        "additionalProperties": false
      }
    },
    "observation_window": {
      "type": "object",
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "type": "string",
          "format": "date-time"
        },
        "duration_seconds": {
          "type": "number",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "subject": {
      "type": "object",
      "properties": {
        "subject_type": {
          "type": "string",
          "enum": [
            "colony",
            "hive",
            "apiary",
            "pollinator",
            "flower",
            "plant",
            "crop",
            "field",
            "landscape",
            "weather_grid",
            "other"
          ]
        },
        "subject_id": {
          "type": "string"
        },
        "parent_subject_id": {
          "type": "string"
        },
        "taxon_id": {
          "type": "string",
          "description": "Optional external taxonomy identifier, URI, or controlled-vocabulary identifier."
        }
      },
      "additionalProperties": true
    },
    "calibration": {
      "type": "object",
      "properties": {
        "calibrated_at": {
          "type": "string",
          "format": "date-time"
        },
        "method": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "coefficient": {
          "type": "number"
        },
        "offset": {
          "type": "number"
        }
      },
      "additionalProperties": true
    },
    "relationships": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "rel",
          "record_id"
        ],
        "properties": {
          "rel": {
            "type": "string",
            "enum": [
              "derived_from",
              "calibrates",
              "validates",
              "same_event_as",
              "precedes",
              "follows",
              "outcome_of",
              "aggregates",
              "other"
            ]
          },
          "record_id": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "controlled_terms": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "scheme",
          "term"
        ],
        "properties": {
          "scheme": {
            "type": "string"
          },
          "term": {
            "type": "string"
          },
          "uri": {
            "type": "string",
            "format": "uri"
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}