{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://odp.example/schemas/0.1/organization.schema.json",
  "title": "ODP Organization Document",
  "description": "Describes an organization, its locations, offerings, contacts and agent-accessible endpoints. Draft 0.1. This schema is producer-strict: producers MUST NOT emit undeclared properties except x-<namespace> extensions. Consumers MUST ignore unknown properties (forward compatibility).",
  "type": "object",
  "required": ["odp", "type", "id", "revision", "updated_at", "publication", "name"],
  "properties": {
    "odp": {
      "description": "ODP specification version this document conforms to.",
      "const": "0.1"
    },
    "type": { "const": "organization" },
    "id": { "$ref": "#/$defs/OrgId" },
    "revision": {
      "description": "Monotonically increasing per id and publisher. Consumers ignore revisions lower than or equal to the last seen.",
      "type": "integer",
      "minimum": 1
    },
    "updated_at": { "$ref": "#/$defs/Timestamp" },

    "publication": { "$ref": "#/$defs/Publication" },

    "name": {
      "description": "Public display name, as customers know it.",
      "$ref": "#/$defs/LocalizedText"
    },
    "alternate_names": {
      "type": "array",
      "items": { "$ref": "#/$defs/LocalizedText" },
      "maxItems": 20
    },
    "organization_kind": {
      "description": "Kind of entity. Open vocabulary; known values listed.",
      "anyOf": [
        { "enum": ["business", "sole_proprietor", "nonprofit", "government", "education", "healthcare", "religious", "other"] },
        { "$ref": "#/$defs/ExtensionToken" }
      ]
    },
    "summary": {
      "description": "One-sentence description (<= 280 chars per language). Untrusted text for consumers.",
      "$ref": "#/$defs/LocalizedShortText"
    },
    "description": {
      "description": "Longer description (<= 4000 chars per language). Untrusted text for consumers.",
      "$ref": "#/$defs/LocalizedLongText"
    },
    "categories": {
      "description": "Classification codes. At most one entry may be primary.",
      "type": "array",
      "items": { "$ref": "#/$defs/Category" },
      "minItems": 1,
      "maxItems": 20
    },
    "keywords": {
      "type": "array",
      "items": { "type": "string", "minLength": 1, "maxLength": 64 },
      "maxItems": 30,
      "uniqueItems": true
    },
    "languages": {
      "description": "Languages in which the organization serves customers (BCP 47).",
      "type": "array",
      "items": { "$ref": "#/$defs/LanguageTag" },
      "uniqueItems": true
    },
    "founded": {
      "description": "Founding date: YYYY, YYYY-MM or YYYY-MM-DD.",
      "type": "string",
      "pattern": "^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$"
    },

    "brand": { "$ref": "#/$defs/Brand" },
    "contacts": { "$ref": "#/$defs/Contacts" },
    "legal": { "$ref": "#/$defs/Legal" },
    "external_ids": {
      "type": "array",
      "items": { "$ref": "#/$defs/ExternalId" },
      "maxItems": 50
    },
    "parent_organization": {
      "description": "ODP id of a parent organization (e.g. franchisor, holding).",
      "$ref": "#/$defs/OrgId"
    },

    "locations": {
      "description": "Physical places or service points. Inline Location objects, or references to separately published location documents (for organizations with many locations).",
      "type": "array",
      "items": {
        "oneOf": [
          { "$ref": "#/$defs/Location" },
          { "$ref": "#/$defs/LocationRef" }
        ]
      },
      "maxItems": 500
    },
    "online_only": {
      "description": "True if customers are served only remotely (no walk-in location). The organization may still list non-public locations such as an office.",
      "type": "boolean"
    },
    "service_area": { "$ref": "#/$defs/ServiceArea" },

    "offerings": {
      "description": "Inline catalog of services/products (knowledge tier). For large catalogs use resources with rel=catalog.",
      "type": "array",
      "items": { "$ref": "#/$defs/Offering" },
      "maxItems": 500
    },
    "price_level": {
      "description": "Relative price level 1 (budget) to 4 (premium).",
      "type": "integer",
      "minimum": 1,
      "maximum": 4
    },
    "payment_methods": {
      "type": "array",
      "items": {
        "anyOf": [
          { "enum": ["cash", "card", "contactless", "bank_transfer", "invoice", "mobile_wallet", "crypto", "check"] },
          { "$ref": "#/$defs/ExtensionToken" }
        ]
      },
      "uniqueItems": true
    },
    "policies": {
      "type": "array",
      "items": { "$ref": "#/$defs/Policy" },
      "maxItems": 20
    },
    "attributes": { "$ref": "#/$defs/Attributes" },

    "media": {
      "type": "array",
      "items": { "$ref": "#/$defs/Media" },
      "maxItems": 50
    },
    "resources": {
      "description": "Links to machine- or human-readable knowledge: website pages, llms.txt, catalogs, menus, FAQs.",
      "type": "array",
      "items": { "$ref": "#/$defs/Resource" },
      "maxItems": 50
    },

    "endpoints": {
      "description": "Agent-accessible interfaces (action tier). An empty or absent list means none published, not none exist.",
      "type": "array",
      "items": { "$ref": "#/$defs/Endpoint" },
      "maxItems": 50
    },

    "attestations": {
      "description": "References to signed attestations about this organization (see attestation spec).",
      "type": "array",
      "items": { "$ref": "#/$defs/AttestationRef" },
      "maxItems": 50
    },
    "provenance": {
      "description": "Where specific fields came from. Absent means: everything is asserted by the publisher on the basis given in publication.basis.",
      "type": "array",
      "items": { "$ref": "#/$defs/ProvenanceEntry" },
      "maxItems": 200
    },
    "operating_status": { "$ref": "#/$defs/OperatingStatus" }
  },
  "patternProperties": {
    "^x-[a-z0-9][a-z0-9-]*$": {}
  },
  "additionalProperties": false,

  "$defs": {
    "Ulid": {
      "type": "string",
      "pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "OrgId": {
      "description": "Provisional ODP identifier (see ADR-0006). Opaque to consumers.",
      "type": "string",
      "pattern": "^odp:org:[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "LocId": {
      "type": "string",
      "pattern": "^odp:loc:[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "LocalRef": {
      "description": "Document-local identifier for cross-references (offerings, endpoints).",
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9_-]{0,63}$"
    },
    "ExtensionToken": {
      "description": "Namespaced extension value: x-<namespace>.<value>.",
      "type": "string",
      "pattern": "^x-[a-z0-9-]+\\.[a-z0-9_.-]+$"
    },
    "Timestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$"
    },
    "Date": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "LocalTime": {
      "description": "24h local time HH:MM. 24:00 allowed as end of day.",
      "type": "string",
      "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]|24:00)$"
    },
    "HttpsUrl": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://[^\\s]+$",
      "maxLength": 2048
    },
    "LanguageTag": {
      "description": "BCP 47 language tag, e.g. en, en-US, es-MX.",
      "type": "string",
      "pattern": "^[a-z]{2,3}(-[A-Za-z]{4})?(-([A-Z]{2}|[0-9]{3}))?$"
    },
    "CountryCode": {
      "description": "ISO 3166-1 alpha-2.",
      "type": "string",
      "pattern": "^[A-Z]{2}$"
    },
    "RegionCode": {
      "description": "ISO 3166-2 subdivision code, e.g. US-NY.",
      "type": "string",
      "pattern": "^[A-Z]{2}-[A-Z0-9]{1,3}$"
    },
    "CurrencyCode": {
      "description": "ISO 4217.",
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "Timezone": {
      "description": "IANA time zone name.",
      "type": "string",
      "pattern": "^[A-Za-z_]+(/[A-Za-z0-9_+-]+){0,2}$|^UTC$"
    },
    "PhoneE164": {
      "type": "string",
      "pattern": "^\\+[1-9][0-9]{6,14}$"
    },
    "Email": {
      "type": "string",
      "format": "email",
      "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$",
      "maxLength": 254
    },

    "LocalizedText": {
      "description": "Either a plain string (language = first of `languages`, or unspecified) or a map of BCP 47 tag -> string.",
      "oneOf": [
        { "type": "string", "minLength": 1, "maxLength": 200 },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": { "$ref": "#/$defs/LanguageTag" },
          "additionalProperties": { "type": "string", "minLength": 1, "maxLength": 200 }
        }
      ]
    },
    "LocalizedShortText": {
      "oneOf": [
        { "type": "string", "minLength": 1, "maxLength": 280 },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": { "$ref": "#/$defs/LanguageTag" },
          "additionalProperties": { "type": "string", "minLength": 1, "maxLength": 280 }
        }
      ]
    },
    "LocalizedLongText": {
      "oneOf": [
        { "type": "string", "minLength": 1, "maxLength": 4000 },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": { "$ref": "#/$defs/LanguageTag" },
          "additionalProperties": { "type": "string", "minLength": 1, "maxLength": 4000 }
        }
      ]
    },

    "Publication": {
      "description": "Who publishes this document and on what basis.",
      "type": "object",
      "required": ["publisher", "basis"],
      "properties": {
        "publisher": {
          "description": "Origin of the publisher (organization's own domain, a provider, or a registrar/hosting platform).",
          "$ref": "#/$defs/HttpsUrl"
        },
        "publisher_role": {
          "enum": ["self", "provider", "registrar"]
        },
        "basis": {
          "description": "owner_managed: content authored/approved by the organization (self or via a registrar it authorized). provider_managed: maintained by a provider serving the organization. observed: compiled from public sources without the organization's involvement.",
          "enum": ["owner_managed", "provider_managed", "observed"]
        },
        "canonical_url": {
          "description": "URL where this document is canonically served.",
          "$ref": "#/$defs/HttpsUrl"
        },
        "profile_url": {
          "description": "Human-readable public profile page, if any.",
          "$ref": "#/$defs/HttpsUrl"
        },
        "license": {
          "description": "SPDX identifier or URL for reuse terms of this document.",
          "type": "string",
          "maxLength": 200
        }
      },
      "additionalProperties": false
    },

    "Category": {
      "type": "object",
      "required": ["scheme", "code"],
      "properties": {
        "scheme": {
          "description": "Taxonomy namespace: odp (ODP vocabulary), naics, overture, schema.org, google, or x-<ns>.",
          "type": "string",
          "pattern": "^(odp|naics|overture|schema\\.org|google|isic|x-[a-z0-9-]+)$"
        },
        "code": { "type": "string", "minLength": 1, "maxLength": 100 },
        "label": { "$ref": "#/$defs/LocalizedText" },
        "primary": { "type": "boolean" }
      },
      "additionalProperties": false
    },

    "Brand": {
      "type": "object",
      "properties": {
        "name": { "$ref": "#/$defs/LocalizedText" },
        "logo": { "$ref": "#/$defs/HttpsUrl" },
        "primary_color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" },
        "slogan": { "$ref": "#/$defs/LocalizedShortText" }
      },
      "additionalProperties": false
    },

    "Contacts": {
      "type": "object",
      "properties": {
        "website": { "$ref": "#/$defs/HttpsUrl" },
        "phones": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["number"],
            "properties": {
              "number": { "$ref": "#/$defs/PhoneE164" },
              "purpose": { "enum": ["main", "booking", "orders", "support", "sales", "fax", "other"] },
              "sms": { "type": "boolean" },
              "label": { "$ref": "#/$defs/LocalizedText" }
            },
            "additionalProperties": false
          },
          "maxItems": 10
        },
        "emails": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["address"],
            "properties": {
              "address": { "$ref": "#/$defs/Email" },
              "purpose": { "enum": ["main", "booking", "orders", "support", "sales", "other"] }
            },
            "additionalProperties": false
          },
          "maxItems": 10
        },
        "messaging": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["platform", "url"],
            "properties": {
              "platform": {
                "anyOf": [
                  { "enum": ["whatsapp", "telegram", "signal", "messenger", "imessage", "wechat", "line", "viber"] },
                  { "$ref": "#/$defs/ExtensionToken" }
                ]
              },
              "url": { "$ref": "#/$defs/HttpsUrl" }
            },
            "additionalProperties": false
          },
          "maxItems": 10
        },
        "social": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["platform", "url"],
            "properties": {
              "platform": { "type": "string", "pattern": "^[a-z0-9_.-]{1,40}$" },
              "url": { "$ref": "#/$defs/HttpsUrl" }
            },
            "additionalProperties": false
          },
          "maxItems": 20
        }
      },
      "additionalProperties": false
    },

    "Legal": {
      "type": "object",
      "properties": {
        "legal_name": { "type": "string", "minLength": 1, "maxLength": 300 },
        "legal_form": {
          "description": "Free text or code, e.g. LLC, Inc., GmbH.",
          "type": "string",
          "maxLength": 100
        },
        "jurisdiction": {
          "oneOf": [ { "$ref": "#/$defs/CountryCode" }, { "$ref": "#/$defs/RegionCode" } ]
        },
        "registrations": {
          "description": "Official registration numbers (state registry, tax-exempt EIN, etc.). Must be public information.",
          "type": "array",
          "items": { "$ref": "#/$defs/ExternalId" },
          "maxItems": 20
        }
      },
      "additionalProperties": false
    },

    "ExternalId": {
      "type": "object",
      "required": ["scheme", "value"],
      "properties": {
        "scheme": {
          "description": "Identifier namespace: lei, gln, duns, npi, ein, us-state:<code>, overture:gers, osm, google:place, or a provider namespace x-<ns>.",
          "type": "string",
          "pattern": "^(lei|gln|duns|npi|ein|vat|overture:gers|osm|wikidata|google:place|apple:place|us-state:[a-z]{2}|x-[a-z0-9-]+)$"
        },
        "value": { "type": "string", "minLength": 1, "maxLength": 200 },
        "url": { "$ref": "#/$defs/HttpsUrl" }
      },
      "additionalProperties": false
    },

    "Address": {
      "type": "object",
      "required": ["country"],
      "properties": {
        "lines": {
          "type": "array",
          "items": { "type": "string", "minLength": 1, "maxLength": 200 },
          "maxItems": 3
        },
        "locality": { "type": "string", "maxLength": 100 },
        "sublocality": { "type": "string", "maxLength": 100 },
        "region": { "$ref": "#/$defs/RegionCode" },
        "postal_code": { "type": "string", "maxLength": 20 },
        "country": { "$ref": "#/$defs/CountryCode" },
        "visibility": {
          "description": "public: full address may be shown. area_only: show locality/region only (e.g. home-based sole proprietor).",
          "enum": ["public", "area_only"],
          "default": "public"
        }
      },
      "additionalProperties": false
    },

    "GeoPoint": {
      "type": "object",
      "required": ["lat", "lon"],
      "properties": {
        "lat": { "type": "number", "minimum": -90, "maximum": 90 },
        "lon": { "type": "number", "minimum": -180, "maximum": 180 },
        "precision_m": {
          "description": "Approximate radius of uncertainty in meters (use a large value for deliberately coarse points).",
          "type": "number",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },

    "ServiceArea": {
      "description": "Where the organization serves customers (for mobile/at-customer services). Any combination.",
      "type": "object",
      "minProperties": 1,
      "properties": {
        "radius": {
          "type": "object",
          "required": ["center", "meters"],
          "properties": {
            "center": { "$ref": "#/$defs/GeoPoint" },
            "meters": { "type": "number", "exclusiveMinimum": 0, "maximum": 500000 }
          },
          "additionalProperties": false
        },
        "regions": {
          "description": "Countries, ISO 3166-2 regions, or postal codes as <CC>:<postal>.",
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^([A-Z]{2}|[A-Z]{2}-[A-Z0-9]{1,3}|[A-Z]{2}:[A-Za-z0-9 -]{2,12})$"
          },
          "maxItems": 500
        },
        "geojson_url": {
          "description": "URL of a GeoJSON (Multi)Polygon for complex areas.",
          "$ref": "#/$defs/HttpsUrl"
        },
        "remote": { "description": "Serves customers remotely regardless of location.", "type": "boolean" }
      },
      "additionalProperties": false
    },

    "OpeningHours": {
      "type": "object",
      "properties": {
        "weekly": {
          "description": "Regular weekly schedule. A day with no entry is closed only if `weekly_complete` is true; otherwise unknown.",
          "type": "array",
          "items": {
            "type": "object",
            "required": ["days", "opens", "closes"],
            "properties": {
              "days": {
                "type": "array",
                "items": { "enum": ["mo", "tu", "we", "th", "fr", "sa", "su"] },
                "minItems": 1,
                "uniqueItems": true
              },
              "opens": { "$ref": "#/$defs/LocalTime" },
              "closes": {
                "description": "If closes <= opens, the interval ends the next day.",
                "$ref": "#/$defs/LocalTime"
              }
            },
            "additionalProperties": false
          },
          "maxItems": 50
        },
        "weekly_complete": {
          "description": "True if `weekly` lists all open intervals (days not listed are closed).",
          "type": "boolean"
        },
        "by_appointment_only": { "type": "boolean" },
        "always_open": { "type": "boolean" },
        "exceptions": {
          "description": "Holidays and special days, overriding weekly for the given dates.",
          "type": "array",
          "items": {
            "type": "object",
            "required": ["from"],
            "properties": {
              "from": { "$ref": "#/$defs/Date" },
              "to": { "$ref": "#/$defs/Date" },
              "closed": { "type": "boolean" },
              "intervals": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": ["opens", "closes"],
                  "properties": {
                    "opens": { "$ref": "#/$defs/LocalTime" },
                    "closes": { "$ref": "#/$defs/LocalTime" }
                  },
                  "additionalProperties": false
                }
              },
              "note": { "$ref": "#/$defs/LocalizedShortText" }
            },
            "additionalProperties": false
          },
          "maxItems": 100
        },
        "note": { "$ref": "#/$defs/LocalizedShortText" }
      },
      "additionalProperties": false
    },

    "OperatingStatus": {
      "type": "object",
      "required": ["status"],
      "properties": {
        "status": { "enum": ["operating", "temporarily_closed", "permanently_closed", "opening_soon"] },
        "since": { "$ref": "#/$defs/Date" },
        "until": { "$ref": "#/$defs/Date" },
        "note": { "$ref": "#/$defs/LocalizedShortText" }
      },
      "additionalProperties": false
    },

    "Location": {
      "type": "object",
      "required": ["id"],
      "properties": {
        "id": { "$ref": "#/$defs/LocId" },
        "ref": { "$ref": "#/$defs/LocalRef" },
        "name": { "$ref": "#/$defs/LocalizedText" },
        "kind": {
          "anyOf": [
            { "enum": ["storefront", "office", "branch", "headquarters", "warehouse", "pickup_point", "mobile_base", "home_based", "venue"] },
            { "$ref": "#/$defs/ExtensionToken" }
          ]
        },
        "address": { "$ref": "#/$defs/Address" },
        "geo": { "$ref": "#/$defs/GeoPoint" },
        "timezone": { "$ref": "#/$defs/Timezone" },
        "opening_hours": { "$ref": "#/$defs/OpeningHours" },
        "operating_status": { "$ref": "#/$defs/OperatingStatus" },
        "contacts": { "$ref": "#/$defs/Contacts" },
        "service_area": { "$ref": "#/$defs/ServiceArea" },
        "attributes": { "$ref": "#/$defs/Attributes" },
        "external_ids": {
          "type": "array",
          "items": { "$ref": "#/$defs/ExternalId" },
          "maxItems": 50
        },
        "media": {
          "type": "array",
          "items": { "$ref": "#/$defs/Media" },
          "maxItems": 50
        }
      },
      "patternProperties": { "^x-[a-z0-9][a-z0-9-]*$": {} },
      "additionalProperties": false
    },

    "LocationRef": {
      "description": "Reference to a separately published location document.",
      "type": "object",
      "required": ["id", "href"],
      "properties": {
        "id": { "$ref": "#/$defs/LocId" },
        "href": { "$ref": "#/$defs/HttpsUrl" },
        "name": { "$ref": "#/$defs/LocalizedText" }
      },
      "additionalProperties": false
    },

    "Price": {
      "type": "object",
      "required": ["currency"],
      "properties": {
        "currency": { "$ref": "#/$defs/CurrencyCode" },
        "amount": {
          "description": "Exact price as a decimal string to avoid float issues, e.g. \"30.00\".",
          "type": "string",
          "pattern": "^[0-9]+(\\.[0-9]{1,4})?$"
        },
        "min": { "type": "string", "pattern": "^[0-9]+(\\.[0-9]{1,4})?$" },
        "max": { "type": "string", "pattern": "^[0-9]+(\\.[0-9]{1,4})?$" },
        "unit": {
          "description": "What the price is per.",
          "anyOf": [
            { "enum": ["item", "session", "hour", "day", "night", "month", "person", "kg", "lb", "sqft", "sqm", "project"] },
            { "$ref": "#/$defs/ExtensionToken" }
          ]
        },
        "tax_included": { "type": "boolean" },
        "note": { "$ref": "#/$defs/LocalizedShortText" }
      },
      "anyOf": [
        { "required": ["amount"] },
        { "required": ["min"] },
        { "required": ["max"] }
      ],
      "additionalProperties": false
    },

    "Offering": {
      "type": "object",
      "required": ["ref", "kind", "name"],
      "properties": {
        "ref": { "$ref": "#/$defs/LocalRef" },
        "kind": { "enum": ["service", "product", "menu_item", "package", "subscription", "rental", "event", "class"] },
        "name": { "$ref": "#/$defs/LocalizedText" },
        "description": { "$ref": "#/$defs/LocalizedShortText" },
        "category": { "type": "string", "maxLength": 100 },
        "price": { "$ref": "#/$defs/Price" },
        "duration_minutes": { "type": "integer", "minimum": 1, "maximum": 100000 },
        "available_at": {
          "description": "Location ids where offered. Absent = all locations.",
          "type": "array",
          "items": { "$ref": "#/$defs/LocId" },
          "uniqueItems": true
        },
        "delivery_modes": {
          "type": "array",
          "items": { "enum": ["on_site", "at_customer", "remote", "pickup", "delivery", "shipping"] },
          "uniqueItems": true
        },
        "action_endpoints": {
          "description": "Endpoint refs (endpoints[].ref) through which this offering can be booked/ordered.",
          "type": "array",
          "items": { "$ref": "#/$defs/LocalRef" },
          "uniqueItems": true
        },
        "url": { "$ref": "#/$defs/HttpsUrl" },
        "image": { "$ref": "#/$defs/HttpsUrl" },
        "tags": {
          "type": "array",
          "items": { "type": "string", "maxLength": 40 },
          "maxItems": 20,
          "uniqueItems": true
        }
      },
      "patternProperties": { "^x-[a-z0-9][a-z0-9-]*$": {} },
      "additionalProperties": false
    },

    "Policy": {
      "type": "object",
      "required": ["kind"],
      "properties": {
        "kind": {
          "anyOf": [
            { "enum": ["cancellation", "refund", "returns", "deposit", "privacy", "terms", "age_restriction", "pets", "accessibility", "warranty"] },
            { "$ref": "#/$defs/ExtensionToken" }
          ]
        },
        "text": { "$ref": "#/$defs/LocalizedLongText" },
        "url": { "$ref": "#/$defs/HttpsUrl" }
      },
      "anyOf": [ { "required": ["text"] }, { "required": ["url"] } ],
      "additionalProperties": false
    },

    "Attributes": {
      "description": "Boolean/enumerated facts used for filtering. Absent = unknown; false = explicitly not.",
      "type": "object",
      "properties": {
        "wheelchair_accessible": { "type": "boolean" },
        "parking": { "enum": ["none", "street", "lot", "garage", "valet"] },
        "wifi": { "type": "boolean" },
        "walk_ins": { "type": "boolean" },
        "reservations": { "enum": ["not_accepted", "accepted", "recommended", "required"] },
        "kids_friendly": { "type": "boolean" },
        "pets_allowed": { "type": "boolean" },
        "outdoor_seating": { "type": "boolean" },
        "delivery": { "type": "boolean" },
        "takeout": { "type": "boolean" },
        "dietary_options": {
          "type": "array",
          "items": { "enum": ["vegetarian", "vegan", "gluten_free", "halal", "kosher", "dairy_free", "nut_free"] },
          "uniqueItems": true
        },
        "ownership": {
          "description": "Self-identified ownership attributes, only if the organization chooses to publish them.",
          "type": "array",
          "items": { "type": "string", "pattern": "^[a-z_]{2,40}$" },
          "uniqueItems": true
        }
      },
      "patternProperties": { "^x-[a-z0-9][a-z0-9-]*$": {} },
      "additionalProperties": false
    },

    "Media": {
      "type": "object",
      "required": ["kind", "url"],
      "properties": {
        "kind": { "enum": ["logo", "cover", "photo", "menu", "price_list", "video", "document"] },
        "url": { "$ref": "#/$defs/HttpsUrl" },
        "media_type": { "type": "string", "pattern": "^[a-z]+/[a-z0-9.+-]+$" },
        "alt": { "$ref": "#/$defs/LocalizedShortText" }
      },
      "additionalProperties": false
    },

    "Resource": {
      "type": "object",
      "required": ["rel", "href"],
      "properties": {
        "rel": {
          "anyOf": [
            { "enum": ["website", "llms_txt", "knowledge", "catalog", "menu", "faq", "booking_page", "order_page", "reviews", "schema_org"] },
            { "$ref": "#/$defs/ExtensionToken" }
          ]
        },
        "href": { "$ref": "#/$defs/HttpsUrl" },
        "media_type": { "type": "string", "pattern": "^[a-z]+/[a-z0-9.+-]+$" },
        "language": { "$ref": "#/$defs/LanguageTag" },
        "title": { "$ref": "#/$defs/LocalizedShortText" }
      },
      "additionalProperties": false
    },

    "Endpoint": {
      "type": "object",
      "required": ["ref", "protocol", "url", "capabilities"],
      "properties": {
        "ref": { "$ref": "#/$defs/LocalRef" },
        "protocol": {
          "description": "Downstream protocol. odp-request is the ODP request relay (for organizations without software; the operator relays requests to the owner and returns their answer).",
          "anyOf": [
            { "enum": ["mcp", "openapi", "a2a", "ucp", "acp", "usp", "odp-request", "web"] },
            { "$ref": "#/$defs/ExtensionToken" }
          ]
        },
        "protocol_version": { "type": "string", "maxLength": 40 },
        "url": { "$ref": "#/$defs/HttpsUrl" },
        "descriptor_url": {
          "description": "Machine-readable description (OpenAPI doc, A2A agent card, UCP profile...).",
          "$ref": "#/$defs/HttpsUrl"
        },
        "capabilities": {
          "description": "ODP capability labels (domain.action), see vocab/capabilities.json.",
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^((x-[a-z0-9-]+\\.)?[a-z][a-z0-9_]*\\.[a-z][a-z0-9_]*)$"
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "auth": {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": { "enum": ["none", "api_key", "oauth2", "openid_connect", "mtls", "x-other"] },
            "metadata_url": {
              "description": "OAuth authorization server metadata or OIDC discovery URL.",
              "$ref": "#/$defs/HttpsUrl"
            },
            "scopes": {
              "type": "array",
              "items": { "type": "string", "maxLength": 100 },
              "uniqueItems": true
            }
          },
          "additionalProperties": false
        },
        "operator": {
          "description": "Origin of whoever runs this endpoint. If it differs from publication.publisher, an endpoint-operation attestation from the operator is required for the endpoint to be verified.",
          "$ref": "#/$defs/HttpsUrl"
        },
        "locations": {
          "description": "Location ids this endpoint serves. Absent = all.",
          "type": "array",
          "items": { "$ref": "#/$defs/LocId" },
          "uniqueItems": true
        },
        "response_time": {
          "description": "Expected response latency, important for odp-request (human in the loop).",
          "enum": ["realtime", "minutes", "hours", "next_business_day"]
        },
        "environment": { "enum": ["production", "sandbox"], "default": "production" }
      },
      "patternProperties": { "^x-[a-z0-9][a-z0-9-]*$": {} },
      "additionalProperties": false
    },

    "AttestationRef": {
      "type": "object",
      "required": ["type", "href"],
      "properties": {
        "type": {
          "anyOf": [
            { "enum": ["provider-customer", "endpoint-operation", "domain-control", "owner-claim", "legal-entity", "transfer"] },
            { "$ref": "#/$defs/ExtensionToken" }
          ]
        },
        "href": { "$ref": "#/$defs/HttpsUrl" },
        "issuer": { "$ref": "#/$defs/HttpsUrl" }
      },
      "additionalProperties": false
    },

    "ProvenanceEntry": {
      "type": "object",
      "required": ["fields", "source"],
      "properties": {
        "fields": {
          "description": "JSON Pointers (RFC 6901) to the fields this entry covers.",
          "type": "array",
          "items": { "type": "string", "pattern": "^(/[^/]*)*$" },
          "minItems": 1
        },
        "source": {
          "enum": ["owner", "provider", "registrar_review", "public_record", "open_data", "crawl", "ai_extraction"]
        },
        "source_ref": {
          "description": "Dataset/release or URL the value came from.",
          "type": "string",
          "maxLength": 500
        },
        "observed_at": { "$ref": "#/$defs/Timestamp" },
        "confirmed_by_owner_at": { "$ref": "#/$defs/Timestamp" },
        "license": { "type": "string", "maxLength": 200 }
      },
      "additionalProperties": false
    }
  }
}
