{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/handover-sh/json-schema/handover-sh-operations-status-envelope-schema.json",
  "title": "OperationsStatusEnvelope",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/handover-sh-openapi.json#/components/schemas/OperationsStatusEnvelope",
  "type": "object",
  "required": [
    "data"
  ],
  "properties": {
    "data": {
      "type": "object",
      "required": [
        "scheduler",
        "imports",
        "exports",
        "semantic",
        "retention",
        "reliability"
      ],
      "properties": {
        "scheduler": {
          "type": "object",
          "required": [
            "schedule",
            "status",
            "lastStartedAt",
            "lastCompletedAt",
            "lastErrorMessage"
          ],
          "properties": {
            "schedule": {
              "type": "string"
            },
            "status": {
              "type": "string",
              "enum": [
                "idle",
                "running",
                "succeeded",
                "failed",
                "never_run"
              ]
            },
            "lastStartedAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "lastCompletedAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "lastErrorMessage": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "exports": {
          "$ref": "#/$defs/JobQueueCounts"
        },
        "imports": {
          "$ref": "#/$defs/JobQueueCounts"
        },
        "semantic": {
          "allOf": [
            {
              "$ref": "#/$defs/JobQueueCounts"
            },
            {
              "type": "object",
              "required": [
                "available",
                "indexed"
              ],
              "properties": {
                "available": {
                  "type": "boolean"
                },
                "indexed": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          ]
        },
        "retention": {
          "type": "object",
          "required": [
            "scheduledForPurge",
            "dueForPurge"
          ],
          "properties": {
            "scheduledForPurge": {
              "type": "integer",
              "minimum": 0
            },
            "dueForPurge": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "reliability": {
          "type": "object",
          "required": [
            "schedule",
            "lastBackupAt",
            "lastVerifiedAt",
            "active",
            "history"
          ],
          "properties": {
            "schedule": {
              "type": "object",
              "required": [
                "backups",
                "verification"
              ],
              "properties": {
                "backups": {
                  "type": "string"
                },
                "verification": {
                  "type": "string"
                }
              }
            },
            "lastBackupAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "lastVerifiedAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "active": {
              "oneOf": [
                {
                  "$ref": "#/$defs/ReliabilityRun"
                },
                {
                  "type": "null"
                }
              ]
            },
            "history": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/ReliabilityRun"
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "JobQueueCounts": {
      "type": "object",
      "required": [
        "pending",
        "running",
        "failed",
        "deadLetter"
      ],
      "properties": {
        "pending": {
          "type": "integer",
          "minimum": 0
        },
        "running": {
          "type": "integer",
          "minimum": 0
        },
        "failed": {
          "type": "integer",
          "minimum": 0
        },
        "deadLetter": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "ReliabilityRun": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "status",
        "backupRunId",
        "manifestAvailable",
        "totalObjects",
        "totalBytes",
        "checkedObjects",
        "missingObjects",
        "corruptObjects",
        "requestedByName",
        "startedAt",
        "completedAt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^rel_"
        },
        "kind": {
          "type": "string",
          "enum": [
            "backup",
            "verification"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "running",
            "succeeded",
            "failed"
          ]
        },
        "backupRunId": {
          "type": [
            "string",
            "null"
          ]
        },
        "manifestAvailable": {
          "type": "boolean"
        },
        "totalObjects": {
          "type": "integer",
          "minimum": 0
        },
        "totalBytes": {
          "type": "integer",
          "minimum": 0
        },
        "checkedObjects": {
          "type": "integer",
          "minimum": 0
        },
        "missingObjects": {
          "type": "integer",
          "minimum": 0
        },
        "corruptObjects": {
          "type": "integer",
          "minimum": 0
        },
        "requestedByName": {
          "type": "string"
        },
        "startedAt": {
          "type": "string",
          "format": "date-time"
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    }
  }
}