{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://spec.exokern.com/schemas/robot_skill.schema.json",
  "title": "EXOKERN Robot Skill Manifest",
  "description": "Metadata manifest for what a robot skill or supporting package does, needs, exposes, and has actually proven. The schema supports technical review; it does not execute code, guarantee compatibility, or certify safety.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "id",
    "name",
    "summary",
    "version",
    "package",
    "task",
    "compatibility",
    "metadata_review"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "0.2"
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]+$",
      "description": "Stable package-style identifier, for example org.example.ur5e.safe-move."
    },
    "name": {
      "type": "string",
      "minLength": 3,
      "maxLength": 120
    },
    "summary": {
      "type": "string",
      "minLength": 10,
      "maxLength": 600
    },
    "what_it_does": {
      "type": "string",
      "minLength": 20,
      "maxLength": 1200,
      "description": "Plain-language description of the skill behavior, intended task, and expected output."
    },
    "version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+([-.+][0-9A-Za-z.-]+)?$"
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "url"],
      "properties": {
        "type": {
          "enum": ["github", "upload", "paper", "external"]
        },
        "url": {
          "type": "string",
          "pattern": "^https://",
          "description": "Durable HTTPS link to the public source."
        },
        "commit": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{7,40}$",
          "description": "Optional source commit used for the metadata review."
        }
      }
    },
    "package": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "license"],
      "properties": {
        "type": {
          "$ref": "#/$defs/package_type"
        },
        "license": {
          "type": "string",
          "minLength": 1
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true,
          "default": []
        },
        "frameworks": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true,
          "default": []
        }
      }
    },
    "task": {
      "type": "object",
      "additionalProperties": false,
      "required": ["categories", "contact_rich"],
      "properties": {
        "categories": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/task_category"
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "contact_rich": {
          "type": "boolean"
        },
        "objects": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true,
          "default": []
        }
      }
    },
    "compatibility": {
      "type": "object",
      "additionalProperties": false,
      "required": ["robots", "grippers", "sensors", "runtimes"],
      "properties": {
        "robots": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/robot_requirement"
          }
        },
        "grippers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/gripper_requirement"
          }
        },
        "sensors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/sensor_requirement"
          }
        },
        "runtimes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/runtime"
          },
          "uniqueItems": true
        }
      }
    },
    "required_hardware": {
      "type": "array",
      "description": "Non-robot, non-sensor hardware required by the skill, such as grippers, fixtures, tools, or workcell accessories.",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "simulation_support": {
      "type": "object",
      "additionalProperties": false,
      "required": ["supported", "status", "notes"],
      "properties": {
        "supported": {
          "type": "boolean"
        },
        "status": {
          "enum": ["not_tested", "source_reported", "reproduced"],
          "description": "Independent simulation-evidence status. Source-reported evidence is not an EXOKERN reproduction."
        },
        "environments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/runtime"
          },
          "uniqueItems": true,
          "default": []
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/evidence_link"
          },
          "default": []
        },
        "notes": {
          "type": "string",
          "maxLength": 1000
        }
      }
    },
    "hardware_tested": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "notes"],
      "properties": {
        "status": {
          "enum": ["not_tested", "owner_reported", "lab_tested", "field_tested"]
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/evidence_link"
          },
          "default": []
        },
        "notes": {
          "type": "string",
          "maxLength": 1000
        }
      }
    },
    "ros_interfaces": {
      "type": "object",
      "additionalProperties": false,
      "required": ["topics", "services", "actions"],
      "properties": {
        "topics": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ros_interface"
          }
        },
        "services": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ros_interface"
          }
        },
        "actions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ros_interface"
          }
        }
      }
    },
    "inputs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/io_signal"
      }
    },
    "outputs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/io_signal"
      }
    },
    "artifacts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/artifact"
      }
    },
    "safety": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "real_robot_motion",
        "risk_grade",
        "requires_operator_confirmation",
        "dry_run_required"
      ],
      "properties": {
        "real_robot_motion": {
          "type": "boolean"
        },
        "risk_grade": {
          "$ref": "#/$defs/risk_grade"
        },
        "requires_operator_confirmation": {
          "type": "boolean"
        },
        "dry_run_required": {
          "type": "boolean"
        },
        "max_speed_scale": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1
        },
        "notes": {
          "type": "string",
          "maxLength": 1000
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true,
          "default": []
        }
      }
    },
    "metadata_review": {
      "type": "object",
      "additionalProperties": false,
      "required": ["level", "notes"],
      "properties": {
        "level": {
          "$ref": "#/$defs/metadata_review_level"
        },
        "notes": {
          "type": "string",
          "maxLength": 1000
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/evidence_link"
          },
          "default": []
        }
      }
    },
    "known_limitations": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "out_of_scope_use": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "quickstart": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode", "path", "notes"],
      "properties": {
        "mode": {
          "enum": ["documentation_only", "simulation_only", "dry_run_only", "hardware_review_required"]
        },
        "path": {
          "type": "string",
          "minLength": 1,
          "description": "Repository path or URL that a reviewer should start from."
        },
        "commands": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "default": []
        },
        "notes": {
          "type": "string",
          "maxLength": 1000
        }
      }
    }
  },
  "$defs": {
    "package_type": {
      "enum": ["skill_pack", "model_pack", "config_pack", "dataset", "tutorial", "template"]
    },
    "task_category": {
      "enum": [
        "insertion",
        "assembly",
        "pick_place",
        "folding",
        "laundry",
        "navigation",
        "perception",
        "calibration",
        "inspection",
        "grasping",
        "teleoperation",
        "simulation",
        "dataset",
        "config"
      ]
    },
    "robot_vendor": {
      "enum": ["universal_robots", "franka", "kuka", "abb", "fanuc", "unitree", "reachy", "custom", "unknown"]
    },
    "runtime": {
      "enum": [
        "ros2",
        "isaac_ros",
        "isaac_lab",
        "isaac_sim",
        "moveit",
        "mujoco",
        "pybullet",
        "docker",
        "python_sdk",
        "onnx",
        "pytorch",
        "unknown"
      ]
    },
    "metadata_review_level": {
      "enum": [
        "unverified",
        "ai_indexed",
        "manifest_validated",
        "owner_confirmed"
      ]
    },
    "risk_grade": {
      "enum": ["low", "medium", "high", "contact_rich"]
    },
    "robot_requirement": {
      "type": "object",
      "additionalProperties": false,
      "required": ["vendor", "models"],
      "properties": {
        "vendor": {
          "$ref": "#/$defs/robot_vendor"
        },
        "models": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "required_dof": {
          "type": "integer",
          "minimum": 1
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "gripper_requirement": {
      "type": "object",
      "additionalProperties": false,
      "required": ["vendor", "models", "required"],
      "properties": {
        "vendor": {
          "type": "string",
          "minLength": 1
        },
        "models": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "required": {
          "type": "boolean"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "sensor_requirement": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "models", "required"],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "models": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "required": {
          "type": "boolean"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "io_signal": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "type"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "minLength": 1
        },
        "dimension": {
          "type": "integer",
          "minimum": 1
        },
        "frame": {
          "type": "string"
        },
        "topic": {
          "type": "string"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "ros_interface": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "description": "ROS message, service, or action type when known."
        },
        "direction": {
          "enum": ["publish", "subscribe", "client", "server", "goal", "result", "feedback", "unknown"]
        },
        "required": {
          "type": "boolean",
          "default": true
        },
        "frame": {
          "type": "string",
          "minLength": 1,
          "description": "Expected or relevant ROS frame when the interface is frame-dependent."
        },
        "qos": {
          "$ref": "#/$defs/ros_qos"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "ros_qos": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "reliability": {
          "enum": ["system_default", "reliable", "best_effort", "unknown"]
        },
        "durability": {
          "enum": ["system_default", "volatile", "transient_local", "unknown"]
        },
        "history": {
          "enum": ["system_default", "keep_last", "keep_all", "unknown"]
        },
        "depth": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "artifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "path", "optional"],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "path": {
          "type": "string",
          "minLength": 1
        },
        "optional": {
          "type": "boolean"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{64}$"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "evidence_link": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "url"],
      "properties": {
        "type": {
          "enum": ["log", "video", "paper", "report", "dataset", "commit", "other"]
        },
        "url": {
          "type": "string",
          "pattern": "^https://",
          "description": "Durable HTTPS link to the evidence."
        },
        "notes": {
          "type": "string"
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "metadata_review": {
            "type": "object",
            "properties": {
              "level": {
                "const": "owner_confirmed"
              }
            },
            "required": ["level"]
          }
        },
        "required": ["metadata_review"]
      },
      "then": {
        "properties": {
          "metadata_review": {
            "type": "object",
            "required": ["evidence"],
            "properties": {
              "evidence": {
                "type": "array",
                "minItems": 1
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "simulation_support": {
            "type": "object",
            "properties": {
              "status": {
                "enum": ["source_reported", "reproduced"]
              }
            },
            "required": ["status"]
          }
        },
        "required": ["simulation_support"]
      },
      "then": {
        "properties": {
          "simulation_support": {
            "type": "object",
            "required": ["evidence"],
            "properties": {
              "supported": {
                "const": true
              },
              "evidence": {
                "type": "array",
                "minItems": 1
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "simulation_support": {
            "type": "object",
            "properties": {
              "supported": {
                "const": true
              }
            },
            "required": ["supported"]
          }
        },
        "required": ["simulation_support"]
      },
      "then": {
        "properties": {
          "simulation_support": {
            "type": "object",
            "properties": {
              "status": {
                "enum": ["source_reported", "reproduced"]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "simulation_support": {
            "type": "object",
            "properties": {
              "supported": {
                "const": false
              }
            },
            "required": ["supported"]
          }
        },
        "required": ["simulation_support"]
      },
      "then": {
        "properties": {
          "simulation_support": {
            "type": "object",
            "properties": {
              "status": {
                "const": "not_tested"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "hardware_tested": {
            "type": "object",
            "properties": {
              "status": {
                "enum": ["owner_reported", "lab_tested", "field_tested"]
              }
            },
            "required": ["status"]
          }
        },
        "required": ["hardware_tested"]
      },
      "then": {
        "properties": {
          "hardware_tested": {
            "type": "object",
            "required": ["evidence"],
            "properties": {
              "evidence": {
                "type": "array",
                "minItems": 1
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "task": {
            "type": "object",
            "properties": {
              "contact_rich": {
                "const": true
              }
            },
            "required": ["contact_rich"]
          }
        },
        "required": ["task"]
      },
      "then": {
        "required": ["safety", "known_limitations", "out_of_scope_use", "quickstart"],
        "properties": {
          "safety": {
            "type": "object",
            "properties": {
              "risk_grade": {
                "const": "contact_rich"
              },
              "requires_operator_confirmation": {
                "const": true
              },
              "dry_run_required": {
                "const": true
              }
            }
          },
          "known_limitations": {
            "type": "array",
            "minItems": 1
          },
          "out_of_scope_use": {
            "type": "array",
            "minItems": 1
          },
          "quickstart": {
            "type": "object"
          }
        }
      }
    }
  ]
}
