{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aiwg.io/schemas/decision/DecisionInteropMapping.v1.schema.json",
  "type": "object",
  "properties": {
    "apiVersion": { "const": "decision-interop.aiwg.io/v1" },
    "kind": { "const": "DecisionInteropMapping" },
    "metadata": {
      "type": "object",
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" },
        "description": { "type": "string", "minLength": 1 }
      },
      "required": ["id", "version", "description"],
      "additionalProperties": false
    },
    "spec": {
      "type": "object",
      "properties": {
        "source": { "$ref": "#/$defs/source" },
        "dryRun": { "const": true },
        "activation": { "const": "requires-review-publish" },
        "profile": { "$ref": "#/$defs/dmnProfile" },
        "normalizedRuleset": { "$ref": "https://aiwg.io/schemas/decision/DecisionRuleset.v1alpha2.schema.json" },
        "normalizedDigest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
        "warnings": { "type": "array", "items": { "type": "string" } },
        "errors": { "type": "array", "items": { "type": "string" } },
        "roundTripStatus": { "enum": ["not-run", "equivalent", "not-equivalent"] }
      },
      "required": ["source", "dryRun", "activation", "profile", "normalizedRuleset", "normalizedDigest", "warnings", "errors", "roundTripStatus"],
      "additionalProperties": false
    }
  },
  "required": ["apiVersion", "kind", "metadata", "spec"],
  "additionalProperties": false,
  "$defs": {
    "source": {
      "type": "object",
      "properties": {
        "format": { "enum": ["dmn-xml", "opa-profile", "aiwg-profile"] },
        "version": { "type": "string", "minLength": 1 },
        "origin": { "type": "string", "minLength": 1 },
        "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
        "signature": {
          "type": "object",
          "properties": {
            "state": { "enum": ["not-provided", "verified", "untrusted"] },
            "keyId": { "type": "string", "minLength": 1 }
          },
          "required": ["state"],
          "additionalProperties": false
        },
        "parser": {
          "type": "object",
          "properties": {
            "id": { "const": "aiwg-decision-interop" },
            "version": { "const": "decision-interop.aiwg.io/v1" }
          },
          "required": ["id", "version"],
          "additionalProperties": false
        },
        "bounds": { "type": "object" }
      },
      "required": ["format", "version", "origin", "digest", "signature", "parser", "bounds"],
      "additionalProperties": false
    },
    "dmnProfile": {
      "type": "object",
      "properties": {
        "profileVersion": { "const": "decision-interop.aiwg.io/v1" },
        "dmnVersion": { "const": "1.6" },
        "namespace": { "const": "https://www.omg.org/spec/DMN/20240513/MODEL/" },
        "hitPolicy": { "enum": ["UNIQUE", "ANY", "FIRST", "RULE ORDER", "COLLECT"] },
        "aggregation": { "enum": ["LIST", "SUM", "MIN", "MAX", "COUNT", null] },
        "ruleOrder": { "type": "array", "items": { "type": "string", "minLength": 1 }, "minItems": 1 },
        "supportedUnaryTests": { "type": "array", "items": { "enum": ["dash", "literal", "eq", "ne", "lt", "lte", "gt", "gte"] }, "minItems": 1 },
        "unsupportedConstructs": { "type": "array", "items": { "type": "string" } },
        "extensions": { "type": "array", "items": { "enum": ["aiwg:order", "aiwg:defer-on-conflict"] } }
      },
      "required": ["profileVersion", "dmnVersion", "namespace", "hitPolicy", "aggregation", "ruleOrder", "supportedUnaryTests", "unsupportedConstructs", "extensions"],
      "additionalProperties": false
    }
  }
}
