{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://e2er.com/catalog/schema/block.schema.json",
  "title": "E2ER building-block record",
  "description": "One entry in the E2ER registry: a template, agent, skill, external pipeline or run, described so that it can be discovered, compared and credited. Draft 0.1. Every facet term carries its provenance: declared by the source, mapped from the source's own term through a vocabulary alias, or inferred by a published rule.",
  "type": "object",
  "required": [
    "id",
    "kind",
    "name",
    "status",
    "source",
    "facets"
  ],
  "additionalProperties": false,
  "$defs": {
    "tag": {
      "type": "object",
      "required": [
        "term",
        "via"
      ],
      "additionalProperties": false,
      "properties": {
        "term": {
          "type": "string"
        },
        "via": {
          "enum": [
            "declared",
            "mapped",
            "inferred",
            "default"
          ]
        },
        "rule": {
          "type": "string",
          "description": "For inferred tags: the id of the inference rule that produced it."
        },
        "from": {
          "type": "string",
          "description": "For mapped tags: the source term before mapping."
        }
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/tag"
      }
    }
  },
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^(template|agent|skill|pipeline|run|dataset|connector):[a-z0-9][a-z0-9/_.-]*$"
    },
    "kind": {
      "enum": [
        "template",
        "agent",
        "skill",
        "pipeline",
        "run",
        "dataset",
        "connector"
      ]
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string"
    },
    "summary": {
      "type": "string"
    },
    "status": {
      "enum": [
        "in-place",
        "prototype",
        "planned",
        "illustration"
      ]
    },
    "source": {
      "type": "object",
      "required": [
        "registry"
      ],
      "additionalProperties": false,
      "properties": {
        "registry": {
          "enum": [
            "e2er",
            "e2et",
            "registry",
            "rise-skills",
            "rise-projects",
            "illustrative",
            "zenodo",
            "dataverse",
            "github"
          ]
        },
        "collection": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "commit": {
          "type": "string"
        }
      }
    },
    "license": {
      "type": "string"
    },
    "maintainers": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "facets": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "discipline",
        "method",
        "design",
        "stage"
      ],
      "properties": {
        "discipline": {
          "$ref": "#/$defs/tags"
        },
        "method": {
          "$ref": "#/$defs/tags"
        },
        "design": {
          "$ref": "#/$defs/tags"
        },
        "stage": {
          "$ref": "#/$defs/tags"
        }
      }
    },
    "relations": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "forkOf": {
          "type": "string"
        },
        "uses": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "evaluations": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "derivedFrom": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "href": {
      "type": "string",
      "description": "Page for this record on e2er.com, or an external URL."
    },
    "sourceStatus": {
      "type": "string",
      "description": "The status term the source catalogue uses, e.g. RISE's active / dormant / archived."
    },
    "contributors": {
      "type": "array",
      "description": "People and groups credited for this block, with CRediT roles (vocabularies/role.json).",
      "items": {
        "type": "object",
        "required": [
          "person",
          "roles"
        ],
        "additionalProperties": false,
        "properties": {
          "person": {
            "type": "string",
            "pattern": "^person:"
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}