{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developer.reits.tech/schemas/auth-s08-four-owner-review-dossier.v1.schema.json",
  "title": "Auth S08 四方生产变更评审 Dossier",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "subknifeId",
    "parentStage",
    "status",
    "observedAt",
    "progress",
    "truthBoundary",
    "source",
    "assembly",
    "evidenceBindings",
    "reviewSteps",
    "ownerPackets",
    "approvalGates",
    "stopConditions",
    "productionBoundary",
    "permissions"
  ],
  "properties": {
    "schemaVersion": {
      "const": "reits.tech/auth-s08-four-owner-review-dossier/v1"
    },
    "subknifeId": {
      "const": "D05-A03-P03c-S08-R01"
    },
    "parentStage": {
      "const": "D05-A03-P03c-S07"
    },
    "status": {
      "const": "REVIEW_DOSSIER_ASSEMBLED_BALLOTS_PENDING_PRODUCTION_HELD"
    },
    "observedAt": {
      "type": "string",
      "format": "date-time"
    },
    "progress": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "auth",
        "s08",
        "ballots"
      ],
      "properties": {
        "auth": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "completed",
            "total"
          ],
          "properties": {
            "completed": {
              "const": 7
            },
            "total": {
              "const": 8
            }
          }
        },
        "s08": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "completedSteps",
            "currentStep",
            "totalSteps",
            "remainingIncludingCurrent"
          ],
          "properties": {
            "completedSteps": {
              "const": 1
            },
            "currentStep": {
              "const": 2
            },
            "totalSteps": {
              "const": 4
            },
            "remainingIncludingCurrent": {
              "const": 3
            }
          }
        },
        "ballots": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "accepted",
            "total"
          ],
          "properties": {
            "accepted": {
              "const": 0
            },
            "total": {
              "const": 4
            }
          }
        }
      }
    },
    "truthBoundary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "externalHumanSignersRequired",
        "proxySignatureAllowed",
        "defaultApprovalAllowed",
        "portalCanSign",
        "dossierIsExecutionPermit"
      ],
      "properties": {
        "externalHumanSignersRequired": {
          "const": true
        },
        "proxySignatureAllowed": {
          "const": false
        },
        "defaultApprovalAllowed": {
          "const": false
        },
        "portalCanSign": {
          "const": false
        },
        "dossierIsExecutionPermit": {
          "const": false
        }
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "repository",
        "mainRevision",
        "stagingSourceRevision",
        "stagingEvidenceRevision",
        "stagingBinarySha256",
        "stagingReceiptSha256",
        "rollbackFloorRevision",
        "productionReleaseRevision"
      ],
      "properties": {
        "repository": {
          "const": "reits/reits-auth"
        },
        "mainRevision": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "stagingSourceRevision": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "stagingEvidenceRevision": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "stagingBinarySha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "stagingReceiptSha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "rollbackFloorRevision": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "productionReleaseRevision": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        }
      }
    },
    "assembly": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "required",
        "bound",
        "missing"
      ],
      "properties": {
        "required": {
          "const": 16
        },
        "bound": {
          "const": 16
        },
        "missing": {
          "const": 0
        }
      }
    },
    "evidenceBindings": {
      "type": "array",
      "minItems": 16,
      "maxItems": 16,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "authority",
          "subject",
          "digest",
          "state"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^EV(0[1-9]|1[0-6])$"
          },
          "authority": {
            "type": "string",
            "minLength": 2
          },
          "subject": {
            "type": "string",
            "minLength": 2
          },
          "digest": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "state": {
            "const": "BOUND"
          }
        }
      }
    },
    "reviewSteps": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "state",
          "exit"
        ],
        "properties": {
          "id": {
            "enum": [
              "R01",
              "R02",
              "R03",
              "R04"
            ]
          },
          "name": {
            "type": "string",
            "minLength": 2
          },
          "state": {
            "enum": [
              "COMPLETE",
              "CURRENT",
              "BLOCKED"
            ]
          },
          "exit": {
            "type": "string",
            "minLength": 2
          }
        }
      }
    },
    "ownerPackets": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "role",
          "decision",
          "identityRef",
          "keyRef",
          "signature",
          "signedAt",
          "delegationAllowed",
          "evidenceRefs",
          "checks"
        ],
        "properties": {
          "id": {
            "enum": [
              "AUTH",
              "SECURITY",
              "SRE_DBA",
              "QA_WITNESS"
            ]
          },
          "role": {
            "type": "string",
            "minLength": 2
          },
          "decision": {
            "const": "PENDING_EXTERNAL_SIGNATURE"
          },
          "identityRef": {
            "type": "null"
          },
          "keyRef": {
            "type": "null"
          },
          "signature": {
            "type": "null"
          },
          "signedAt": {
            "type": "null"
          },
          "delegationAllowed": {
            "const": false
          },
          "evidenceRefs": {
            "type": "array",
            "minItems": 4,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^EV(0[1-9]|1[0-6])$"
            }
          },
          "checks": {
            "type": "array",
            "minItems": 6,
            "maxItems": 6,
            "items": {
              "type": "string",
              "minLength": 2
            }
          }
        }
      }
    },
    "approvalGates": {
      "type": "array",
      "minItems": 12,
      "maxItems": 12,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "state"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^G(0[1-9]|1[0-2])$"
          },
          "name": {
            "type": "string",
            "minLength": 2
          },
          "state": {
            "enum": [
              "PASS",
              "WAITING",
              "HELD"
            ]
          }
        }
      }
    },
    "stopConditions": {
      "type": "array",
      "minItems": 12,
      "maxItems": 12,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "trigger",
          "action"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^SC(0[1-9]|1[0-2])$"
          },
          "trigger": {
            "type": "string",
            "minLength": 2
          },
          "action": {
            "const": "ABORT_AND_HOLD_PRODUCTION"
          }
        }
      }
    },
    "productionBoundary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "connections",
        "databaseMigrations",
        "databaseWrites",
        "authDeployments",
        "routeChanges",
        "keyReads",
        "keyWrites",
        "accountMutations",
        "sessionMutations",
        "tokenIssuanceChanges",
        "algorithmChanges",
        "jwksChanges"
      ],
      "properties": {
        "connections": {
          "const": 0
        },
        "databaseMigrations": {
          "const": 0
        },
        "databaseWrites": {
          "const": 0
        },
        "authDeployments": {
          "const": 0
        },
        "routeChanges": {
          "const": 0
        },
        "keyReads": {
          "const": 0
        },
        "keyWrites": {
          "const": 0
        },
        "accountMutations": {
          "const": 0
        },
        "sessionMutations": {
          "const": 0
        },
        "tokenIssuanceChanges": {
          "const": 0
        },
        "algorithmChanges": {
          "const": 0
        },
        "jwksChanges": {
          "const": 0
        }
      }
    },
    "permissions": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "productionDatabaseConnection",
        "productionMigration",
        "productionAuthDeployment",
        "shadowMode",
        "activeMode",
        "es256Activation",
        "jwksPublication",
        "formalAdvance"
      ],
      "properties": {
        "productionDatabaseConnection": {
          "const": false
        },
        "productionMigration": {
          "const": false
        },
        "productionAuthDeployment": {
          "const": false
        },
        "shadowMode": {
          "const": false
        },
        "activeMode": {
          "const": false
        },
        "es256Activation": {
          "const": false
        },
        "jwksPublication": {
          "const": false
        },
        "formalAdvance": {
          "const": false
        }
      }
    }
  }
}
