{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chris-page-gov.github.io/okf-explorer/profiles/context-assembly/v1/evaluation-controls.schema.json",
  "title": "Synthetic context assembly controls",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "okf-context-evaluation-controls.v1"
    },
    "id": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "minLength": 1
    },
    "controls": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]{0,79}$"
          },
          "description": {
            "type": "string",
            "minLength": 1
          },
          "mutations": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "drop_record"
                    },
                    "record_id": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "record_id"
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "reverse_incoming"
                    },
                    "record_id": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "record_id"
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "corrupt_text"
                    },
                    "record_id": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "record_id"
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "restrict_record"
                    },
                    "record_id": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "record_id"
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "clear_provenance"
                    },
                    "record_id": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "record_id"
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "remove_assertion"
                    },
                    "assertion_id": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "assertion_id"
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "add_alias"
                    },
                    "record_id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "alias": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "record_id",
                    "alias"
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "op": {
                      "const": "declare_conflict"
                    },
                    "record_id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "other_id": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "op",
                    "record_id",
                    "other_id"
                  ]
                }
              ]
            }
          },
          "question": {
            "type": "string",
            "minLength": 1
          },
          "budget": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "max_nodes": {
                "type": "integer",
                "minimum": 0
              },
              "max_relationships": {
                "type": "integer",
                "minimum": 0
              },
              "max_depth": {
                "type": "integer",
                "minimum": 0
              },
              "max_bytes": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": []
          },
          "expected": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "evidence_status": {
                "type": "array",
                "items": {
                  "enum": [
                    "sufficient",
                    "insufficient",
                    "conflicting"
                  ]
                }
              },
              "failed_stages": {
                "type": "array",
                "items": {
                  "enum": [
                    "A",
                    "B",
                    "C",
                    "D",
                    "E",
                    "F",
                    "G",
                    "H"
                  ]
                }
              },
              "issues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "area": {
                      "enum": [
                        "missing_evidence",
                        "conflicts",
                        "omissions"
                      ]
                    },
                    "code": {
                      "type": "string",
                      "minLength": 1
                    },
                    "ids": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      }
                    }
                  },
                  "required": [
                    "area",
                    "code",
                    "ids"
                  ]
                }
              },
              "absent_records": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "truncated": {
                "type": "boolean"
              },
              "max_selected": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "evidence_status",
              "failed_stages",
              "issues",
              "absent_records"
            ]
          }
        },
        "required": [
          "id",
          "description",
          "mutations",
          "expected"
        ]
      }
    }
  },
  "required": [
    "schema",
    "id",
    "description",
    "controls"
  ]
}
