{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Intentrail Mission Manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "kind",
    "version",
    "mode",
    "createdAt",
    "mission",
    "claims",
    "note",
    "manifestDigest"
  ],
  "properties": {
    "kind": { "const": "intentrail.mission-manifest" },
    "version": { "const": "1.0" },
    "mode": { "enum": ["local", "sample"] },
    "createdAt": { "type": "string", "format": "date-time" },
    "mission": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "grid",
        "start",
        "goal",
        "checkpoints",
        "obstacles",
        "maxSteps",
        "commands"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
        },
        "title": { "type": "string", "minLength": 1, "maxLength": 120 },
        "grid": {
          "type": "object",
          "additionalProperties": false,
          "required": ["width", "height"],
          "properties": {
            "width": { "type": "integer", "minimum": 2, "maximum": 32 },
            "height": { "type": "integer", "minimum": 2, "maximum": 32 }
          }
        },
        "start": { "$ref": "#/$defs/coordinate" },
        "goal": { "$ref": "#/$defs/coordinate" },
        "checkpoints": {
          "type": "array",
          "maxItems": 24,
          "uniqueItems": true,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id", "x", "y"],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 48,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
              },
              "x": { "type": "integer", "minimum": 0, "maximum": 31 },
              "y": { "type": "integer", "minimum": 0, "maximum": 31 }
            }
          }
        },
        "obstacles": {
          "type": "array",
          "maxItems": 256,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/coordinate" }
        },
        "maxSteps": { "type": "integer", "minimum": 1, "maximum": 512 },
        "commands": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1024,
          "items": { "enum": ["N", "E", "S", "W", "WAIT"] }
        }
      }
    },
    "claims": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "simulatorOnly",
        "realRobotControlled",
        "physicalExecutionProven",
        "safetyCertified",
        "aiGenerated",
        "uploaded"
      ],
      "properties": {
        "simulatorOnly": { "const": true },
        "realRobotControlled": { "const": false },
        "physicalExecutionProven": { "const": false },
        "safetyCertified": { "const": false },
        "aiGenerated": { "const": false },
        "uploaded": { "const": false }
      }
    },
    "note": {
      "const": "Browser-only mission plan for a deterministic simulator. It does not control a real robot, prove physical execution, provide safety certification, use AI, or upload mission data."
    },
    "manifestDigest": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    }
  },
  "$defs": {
    "coordinate": {
      "type": "object",
      "additionalProperties": false,
      "required": ["x", "y"],
      "properties": {
        "x": { "type": "integer", "minimum": 0, "maximum": 31 },
        "y": { "type": "integer", "minimum": 0, "maximum": 31 }
      }
    }
  }
}
