{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://platoskallipolis.com/schemas/revalidation-client-bundle.v1.json",
  "title": "Plato's Kallipolis revalidation client bundle",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "bundleVersion", "state", "snapshotAt", "sources", "counts", "clients", "bundleHash", "boundaries", "privacy"],
  "properties": {
    "schema": { "const": "kallipolis.revalidation-client-bundle.v1" },
    "bundleVersion": { "const": "1.0.0" },
    "state": { "const": "verified-local-bundle-contract" },
    "snapshotAt": { "type": "string", "format": "date-time" },
    "sources": { "$ref": "#/$defs/sources" },
    "counts": { "$ref": "#/$defs/counts" },
    "clients": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/$defs/client" } },
    "bundleHash": { "$ref": "#/$defs/digest" },
    "boundaries": { "$ref": "#/$defs/boundaries" },
    "privacy": { "$ref": "#/$defs/privacy" }
  },
  "$defs": {
    "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "rawHash"],
      "properties": {
        "path": { "type": "string", "pattern": "^ops/evidence/[A-Za-z0-9._/-]+\\.json$" },
        "rawHash": { "$ref": "#/$defs/digest" },
        "clientSetHash": { "$ref": "#/$defs/digest" },
        "schema": { "type": "string" },
        "state": { "type": "string" }
      }
    },
    "sources": {
      "type": "object",
      "additionalProperties": false,
      "required": ["integrityManifest", "discoveryStateContract"],
      "properties": {
        "integrityManifest": { "$ref": "#/$defs/source" },
        "discoveryStateContract": { "$ref": "#/$defs/source" }
      }
    },
    "testEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "sha256"],
      "properties": {
        "path": { "type": "string", "pattern": "^(apps/web/tests|tests)/[A-Za-z0-9._/-]+$" },
        "sha256": { "$ref": "#/$defs/digest" }
      }
    },
    "client": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "clientPath", "publicPath", "clientSha256", "resultSchema", "catalogResourceId", "catalogSchema", "discoveryState", "discoverySurfaces", "classification", "testEvidence", "memberHash"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "clientPath": { "type": "string", "pattern": "^apps/web/public/examples/revalidation/[a-z0-9-]+\\.mjs$" },
        "publicPath": { "type": "string", "pattern": "^/examples/revalidation/[a-z0-9-]+\\.mjs$" },
        "clientSha256": { "$ref": "#/$defs/digest" },
        "resultSchema": { "type": "string", "pattern": "^kallipolis\\.[a-z0-9.-]+\\.v1$" },
        "catalogResourceId": { "type": "string", "pattern": "^resource\\.integration-candidate\\." },
        "catalogSchema": { "type": "string", "pattern": "^kallipolis\\.[a-z0-9.-]+\\.v1$" },
        "discoveryState": { "const": "catalog-llms-sitemap-local-candidate" },
        "discoverySurfaces": { "const": ["source-tree", "catalog", "llms.txt", "sitemap"] },
        "classification": { "const": "prepared-local-candidate" },
        "testEvidence": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "$ref": "#/$defs/testEvidence" } },
        "memberHash": { "$ref": "#/$defs/digest" }
      }
    },
    "counts": {
      "type": "object",
      "additionalProperties": false,
      "required": ["clients", "testEvidenceFiles", "catalogDiscoverableClients", "preparedLocalCandidates", "verifiedExternalIntegrations"],
      "properties": {
        "clients": { "const": 3 },
        "testEvidenceFiles": { "const": 6 },
        "catalogDiscoverableClients": { "const": 3 },
        "preparedLocalCandidates": { "const": 3 },
        "verifiedExternalIntegrations": { "const": 0 }
      }
    },
    "boundaries": {
      "type": "object",
      "additionalProperties": false,
      "required": ["publicDeploymentPerformed", "sitesVersion", "verifiedIntegrationExamples", "verifiedIntegrationKpiIncrease", "productionStateChanged", "organicUseClaimed", "walletWrites", "niulaiTransactions"],
      "properties": {
        "publicDeploymentPerformed": { "const": false },
        "sitesVersion": { "const": 19 },
        "verifiedIntegrationExamples": { "const": 50 },
        "verifiedIntegrationKpiIncrease": { "const": 0 },
        "productionStateChanged": { "const": false },
        "organicUseClaimed": { "const": false },
        "walletWrites": { "const": 0 },
        "niulaiTransactions": { "const": 0 }
      }
    },
    "privacy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["credentialsStored", "identityOrActivityStored", "requestOrResponseBodiesStored", "walletDataStored"],
      "properties": {
        "credentialsStored": { "const": false },
        "identityOrActivityStored": { "const": false },
        "requestOrResponseBodiesStored": { "const": false },
        "walletDataStored": { "const": false }
      }
    }
  }
}
