{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://grounding-map.com/assets/schema/grounding-map.schema.json",
  "title": "Grounding Map",
  "description": "Experimental v0.1 schema for a Grounding Map directory, index page, Grounding Pages, relationships, evidence and machine-readable resources.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "status",
    "site",
    "mapDirectory",
    "mapIndexUrl",
    "groundingPages",
    "relationshipLayer",
    "evidence",
    "machineReadableResources",
    "referenceImplementation"
  ],
  "properties": {
    "version": {
      "type": "string",
      "const": "0.1"
    },
    "status": {
      "type": "string",
      "enum": [
        "experimental"
      ]
    },
    "schemaUrl": {
      "type": "string",
      "format": "uri"
    },
    "site": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "url"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "description": {
          "type": "string"
        },
        "language": {
          "type": "string"
        }
      }
    },
    "mapDirectory": {
      "type": "string",
      "pattern": "^/.*/$"
    },
    "mapIndexUrl": {
      "type": "string",
      "format": "uri"
    },
    "groundingPages": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/groundingPage"
      }
    },
    "relationshipLayer": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/relationship"
      }
    },
    "evidence": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/evidence"
      }
    },
    "machineReadableResources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/machineReadableResource"
      }
    },
    "referenceImplementation": {
      "$ref": "#/$defs/referenceImplementation"
    }
  },
  "$defs": {
    "groundingPage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "entityName",
        "entityType",
        "groundingPageUrl",
        "canonicalReference",
        "editorialExplanationUrl",
        "evidenceUrls",
        "relatedGroundingPages",
        "relationshipType",
        "machineReadableUrl",
        "status",
        "stability",
        "lastReviewed",
        "openGaps"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "entityName": {
          "type": "string",
          "minLength": 1
        },
        "entityType": {
          "type": "string",
          "enum": [
            "Person",
            "Organization",
            "Concept",
            "Method",
            "Product",
            "Topic",
            "Dataset",
            "Standard"
          ]
        },
        "groundingPageUrl": {
          "type": "string",
          "format": "uri"
        },
        "canonicalReference": {
          "type": "string",
          "format": "uri"
        },
        "editorialExplanationUrl": {
          "type": "string",
          "format": "uri"
        },
        "evidenceUrls": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "format": "uri"
          }
        },
        "relatedGroundingPages": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "relationshipType": {
          "$ref": "#/$defs/relationshipType"
        },
        "signalStrength": {
          "type": "string",
          "enum": [
            "strong",
            "medium",
            "weak"
          ]
        },
        "status": {
          "$ref": "#/$defs/status"
        },
        "stability": {
          "$ref": "#/$defs/stability"
        },
        "owner": {
          "type": "string"
        },
        "lastReviewed": {
          "type": "string",
          "format": "date"
        },
        "machineReadableUrl": {
          "type": "string",
          "format": "uri"
        },
        "openGaps": {
          "type": "string"
        }
      }
    },
    "relationship": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "from",
        "to",
        "relationshipType",
        "status",
        "stability"
      ],
      "properties": {
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "relationshipType": {
          "$ref": "#/$defs/relationshipType"
        },
        "signalStrength": {
          "type": "string",
          "enum": [
            "strong",
            "medium",
            "weak"
          ]
        },
        "evidenceUrl": {
          "type": "string",
          "format": "uri"
        },
        "status": {
          "$ref": "#/$defs/status"
        },
        "stability": {
          "$ref": "#/$defs/stability"
        },
        "note": {
          "type": "string"
        }
      }
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "url",
        "type"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "type": {
          "type": "string",
          "enum": [
            "map_index",
            "grounding_page",
            "explanatory_article",
            "source_reference",
            "registry",
            "text_twin",
            "schema",
            "template"
          ]
        }
      }
    },
    "machineReadableResource": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "url",
        "type"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "type": {
          "type": "string",
          "enum": [
            "md_txt",
            "llms_txt",
            "json",
            "json_schema",
            "structured_data",
            "registry"
          ]
        }
      }
    },
    "referenceImplementation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "url",
        "mapDirectoryUrl",
        "mapIndexUrl",
        "groundingMapPageUrl",
        "editorialExplanationUrl"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "mapDirectoryUrl": {
          "type": "string",
          "format": "uri"
        },
        "mapIndexUrl": {
          "type": "string",
          "format": "uri"
        },
        "groundingMapPageUrl": {
          "type": "string",
          "format": "uri"
        },
        "editorialExplanationUrl": {
          "type": "string",
          "format": "uri"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "relationshipType": {
      "type": "string",
      "enum": [
        "defines",
        "explains",
        "supports",
        "extends",
        "differentiates",
        "operationalizes",
        "aggregates",
        "diagnoses",
        "identifies",
        "structures",
        "implements_on",
        "updates",
        "replaces",
        "is_example_for",
        "is_source_for",
        "is_reference_implementation_for"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "emerging",
        "parked",
        "deprecated"
      ]
    },
    "stability": {
      "type": "string",
      "enum": [
        "stable",
        "evolving",
        "parked",
        "replaced"
      ]
    }
  }
}
