{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://genesiscode.dev/schemas/cargo-cache-policy-v0.1.json",
  "title": "GenesisCode Cargo Cache Policy v0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["kind", "version", "strategyVersion", "keyAlgorithm", "cacheRoot", "metadataFile", "sourceInputs", "buildEnvironment", "scopes"],
  "properties": {
    "kind": {"const": "genesis/cargo-cache-policy-v0.1"},
    "version": {"const": "0.1"},
    "strategyVersion": {"const": 1},
    "keyAlgorithm": {"const": "sha256-canonical-json"},
    "cacheRoot": {"const": ".genesis/build/cargo-cache/v1"},
    "metadataFile": {"const": ".genesis-cargo-cache-key.json"},
    "sourceInputs": {"const": "cargo-fingerprinted-not-cache-addressed"},
    "buildEnvironment": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {"type": "string", "pattern": "^[A-Z][A-Z0-9_]+$"}
    },
    "scopes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "workspace", "target", "manifestGlobs"],
        "properties": {
          "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$"},
          "workspace": {"type": "string", "pattern": "^(\\.|[A-Za-z0-9_.-]+(?:/[A-Za-z0-9_.-]+)*)$"},
          "target": {"type": "string", "pattern": "^(host|[A-Za-z0-9_.-]+)$"},
          "manifestGlobs": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {"type": "string", "pattern": "^[A-Za-z0-9_.*-]+(?:/[A-Za-z0-9_.*-]+)*$"}
          }
        }
      }
    }
  }
}
