{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Living-Proof-Labs/robot-capability-specs/specs/robots/robot-profile.schema.json",
  "title": "livingproof-robot-profile/0.1",
  "description": "Facts about one robot model, owned by its robot repository (livingproof-<manufacturer>-<model>, or a partner's downstream repository). It names the configuration profiles the repository offers; what each profile contains is the robot repository's responsibility.",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "id", "manufacturer", "model", "class", "model_source", "dimensions", "configurations", "simulators"],
  "properties": {
    "$comment": {"type": "string"},
    "format": {"const": "livingproof-robot-profile/0.1"},
    "id": {"$ref": "#/$defs/name"},
    "manufacturer": {"type": "string", "minLength": 1},
    "model": {"type": "string", "minLength": 1},
    "class": {"enum": ["humanoid", "quadruped", "wheeled", "other"]},
    "model_source": {"$ref": "#/$defs/pinned"},
    "dimensions": {
      "type": "object",
      "additionalProperties": false,
      "required": ["width", "length", "height"],
      "properties": {
        "width": {"$ref": "#/$defs/quantity"},
        "length": {"$ref": "#/$defs/quantity"},
        "height": {"$ref": "#/$defs/quantity"},
        "mass": {"$ref": "#/$defs/quantity"}
      }
    },
    "configurations": {
      "description": "Configuration profile names this robot offers, each with the repository path of its profile file. A run selects exactly one by name.",
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "path"],
        "properties": {
          "name": {"$ref": "#/$defs/name"},
          "path": {"type": "string", "minLength": 1}
        }
      }
    },
    "default_configuration": {"$ref": "#/$defs/name", "description": "Used only when a run names no configuration; comparisons always name one."},
    "simulators": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"enum": ["mujoco", "gazebo"]}}
  },
  "$defs": {
    "name": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"},
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "pinned": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repo", "commit", "sha256", "license"],
      "properties": {
        "repo": {"type": "string", "minLength": 1},
        "path": {"type": "string"},
        "commit": {"type": "string", "pattern": "^[0-9a-f]{40}$"},
        "sha256": {"$ref": "#/$defs/sha256"},
        "license": {"type": "string", "minLength": 1}
      }
    },
    "quantity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["value", "unit", "source"],
      "properties": {
        "value": {"type": "number"},
        "unit": {"type": "string", "minLength": 1},
        "source": {"enum": ["measured", "published", "chosen"]},
        "ref": {"type": "string"},
        "reason": {"type": "string"}
      },
      "allOf": [{"if": {"properties": {"source": {"const": "chosen"}}}, "then": {"required": ["reason"]}}]
    }
  }
}
