{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getzero.dev/contracts/zero.developer_proof_api.v1.schema.json",
  "title": "ZERO Developer Proof API Contract",
  "description": "Machine-readable launch contract for public read-only proof and replay integration.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "schema",
    "kind",
    "canonical_url",
    "contract_url",
    "changelog_url",
    "example_url",
    "discovery_url",
    "published_at",
    "versioning",
    "auth",
    "rate_limits",
    "safety",
    "endpoints",
    "fixtures",
    "integration_flow"
  ],
  "properties": {
    "schema_version": { "const": "zero.developer_proof_api.v1" },
    "schema": { "const": "https://getzero.dev/contracts/zero.developer_proof_api.v1.schema.json" },
    "kind": { "const": "developer_proof_api" },
    "canonical_url": { "const": "https://getzero.dev/developers" },
    "contract_url": { "const": "https://getzero.dev/api/developers/proof" },
    "changelog_url": { "const": "https://getzero.dev/contracts/zero.developer_proof_api.changelog.v1.json" },
    "example_url": { "const": "https://getzero.dev/examples/developer-proof-api/fetch-public-replay.mjs" },
    "discovery_url": { "const": "https://getzero.dev/.well-known/zero.json" },
    "published_at": { "type": "string", "format": "date-time" },
    "versioning": { "$ref": "#/$defs/versioning" },
    "auth": {
      "type": "object",
      "additionalProperties": false,
      "required": ["public_reads", "api_keys", "operator_mcp"],
      "properties": {
        "public_reads": { "const": "none" },
        "api_keys": { "const": "not_required_for_public_proof_reads" },
        "operator_mcp": { "const": "scoped_bearer_required" }
      }
    },
    "rate_limits": {
      "type": "object",
      "additionalProperties": false,
      "required": ["global_public_read"],
      "properties": {
        "global_public_read": {
          "type": "object",
          "additionalProperties": false,
          "required": ["requests", "window_seconds", "scope", "enforcement"],
          "properties": {
            "requests": { "const": 100 },
            "window_seconds": { "const": 60 },
            "scope": { "const": "ip" },
            "enforcement": { "const": "upstash_redis_when_configured_with_per_instance_fallback" }
          }
        }
      }
    },
    "safety": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "read_only",
        "paper_first",
        "can_execute_orders",
        "can_mutate_runtime",
        "can_read_private_keys",
        "can_custody_assets"
      ],
      "properties": {
        "read_only": { "const": true },
        "paper_first": { "const": true },
        "can_execute_orders": { "const": false },
        "can_mutate_runtime": { "const": false },
        "can_read_private_keys": { "const": false },
        "can_custody_assets": { "const": false }
      }
    },
    "endpoints": {
      "type": "array",
      "minItems": 8,
      "items": { "$ref": "#/$defs/endpoint" }
    },
    "fixtures": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/fixture" }
    },
    "integration_flow": {
      "type": "array",
      "minItems": 4,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["step", "action", "endpoint", "validates"],
        "properties": {
          "step": { "type": "integer", "minimum": 1 },
          "action": { "type": "string", "minLength": 12 },
          "endpoint": { "type": "string", "minLength": 3 },
          "validates": { "type": "string", "minLength": 10 }
        }
      }
    }
  },
  "$defs": {
    "versioning": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "current_version",
        "major_version",
        "stability",
        "version_negotiation",
        "compatibility_policy",
        "breaking_change_policy",
        "deprecation_notice_days",
        "safe_additions",
        "breaking_changes",
        "required_validation"
      ],
      "properties": {
        "current_version": { "const": "zero.developer_proof_api.v1" },
        "major_version": { "const": 1 },
        "stability": { "const": "public_beta" },
        "version_negotiation": { "const": "schema_version_field" },
        "compatibility_policy": { "const": "v1_additive_only" },
        "breaking_change_policy": { "const": "new_schema_version_required" },
        "deprecation_notice_days": { "type": "integer", "minimum": 30 },
        "safe_additions": {
          "type": "array",
          "minItems": 3,
          "items": { "type": "string", "minLength": 6 }
        },
        "breaking_changes": {
          "type": "array",
          "minItems": 3,
          "items": { "type": "string", "minLength": 6 }
        },
        "required_validation": {
          "type": "array",
          "minItems": 3,
          "items": { "type": "string", "minLength": 6 }
        }
      }
    },
    "fixture": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "url", "command", "validates"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9_]+$" },
        "url": { "type": "string", "format": "uri" },
        "command": { "type": "string", "minLength": 20 },
        "validates": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string", "minLength": 6 }
        }
      }
    },
    "endpoint": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "method",
        "path",
        "url",
        "auth",
        "purpose",
        "response_schema",
        "schema_url",
        "rate_limit_bucket",
        "cache",
        "can_execute_orders",
        "can_mutate_runtime"
      ],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9_]+$" },
        "method": { "const": "GET" },
        "path": { "type": "string", "pattern": "^/" },
        "url": { "type": "string", "format": "uri" },
        "auth": { "const": "none" },
        "purpose": { "type": "string", "minLength": 20 },
        "response_schema": { "type": "string", "minLength": 6 },
        "schema_url": {
          "anyOf": [
            { "type": "string", "format": "uri" },
            { "type": "null" }
          ]
        },
        "rate_limit_bucket": { "const": "global_public_read" },
        "cache": { "type": "string", "minLength": 4 },
        "can_execute_orders": { "const": false },
        "can_mutate_runtime": { "const": false }
      }
    }
  }
}
