{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://intelligence.metatron.marketing/sources/global/registry.schema.json",
  "title": "Metatron Global AI Source Observatory",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "version",
    "atlasRevision",
    "reviewedAt",
    "status",
    "counts",
    "coverage",
    "sources",
    "gaps",
    "apifyResearch",
    "provenance",
    "boundaries"
  ],
  "properties": {
    "schema": {
      "const": "metatron.intelligence.global-source-observatory.v1"
    },
    "version": {
      "type": "string",
      "pattern": "^r[0-9]{4}-u[0-9]{4}$"
    },
    "atlasRevision": {
      "type": "string",
      "pattern": "^r[0-9]{4}$"
    },
    "reviewedAt": {
      "type": "string",
      "format": "date"
    },
    "status": {
      "const": "curated_discovery_registry_not_claim_evidence"
    },
    "counts": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sources",
        "regions",
        "languages",
        "publishers",
        "machineReadableSources"
      ],
      "properties": {
        "sources": {
          "type": "integer",
          "minimum": 0
        },
        "regions": {
          "type": "integer",
          "minimum": 0
        },
        "languages": {
          "type": "integer",
          "minimum": 0
        },
        "publishers": {
          "type": "integer",
          "minimum": 0
        },
        "machineReadableSources": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "coverage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "requiredRegions",
        "representedRegions",
        "missingRequiredRegions",
        "regionCounts",
        "languages",
        "domainCounts",
        "englishOnlySources",
        "machineReadableSources",
        "reuseRightsAssessedSources"
      ],
      "properties": {
        "requiredRegions": {
          "type": "array",
          "items": {
            "enum": [
              "GLOBAL",
              "AFRICA",
              "LATIN_AMERICA_CARIBBEAN",
              "EAST_ASIA",
              "SOUTH_ASIA",
              "SOUTHEAST_ASIA",
              "MIDDLE_EAST_NORTH_AFRICA",
              "EUROPE",
              "NORTH_AMERICA",
              "OCEANIA"
            ]
          },
          "uniqueItems": true
        },
        "representedRegions": {
          "type": "array",
          "items": {
            "enum": [
              "GLOBAL",
              "AFRICA",
              "LATIN_AMERICA_CARIBBEAN",
              "EAST_ASIA",
              "SOUTH_ASIA",
              "SOUTHEAST_ASIA",
              "MIDDLE_EAST_NORTH_AFRICA",
              "EUROPE",
              "NORTH_AMERICA",
              "OCEANIA"
            ]
          },
          "uniqueItems": true
        },
        "missingRequiredRegions": {
          "type": "array",
          "items": {
            "enum": [
              "GLOBAL",
              "AFRICA",
              "LATIN_AMERICA_CARIBBEAN",
              "EAST_ASIA",
              "SOUTH_ASIA",
              "SOUTHEAST_ASIA",
              "MIDDLE_EAST_NORTH_AFRICA",
              "EUROPE",
              "NORTH_AMERICA",
              "OCEANIA"
            ]
          },
          "uniqueItems": true
        },
        "regionCounts": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "domainCounts": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "englishOnlySources": {
          "type": "integer",
          "minimum": 0
        },
        "machineReadableSources": {
          "type": "integer",
          "minimum": 0
        },
        "reuseRightsAssessedSources": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "$id": "https://intelligence.metatron.marketing/sources/global/source.schema.json",
        "title": "Metatron global AI source discovery record",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "publisher",
          "publisherType",
          "canonicalUrl",
          "sourceClass",
          "regions",
          "jurisdictions",
          "languages",
          "languageExpressions",
          "intelligenceDomains",
          "access",
          "publicationPattern",
          "authorityLevel",
          "admissionState",
          "evidenceUse",
          "coverageBoundary",
          "rights",
          "sourceReference"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^AISRC-[A-F0-9]{20}$"
          },
          "name": {
            "type": "string",
            "minLength": 3
          },
          "publisher": {
            "type": "string",
            "minLength": 2
          },
          "publisherType": {
            "enum": [
              "international_organization",
              "regional_organization",
              "national_government",
              "government_research_institute",
              "multi_government_scientific_collaboration"
            ]
          },
          "canonicalUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          },
          "sourceClass": {
            "enum": [
              "observatory",
              "policy_database",
              "official_portal",
              "strategy",
              "report_series",
              "research_portal",
              "regulatory_service",
              "governance_guide"
            ]
          },
          "regions": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "enum": [
                "GLOBAL",
                "AFRICA",
                "LATIN_AMERICA_CARIBBEAN",
                "EAST_ASIA",
                "SOUTH_ASIA",
                "SOUTHEAST_ASIA",
                "MIDDLE_EAST_NORTH_AFRICA",
                "EUROPE",
                "NORTH_AMERICA",
                "OCEANIA"
              ]
            }
          },
          "jurisdictions": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 2
            }
          },
          "languages": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[a-z]{2,3}(-[A-Z]{2})?$"
            }
          },
          "languageExpressions": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "language",
                "url",
                "locator",
                "legalStatus",
                "publisherDesignatedEquivalent"
              ],
              "properties": {
                "language": {
                  "type": "string",
                  "pattern": "^[a-z]{2,3}(-[A-Z]{2})?$"
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "pattern": "^https://"
                },
                "locator": {
                  "type": "string",
                  "minLength": 10
                },
                "legalStatus": {
                  "const": "not_separately_assessed"
                },
                "publisherDesignatedEquivalent": {
                  "const": false
                }
              }
            }
          },
          "intelligenceDomains": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "enum": [
                "adoption",
                "applications",
                "benchmarks",
                "compute",
                "governance",
                "incidents",
                "labor",
                "models",
                "regulation",
                "research",
                "safety"
              ]
            }
          },
          "access": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "formats",
              "machineReadable",
              "accessBoundary"
            ],
            "properties": {
              "formats": {
                "type": "array",
                "minItems": 1,
                "uniqueItems": true,
                "items": {
                  "enum": [
                    "html",
                    "pdf",
                    "interactive",
                    "download",
                    "api",
                    "csv",
                    "json",
                    "feed"
                  ]
                }
              },
              "machineReadable": {
                "type": "boolean"
              },
              "accessBoundary": {
                "type": "string",
                "minLength": 10
              }
            }
          },
          "publicationPattern": {
            "enum": [
              "living_portal",
              "versioned_document",
              "periodic_series",
              "research_stream"
            ]
          },
          "authorityLevel": {
            "enum": [
              "primary_owner",
              "intergovernmental_compilation"
            ]
          },
          "admissionState": {
            "const": "discovery_only"
          },
          "evidenceUse": {
            "type": "string",
            "minLength": 10
          },
          "coverageBoundary": {
            "type": "string",
            "minLength": 20
          },
          "rights": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "status",
              "boundary"
            ],
            "properties": {
              "status": {
                "enum": [
                  "not_assessed",
                  "restricted",
                  "open_license",
                  "permission_verified"
                ]
              },
              "boundary": {
                "type": "string",
                "minLength": 20
              }
            }
          },
          "sourceReference": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "url",
              "locator",
              "observedAt"
            ],
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              },
              "locator": {
                "type": "string",
                "minLength": 3
              },
              "observedAt": {
                "type": "string",
                "format": "date"
              }
            }
          }
        }
      }
    },
    "gaps": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 10
      },
      "uniqueItems": true
    },
    "apifyResearch": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "receiptType",
        "status",
        "tool",
        "observedAt",
        "runId",
        "datasetId",
        "capturedRecords",
        "boundary"
      ],
      "properties": {
        "receiptType": {
          "enum": [
            "attempt",
            "run"
          ]
        },
        "status": {
          "enum": [
            "completed",
            "partial",
            "failed",
            "auth_required_before_actor_start"
          ]
        },
        "tool": {
          "type": "string",
          "minLength": 3
        },
        "observedAt": {
          "type": "string",
          "format": "date"
        },
        "runId": {
          "type": [
            "string",
            "null"
          ]
        },
        "datasetId": {
          "type": [
            "string",
            "null"
          ]
        },
        "capturedRecords": {
          "type": "integer",
          "minimum": 0
        },
        "boundary": {
          "type": "string",
          "minLength": 20
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "receiptType": {
                "const": "attempt"
              }
            }
          },
          "then": {
            "properties": {
              "status": {
                "enum": [
                  "failed",
                  "auth_required_before_actor_start"
                ]
              },
              "runId": {
                "type": "null"
              },
              "datasetId": {
                "type": "null"
              },
              "capturedRecords": {
                "const": 0
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "receiptType": {
                "const": "run"
              }
            }
          },
          "then": {
            "properties": {
              "status": {
                "enum": [
                  "completed",
                  "partial",
                  "failed"
                ]
              },
              "runId": {
                "type": "string",
                "minLength": 1
              },
              "datasetId": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        }
      ]
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "configSha256",
        "researchReport"
      ],
      "properties": {
        "configSha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "researchReport": {
          "type": "string",
          "minLength": 10
        }
      }
    },
    "boundaries": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "coverageIsCompleteness",
        "discoveryIsEvidence",
        "transportIsTruth",
        "translationIsEquivalence",
        "statement"
      ],
      "properties": {
        "coverageIsCompleteness": {
          "const": false
        },
        "discoveryIsEvidence": {
          "const": false
        },
        "transportIsTruth": {
          "const": false
        },
        "translationIsEquivalence": {
          "const": false
        },
        "statement": {
          "type": "string",
          "minLength": 30
        }
      }
    }
  }
}
