{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openssom.org/schema/profile-origin-free-observation.json",
  "title": "SSOM Origin-free Release Profile: Observation",
  "description": "An Observation as released under the origin-free release profile. It has no place for a source system, a host, an address, a tag, a clock source, a transport time, a software version, a person, a grouping token, or any text. At base level the original measurement keeps the value and unit the source gave; the reserve option rounding_and_source_measurement_removal replaces them with the released value and unit. Unknown properties are rejected.",
  "allOf": [
    {
      "$ref": "observation.json"
    }
  ],
  "type": "object",
  "required": [
    "record_id",
    "semantic_truth_state",
    "ssom_version",
    "subject_ref",
    "signal_ref",
    "metric",
    "value",
    "event_time",
    "quality",
    "provenance",
    "temporal_integrity"
  ],
  "properties": {
    "record_id": {
      "type": "string",
      "pattern": "^urn:ssom:record:tok:[0-9a-f]{32,64}$"
    },
    "semantic_truth_state": {
      "const": "observation"
    },
    "ssom_version": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]*$"
    },
    "subject_ref": {
      "type": "string",
      "pattern": "^urn:ssom:asset:tok:[0-9a-f]{32,64}$"
    },
    "signal_ref": {
      "type": "string",
      "pattern": "^urn:ssom:signal:tok:[0-9a-f]{32,64}$"
    },
    "metric": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*$"
    },
    "value": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        }
      ]
    },
    "event_time": {
      "type": "string",
      "format": "date-time"
    },
    "quality": {
      "type": "object",
      "required": [
        "status",
        "validation_status"
      ],
      "properties": {
        "status": {},
        "validation_status": {}
      },
      "additionalProperties": false
    },
    "canonical_measurement": {
      "type": "object",
      "properties": {
        "quantity_kind": {},
        "canonical_value": {
          "type": "number"
        },
        "canonical_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "original_measurement": {
      "type": "object",
      "required": [
        "source_value",
        "source_unit",
        "source_timestamp",
        "source_representation"
      ],
      "properties": {
        "source_value": {
          "type": "number"
        },
        "source_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        },
        "source_timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "source_representation": {
          "const": "numeric_scalar"
        }
      },
      "additionalProperties": false
    },
    "conversion_lineage": {
      "type": "object",
      "properties": {
        "source_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        },
        "canonical_unit": {
          "type": "object",
          "required": [
            "unit_code",
            "vocabulary_id"
          ],
          "properties": {
            "unit_code": {
              "type": "string",
              "pattern": "^[A-Z][A-Z0-9_]*$"
            },
            "vocabulary_id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            }
          },
          "additionalProperties": false
        },
        "conversion_method": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "conversion_service": {
          "const": "origin_free_release"
        },
        "conversion_version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]*$"
        },
        "conversion_timestamp": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    "measurement_quality": {
      "type": "object",
      "properties": {
        "quality_code": {},
        "communication_quality": {},
        "validity_status": {},
        "missing_data_state": {},
        "stale_data_state": {}
      },
      "additionalProperties": false
    },
    "time_synchronization_context": {
      "type": "object",
      "properties": {
        "source_timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "ingestion_timestamp": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    "comparability": {
      "type": "object",
      "required": [
        "comparable",
        "comparable_view_eligible"
      ],
      "properties": {
        "comparable": {
          "const": true
        },
        "comparable_view_eligible": {
          "const": true
        }
      },
      "additionalProperties": false
    },
    "provenance": {
      "type": "object",
      "required": [
        "source_platform",
        "source_authority_id",
        "source_reference",
        "lineage_id",
        "ingest_time",
        "processing_time",
        "mapping_package_id",
        "mapping_version"
      ],
      "properties": {
        "source_platform": {
          "const": "origin_free_release"
        },
        "source_authority_id": {
          "type": "string",
          "pattern": "^urn:ssom:release:tok:[0-9a-f]{32,64}$"
        },
        "source_reference": {
          "type": "string",
          "pattern": "^urn:ssom:(signal|asset|relationship):tok:[0-9a-f]{32,64}$"
        },
        "lineage_id": {
          "type": "string",
          "pattern": "^urn:ssom:(record|asset|relationship):tok:[0-9a-f]{32,64}$"
        },
        "ingest_time": {
          "type": "string",
          "format": "date-time"
        },
        "processing_time": {
          "type": "string",
          "format": "date-time"
        },
        "mapping_package_id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$"
        },
        "mapping_version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]*$"
        }
      },
      "additionalProperties": false
    },
    "temporal_integrity": {
      "type": "object",
      "required": [
        "event_time",
        "receive_time",
        "processing_time",
        "delivery_classification"
      ],
      "properties": {
        "event_time": {
          "type": "string",
          "format": "date-time"
        },
        "receive_time": {
          "type": "string",
          "format": "date-time"
        },
        "processing_time": {
          "type": "string",
          "format": "date-time"
        },
        "delivery_classification": {
          "const": "replay"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
