{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://iarpg.com/saved-work-backup.schema.json",
  "title": "IARPG Browser-local Saved Work Backup",
  "description": "Indexed browser-local saved-work backup with per-record checksums, duplicate groups, quarantine, and explicit local-only privacy boundary.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "backup_id",
    "release",
    "version",
    "exported_utc",
    "manifest",
    "records",
    "quarantine",
    "privacy_notice"
  ],
  "properties": {
    "backup_id": {
      "type": "string",
      "minLength": 1
    },
    "release": {
      "const": "IARPG-OPS-2"
    },
    "version": {
      "const": "2.0.4-wip"
    },
    "exported_utc": {
      "type": "string",
      "format": "date-time"
    },
    "manifest": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "record_count",
        "quarantine_count",
        "records",
        "record_checksums",
        "duplicate_groups",
        "manifest_checksum"
      ],
      "properties": {
        "record_count": {
          "type": "integer",
          "minimum": 0
        },
        "quarantine_count": {
          "type": "integer",
          "minimum": 0
        },
        "records": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "type",
              "name",
              "modified_utc",
              "checksum",
              "bytes"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "modified_utc": {
                "type": "string",
                "format": "date-time"
              },
              "checksum": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "bytes": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        },
        "record_checksums": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "duplicate_groups": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "kind"
            ],
            "additionalProperties": true
          }
        },
        "manifest_checksum": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      }
    },
    "records": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "quarantine": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "privacy_notice": {
      "type": "string",
      "minLength": 1
    }
  }
}
