{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://altheia.local/schemas/altheia-ownership-lineage-1.0.schema.json",
  "title": "ALTHEIA ownership source and selection lineage 1.0",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "sources",
    "members",
    "observed"
  ],
  "properties": {
    "schema_version": {
      "const": "altheia_ownership_lineage_1.0"
    },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_hash",
          "source"
        ],
        "properties": {
          "source_hash": {
            "type": "string",
            "pattern": "^fnv1a-[a-f0-9]{8}$"
          },
          "source": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "sector_pack_hash",
              "brand_pack_hash",
              "policy",
              "assessment",
              "requirements",
              "taxonomy",
              "settings",
              "profiles"
            ],
            "properties": {
              "sector_pack_hash": {
                "type": "string",
                "pattern": "^fnv1a-[a-f0-9]{8}$"
              },
              "brand_pack_hash": {
                "type": "string",
                "pattern": "^fnv1a-[a-f0-9]{8}$"
              },
              "policy": {
                "$ref": "altheia_product_ownership_policy_1.0.schema.json"
              },
              "assessment": {
                "$ref": "altheia_product_ownership_assessment_1.0.schema.json"
              },
              "requirements": {
                "$ref": "altheia_archetype_ownership_requirements_1.0.schema.json"
              },
              "taxonomy": {
                "type": "object"
              },
              "settings": {
                "type": "object"
              },
              "profiles": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object"
                }
              },
              "source_schema": {
                "const": "altheia_ownership_source_1.1"
              },
              "generation_source": {
                "$ref": "altheia_replenishment_generation_source_1.0.schema.json"
              }
            },
            "dependentRequired": {
              "source_schema": [
                "generation_source"
              ],
              "generation_source": [
                "source_schema"
              ]
            }
          }
        }
      }
    },
    "members": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "profile_uuid",
          "profile_id",
          "content_hash",
          "source_hash"
        ],
        "properties": {
          "profile_uuid": {
            "type": "string",
            "minLength": 1
          },
          "profile_id": {
            "type": "string",
            "minLength": 1
          },
          "content_hash": {
            "type": "string",
            "pattern": "^fnv1a-[a-f0-9]{8}$"
          },
          "source_hash": {
            "type": "string",
            "pattern": "^fnv1a-[a-f0-9]{8}$"
          }
        }
      }
    },
    "observed": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "semantics",
        "population_size",
        "products"
      ],
      "properties": {
        "semantics": {
          "const": "observed_selection_not_generation_quota"
        },
        "population_size": {
          "type": "integer",
          "minimum": 1
        },
        "products": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "offer_id",
              "count",
              "percentage"
            ],
            "properties": {
              "offer_id": {
                "type": "string"
              },
              "count": {
                "type": "integer",
                "minimum": 1
              },
              "percentage": {
                "type": "number",
                "minimum": 0,
                "maximum": 100
              }
            }
          }
        }
      }
    }
  }
}
