{
  "$id": "https://firefox-ci-tc.services.mozilla.com/schemas/queue/v1/task-status.json#",
  "$schema": "https://firefox-ci-tc.services.mozilla.com/schemas/common/metaschema.json#",
  "additionalProperties": false,
  "description": "A representation of **task status** as known by the queue\n",
  "properties": {
    "deadline": {
      "description": "Deadline of the task, by which this task must be complete. `pending` and\n`running` runs are resolved as **exception** if not resolved by other means\nbefore the deadline. After the deadline, a task is immutable. Note,\ndeadline cannot be more than 5 days into the future\n",
      "format": "date-time",
      "title": "Deadline",
      "type": "string"
    },
    "expires": {
      "description": "Task expiration, time at which task definition and\nstatus is deleted. Notice that all artifacts for the task\nmust have an expiration that is no later than this.\n",
      "format": "date-time",
      "title": "Expiration",
      "type": "string"
    },
    "priority": {
      "$ref": "task.json#/properties/priority"
    },
    "projectId": {
      "$ref": "task.json#/properties/projectId"
    },
    "provisionerId": {
      "$ref": "task.json#/properties/provisionerId"
    },
    "retriesLeft": {
      "description": "Number of retries left for the task in case of infrastructure issues\n",
      "maximum": 999,
      "minimum": 0,
      "title": "Retries Left",
      "type": "integer"
    },
    "runs": {
      "description": "List of runs, ordered so that index `i` has `runId == i`\n",
      "items": {
        "additionalProperties": false,
        "description": "JSON object with information about a run\n",
        "properties": {
          "reasonCreated": {
            "description": "Reason for the creation of this run,\n**more reasons may be added in the future**.\n",
            "enum": [
              "scheduled",
              "retry",
              "task-retry",
              "rerun",
              "exception"
            ],
            "title": "Reason Created",
            "type": "string"
          },
          "reasonResolved": {
            "description": "Reason that run was resolved, this is mainly\nuseful for runs resolved as `exception`.\nNote, **more reasons may be added in the future**, also this\nproperty is only available after the run is resolved. Some of these\nreasons, notably `intermittent-task`, `worker-shutdown`, and\n`claim-expired`, will trigger an automatic retry of the task.\nNote that 'superseded' is here only for compatibility, as that\nfunctionality has been removed.\n",
            "enum": [
              "completed",
              "failed",
              "deadline-exceeded",
              "canceled",
              "claim-expired",
              "worker-shutdown",
              "malformed-payload",
              "resource-unavailable",
              "internal-error",
              "intermittent-task",
              "superseded"
            ],
            "title": "Reason Resolved",
            "type": "string"
          },
          "resolved": {
            "description": "Date-time at which this run was resolved, ie. when the run changed\nstate from `running` to either `completed`, `failed` or `exception`.\nThis property is only present after the run as been resolved.\n",
            "format": "date-time",
            "title": "Resolved",
            "type": "string"
          },
          "runId": {
            "description": "Id of this task run, `run-id`s always starts from `0`\n",
            "maximum": 1000,
            "minimum": 0,
            "title": "Run Identifier",
            "type": "integer"
          },
          "scheduled": {
            "description": "Date-time at which this run was scheduled, ie. when the run was\ncreated in state `pending`.\n",
            "format": "date-time",
            "title": "Scheduled",
            "type": "string"
          },
          "started": {
            "description": "Date-time at which this run was claimed, ie. when the run changed\nstate from `pending` to `running`. This property is only present\nafter the run has been claimed.\n",
            "format": "date-time",
            "title": "Started",
            "type": "string"
          },
          "state": {
            "description": "State of this run\n",
            "enum": [
              "pending",
              "running",
              "completed",
              "failed",
              "exception"
            ],
            "title": "Run State",
            "type": "string"
          },
          "takenUntil": {
            "description": "Time at which the run expires and is resolved as `failed`, if the\nrun isn't reclaimed. Note, only present after the run has been\nclaimed.\n",
            "format": "date-time",
            "title": "Taken Until",
            "type": "string"
          },
          "workerGroup": {
            "description": "Identifier for group that worker who executes this run is a part of,\nthis identifier is mainly used for efficient routing.\nNote, this property is only present after the run is claimed.\n",
            "maxLength": 38,
            "minLength": 1,
            "pattern": "^([a-zA-Z0-9-_]*)$",
            "title": "Worker Group",
            "type": "string"
          },
          "workerId": {
            "description": "Identifier for worker evaluating this run within given\n`workerGroup`. Note, this property is only available after the run\nhas been claimed.\n",
            "maxLength": 38,
            "minLength": 1,
            "pattern": "^([a-zA-Z0-9-_]*)$",
            "title": "Worker Identifier",
            "type": "string"
          }
        },
        "required": [
          "runId",
          "state",
          "reasonCreated",
          "scheduled"
        ],
        "title": "Run Information",
        "type": "object"
      },
      "title": "List of Runs",
      "type": "array",
      "uniqueItems": true
    },
    "schedulerId": {
      "$ref": "task.json#/properties/schedulerId",
      "default": "-"
    },
    "state": {
      "description": "State of this task. This is just an auxiliary property derived from state\nof latests run, or `unscheduled` if none.\n",
      "enum": [
        "unscheduled",
        "pending",
        "running",
        "completed",
        "failed",
        "exception"
      ],
      "title": "State",
      "type": "string"
    },
    "taskGroupId": {
      "$ref": "task.json#/properties/taskGroupId"
    },
    "taskId": {
      "description": "Unique task identifier, this is UUID encoded as\n[URL-safe base64](http://tools.ietf.org/html/rfc4648#section-5) and\nstripped of `=` padding.\n",
      "pattern": "^[A-Za-z0-9_-]{8}[Q-T][A-Za-z0-9_-][CGKOSWaeimquy26-][A-Za-z0-9_-]{10}[AQgw]$",
      "title": "Task Identifier",
      "type": "string"
    },
    "taskQueueId": {
      "$ref": "task.json#/properties/taskQueueId"
    },
    "workerType": {
      "$ref": "task.json#/properties/workerType"
    }
  },
  "required": [
    "taskId",
    "provisionerId",
    "workerType",
    "taskQueueId",
    "schedulerId",
    "projectId",
    "taskGroupId",
    "deadline",
    "expires",
    "retriesLeft",
    "state",
    "runs"
  ],
  "title": "Task Status Structure",
  "type": "object"
}