{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "AGLA_W_FIXTURE_CASE.schema.json",
  "title": "AGLA Stack W executable fixture suite",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "schema",
    "version",
    "status",
    "runtime_posture",
    "authority_effect",
    "profile_kind",
    "execution_claim",
    "polarity",
    "decision_reference_transition_map",
    "cases"
  ],
  "properties": {
    "$schema": {
      "const": "../../schemas/W_FIXTURE_CASE.schema.json"
    },
    "schema": {
      "const": "AGLA_W_FIXTURE_SUITE_v0.1.0"
    },
    "version": {
      "const": "0.1.0"
    },
    "status": {
      "const": "EXECUTABLE_CANDIDATE_FIXTURES_NON_RUNTIME"
    },
    "runtime_posture": {
      "const": "CANDIDATE_NON_RUNTIME"
    },
    "authority_effect": {
      "const": "NONE"
    },
    "profile_kind": {
      "const": "SYNTHETIC_INTERFACE_REFERENCE"
    },
    "execution_claim": {
      "const": "NO_UPSTREAM_OPERA_EXECUTED"
    },
    "polarity": {
      "type": "string",
      "enum": [
        "POSITIVE",
        "ADVERSE"
      ]
    },
    "decision_reference_transition_map": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "PASS_REFERENCE",
        "ADMIT_REFERENCE",
        "ADMIT_REFERENCE_WITH_FLAGS",
        "BLOCK",
        "REJECT",
        "NO_W_INVOCATION",
        "FIXTURE_INVALID"
      ],
      "properties": {
        "PASS_REFERENCE": {
          "const": false
        },
        "ADMIT_REFERENCE": {
          "const": true
        },
        "ADMIT_REFERENCE_WITH_FLAGS": {
          "const": true
        },
        "BLOCK": {
          "const": false
        },
        "REJECT": {
          "const": false
        },
        "NO_W_INVOCATION": {
          "const": false
        },
        "FIXTURE_INVALID": {
          "const": false
        }
      }
    },
    "cases": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/fixtureCase"
      }
    }
  },
  "$defs": {
    "jsonValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "boolean"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
      "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "boolean"
              },
              {
                "type": "integer"
              },
              {
                "type": "number"
              }
            ]
          }
        },
        {
          "type": "object",
          "additionalProperties": {
      "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "boolean"
              },
              {
                "type": "integer"
              },
              {
                "type": "number"
              }
            ]
          }
        }
      ]
    },
    "predicate": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "fact",
        "operator",
        "expected"
      ],
      "properties": {
        "fact": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "operator": {
          "type": "string",
          "enum": [
            "EQUALS",
            "NOT_EQUALS",
            "CONTAINS",
            "NOT_CONTAINS",
            "SET_EQUALS",
            "COUNT_EQUALS"
          ]
        },
        "expected": {
          "$ref": "#/$defs/jsonValue"
        }
      }
    },
    "outcome": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "decision",
        "reason_codes"
      ],
      "properties": {
        "decision": {
          "type": "string",
          "enum": [
            "PASS_REFERENCE",
            "ADMIT_REFERENCE",
            "ADMIT_REFERENCE_WITH_FLAGS",
            "BLOCK",
            "REJECT",
            "NO_W_INVOCATION",
            "FIXTURE_INVALID"
          ]
        },
        "reason_codes": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[A-Z0-9_]+$"
          }
        }
      }
    },
    "evaluationContract": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "rule_id",
        "combinator",
        "predicates",
        "when_satisfied",
        "when_unsatisfied"
      ],
      "properties": {
        "rule_id": {
          "type": "string",
          "pattern": "^W-FXR-[A-Z0-9_-]+$"
        },
        "combinator": {
          "type": "string",
          "enum": [
            "ALL",
            "ANY"
          ]
        },
        "predicates": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/predicate"
          }
        },
        "when_satisfied": {
          "$ref": "#/$defs/outcome"
        },
        "when_unsatisfied": {
          "$ref": "#/$defs/outcome"
        }
      }
    },
    "assertion": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "assertion_id",
        "subject",
        "operator",
        "expected"
      ],
      "properties": {
        "assertion_id": {
          "type": "string",
          "pattern": "^W-FXA-[A-Z0-9_-]+$"
        },
        "subject": {
          "type": "string",
          "pattern": "^(derived\\.(decision|candidate_reference_transition_allowed|runtime_execution_allowed|reason_codes)|input\\.facts\\.[a-z][a-z0-9_]*)$"
        },
        "operator": {
          "type": "string",
          "enum": [
            "EQUALS",
            "NOT_EQUALS",
            "CONTAINS",
            "NOT_CONTAINS",
            "SET_EQUALS",
            "COUNT_EQUALS"
          ]
        },
        "expected": {
          "$ref": "#/$defs/jsonValue"
        }
      }
    },
    "fixtureCase": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "fixture_id",
        "title",
        "polarity",
        "scenario_type",
        "profile_kind",
        "execution_claim",
        "input",
        "expected"
      ],
      "properties": {
        "fixture_id": {
          "type": "string",
          "pattern": "^W-FX-[PA][0-9]{3}$"
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "polarity": {
          "type": "string",
          "enum": [
            "POSITIVE",
            "ADVERSE"
          ]
        },
        "scenario_type": {
          "type": "string",
          "pattern": "^[A-Z0-9_]+$"
        },
        "profile_kind": {
          "const": "SYNTHETIC_INTERFACE_REFERENCE"
        },
        "execution_claim": {
          "const": "NO_UPSTREAM_OPERA_EXECUTED"
        },
        "input": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "facts",
            "evaluation_contract"
          ],
          "properties": {
            "facts": {
              "type": "object",
              "minProperties": 1,
              "additionalProperties": {
                "$ref": "#/$defs/jsonValue"
              }
            },
            "evaluation_contract": {
              "$ref": "#/$defs/evaluationContract"
            }
          }
        },
        "expected": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "decision",
            "candidate_reference_transition_allowed",
            "runtime_execution_allowed",
            "reason_codes",
            "assertions"
          ],
          "properties": {
            "decision": {
              "type": "string",
              "enum": [
                "PASS_REFERENCE",
                "ADMIT_REFERENCE",
                "ADMIT_REFERENCE_WITH_FLAGS",
                "BLOCK",
                "REJECT",
                "NO_W_INVOCATION"
              ]
            },
            "candidate_reference_transition_allowed": {
              "type": "boolean"
            },
            "runtime_execution_allowed": {
              "const": false
            },
            "reason_codes": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "pattern": "^[A-Z0-9_]+$"
              }
            },
            "assertions": {
              "type": "array",
              "minItems": 3,
              "items": {
                "$ref": "#/$defs/assertion"
              }
            }
          }
        }
      }
    }
  }
}
