{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://heartcortex.ai/schemas/1.0/fleet.schema.json",
  "title": "fleet",
  "type": "object",
  "required": [
    "id",
    "status"
  ],
  "properties": {
    "id": {
      "$ref": "common.schema.json#/$defs/uuid",
      "x-heart-privacy": "public"
    },
    "status": {
      "enum": [
        "awaiting-approval",
        "running",
        "paused",
        "succeeded",
        "partial",
        "failed",
        "cancelled"
      ],
      "x-heart-privacy": "public",
      "description": "paused: stopped between stages, by its failure limit or by pause. Only resume (with a new human approval) or cancel move it on. cancelled: no further stage is started; systems already done stay done (D30)."
    },
    "total": {
      "type": "integer",
      "minimum": 0,
      "x-heart-privacy": "public"
    },
    "succeeded": {
      "type": "integer",
      "minimum": 0,
      "x-heart-privacy": "public"
    },
    "failed": {
      "type": "integer",
      "minimum": 0,
      "x-heart-privacy": "public"
    },
    "selector": {
      "type": "object",
      "x-heart-privacy": "internal"
    },
    "rollout": {
      "type": "object",
      "x-heart-privacy": "internal"
    },
    "operation": {
      "type": "object",
      "x-heart-privacy": "private"
    },
    "pausedBy": {
      "type": "string",
      "x-heart-privacy": "internal",
      "description": "failure-limit, or the principal that paused it."
    },
    "resumedBy": {
      "type": "string",
      "x-heart-privacy": "internal",
      "description": "The person who approved the resume."
    },
    "cancelledBy": {
      "type": "string",
      "x-heart-privacy": "internal"
    },
    "actionId": {
      "$ref": "common.schema.json#/$defs/uuid",
      "x-heart-privacy": "internal",
      "description": "The Gateway Action that holds this command, or its resume, for a person's approval (Part 6, Section 8 rule 5). Approve it with POST /heart/v1/actions/{actionId}/decision at the Gateway."
    },
    "digest": {
      "description": "The fleet digest: lower-case hex SHA-256 over the RFC 8785 JSON of {command, operation, arguments, physical, selector, targets, rollout} (API Standard 13.3). The person's proof of presence covers it.",
      "$ref": "common.schema.json#/$defs/sha256",
      "x-heart-privacy": "internal"
    },
    "physical": {
      "type": "boolean",
      "x-heart-privacy": "internal"
    },
    "accepted": {
      "type": "integer",
      "minimum": 0,
      "x-heart-privacy": "public",
      "description": "Systems whose own gate is holding the operation for approval (202). They count as delivered, not as failed."
    },
    "pending": {
      "type": "integer",
      "minimum": 0,
      "x-heart-privacy": "public",
      "description": "Systems not yet reached."
    },
    "nextStageAt": {
      "$ref": "common.schema.json#/$defs/timestamp",
      "x-heart-privacy": "internal"
    },
    "systems": {
      "type": "array",
      "x-heart-privacy": "internal",
      "description": "Progress per system.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "pending",
              "succeeded",
              "accepted",
              "failed",
              "skipped"
            ]
          },
          "httpStatus": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "at": {
            "$ref": "common.schema.json#/$defs/timestamp"
          }
        }
      }
    },
    "ext": {
      "$ref": "common.schema.json#/$defs/ext",
      "x-heart-privacy": "private"
    }
  }
}
