{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arcnm-io/json-schema/arcnm-io-calibration-import-status-public-schema.json",
  "title": "CalibrationImportStatusPublic",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/arcnm-io-calibration-api-openapi.yml#/components/schemas/CalibrationImportStatusPublic",
  "properties": {
    "import_id": {
      "type": "string",
      "title": "Import Id"
    },
    "env_id": {
      "type": "string",
      "title": "Env Id"
    },
    "status": {
      "type": "string",
      "title": "Status"
    },
    "settled": {
      "type": "boolean",
      "title": "Settled",
      "description": "True when no calculation this import started is still running. Not a readiness signal on its own: rows that still need a calculation are unpriced, not settled-and-usable. Read ready_to_calibrate."
    },
    "ready_to_calibrate": {
      "type": "boolean",
      "title": "Ready To Calibrate",
      "description": "True when the import can be calibrated with every row it could use: at least one row is priced and none is still waiting for a calculation (needs_calc, cache_hit) or running.",
      "default": false
    },
    "pending_calculations": {
      "type": "integer",
      "title": "Pending Calculations",
      "description": "Rows whose calculation is still queued or running."
    },
    "calculations_required": {
      "type": "integer",
      "title": "Calculations Required",
      "description": "Billable pairs disclosed at preflight."
    },
    "calculations_run": {
      "type": "integer",
      "title": "Calculations Run",
      "description": "Calculations actually created by the price commits."
    },
    "state_counts": {
      "additionalProperties": {
        "type": "integer"
      },
      "type": "object",
      "title": "State Counts",
      "description": "Row count per disposition state."
    },
    "rows": {
      "items": {
        "$ref": "#/$defs/CalibrationImportRowPublic"
      },
      "type": "array",
      "title": "Rows"
    },
    "rows_truncated": {
      "type": "boolean",
      "title": "Rows Truncated",
      "description": "True when more than 1000 rows exist; counts are never truncated.",
      "default": false
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error",
      "description": "Import-level failure, when one happened."
    }
  },
  "type": "object",
  "required": [
    "import_id",
    "env_id",
    "status",
    "settled",
    "pending_calculations",
    "calculations_required",
    "calculations_run",
    "state_counts"
  ],
  "$defs": {
    "CalibrationImportRowPublic": {
      "properties": {
        "row_ordinal": {
          "type": "integer",
          "title": "Row Ordinal",
          "description": "1-based position in the submitted rows."
        },
        "part_number": {
          "type": "string",
          "title": "Part Number"
        },
        "lot_size": {
          "type": "integer",
          "title": "Lot Size"
        },
        "annual_volume": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Annual Volume"
        },
        "actual_unit_cost": {
          "type": "number",
          "title": "Actual Unit Cost",
          "description": "The actual you supplied."
        },
        "state": {
          "type": "string",
          "title": "State",
          "description": "Row disposition (see the import guide)."
        },
        "detail": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Detail",
          "description": "Why, for states that need explaining."
        },
        "calculation_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Calculation Id",
          "description": "The calculation this row is paired with."
        }
      },
      "type": "object",
      "required": [
        "row_ordinal",
        "part_number",
        "lot_size",
        "actual_unit_cost",
        "state"
      ],
      "title": "CalibrationImportRowPublic"
    }
  }
}