{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gships.dammonburden.com/review-packets/schemas/packet-v1.json",
  "title": "GShips frozen review packet",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "packetId",
    "stableId",
    "family",
    "slug",
    "title",
    "status",
    "release",
    "paths",
    "boundary",
    "governingPolicies",
    "reviewContract",
    "primaryRecords",
    "linkedRecords",
    "referenceSnapshots",
    "packetFingerprint"
  ],
  "properties": {
    "schemaVersion": {
      "const": "gships-review-packet-1"
    },
    "packetId": {
      "type": "string",
      "minLength": 3
    },
    "stableId": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]*$"
    },
    "family": {
      "type": "string",
      "minLength": 3
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]*$"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "const": "prepared-human-review-not-started"
    },
    "release": {
      "$ref": "#/$defs/release"
    },
    "paths": {
      "$ref": "#/$defs/paths"
    },
    "boundary": {
      "type": "string",
      "minLength": 20
    },
    "governingPolicies": {
      "type": "array",
      "minItems": 2,
      "items": {
        "$ref": "#/$defs/governingPolicy"
      }
    },
    "reviewContract": {
      "$ref": "#/$defs/reviewContract"
    },
    "packetFingerprint": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "primaryRecords": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/primaryRecord"
      }
    },
    "linkedRecords": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/linkedRecord"
      }
    },
    "referenceSnapshots": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/referenceSnapshot"
      }
    }
  },
  "$defs": {
    "fingerprint": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "release": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "releaseId",
        "sourceCommit",
        "corpusGeneratedAt",
        "frozenAt",
        "canonicalOrigin"
      ],
      "properties": {
        "releaseId": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9._-]{2,119}$"
        },
        "sourceCommit": {
          "type": "string",
          "pattern": "^(development|[a-f0-9]{40})$"
        },
        "corpusGeneratedAt": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "frozenAt": {
          "type": "string",
          "format": "date-time"
        },
        "canonicalOrigin": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "paths": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "human",
        "family",
        "packet",
        "decisionTemplate",
        "worksheet",
        "byFingerprint"
      ],
      "properties": {
        "human": {
          "type": "string",
          "pattern": "^/"
        },
        "family": {
          "type": "string",
          "pattern": "^/"
        },
        "packet": {
          "type": "string",
          "pattern": "^/"
        },
        "decisionTemplate": {
          "type": "string",
          "pattern": "^/"
        },
        "worksheet": {
          "type": "string",
          "pattern": "^/"
        },
        "byFingerprint": {
          "type": "string",
          "pattern": "^/"
        }
      }
    },
    "governingPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "version",
        "path",
        "recordType",
        "fingerprint",
        "snapshot"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "path": {
          "type": "string",
          "pattern": "^/"
        },
        "recordType": {
          "const": "governing-policy"
        },
        "fingerprint": {
          "$ref": "#/$defs/fingerprint"
        },
        "snapshot": {
          "type": "object"
        }
      }
    },
    "scopeGroup": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "scopeClass",
        "oneOf"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "scopeClass": {
          "enum": [
            "bounded-competence",
            "domain-method",
            "rights-public-interest"
          ]
        },
        "oneOf": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "affected-public-rights",
              "ai-knowledge-assurance",
              "accessibility-disability-justice",
              "closed-loop-systems",
              "clinical-health",
              "communications-navigation",
              "culture-education",
              "defensive-cyber-safety",
              "dual-use-risk",
              "ecology-food",
              "ecosystem-due-diligence",
              "editorial-governance",
              "ethics-planetary-protection",
              "event-access-freshness",
              "governance-law-rights",
              "human-factors",
              "information-science",
              "institution-building",
              "manufacturing-maintenance",
              "mission-physics",
              "nuclear-safety",
              "opportunity-eligibility-access",
              "propulsion-energy",
              "radiation-health-physics",
              "reproductive-health-rights",
              "security-assurance",
              "structures-safety",
              "systems-engineering",
              "visual-science-communication"
            ]
          }
        }
      }
    },
    "reviewRequirements": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "minimumIndependentApprovals",
        "highConsequenceDomains",
        "requiredDomainCodes",
        "requiredComplementaryScopeGroups",
        "unresolvedNegativeFindingBlocksPublication"
      ],
      "properties": {
        "minimumIndependentApprovals": {
          "type": "integer",
          "minimum": 1,
          "maximum": 2
        },
        "highConsequenceDomains": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string"
          }
        },
        "requiredDomainCodes": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "affected-public-rights",
              "ai-knowledge-assurance",
              "accessibility-disability-justice",
              "closed-loop-systems",
              "clinical-health",
              "communications-navigation",
              "culture-education",
              "defensive-cyber-safety",
              "dual-use-risk",
              "ecology-food",
              "ecosystem-due-diligence",
              "editorial-governance",
              "ethics-planetary-protection",
              "event-access-freshness",
              "governance-law-rights",
              "human-factors",
              "information-science",
              "institution-building",
              "manufacturing-maintenance",
              "mission-physics",
              "nuclear-safety",
              "opportunity-eligibility-access",
              "propulsion-energy",
              "radiation-health-physics",
              "reproductive-health-rights",
              "security-assurance",
              "structures-safety",
              "systems-engineering",
              "visual-science-communication"
            ]
          }
        },
        "requiredComplementaryScopeGroups": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/scopeGroup"
          }
        },
        "unresolvedNegativeFindingBlocksPublication": {
          "const": true
        },
        "currentUntil": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      }
    },
    "primaryRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "recordType",
        "recordId",
        "title",
        "publicPath",
        "recordFingerprint",
        "reviewRequirements",
        "referenceIds",
        "snapshot"
      ],
      "properties": {
        "recordType": {
          "type": "string",
          "minLength": 1
        },
        "recordId": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "publicPath": {
          "type": "string",
          "minLength": 1
        },
        "recordFingerprint": {
          "$ref": "#/$defs/fingerprint"
        },
        "reviewRequirements": {
          "$ref": "#/$defs/reviewRequirements"
        },
        "referenceIds": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string"
          }
        },
        "snapshot": {
          "type": "object"
        }
      }
    },
    "linkedRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "recordType",
        "recordId",
        "title",
        "publicPath",
        "recordFingerprint"
      ],
      "properties": {
        "recordType": {
          "type": "string"
        },
        "recordId": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "publicPath": {
          "type": "string"
        },
        "recordFingerprint": {
          "$ref": "#/$defs/fingerprint"
        }
      }
    },
    "referenceSnapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sourceId",
        "sourceRecordType",
        "sourceFingerprint",
        "snapshot"
      ],
      "properties": {
        "sourceId": {
          "type": "string",
          "minLength": 1
        },
        "sourceRecordType": {
          "enum": [
            "claim-source",
            "reference-source"
          ]
        },
        "sourceFingerprint": {
          "$ref": "#/$defs/fingerprint"
        },
        "snapshot": {
          "type": "object"
        }
      }
    },
    "reviewContract": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "questions",
        "exclusions",
        "requestedScopeCodes",
        "dispositions",
        "prohibitedInputs",
        "freshness",
        "completionRule",
        "highConsequenceRule"
      ],
      "properties": {
        "questions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "text",
              "required"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "text": {
                "type": "string"
              },
              "required": {
                "const": true
              }
            }
          }
        },
        "exclusions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "requestedScopeCodes": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "affected-public-rights",
              "ai-knowledge-assurance",
              "accessibility-disability-justice",
              "closed-loop-systems",
              "clinical-health",
              "communications-navigation",
              "culture-education",
              "defensive-cyber-safety",
              "dual-use-risk",
              "ecology-food",
              "ecosystem-due-diligence",
              "editorial-governance",
              "ethics-planetary-protection",
              "event-access-freshness",
              "governance-law-rights",
              "human-factors",
              "information-science",
              "institution-building",
              "manufacturing-maintenance",
              "mission-physics",
              "nuclear-safety",
              "opportunity-eligibility-access",
              "propulsion-energy",
              "radiation-health-physics",
              "reproductive-health-rights",
              "security-assurance",
              "structures-safety",
              "systems-engineering",
              "visual-science-communication"
            ]
          }
        },
        "dispositions": {
          "type": "array",
          "items": {
            "enum": [
              "approve",
              "revise",
              "contest",
              "reject",
              "recuse"
            ]
          }
        },
        "prohibitedInputs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "freshness": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "maximumDecisionAgeFromFreezeDays",
            "eventOccurrenceRule"
          ],
          "properties": {
            "maximumDecisionAgeFromFreezeDays": {
              "type": "integer",
              "minimum": 1
            },
            "eventOccurrenceRule": {
              "type": "string"
            }
          }
        },
        "completionRule": {
          "type": "string"
        },
        "highConsequenceRule": {
          "type": "string"
        }
      }
    }
  }
}
