{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/thinair-co/json-schema/thinair-co-intersection-resolve-response-schema.json",
  "title": "IntersectionResolveResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/thinair-co-intersections-api-openapi.yml#/components/schemas/IntersectionResolveResponse",
  "type": "object",
  "properties": {
    "feature": {
      "$ref": "#/$defs/IntersectionResolvedFeature"
    },
    "confidence": {
      "type": "number",
      "description": "Resolved feature's confidence (0–1); 0 when unresolved."
    },
    "fallback_used": {
      "type": "boolean",
      "description": "True when the geocoder fallback produced the answer (CSV missed or was below threshold)."
    },
    "admin": {
      "type": "object",
      "properties": {
        "locality": {
          "type": "string"
        },
        "region": {
          "type": "string"
        },
        "country": {
          "type": "string"
        }
      },
      "description": "Admin context echoed back."
    },
    "meta": {
      "type": "object",
      "properties": {
        "upstream_ms": {
          "type": "number"
        },
        "method": {
          "type": "string"
        },
        "query": {
          "type": "string"
        }
      },
      "required": [
        "upstream_ms",
        "method",
        "query"
      ],
      "description": "Resolution metadata; `method` is the rung that resolved (csv_intersection | intersection | none)."
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Advisory strings — present on a miss (coverage hint) or geocoder suppress signals."
    },
    "upstream_error": {
      "type": [
        "string",
        "null"
      ]
    },
    "precision": {
      "allOf": [
        {
          "$ref": "#/$defs/PrecisionBlock"
        },
        {
          "description": "Learning-overlay precision adjudication. Present only when the flag-gated overlay applied to this resolution. Omitted otherwise — legacy consumers see no shape change."
        }
      ]
    }
  },
  "required": [
    "feature",
    "confidence",
    "fallback_used",
    "admin",
    "meta"
  ],
  "$defs": {
    "IntersectionResolvedFeature": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "Stable public ThinAir id (`ta_intersection_<key>` when the resolved doc carries the derivation inputs, else `ta_place_<key>`). Resolvable via `GET /v1/place`."
        },
        "name": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "confidence": {
          "type": "number"
        },
        "layer": {
          "type": "string"
        },
        "intersection_type": {
          "type": "string",
          "enum": [
            "corner",
            "interchange"
          ]
        },
        "intersection_precision": {
          "type": "string",
          "enum": [
            "geometric_crossing",
            "tangent_intersection",
            "centroid_cluster",
            "approximate"
          ]
        },
        "street_kind": {
          "type": "string",
          "enum": [
            "street",
            "route"
          ]
        },
        "cross_street_kind": {
          "type": "string",
          "enum": [
            "street",
            "route"
          ]
        },
        "street_route": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "cross_street_route": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "place_type": {
          "type": "string"
        },
        "method": {
          "type": "string"
        },
        "lat": {
          "type": "number"
        },
        "lon": {
          "type": "number"
        }
      },
      "required": [
        "place_type",
        "method",
        "lat",
        "lon"
      ],
      "description": "Best resolved intersection feature, or null when nothing resolved."
    },
    "PrecisionBlock": {
      "type": "object",
      "properties": {
        "class": {
          "type": "string"
        },
        "risk_flags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "required_context": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "learning_overlay": {
          "type": "object",
          "properties": {
            "applied": {
              "type": "boolean"
            },
            "rule_ids": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "actions": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "required": [
            "applied"
          ]
        }
      },
      "required": [
        "class",
        "risk_flags",
        "required_context",
        "learning_overlay"
      ],
      "description": "Learning-overlay precision adjudication. Present only when the overlay evaluated this query (intersection-class). Omitted otherwise — legacy consumers see no shape change."
    }
  }
}