{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chris-page-gov.github.io/okf-explorer/profile/evidence-workbench-passages/v1/manifest.schema.json",
  "title": "Passage boundary review manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "title",
    "status",
    "baseline_commit",
    "source",
    "impact",
    "limits",
    "cases"
  ],
  "properties": {
    "schema": {
      "const": "okf-passage-boundary-review-manifest.v1"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300
    },
    "status": {
      "type": "string",
      "minLength": 1
    },
    "baseline_commit": {
      "type": "string",
      "minLength": 1
    },
    "source": {
      "type": "object",
      "maxProperties": 30,
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9_]*_sha256$"
      },
      "additionalProperties": {
        "$ref": "#/$defs/sha256"
      }
    },
    "impact": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "added_ids": {
          "type": "integer",
          "minimum": 0
        },
        "authored_units_exact": {
          "type": "integer",
          "minimum": 0
        },
        "baseline_units": {
          "type": "integer",
          "minimum": 0
        },
        "candidate_units": {
          "type": "integer",
          "minimum": 0
        },
        "changed_documents": {
          "type": "integer",
          "minimum": 0
        },
        "documents": {
          "type": "integer",
          "minimum": 0
        },
        "historical_amendments_changed": {
          "type": "integer",
          "minimum": 0
        },
        "original_source_bytes": {
          "type": "integer",
          "minimum": 0
        },
        "removed_ids": {
          "type": "integer",
          "minimum": 0
        },
        "identity_migration": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "url",
            "sha256",
            "bytes"
          ],
          "properties": {
            "url": {
              "type": "string",
              "minLength": 1
            },
            "sha256": {
              "$ref": "#/$defs/sha256"
            },
            "bytes": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "identity_migration_status": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "substantive_chapters_changed": {
          "type": "array",
          "maxItems": 100,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "document_id",
              "family",
              "source_role",
              "before_units",
              "after_units",
              "added_ids",
              "removed_ids",
              "unchanged_record_ids",
              "before_roles",
              "after_roles"
            ],
            "properties": {
              "document_id": {
                "type": "string",
                "minLength": 1
              },
              "family": {
                "type": "string",
                "minLength": 1
              },
              "source_role": {
                "type": "string",
                "minLength": 1
              },
              "before_units": {
                "type": "integer",
                "minimum": 0
              },
              "after_units": {
                "type": "integer",
                "minimum": 0
              },
              "added_ids": {
                "type": "integer",
                "minimum": 0
              },
              "removed_ids": {
                "type": "integer",
                "minimum": 0
              },
              "unchanged_record_ids": {
                "type": "integer",
                "minimum": 0
              },
              "before_roles": {
                "type": "object",
                "maxProperties": 100,
                "additionalProperties": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "after_roles": {
                "type": "object",
                "maxProperties": 100,
                "additionalProperties": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        }
      }
    },
    "candidate_comparison": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "status": {
          "type": "string"
        },
        "parser_version": {
          "type": "string"
        },
        "ruleset_version": {
          "type": "string"
        },
        "settings_sha256": {
          "$ref": "#/$defs/sha256"
        },
        "changed_documents": {
          "type": "integer",
          "minimum": 0
        },
        "historical_amendments_changed": {
          "type": "integer",
          "minimum": 0
        },
        "substantive_chapters_changed": {
          "type": "integer",
          "minimum": 0
        },
        "case_outputs_sha256": {
          "$ref": "#/$defs/sha256"
        },
        "candidate_units": {
          "type": "integer",
          "minimum": 0
        },
        "identity_version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "settings_text": {
          "type": "string",
          "maxLength": 65536
        },
        "implementation_bindings_sha256": {
          "$ref": "#/$defs/sha256"
        }
      }
    },
    "limits": {
      "type": "array",
      "maxItems": 30,
      "items": {
        "type": "string"
      }
    },
    "cases": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "url",
          "sha256",
          "bytes",
          "document_id",
          "classification",
          "review_status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._:-]*$"
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "minLength": 1
          },
          "sha256": {
            "$ref": "#/$defs/sha256"
          },
          "bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 524288
          },
          "document_id": {
            "type": "string",
            "minLength": 1
          },
          "classification": {
            "type": "string",
            "minLength": 1
          },
          "review_status": {
            "type": "string",
            "minLength": 1
          },
          "technical_outcome": {
            "enum": [
              "corrected",
              "partial",
              "unresolved"
            ]
          }
        }
      }
    },
    "successor_case_differences": {
      "type": "array",
      "maxItems": 100,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9._:-]*$"
      }
    }
  },
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    }
  }
}
