{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usemakoto.dev/schema/v0.2/handoff.schema.json",
  "title": "Makoto v0.2 Handoff Manifest",
  "type": "object",
  "required": ["version", "bundleId", "issuedAt", "roots", "heads", "statements", "artifacts", "requiredProfiles"],
  "properties": {
    "version": { "const": "0.2" },
    "bundleId": { "type": "string", "minLength": 1, "maxLength": 4096 },
    "issuedAt": { "$ref": "#/$defs/timestamp" },
    "recipient": { "$ref": "#/$defs/audience" },
    "roots": { "$ref": "#/$defs/nonemptyDigests" },
    "heads": { "$ref": "#/$defs/nonemptyDigests" },
    "statements": { "$ref": "#/$defs/nonemptyDigests" },
    "artifacts": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/artifact" }
    },
    "requiredProfiles": {
      "type": "array",
      "items": { "$ref": "#/$defs/requiredProfile" }
    },
    "nonce": { "$ref": "#/$defs/audience" }
  },
  "$defs": {
    "digest": {
      "type": "object",
      "required": ["sha256"],
      "properties": { "sha256": { "type": "string", "minLength": 64, "maxLength": 64 } },
      "additionalProperties": false
    },
    "timestamp": {
      "type": "string",
      "minLength": 20,
      "maxLength": 30
    },
    "audience": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "mediaType": {
      "type": "string",
      "maxLength": 255
    },
    "nonemptyDigests": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/digest" }
    },
    "artifact": {
      "type": "object",
      "required": ["name", "digest", "head"],
      "properties": {
        "name": { "type": "string", "minLength": 1, "maxLength": 4096 },
        "digest": { "$ref": "#/$defs/digest" },
        "mediaType": { "$ref": "#/$defs/mediaType" },
        "head": { "$ref": "#/$defs/digest" }
      },
      "additionalProperties": false
    },
    "requiredProfile": {
      "type": "object",
      "required": ["head", "id", "digest", "closureDigest", "target", "subjectName", "mediaType", "scope"],
      "properties": {
        "head": { "$ref": "#/$defs/digest" },
        "id": { "type": "string", "minLength": 1, "maxLength": 4096 },
        "digest": { "$ref": "#/$defs/digest" },
        "closureDigest": { "$ref": "#/$defs/digest" },
        "target": { "const": "artifact" },
        "subjectName": { "type": "string", "minLength": 1, "maxLength": 4096 },
        "mediaType": { "$ref": "#/$defs/mediaType" },
        "scope": { "const": "eachMatchingFinalArtifact" }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
