{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arcnm-io/json-schema/arcnm-io-calibration-result-schema.json",
  "title": "CalibrationResult",
  "description": "Result of a calibration *write* run (ingest, finalize, teach,\nauto-calibrate, ERP auto-calibrate, learning-curve fit, interval\nrecalibrate, policy calibrate).\n\nA single closed envelope shared by every write route: each route\npopulates the subset relevant to it, and ``extra=\"ignore\"`` drops any\nundeclared handler key by design (fail SAFE — adding a key means adding\na field here first). Nested payloads (``fit``, ``fitted_policy``) are\npassed through as open objects rather than re-validated so their numeric\ninternals are never coerced or dropped.",
  "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/CalibrationResult",
  "properties": {
    "run_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Run Id",
      "description": "Identifier of the calibration run, when one was created."
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Id",
      "description": "Identifier of the resulting record, when applicable."
    },
    "status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Status",
      "description": "Outcome status of the calibration run."
    },
    "scope": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Scope",
      "description": "Scope the run applied to: 'platform' or 'environment'."
    },
    "ingested": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ingested",
      "description": "Number of observations persisted by an ingest call."
    },
    "samples": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Samples",
      "description": "Number of samples considered by the run."
    },
    "samples_applied": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Samples Applied",
      "description": "Number of samples actually applied to the fit."
    },
    "unmatched_part_ids": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Unmatched Part Ids",
      "description": "Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped."
    },
    "history_received": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "History Received",
      "description": "Historical choice records supplied in the request."
    },
    "history_used": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "History Used",
      "description": "Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``."
    },
    "history_rejected": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "History Rejected",
      "description": "Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated."
    },
    "message": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Message",
      "description": "Human-readable note about the run, when present."
    },
    "env_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Env Id",
      "description": "Identifier of the calibrated environment."
    },
    "matched": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Matched",
      "description": "Number of supplied rows matched to an existing quote."
    },
    "n_train": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "N Train",
      "description": "Number of rows used to fit the calibration."
    },
    "n_holdout": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "N Holdout",
      "description": "Number of rows held out to size the prediction interval."
    },
    "holdout_mape": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Holdout Mape",
      "description": "Mean absolute percentage error of the PRE-calibration predictions on the held-out rows — the miss this run set out to close, not the outcome. Read mape_after for the result."
    },
    "mape_before": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Mape Before",
      "description": "Holdout MAPE before the fit (same figure as holdout_mape, named for the before/after pair)."
    },
    "mape_after": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Mape After",
      "description": "Holdout MAPE AFTER the fit — the held-out rows re-priced under the calibrated result. The run's headline outcome; null when no rows were held out."
    },
    "holdout_coverage": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Holdout Coverage",
      "description": "Fraction (0–1) of held-out actuals falling inside the interval."
    },
    "fit": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Fit",
      "description": "Structured object with the fitted parameters and fit diagnostics."
    },
    "n_observations": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "N Observations",
      "description": "Number of observations the calibration fit used."
    },
    "work_orders_received": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Work Orders Received",
      "description": "Number of ERP work-order rows received."
    },
    "work_orders_resolved": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Work Orders Resolved",
      "description": "Number of work orders resolved to a known part revision."
    },
    "unknown_part_numbers": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Unknown Part Numbers",
      "description": "Part numbers that could not be resolved to a known part."
    },
    "target_metric": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Target Metric",
      "description": "Metric the calibration targeted (e.g. 'unit_cost')."
    },
    "part_revision_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Part Revision Id",
      "description": "Identifier of the part revision that was fit."
    },
    "model": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Model",
      "description": "Learning-curve model that was fit (crawford_unit or wright_cumulative)."
    },
    "a": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "A",
      "description": "Fitted first-unit cost coefficient of the curve."
    },
    "b": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "B",
      "description": "Fitted log-log slope exponent of the learning curve."
    },
    "learning_rate": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Learning Rate",
      "description": "Learning rate (0–1): cost retained each time output doubles."
    },
    "r_squared": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "R Squared",
      "description": "Coefficient of determination (0–1) of the curve fit."
    },
    "residual_sigma_log": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Residual Sigma Log",
      "description": "Standard deviation of the fit residuals in log space."
    },
    "n_lots": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "N Lots",
      "description": "Number of production lots used in the curve fit."
    },
    "n_iterations": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "N Iterations",
      "description": "Iterations the midpoint solver ran before converging."
    },
    "policy_history_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Policy History Id",
      "description": "Identifier of the newly written selection-policy row."
    },
    "seed_accuracy": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Seed Accuracy",
      "description": "Accuracy (0–1) of the seed policy before calibration."
    },
    "fitted_accuracy": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Fitted Accuracy",
      "description": "Accuracy (0–1) of the fitted policy on the training rows."
    },
    "holdout_accuracy": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Holdout Accuracy",
      "description": "Accuracy (0–1) of the fitted policy on held-out rows."
    },
    "grid_size": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Grid Size",
      "description": "Number of policy candidates evaluated during the fit."
    },
    "fitted_policy": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Fitted Policy",
      "description": "Structured object describing the fitted selection policy."
    }
  },
  "type": "object"
}