{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.rootblocks.com/schemas/cache/bundle-cache-metadata.v1.schema.json",
  "title": "RootBlocks Bundle Cache Metadata v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "bundleId",
    "version",
    "bundleHash",
    "source",
    "cachedAt",
    "verifiedAt",
    "state"
  ],
  "properties": {
    "schemaVersion": {
      "const": "rootblocks.bundle-cache/v1"
    },
    "bundleId": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[A-Za-z0-9.-]+)?(\\+[A-Za-z0-9.-]+)?$"
    },
    "bundleHash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64,128}$"
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "uri"],
      "properties": {
        "kind": {
          "enum": ["rootblocks-global", "organization", "personal", "project-local"]
        },
        "uri": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "cachedAt": {
      "type": "string",
      "format": "date-time"
    },
    "verifiedAt": {
      "type": "string",
      "format": "date-time"
    },
    "lastRefreshCheckAt": {
      "type": "string",
      "format": "date-time"
    },
    "state": {
      "enum": ["current", "stale-warning", "stale-critical", "invalid", "quarantined", "refreshing"]
    },
    "offlineAllowedUntil": {
      "type": "string",
      "format": "date-time"
    }
  }
}

