{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://raw.githubusercontent.com/hegemonart/get-design-done/main/reference/schemas/rate-limits.schema.json",
  "title": "RateLimits",
  "description": "Shape of .design/rate-limits/<provider>.json produced by scripts/lib/rate-guard.cjs. One file per provider (anthropic, openai, figma, ...) — header ingestion overwrites atomically via tmp+rename under scripts/lib/lockfile.cjs protection. See .planning/phases/20-gdd-sdk-foundation/20-14-PLAN.md §Task 2.",
  "type": "object",
  "additionalProperties": false,
  "required": ["provider", "remaining", "resetAt", "updatedAt"],
  "properties": {
    "provider": {
      "type": "string",
      "minLength": 1,
      "description": "Provider identifier (e.g. 'anthropic', 'openai', 'figma'). Matches the state file basename."
    },
    "remaining": {
      "type": "integer",
      "minimum": 0,
      "description": "Number of API calls the provider says are still allowed before the next reset. When ingestion sees both requests-remaining and tokens-remaining, the lower value wins (most-restrictive)."
    },
    "resetAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO-8601 timestamp when the rate-limit window resets. Synthesized from whichever header is present: retry-after (seconds or HTTP date), x-ratelimit-reset-requests / -tokens (Unix seconds), anthropic-ratelimit-requests-reset (ISO string). When multiple candidates are present, the latest resetAt wins."
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO-8601 timestamp when this state file was last written (ingestHeaders call time)."
    }
  }
}
