{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Living-Proof-Labs/robot-capability-specs/specs/robots/robot-manifest.schema.json",
  "title": "livingproof-robot-manifest/0.1",
  "description": "What one robot repository offers a verifier, in one file: its configurations, the adapter entry point, every pinned asset with its digest, feature flags, the scenarios its adapter supports, and optional per-simulator compatibility. It cites the robot profile and configuration profiles by path and sha256 rather than copying them.",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "robot", "source", "profile", "adapter", "configurations", "assets", "features"],
  "properties": {
    "$comment": {"type": "string"},
    "format": {"const": "livingproof-robot-manifest/0.1"},
    "robot": {"$ref": "#/$defs/name", "description": "The robot profile id, such as unitree-g1."},
    "source": {
      "description": "The robot repository and commit these facts were read from.",
      "type": "object",
      "additionalProperties": false,
      "required": ["repository", "commit"],
      "properties": {
        "repository": {"$ref": "#/$defs/repository"},
        "commit": {"$ref": "#/$defs/commit"}
      }
    },
    "profile": {"$ref": "#/$defs/file", "description": "The robot profile (robot-profile.schema.json), normally robot.json."},
    "adapter": {
      "description": "Entry point a generic runner loads to drive this robot.",
      "type": "object",
      "additionalProperties": false,
      "required": ["entry_point", "package"],
      "properties": {
        "entry_point": {"type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*:[A-Za-z_][A-Za-z0-9_]*$", "description": "module:object, as in pyproject [tool.livingproof] adapter."},
        "package": {"type": "string", "minLength": 1, "description": "The distribution that provides the module."}
      }
    },
    "configurations": {
      "description": "Configuration profiles offered, each cited by name, version and file sha256.",
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "version", "path", "sha256"],
        "properties": {
          "name": {"$ref": "#/$defs/name"},
          "version": {"$ref": "#/$defs/semver"},
          "path": {"$ref": "#/$defs/path"},
          "sha256": {"$ref": "#/$defs/sha256"},
          "default": {"type": "boolean"}
        }
      }
    },
    "assets": {
      "description": "Every upstream file a run needs, fetched by commit and checked by sha256; nothing is vendored.",
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["repository", "commit", "path", "sha256", "bytes"],
        "properties": {
          "group": {"$ref": "#/$defs/name"},
          "repository": {"$ref": "#/$defs/repository"},
          "commit": {"$ref": "#/$defs/commit"},
          "path": {"$ref": "#/$defs/path"},
          "sha256": {"$ref": "#/$defs/sha256"},
          "bytes": {"type": "integer", "minimum": 0}
        }
      }
    },
    "features": {
      "description": "Named capabilities of this repository that tooling may rely on. A missing flag means false.",
      "type": "object",
      "propertyNames": {"$ref": "#/$defs/name"},
      "additionalProperties": {"type": "boolean"}
    },
    "scenarios": {
      "description": "Optional. The scenario ids this repository's adapter supports, such as walk-hallway. A scenario that requires the precondition scenario_supported and is not listed here, or any such scenario when this list is absent, is UNSUPPORTED before any trial, never a FAIL. How the adapter drives the robot for each scenario is its own.",
      "type": "array",
      "uniqueItems": true,
      "items": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"}
    },
    "simulators": {
      "description": "Optional per-simulator compatibility, keyed by simulator id (as in the robot profile's simulators).",
      "type": "object",
      "propertyNames": {"$ref": "#/$defs/name"},
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": ["engine", "runner", "status"],
        "properties": {
          "engine": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "version"],
            "properties": {"name": {"type": "string", "minLength": 1}, "version": {"$ref": "#/$defs/semver"}}
          },
          "runner": {
            "type": "object",
            "additionalProperties": false,
            "required": ["repository", "tag", "commit"],
            "properties": {
              "repository": {"$ref": "#/$defs/repository"},
              "tag": {"type": "string", "pattern": "^v[0-9]+\\.[0-9]+\\.[0-9]+$"},
              "commit": {"$ref": "#/$defs/commit"}
            }
          },
          "status": {"enum": ["verified", "experimental", "unsupported"]},
          "notes": {"type": "string"}
        }
      }
    }
  },
  "$defs": {
    "name": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_-]*$"},
    "semver": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "commit": {"type": "string", "pattern": "^[0-9a-f]{40}$"},
    "repository": {"type": "string", "pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"},
    "path": {"type": "string", "minLength": 1, "not": {"pattern": "(^/|(^|/)\\.\\.(/|$))"}},
    "file": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "sha256"],
      "properties": {"path": {"$ref": "#/$defs/path"}, "sha256": {"$ref": "#/$defs/sha256"}}
    }
  }
}
