{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developer.reits.tech/schemas/auth-s08-r02-c02-owner-handoff-kits.v1.schema.json",
  "title": "Auth S08 R02 C02 四席公开材料交接包清单",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "subknifeId",
    "parentSubknife",
    "status",
    "progress",
    "dossier",
    "handoffBoundary",
    "kits",
    "protocol",
    "assemblyContract",
    "qaGates",
    "permissions",
    "effects",
    "decision"
  ],
  "properties": {
    "schemaVersion": {
      "const": "developer.reits.tech/auth-s08-r02-c02-owner-handoff-kits/v1"
    },
    "subknifeId": {
      "const": "D05-A03-P03c-S08-R02-C02-H01"
    },
    "parentSubknife": {
      "const": "D05-A03-P03c-S08-R02-C02"
    },
    "status": {
      "const": "PUBLIC_HANDOFF_KITS_READY_EXTERNAL_CONTRIBUTIONS_ABSENT"
    },
    "progress": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "formal",
        "auth",
        "s08",
        "r02Engineering",
        "handoffKits",
        "externalContributions"
      ],
      "properties": {
        "formal": {
          "$ref": "#/$defs/formalProgress"
        },
        "auth": {
          "$ref": "#/$defs/authProgress"
        },
        "s08": {
          "$ref": "#/$defs/stageProgress"
        },
        "r02Engineering": {
          "$ref": "#/$defs/engineeringProgress"
        },
        "handoffKits": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "published",
            "total"
          ],
          "properties": {
            "published": {
              "const": 4
            },
            "total": {
              "const": 4
            }
          }
        },
        "externalContributions": {
          "$ref": "#/$defs/externalProgress"
        }
      }
    },
    "dossier": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "subknifeId",
        "digest",
        "authoritySetSchemaHref",
        "contributionTemplateSchemaHref",
        "manifestSchemaHref"
      ],
      "properties": {
        "subknifeId": {
          "const": "D05-A03-P03c-S08-R01"
        },
        "digest": {
          "const": "684783317dc35c1c7a1303e57b7143278d1f5fb2e3ba743671c6555f4a883f6b"
        },
        "authoritySetSchemaHref": {
          "const": "/schemas/auth-s08-owner-authority-set.v1.schema.json"
        },
        "contributionTemplateSchemaHref": {
          "const": "/schemas/auth-s08-r02-c02-owner-authority-contribution-template.v1.schema.json"
        },
        "manifestSchemaHref": {
          "const": "/schemas/auth-s08-r02-c02-owner-handoff-kits.v1.schema.json"
        }
      }
    },
    "handoffBoundary": {
      "type": "object",
      "minProperties": 14,
      "maxProperties": 14,
      "additionalProperties": {
        "type": "boolean"
      },
      "required": [
        "onlyPublicMaterialInKit",
        "templatesAreUnfilled",
        "templateIsAuthorityBinding",
        "templateIsBallot",
        "templateIsExecutionPermit",
        "portalCanGenerateIdentity",
        "portalCanGenerateKey",
        "portalCanReadPrivateKey",
        "portalCanReceivePrivateMaterial",
        "portalCanSubmitForOwner",
        "portalCanSign",
        "ciCanSign",
        "codexCanSign",
        "delegationAllowed"
      ],
      "properties": {
        "onlyPublicMaterialInKit": {
          "const": true
        },
        "templatesAreUnfilled": {
          "const": true
        },
        "templateIsAuthorityBinding": {
          "const": false
        },
        "templateIsBallot": {
          "const": false
        },
        "templateIsExecutionPermit": {
          "const": false
        },
        "portalCanGenerateIdentity": {
          "const": false
        },
        "portalCanGenerateKey": {
          "const": false
        },
        "portalCanReadPrivateKey": {
          "const": false
        },
        "portalCanReceivePrivateMaterial": {
          "const": false
        },
        "portalCanSubmitForOwner": {
          "const": false
        },
        "portalCanSign": {
          "const": false
        },
        "ciCanSign": {
          "const": false
        },
        "codexCanSign": {
          "const": false
        },
        "delegationAllowed": {
          "const": false
        }
      }
    },
    "kits": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "prefixItems": [
        {
          "$ref": "#/$defs/authKit"
        },
        {
          "$ref": "#/$defs/securityKit"
        },
        {
          "$ref": "#/$defs/sreDbaKit"
        },
        {
          "$ref": "#/$defs/qaWitnessKit"
        }
      ],
      "items": false
    },
    "protocol": {
      "type": "array",
      "minItems": 6,
      "maxItems": 6,
      "items": {
        "$ref": "#/$defs/protocolStep"
      }
    },
    "assemblyContract": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "inputMode",
        "inputCount",
        "requiredInputCount",
        "ownerOrder",
        "outputState",
        "validationCli",
        "sanitizedReceipt",
        "nextOnSuccess",
        "nextOnFailure"
      ],
      "properties": {
        "inputMode": {
          "const": "FOUR_OUT_OF_BAND_PUBLIC_CONTRIBUTIONS"
        },
        "inputCount": {
          "const": 0
        },
        "requiredInputCount": {
          "const": 4
        },
        "ownerOrder": {
          "$ref": "#/$defs/ownerOrder"
        },
        "outputState": {
          "const": "AUTHORITY_SET_ABSENT"
        },
        "validationCli": {
          "type": "string",
          "minLength": 80
        },
        "sanitizedReceipt": {
          "const": "IDENTITYREF_KEYREF_PUBLIC_KEY_FINGERPRINT_ONLY"
        },
        "nextOnSuccess": {
          "const": "ADMIT_C03_BALLOT_INTAKE_ONLY"
        },
        "nextOnFailure": {
          "const": "REJECT_AND_HOLD_PRODUCTION"
        }
      }
    },
    "qaGates": {
      "type": "array",
      "minItems": 8,
      "maxItems": 8,
      "items": {
        "$ref": "#/$defs/qaGate"
      }
    },
    "permissions": {
      "type": "object",
      "minProperties": 8,
      "maxProperties": 8,
      "additionalProperties": {
        "const": false
      }
    },
    "effects": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kitsPublished",
        "externalContributionsReceived",
        "externalContributionsValidated",
        "authoritySetCreated",
        "authorityBindingsCreated",
        "ballotsCreated",
        "productionConnections",
        "databaseMigrations",
        "authDeployments",
        "formalAdvances"
      ],
      "properties": {
        "kitsPublished": {
          "const": 4
        },
        "externalContributionsReceived": {
          "const": 0
        },
        "externalContributionsValidated": {
          "const": 0
        },
        "authoritySetCreated": {
          "const": 0
        },
        "authorityBindingsCreated": {
          "const": 0
        },
        "ballotsCreated": {
          "const": 0
        },
        "productionConnections": {
          "const": 0
        },
        "databaseMigrations": {
          "const": 0
        },
        "authDeployments": {
          "const": 0
        },
        "formalAdvances": {
          "const": 0
        }
      }
    },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "handoffPreparationReady",
        "externalContributionsPresent",
        "authoritySetPresent",
        "c02Complete",
        "c03Admitted",
        "productionHeld",
        "nextRequiredEvent"
      ],
      "properties": {
        "handoffPreparationReady": {
          "const": true
        },
        "externalContributionsPresent": {
          "const": false
        },
        "authoritySetPresent": {
          "const": false
        },
        "c02Complete": {
          "const": false
        },
        "c03Admitted": {
          "const": false
        },
        "productionHeld": {
          "const": true
        },
        "nextRequiredEvent": {
          "type": "string",
          "minLength": 40
        }
      }
    }
  },
  "$defs": {
    "formalProgress": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "currentKnife",
        "acceptedKnives",
        "totalKnives",
        "remainingIncludingCurrent"
      ],
      "properties": {
        "currentKnife": {
          "const": 5
        },
        "acceptedKnives": {
          "const": 4
        },
        "totalKnives": {
          "const": 36
        },
        "remainingIncludingCurrent": {
          "const": 32
        }
      }
    },
    "authProgress": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "completed",
        "total"
      ],
      "properties": {
        "completed": {
          "const": 7
        },
        "total": {
          "const": 8
        }
      }
    },
    "stageProgress": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "completedSteps",
        "currentStep",
        "totalSteps",
        "remainingIncludingCurrent"
      ],
      "properties": {
        "completedSteps": {
          "const": 1
        },
        "currentStep": {
          "const": 2
        },
        "totalSteps": {
          "const": 4
        },
        "remainingIncludingCurrent": {
          "const": 3
        }
      }
    },
    "engineeringProgress": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "completedSlices",
        "currentSlice",
        "totalSlices",
        "remainingIncludingCurrent"
      ],
      "properties": {
        "completedSlices": {
          "const": 1
        },
        "currentSlice": {
          "const": 2
        },
        "totalSlices": {
          "const": 4
        },
        "remainingIncludingCurrent": {
          "const": 3
        }
      }
    },
    "externalProgress": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "required",
        "received",
        "valid",
        "bound",
        "waiting"
      ],
      "properties": {
        "required": {
          "const": 4
        },
        "received": {
          "const": 0
        },
        "valid": {
          "const": 0
        },
        "bound": {
          "const": 0
        },
        "waiting": {
          "const": 4
        }
      }
    },
    "ownerOrder": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "prefixItems": [
        {
          "const": "AUTH"
        },
        {
          "const": "SECURITY"
        },
        {
          "const": "SRE_DBA"
        },
        {
          "const": "QA_WITNESS"
        }
      ],
      "items": false
    },
    "kitBase": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sequence",
        "ownerId",
        "role",
        "state",
        "filename",
        "href",
        "responsibilities",
        "requiredPublicFields",
        "forbiddenMaterial"
      ],
      "properties": {
        "sequence": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4
        },
        "ownerId": {
          "type": "string"
        },
        "role": {
          "type": "string",
          "minLength": 4
        },
        "state": {
          "const": "UNFILLED_PUBLIC_TEMPLATE"
        },
        "filename": {
          "type": "string",
          "pattern": "^[a-z0-9-]+\\.template\\.json$"
        },
        "href": {
          "type": "string",
          "pattern": "^/handoff/auth-s08-r02-c02/[a-z0-9-]+\\.template\\.json$"
        },
        "responsibilities": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "items": {
            "type": "string",
            "minLength": 8
          }
        },
        "requiredPublicFields": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "prefixItems": [
            {
              "const": "ownerId"
            },
            {
              "const": "identityRef"
            },
            {
              "const": "keyRef"
            },
            {
              "const": "publicKey"
            },
            {
              "const": "delegationAllowed"
            }
          ],
          "items": false
        },
        "forbiddenMaterial": {
          "type": "array",
          "minItems": 7,
          "maxItems": 7,
          "items": {
            "type": "string",
            "minLength": 4
          }
        }
      }
    },
    "authKit": {
      "allOf": [
        {
          "$ref": "#/$defs/kitBase"
        },
        {
          "properties": {
            "sequence": {
              "const": 1
            },
            "ownerId": {
              "const": "AUTH"
            }
          }
        }
      ]
    },
    "securityKit": {
      "allOf": [
        {
          "$ref": "#/$defs/kitBase"
        },
        {
          "properties": {
            "sequence": {
              "const": 2
            },
            "ownerId": {
              "const": "SECURITY"
            }
          }
        }
      ]
    },
    "sreDbaKit": {
      "allOf": [
        {
          "$ref": "#/$defs/kitBase"
        },
        {
          "properties": {
            "sequence": {
              "const": 3
            },
            "ownerId": {
              "const": "SRE_DBA"
            }
          }
        }
      ]
    },
    "qaWitnessKit": {
      "allOf": [
        {
          "$ref": "#/$defs/kitBase"
        },
        {
          "properties": {
            "sequence": {
              "const": 4
            },
            "ownerId": {
              "const": "QA_WITNESS"
            }
          }
        }
      ]
    },
    "protocolStep": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "state",
        "actor",
        "exit"
      ],
      "properties": {
        "id": {
          "pattern": "^H0[1-6]$"
        },
        "name": {
          "type": "string",
          "minLength": 6
        },
        "state": {
          "enum": [
            "READY",
            "WAITING",
            "BLOCKED",
            "HELD"
          ]
        },
        "actor": {
          "type": "string",
          "minLength": 4
        },
        "exit": {
          "type": "string",
          "minLength": 12
        }
      }
    },
    "qaGate": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "state"
      ],
      "properties": {
        "id": {
          "pattern": "^Q0[1-8]$"
        },
        "name": {
          "type": "string",
          "minLength": 6
        },
        "state": {
          "enum": [
            "PASS",
            "WAITING",
            "BLOCKED",
            "HELD"
          ]
        }
      }
    }
  }
}
