{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/axuall/json-schema/axuall-address-deduplication-status-schema-schema.json",
  "title": "AddressDeduplicationStatusSchema",
  "description": "The state of a dispatched run, with the ranked result once it completes.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/axuall-address-deduplications-api-openapi.yml#/components/schemas/AddressDeduplicationStatusSchema",
  "properties": {
    "task_id": {
      "type": "string",
      "title": "Task Id"
    },
    "status": {
      "$ref": "#/$defs/TaskStatus"
    },
    "expires": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expires",
      "description": "Seconds until this task id is forgotten; null once it has no expiry"
    },
    "result": {
      "anyOf": [
        {
          "$ref": "#/$defs/AddressDeduplicationSchema"
        },
        {
          "type": "null"
        }
      ],
      "description": "The ranked candidates; null unless status is complete"
    }
  },
  "type": "object",
  "required": [
    "task_id",
    "status"
  ],
  "$defs": {
    "AddressDeduplicationSchema": {
      "properties": {
        "target": {
          "$ref": "#/$defs/AddressSchema-Output"
        },
        "candidates": {
          "items": {
            "$ref": "#/$defs/RankedAddressSchema"
          },
          "type": "array",
          "title": "Candidates"
        }
      },
      "type": "object",
      "required": [
        "target",
        "candidates"
      ],
      "title": "AddressDeduplicationSchema",
      "description": "Completed result: the target and its ranked candidates, in request order."
    },
    "AddressSchema-Output": {
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        },
        "line1": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Line1"
        },
        "line2": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Line2"
        },
        "city": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "City"
        },
        "state": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "State"
        },
        "postal_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Postal Code"
        },
        "country": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Country"
        }
      },
      "type": "object",
      "title": "AddressSchema",
      "description": "A loosely structured postal address. Every field is optional."
    },
    "RankedAddressSchema": {
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        },
        "line1": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Line1"
        },
        "line2": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Line2"
        },
        "city": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "City"
        },
        "state": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "State"
        },
        "postal_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Postal Code"
        },
        "country": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Country"
        },
        "id": {
          "type": "string",
          "title": "Id",
          "description": "Content hash of the candidate address"
        },
        "ranking": {
          "type": "string",
          "title": "Ranking",
          "description": "One of same_entity, same_entity_variant, same_org_different_site, different_entity"
        },
        "rationale": {
          "type": "string",
          "title": "Rationale",
          "description": "One sentence naming the fields that drove the ranking"
        }
      },
      "type": "object",
      "required": [
        "id",
        "ranking",
        "rationale"
      ],
      "title": "RankedAddressSchema",
      "description": "One candidate with the ranking the agent gave it."
    },
    "TaskStatus": {
      "type": "string",
      "enum": [
        "pending",
        "complete",
        "failed"
      ],
      "title": "TaskStatus",
      "description": "What a dispatched run is doing, derived from the Celery task state."
    }
  }
}