{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nashboard-ai/json-schema/nashboard-ai-enrich-response-schema.json",
  "title": "EnrichResponse",
  "description": "W5a flat EnrichResponse. additionalProperties:true — fields such as merchant{}, hierarchy, bin_signal, debug fields (rank_gap, nb_extensions) are present but not fully closed in this schema.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nashboard-ai-openapi.json#/components/schemas/EnrichResponse",
  "type": "object",
  "required": [
    "request_id",
    "match_score",
    "match_method",
    "ai_generated",
    "counterparties",
    "is_recurring",
    "homoglyph_detected",
    "ai_confidence",
    "latency_ms"
  ],
  "properties": {
    "request_id": {
      "type": "string",
      "format": "uuid"
    },
    "merchant_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Matched merchant ID, or null on no-match."
    },
    "merchant": {
      "type": [
        "object",
        "null"
      ],
      "description": "Resolved merchant object (null on no-match). Carries additional hierarchy/standards fields not all enumerated here.",
      "properties": {
        "name": {
          "type": "string"
        },
        "name_localized": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": {
            "type": "string"
          },
          "description": "Localized display names keyed by locale (e.g. en, ar, ru)."
        },
        "logo_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "confidence_tier": {
          "type": "integer"
        }
      },
      "additionalProperties": true
    },
    "match_score": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Customer-facing retrieval confidence 0-1. Distinct from ai_confidence."
    },
    "match_method": {
      "type": "string",
      "description": "How the match was determined (e.g. exact, fuzzy, ai_haiku, ai_sonnet, no_match)."
    },
    "ai_generated": {
      "type": "boolean",
      "description": "True only when the AI disambiguation step produced/altered the returned match (EU AI Act Art. 50)."
    },
    "ai_confidence": {
      "type": [
        "number",
        "null"
      ],
      "description": "AI self-reported confidence 0-1 when AI fired; null otherwise."
    },
    "counterparties": {
      "type": "array",
      "description": "Rail-aware counterparty provenance (e.g. BNPL chains).",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "is_recurring": {
      "type": "boolean",
      "description": "True when the merchant has a known subscription pattern."
    },
    "recurrence": {
      "type": [
        "object",
        "null"
      ],
      "description": "Recurrence cadence details; null when is_recurring is false.",
      "additionalProperties": true
    },
    "homoglyph_detected": {
      "type": "boolean",
      "description": "Fraud signal: true when the descriptor mixes lookalike scripts (e.g. Cyrillic+Latin)."
    },
    "latency_ms": {
      "type": "integer",
      "description": "Server-side pipeline latency in ms."
    },
    "cache_hit": {
      "type": "boolean"
    },
    "category": {
      "type": "object",
      "description": "Taxonomy classification result.",
      "additionalProperties": true
    },
    "hierarchy": {
      "type": [
        "object",
        "null"
      ],
      "description": "Brand → operator → location hierarchy.",
      "additionalProperties": true
    },
    "alternates": {
      "type": "array",
      "description": "Top-N alternate merchant candidates.",
      "items": {
        "type": "object",
        "properties": {
          "merchant_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "confidence": {
            "type": "number"
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true
}