{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "schema/provider.schema.json",
  "title": "Provider page YAML header",
  "description": "One provider page per broker or service. Every value is either backed by sources listed in field_sources or is the literal string \"unknown\".",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "type",
    "id",
    "title",
    "summary",
    "provider",
    "page_status",
    "last_verified",
    "status",
    "can_place_orders",
    "approval_model",
    "assets",
    "order_types",
    "auth",
    "endpoint",
    "transport",
    "reads_portfolio",
    "paper_trading",
    "limits",
    "notifications",
    "field_sources"
  ],
  "$defs": {
    "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "source_id": {
      "type": "string",
      "pattern": "^[a-z]{2}-\\d{2}$"
    },
    "unknown": {
      "const": "unknown"
    },
    "text_or_unknown": {
      "type": "string",
      "minLength": 1
    },
    "list_or_unknown": {
      "oneOf": [
        {
          "$ref": "#/$defs/unknown"
        },
        {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      ]
    },
    "yes_no_unknown": {
      "enum": [
        "yes",
        "no",
        "unknown"
      ]
    },
    "ids": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/source_id"
      }
    }
  },
  "properties": {
    "type": {
      "const": "provider"
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$",
      "description": "Matches the file name: providers/<id>.md"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "summary": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300
    },
    "provider": {
      "type": "string",
      "minLength": 1
    },
    "page_status": {
      "enum": [
        "current",
        "stale",
        "archived"
      ]
    },
    "last_verified": {
      "$ref": "#/$defs/date"
    },
    "status": {
      "enum": [
        "official-mcp",
        "official-other",
        "community",
        "none",
        "blocked",
        "unknown"
      ],
      "description": "Best documented form of agent access."
    },
    "can_place_orders": {
      "oneOf": [
        {
          "$ref": "#/$defs/unknown"
        },
        {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "yes",
              "draft-only",
              "confirm-in-app",
              "no"
            ]
          }
        }
      ],
      "description": "One entry per documented access path, default or hosted path first."
    },
    "approval_model": {
      "oneOf": [
        {
          "$ref": "#/$defs/unknown"
        },
        {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "separate-account",
              "ai-partition",
              "per-order-confirm",
              "draft-then-submit",
              "none"
            ]
          }
        }
      ],
      "description": "See approval-models/. One entry per documented access path."
    },
    "assets": {
      "$ref": "#/$defs/list_or_unknown"
    },
    "order_types": {
      "$ref": "#/$defs/list_or_unknown"
    },
    "auth": {
      "$ref": "#/$defs/text_or_unknown"
    },
    "endpoint": {
      "oneOf": [
        {
          "$ref": "#/$defs/unknown"
        },
        {
          "type": "null",
          "description": "No provider-hosted endpoint (self-hosted only)."
        },
        {
          "type": "string",
          "pattern": "^https://[^\\s]+$"
        }
      ]
    },
    "endpoint_note": {
      "type": "string"
    },
    "transport": {
      "oneOf": [
        {
          "$ref": "#/$defs/unknown"
        },
        {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "remote-http",
              "local-stdio",
              "cli"
            ]
          }
        }
      ]
    },
    "reads_portfolio": {
      "$ref": "#/$defs/yes_no_unknown"
    },
    "paper_trading": {
      "$ref": "#/$defs/yes_no_unknown"
    },
    "limits": {
      "$ref": "#/$defs/text_or_unknown"
    },
    "notifications": {
      "$ref": "#/$defs/text_or_unknown"
    },
    "notes": {
      "type": "string"
    },
    "field_sources": {
      "type": "object",
      "description": "Source card ids (sources/<id>.md) backing each non-unknown field.",
      "additionalProperties": false,
      "properties": {
        "status": {
          "$ref": "#/$defs/ids"
        },
        "can_place_orders": {
          "$ref": "#/$defs/ids"
        },
        "approval_model": {
          "$ref": "#/$defs/ids"
        },
        "assets": {
          "$ref": "#/$defs/ids"
        },
        "order_types": {
          "$ref": "#/$defs/ids"
        },
        "auth": {
          "$ref": "#/$defs/ids"
        },
        "endpoint": {
          "$ref": "#/$defs/ids"
        },
        "transport": {
          "$ref": "#/$defs/ids"
        },
        "reads_portfolio": {
          "$ref": "#/$defs/ids"
        },
        "paper_trading": {
          "$ref": "#/$defs/ids"
        },
        "limits": {
          "$ref": "#/$defs/ids"
        },
        "notifications": {
          "$ref": "#/$defs/ids"
        }
      }
    }
  }
}
