{
  "$defs": {
    "ScorecardItem": {
      "examples": [
        {
          "code": "RHAT_OK",
          "message_plain": "All chains got the same answer.",
          "metric": "r_hat_max",
          "status": "pass",
          "threshold": 1.01,
          "title": "Chains agree",
          "value": 1.004
        },
        {
          "category": "holdout",
          "check": "holdout.mape",
          "code": "HOLDOUT_MAPE",
          "docs_anchor": "check-holdout-mape",
          "message_plain": "The forecast error on the holdout periods was 14%.",
          "metric": "mape",
          "status": "warn",
          "suggested_action": "Look for gaps or one-time events in the last weeks of data.",
          "threshold": 0.1,
          "title": "Holdout error",
          "value": 0.14
        }
      ],
      "properties": {
        "category": {
          "anyOf": [
            {
              "enum": [
                "convergence",
                "holdout",
                "plausibility",
                "data"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "M3: the check's category",
          "title": "Category"
        },
        "check": {
          "anyOf": [
            {
              "pattern": "^[a-z]+\\.[a-z0-9_]{1,63}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "M3: the stable check id (SCORECARD_CHECKS), e.g. holdout.mape",
          "title": "Check"
        },
        "code": {
          "pattern": "^[A-Z][A-Z0-9_]{1,63}$",
          "title": "Code",
          "type": "string"
        },
        "docs_anchor": {
          "anyOf": [
            {
              "pattern": "^[a-z0-9][a-z0-9-]{0,99}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "M3: anchor on the scorecard docs page that explains the check",
          "title": "Docs Anchor"
        },
        "message_expert": {
          "anyOf": [
            {
              "maxLength": 2000,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Message Expert"
        },
        "message_plain": {
          "maxLength": 2000,
          "title": "Message Plain",
          "type": "string"
        },
        "metric": {
          "anyOf": [
            {
              "pattern": "^[a-z][a-z0-9_]{0,63}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Metric"
        },
        "status": {
          "enum": [
            "pass",
            "warn",
            "fail"
          ],
          "title": "Status",
          "type": "string"
        },
        "suggested_action": {
          "anyOf": [
            {
              "maxLength": 2000,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Suggested Action"
        },
        "threshold": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Threshold"
        },
        "title": {
          "maxLength": 200,
          "title": "Title",
          "type": "string"
        },
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Value"
        }
      },
      "required": [
        "code",
        "status",
        "title",
        "message_plain"
      ],
      "title": "ScorecardItem",
      "type": "object"
    }
  },
  "$id": "https://schemas.mapi.dev/v1/api-Scorecard.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Sanity scorecard: convergence, holdout error and plausibility checks rolled up.",
  "examples": [
    {
      "items": [
        {
          "code": "RHAT_OK",
          "message_plain": "All chains got the same answer.",
          "metric": "r_hat_max",
          "status": "pass",
          "threshold": 1.01,
          "title": "Chains agree",
          "value": 1.004
        },
        {
          "code": "HOLDOUT_MAPE",
          "message_plain": "The forecast error on the last 8 weeks was 14%.",
          "metric": "mape",
          "status": "warn",
          "suggested_action": "Add holidays, or look at the data for the last weeks.",
          "threshold": 0.1,
          "title": "Holdout error",
          "value": 0.14
        }
      ],
      "overall": "warn"
    }
  ],
  "properties": {
    "items": {
      "items": {
        "$ref": "#/$defs/ScorecardItem"
      },
      "title": "Items",
      "type": "array"
    },
    "overall": {
      "enum": [
        "pass",
        "warn",
        "fail"
      ],
      "title": "Overall",
      "type": "string"
    },
    "skipped": {
      "additionalProperties": {
        "type": "string"
      },
      "description": "M3: checks that could not run, with the reason (check id -> text)",
      "maxProperties": 64,
      "title": "Skipped",
      "type": "object"
    }
  },
  "required": [
    "overall"
  ],
  "title": "Scorecard",
  "type": "object",
  "x-mapi-contract-version": "0.2"
}
