{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://law.arxo.io/schema/concept-alignment-report.schema.json",
  "type": "object",
  "properties": {
    "format": {
      "const": "arxo.concept-alignment.report/0.1"
    },
    "profile": {
      "const": "qudt-wikidata-dimension/0.1"
    },
    "policy": {
      "type": "object",
      "properties": {
        "format": {
          "const": "arxo.concept-alignment.policy/0.1"
        },
        "profile": {
          "const": "qudt-wikidata-dimension/0.1"
        },
        "enabled": {
          "type": "boolean"
        },
        "package": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1
            },
            "version": {
              "type": "string",
              "minLength": 1
            },
            "namespace": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "name",
            "version",
            "namespace"
          ],
          "additionalProperties": false
        },
        "type_owner": {
          "type": "string",
          "minLength": 1
        },
        "projects": {
          "type": "object",
          "properties": {
            "wikidata": {
              "type": "string",
              "minLength": 1
            },
            "qudt": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "wikidata",
            "qudt"
          ],
          "additionalProperties": false
        },
        "allowed_qudt_types": {
          "type": "array",
          "items": {
            "enum": [
              "http://qudt.org/schema/qudt/Unit",
              "http://qudt.org/schema/qudt/QuantityKind"
            ]
          },
          "minItems": 1,
          "uniqueItems": true
        }
      },
      "required": [
        "format",
        "profile",
        "enabled",
        "package",
        "type_owner",
        "projects",
        "allowed_qudt_types"
      ],
      "additionalProperties": false
    },
    "policy_hash": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "validator_hash": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "sources": {
      "type": "object",
      "properties": {
        "wikidata": {
          "type": "object",
          "properties": {
            "project": {
              "type": "string",
              "minLength": 1
            },
            "revision": {
              "type": "string",
              "minLength": 1
            },
            "input_hash": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "mapping_hash": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "package": {
              "type": "string",
              "minLength": 1
            },
            "package_pin": {
              "type": "object",
              "properties": {
                "version": {
                  "type": "string",
                  "minLength": 1
                },
                "namespace": {
                  "type": "string",
                  "minLength": 1
                },
                "content_hash": {
                  "type": "string",
                  "pattern": "^sha256:[0-9a-f]{64}$"
                }
              },
              "required": [
                "version",
                "namespace",
                "content_hash"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "project",
            "revision",
            "input_hash",
            "mapping_hash",
            "package",
            "package_pin"
          ],
          "additionalProperties": false
        },
        "qudt": {
          "type": "object",
          "properties": {
            "project": {
              "type": "string",
              "minLength": 1
            },
            "revision": {
              "type": "string",
              "minLength": 1
            },
            "input_hash": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "mapping_hash": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "package": {
              "type": "string",
              "minLength": 1
            },
            "package_pin": {
              "type": "object",
              "properties": {
                "version": {
                  "type": "string",
                  "minLength": 1
                },
                "namespace": {
                  "type": "string",
                  "minLength": 1
                },
                "content_hash": {
                  "type": "string",
                  "pattern": "^sha256:[0-9a-f]{64}$"
                }
              },
              "required": [
                "version",
                "namespace",
                "content_hash"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "project",
            "revision",
            "input_hash",
            "mapping_hash",
            "package",
            "package_pin"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "wikidata",
        "qudt"
      ],
      "additionalProperties": false
    },
    "discovery": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "channel": {
          "const": "source_alignment"
        },
        "complete": {
          "const": true
        },
        "count": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "source",
        "channel",
        "complete",
        "count"
      ],
      "additionalProperties": false
    },
    "previous_hash": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "decisions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          },
          "wikidata": {
            "type": "string",
            "minLength": 1
          },
          "qudt": {
            "type": "string",
            "minLength": 1
          },
          "relation": {
            "const": "dimension_transfer"
          },
          "direction": {
            "const": "qudt_to_wikidata"
          },
          "status": {
            "enum": [
              "accepted",
              "review",
              "revoked"
            ]
          },
          "reasons": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "conditions": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "evidence": {
            "type": "object",
            "properties": {
              "wikidata": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "fact": {
                      "type": "string",
                      "minLength": 1
                    },
                    "anchor": {
                      "type": "string",
                      "minLength": 1
                    },
                    "document": {
                      "type": "string",
                      "minLength": 1
                    },
                    "document_hash": {
                      "type": "string",
                      "pattern": "^sha256:[0-9a-f]{64}$"
                    },
                    "locator": {
                      "type": "string",
                      "minLength": 1
                    },
                    "start": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "end": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "fact",
                    "anchor",
                    "document",
                    "document_hash",
                    "locator",
                    "start",
                    "end"
                  ],
                  "additionalProperties": false
                }
              },
              "qudt": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "fact": {
                      "type": "string",
                      "minLength": 1
                    },
                    "anchor": {
                      "type": "string",
                      "minLength": 1
                    },
                    "document": {
                      "type": "string",
                      "minLength": 1
                    },
                    "document_hash": {
                      "type": "string",
                      "pattern": "^sha256:[0-9a-f]{64}$"
                    },
                    "locator": {
                      "type": "string",
                      "minLength": 1
                    },
                    "start": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "end": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "fact",
                    "anchor",
                    "document",
                    "document_hash",
                    "locator",
                    "start",
                    "end"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "wikidata",
              "qudt"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "wikidata",
          "qudt",
          "relation",
          "direction",
          "status",
          "reasons",
          "conditions",
          "evidence"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "format",
    "profile",
    "policy",
    "policy_hash",
    "validator_hash",
    "sources",
    "discovery",
    "previous_hash",
    "decisions"
  ],
  "additionalProperties": false
}
