{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://uklsp.org/schemas/v0.1/provider.schema.json",
  "title": "Provider",
  "description": "A service provider (sole trader or firm) discoverable and bookable by AI agents.",
  "type": "object",
  "properties": {
    "uklsp_version": {
      "type": "string",
      "const": "0.1"
    },
    "provider_id": {
      "type": "string",
      "pattern": "^prv_[a-z0-9]{8,}$"
    },
    "legal_name": {
      "type": "string",
      "minLength": 2
    },
    "trading_name": {
      "type": "string"
    },
    "companies_house_number": {
      "type": "string",
      "pattern": "^[A-Z0-9]{8}$",
      "description": "Optional; sole traders omit."
    },
    "contact": {
      "type": "object",
      "properties": {
        "phone_e164": {
          "type": "string",
          "pattern": "^\\+44[0-9]{9,10}$"
        },
        "email": {
          "type": "string",
          "format": "email"
        },
        "booking_endpoint": {
          "type": "string",
          "format": "uri",
          "description": "UKLSP REST base URL for this provider (may be operator-hosted)."
        }
      },
      "required": [
        "phone_e164"
      ],
      "additionalProperties": false
    },
    "coverage": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "pattern": "^[A-Z]{1,2}[0-9][A-Z0-9]?$",
        "description": "UK postcode district, e.g. LS6, M14, B1."
      }
    },
    "capabilities": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "https://uklsp.org/schemas/v0.1/service-capability.schema.json"
      }
    },
    "credentials": {
      "type": "array",
      "items": {
        "$ref": "https://uklsp.org/schemas/v0.1/compliance-credential.schema.json"
      }
    },
    "review_attestations": {
      "type": "array",
      "items": {
        "$ref": "https://uklsp.org/schemas/v0.1/review-attestation.schema.json"
      }
    },
    "certification_level": {
      "type": "integer",
      "enum": [
        0,
        1,
        2,
        3
      ],
      "description": "0=uncertified 1=Discoverable 2=Quotable 3=Bookable. Asserted by certification harness only."
    },
    "operator": {
      "type": "string",
      "description": "Rails operator hosting this listing, e.g. 'Greenboard'."
    },
    "demo": {
      "type": "boolean",
      "default": false,
      "description": "True for fictional demonstration records. Agents MUST NOT book demo providers."
    }
  },
  "required": [
    "uklsp_version",
    "provider_id",
    "legal_name",
    "contact",
    "coverage",
    "capabilities"
  ],
  "additionalProperties": false
}
