{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://evidencepress.org/api/schemas/research-graph.schema.json",
  "title": "Evidence Press research graph",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "graphId",
    "title",
    "description",
    "claimCeiling",
    "generatedFrom",
    "stats",
    "predicates",
    "nodes",
    "edges",
    "proposalRegister"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0"
    },
    "graphId": {
      "type": "string",
      "pattern": "^ep-graph:sha256:[0-9a-f]{64}$"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "minLength": 1
    },
    "claimCeiling": {
      "type": "string",
      "minLength": 1
    },
    "generatedFrom": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sourceCommit",
        "sourceDate",
        "artifacts"
      ],
      "properties": {
        "sourceCommit": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        },
        "sourceDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "artifacts": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "stats": {
      "type": "object",
      "additionalProperties": {
        "type": "integer",
        "minimum": 0
      }
    },
    "predicates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/predicate"
      }
    },
    "nodes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/node"
      }
    },
    "edges": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/edge"
      }
    },
    "proposalRegister": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "count",
        "publicationRule",
        "relations"
      ],
      "properties": {
        "count": {
          "type": "integer",
          "minimum": 0
        },
        "publicationRule": {
          "type": "string",
          "minLength": 1
        },
        "relations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/edge"
          }
        }
      }
    }
  },
  "$defs": {
    "predicate": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "label",
        "inverseLabel",
        "directed",
        "meaning",
        "inferenceLimit"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "inverseLabel": {
          "type": "string",
          "minLength": 1
        },
        "directed": {
          "type": "boolean"
        },
        "meaning": {
          "type": "string",
          "minLength": 1
        },
        "inferenceLimit": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "node": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "type",
        "label",
        "description",
        "url",
        "sourceRefs"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^(release|method|cluster|lineage):[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "type": {
          "enum": [
            "release",
            "method",
            "cluster",
            "lineage"
          ]
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "sourceRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "edge": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "source",
        "target",
        "predicate",
        "knowledgeStatus",
        "construction",
        "basis",
        "inferenceLimit",
        "sourceRefs"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^edge:[0-9a-f]{20}$"
        },
        "source": {
          "type": "string"
        },
        "target": {
          "type": "string"
        },
        "predicate": {
          "type": "string"
        },
        "knowledgeStatus": {
          "enum": [
            "asserted",
            "computed",
            "proposed"
          ]
        },
        "construction": {
          "enum": [
            "generated-from-source-record",
            "registered-directly"
          ]
        },
        "basis": {
          "type": "string",
          "minLength": 1
        },
        "inferenceLimit": {
          "type": "string",
          "minLength": 1
        },
        "sourceRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  }
}
