{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opentine.com/schemas/tine-cli-holdout-1.schema.json",
  "title": "tine dataset seal|unseal|exposure --json",
  "description": "Sealed holdouts. `seal` commits to the items with a Merkle root (signed claim `opentine.holdout.commitment/1`) and stores each item TINEAES-sealed; `previous` names the generation it rotates. `unseal` writes a signed `opentine.holdout.access/1` record (who, which run, why) before it releases items. `exposure` counts the valid access records against the budget and checks the commitment chain. Canaries are `tine-cli-canary-1`. A refusal is `ok` false with `refusals` (`holdout.*`) and exit 1.",
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "ok",
        "out",
        "holdout",
        "root",
        "items",
        "generation",
        "previous",
        "budget"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-holdout/1"
        },
        "ok": {
          "type": "boolean"
        },
        "command": {
          "const": "dataset seal"
        },
        "out": {
          "type": "string"
        },
        "holdout": {
          "type": "string"
        },
        "root": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "items": {
          "type": "integer",
          "minimum": 0
        },
        "generation": {
          "type": "integer",
          "minimum": 0
        },
        "previous": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "budget": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "max_unseals",
            "max_items"
          ],
          "properties": {
            "max_unseals": {
              "type": "integer",
              "minimum": 0
            },
            "max_items": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "ok",
        "holdout",
        "root",
        "run",
        "purpose",
        "items",
        "out",
        "over_budget",
        "access",
        "access_sha256",
        "signer"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-holdout/1"
        },
        "ok": {
          "type": "boolean"
        },
        "command": {
          "const": "dataset unseal"
        },
        "holdout": {
          "type": "string"
        },
        "root": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "run": {
          "type": "string"
        },
        "purpose": {
          "enum": [
            "eval",
            "other"
          ]
        },
        "items": {
          "type": "integer",
          "minimum": 0
        },
        "out": {
          "type": "string"
        },
        "over_budget": {
          "type": "boolean"
        },
        "access": {
          "type": "string"
        },
        "access_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "signer": {
          "type": "string"
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "ok",
        "holdout",
        "root",
        "unseals",
        "revealed",
        "budget",
        "over_budget",
        "chain_ok",
        "records",
        "chain"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-holdout/1"
        },
        "ok": {
          "type": "boolean"
        },
        "command": {
          "const": "dataset exposure"
        },
        "holdout": {
          "type": "string"
        },
        "root": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "unseals": {
          "type": "integer",
          "minimum": 0
        },
        "revealed": {
          "type": "integer",
          "minimum": 0
        },
        "budget": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "max_unseals",
            "max_items"
          ],
          "properties": {
            "max_unseals": {
              "type": "integer",
              "minimum": 0
            },
            "max_items": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "over_budget": {
          "type": "boolean"
        },
        "chain_ok": {
          "type": "boolean"
        },
        "records": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "sequence",
              "run",
              "signer",
              "purpose",
              "items",
              "sha256"
            ],
            "properties": {
              "sequence": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "run": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "signer": {
                "type": "string"
              },
              "purpose": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "items": {
                "type": "integer",
                "minimum": 0
              },
              "sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            }
          }
        },
        "chain": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "generation",
              "root",
              "commitment_sha256"
            ],
            "properties": {
              "generation": {
                "type": "integer",
                "minimum": 0
              },
              "root": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "commitment_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "ok",
        "refusals"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-holdout/1"
        },
        "ok": {
          "const": false
        },
        "command": {
          "type": "string"
        },
        "refusals": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "code",
              "detail"
            ],
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "detail": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  ]
}
