{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/decide-fyi/json-schema/decide-fyi-policy-anomaly-report-schema.json",
  "title": "PolicyAnomalyReport",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/decide-fyi-openapi.json#/components/schemas/PolicyAnomalyReport",
  "type": "object",
  "required": [
    "ok",
    "decision_anomaly_report_version",
    "policy_id",
    "decisions_analyzed",
    "summary",
    "baseline",
    "anomalies",
    "anomaly_hash",
    "recommendation"
  ],
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "decision_anomaly_report_version": {
      "type": "string",
      "const": "decision_anomaly_report_v1"
    },
    "generated_at": {
      "type": "string"
    },
    "policy_id": {
      "type": "string"
    },
    "policy_version": {
      "type": [
        "string",
        "null"
      ]
    },
    "source": {
      "type": "string",
      "const": "decision_outcomes"
    },
    "minimum_sample_size": {
      "type": "integer"
    },
    "anomaly_threshold": {
      "type": "number"
    },
    "max_anomalies_returned": {
      "type": "integer"
    },
    "decisions_analyzed": {
      "type": "integer"
    },
    "outcomes_analyzed": {
      "type": "integer"
    },
    "distinct_decisions": {
      "type": "integer"
    },
    "status": {
      "type": "string",
      "enum": [
        "scored",
        "insufficient_data"
      ]
    },
    "recommendation": {
      "type": "string",
      "enum": [
        "collect_more_outcomes",
        "review_high_anomalies",
        "monitor_anomalies",
        "stable"
      ]
    },
    "summary": {
      "type": "object",
      "properties": {
        "anomaly_count": {
          "type": "integer"
        },
        "returned_count": {
          "type": "integer"
        },
        "high_count": {
          "type": "integer"
        },
        "medium_count": {
          "type": "integer"
        },
        "low_count": {
          "type": "integer"
        },
        "max_score": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "additionalProperties": true
    },
    "baseline": {
      "type": "object",
      "additionalProperties": true
    },
    "anomalies": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PolicyAnomaly"
      }
    },
    "window": {
      "type": "object",
      "additionalProperties": true
    },
    "data_quality": {
      "type": "object",
      "additionalProperties": true
    },
    "anomaly_hash": {
      "type": "string"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "PolicyAnomaly": {
      "type": "object",
      "required": [
        "decision_id",
        "outcome_id",
        "anomaly_score",
        "severity",
        "reasons"
      ],
      "properties": {
        "decision_id": {
          "type": "string"
        },
        "outcome_id": {
          "type": "string"
        },
        "anomaly_score": {
          "type": "number"
        },
        "severity": {
          "type": "string",
          "enum": [
            "normal",
            "low",
            "medium",
            "high"
          ]
        },
        "reasons": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PolicyAnomalyReason"
          }
        },
        "decision_verdict": {
          "type": "string"
        },
        "outcome_status": {
          "type": "string"
        },
        "action_executed": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "policy_id": {
          "type": "string"
        },
        "policy_version": {
          "type": [
            "string",
            "null"
          ]
        },
        "target_system": {
          "type": [
            "string",
            "null"
          ]
        },
        "target_object_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "mutation": {
          "type": [
            "string",
            "null"
          ]
        },
        "reported_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "outcome_hash": {
          "type": [
            "string",
            "null"
          ]
        },
        "decision_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "verify_url": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": true
    },
    "PolicyAnomalyReason": {
      "type": "object",
      "required": [
        "code",
        "message",
        "weight"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "weight": {
          "type": "number"
        },
        "observed": {
          "type": "object",
          "additionalProperties": true
        },
        "baseline": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    }
  }
}