{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opentine.com/schemas/tine-cli-merge-queue-1.schema.json",
  "title": "tine merge-queue ACTION --json",
  "description": "Every `tine merge-queue` action: `queue` (the record's value) for init, add, claim, heartbeat and show; `result` for land (one landing) and verify (the record check); `results` for work; `record` for approve, and `ticket` when it was issued into a queue (0.52).",
  "type": "object",
  "required": [
    "command",
    "action",
    "ok"
  ],
  "properties": {
    "command": {
      "const": "merge-queue"
    },
    "action": {
      "enum": [
        "init",
        "add",
        "claim",
        "heartbeat",
        "land",
        "work",
        "show",
        "approve",
        "verify"
      ]
    },
    "ok": {
      "type": "boolean"
    },
    "queue": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "queue",
        "target",
        "gates",
        "head",
        "entries",
        "holder",
        "fencing",
        "lease_expires_ms",
        "landed",
        "rejected",
        "updated_ms"
      ],
      "properties": {
        "queue": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$"
        },
        "target": {
          "type": "string"
        },
        "gates": {
          "anyOf": [
            {
              "$ref": "opentine-merge-gates-1.schema.json"
            },
            {
              "type": "null"
            }
          ]
        },
        "head": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^run:sha256:[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "holder": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "fencing": {
          "type": "integer",
          "minimum": 0
        },
        "lease_expires_ms": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "updated_ms": {
          "type": "integer",
          "minimum": 0
        },
        "entries": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "run",
              "by",
              "enqueued_ms"
            ],
            "properties": {
              "run": {
                "type": "string",
                "pattern": "^run:sha256:[0-9a-f]{64}$"
              },
              "by": {
                "type": "string"
              },
              "enqueued_ms": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        },
        "landed": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "run",
              "merge",
              "fencing",
              "attestation"
            ],
            "properties": {
              "run": {
                "type": "string",
                "pattern": "^run:sha256:[0-9a-f]{64}$"
              },
              "merge": {
                "type": "string",
                "pattern": "^run:sha256:[0-9a-f]{64}$"
              },
              "fencing": {
                "type": "integer",
                "minimum": 0
              },
              "attestation": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^blob:sha256:[0-9a-f]{64}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        },
        "rejected": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "run",
              "reason",
              "fencing"
            ],
            "properties": {
              "run": {
                "type": "string",
                "pattern": "^run:sha256:[0-9a-f]{64}$"
              },
              "reason": {
                "type": "string"
              },
              "fencing": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        },
        "tickets": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "nonce",
              "approval",
              "run",
              "target",
              "approver",
              "expires_ms",
              "spent_fencing"
            ],
            "properties": {
              "nonce": {
                "type": "string",
                "pattern": "^[0-9a-f]{32}$"
              },
              "approval": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "run": {
                "type": "string",
                "pattern": "^run:sha256:[0-9a-f]{64}$"
              },
              "target": {
                "type": "string"
              },
              "approver": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "expires_ms": {
                "type": "integer",
                "minimum": 0
              },
              "spent_fencing": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": 0
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "result": {
      "type": "object"
    },
    "total": {
      "type": "integer",
      "minimum": 0
    },
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "status",
          "run",
          "merge",
          "fencing",
          "attestation",
          "gates"
        ],
        "properties": {
          "status": {
            "enum": [
              "landed",
              "rejected"
            ]
          },
          "run": {
            "type": "string",
            "pattern": "^run:sha256:[0-9a-f]{64}$"
          },
          "merge": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^run:sha256:[0-9a-f]{64}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "parents": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^run:sha256:[0-9a-f]{64}$"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "fencing": {
            "type": "integer",
            "minimum": 0
          },
          "attestation": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^blob:sha256:[0-9a-f]{64}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "gates": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "gate",
                "digest"
              ],
              "properties": {
                "gate": {
                  "enum": [
                    "vsa",
                    "eval",
                    "approval"
                  ]
                },
                "digest": {
                  "type": "string",
                  "pattern": "^sha256:[0-9a-f]{64}$"
                }
              }
            }
          },
          "fast_forward": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          }
        }
      }
    },
    "record": {
      "$ref": "opentine-merge-approval-1.schema.json"
    },
    "ticket": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "nonce",
        "approval",
        "run",
        "target",
        "approver",
        "expires_ms",
        "spent_fencing"
      ],
      "properties": {
        "nonce": {
          "type": "string",
          "pattern": "^[0-9a-f]{32}$"
        },
        "approval": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "run": {
          "type": "string",
          "pattern": "^run:sha256:[0-9a-f]{64}$"
        },
        "target": {
          "type": "string"
        },
        "approver": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "expires_ms": {
          "type": "integer",
          "minimum": 0
        },
        "spent_fencing": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  }
}
