{
  "$defs": {
    "isoDate": {
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "type": "string"
    },
    "localeMap": {
      "additionalProperties": false,
      "properties": {
        "de": {
          "minLength": 1,
          "type": "string"
        },
        "en": {
          "minLength": 1,
          "type": "string"
        },
        "es": {
          "minLength": 1,
          "type": "string"
        },
        "fr": {
          "minLength": 1,
          "type": "string"
        },
        "pt-BR": {
          "minLength": 1,
          "type": "string"
        }
      },
      "propertyNames": {
        "enum": [
          "en",
          "de",
          "pt-BR",
          "es",
          "fr"
        ],
        "pattern": "^[a-z]{2}(-[A-Z]{2})?$"
      },
      "required": [
        "en",
        "de",
        "pt-BR",
        "es",
        "fr"
      ],
      "type": "object"
    }
  },
  "$id": "https://anylai.eu/coadf/downloads/2.2/r3/coadf-2.2-r3.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "agent_charter": {
      "additionalProperties": false,
      "properties": {
        "ladder": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "description": {
                "$ref": "#/$defs/localeMap"
              },
              "level": {
                "pattern": "^L\\d$",
                "type": "string"
              },
              "name": {
                "$ref": "#/$defs/localeMap"
              }
            },
            "required": [
              "level",
              "name",
              "description"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "never_autonomous": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "text": {
                "$ref": "#/$defs/localeMap"
              }
            },
            "required": [
              "id",
              "text"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "source_of_truth": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "text": {
                "$ref": "#/$defs/localeMap"
              }
            },
            "required": [
              "id",
              "text"
            ],
            "type": "object"
          },
          "type": "array"
        }
      },
      "required": [
        "ladder",
        "never_autonomous",
        "source_of_truth"
      ],
      "type": "object"
    },
    "alternate_name": {
      "const": "COADF"
    },
    "attribution": {
      "$ref": "#/$defs/localeMap"
    },
    "candidates": {
      "items": {
        "additionalProperties": false,
        "else": {
          "properties": {
            "withheld": {
              "type": "null"
            }
          }
        },
        "if": {
          "properties": {
            "published_depth": {
              "const": "principle"
            }
          }
        },
        "properties": {
          "alignment": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "article": {
                  "minLength": 1,
                  "type": "string"
                },
                "checked_on": {
                  "$ref": "#/$defs/isoDate"
                },
                "instrument": {
                  "minLength": 1,
                  "type": "string"
                },
                "source_kind": {
                  "const": "primary"
                },
                "source_url": {
                  "pattern": "^https?://",
                  "type": "string"
                }
              },
              "required": [
                "instrument",
                "article",
                "source_kind",
                "source_url",
                "checked_on"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "id": {
            "type": "string"
          },
          "published_depth": {
            "enum": [
              "full",
              "principle"
            ]
          },
          "statement": {
            "$ref": "#/$defs/localeMap"
          },
          "status": {
            "const": "candidate"
          },
          "title": {
            "$ref": "#/$defs/localeMap"
          },
          "withheld": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/$defs/localeMap"
              }
            ]
          }
        },
        "required": [
          "id",
          "status",
          "title",
          "statement",
          "published_depth",
          "withheld",
          "alignment"
        ],
        "then": {
          "properties": {
            "withheld": {
              "$ref": "#/$defs/localeMap"
            }
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "conformance_public": {
      "additionalProperties": false,
      "properties": {
        "assessed_on": {
          "$ref": "#/$defs/isoDate"
        },
        "disclaimer": {
          "$ref": "#/$defs/localeMap"
        },
        "disclosed_scope": {
          "additionalProperties": false,
          "properties": {
            "disclosed_controls": {
              "minimum": 0,
              "type": "integer"
            },
            "enforced": {
              "minimum": 0,
              "type": "integer"
            },
            "gap": {
              "minimum": 0,
              "type": "integer"
            },
            "internal_controls": {
              "minimum": 0,
              "type": "integer"
            },
            "manual": {
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "disclosed_controls",
            "internal_controls",
            "enforced",
            "manual",
            "gap"
          ],
          "type": "object"
        },
        "framework_version": {
          "type": "string"
        },
        "run_id": {
          "type": "string"
        }
      },
      "required": [
        "framework_version",
        "assessed_on",
        "run_id",
        "disclosed_scope",
        "disclaimer"
      ],
      "type": "object"
    },
    "edition_revision": {
      "pattern": "^r\\d+$",
      "type": "string"
    },
    "fences_public_subset": {
      "items": {
        "additionalProperties": false,
        "properties": {
          "candidate": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "string"
              }
            ]
          },
          "control_id": {
            "minLength": 1,
            "type": "string"
          },
          "enforcement": {
            "enum": [
              "automated-test",
              "ci-job",
              "review-at-merge",
              "none"
            ]
          },
          "principle": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "pattern": "^P-[1-8]$",
                "type": "string"
              }
            ]
          },
          "public_statement": {
            "$ref": "#/$defs/localeMap"
          },
          "scope_note": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/$defs/localeMap"
              }
            ]
          },
          "status": {
            "enum": [
              "enforced",
              "manual",
              "gap"
            ]
          },
          "what_closing_would_take": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/$defs/localeMap"
              }
            ]
          }
        },
        "required": [
          "control_id",
          "principle",
          "candidate",
          "public_statement",
          "enforcement",
          "status",
          "scope_note",
          "what_closing_would_take"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "framework_version": {
      "pattern": "^\\d+\\.\\d+$",
      "type": "string"
    },
    "licence_line": {
      "$ref": "#/$defs/localeMap"
    },
    "licence_status": {
      "enum": [
        "proposed_not_granted"
      ]
    },
    "name": {
      "type": "string"
    },
    "patent_notice": {
      "$ref": "#/$defs/localeMap"
    },
    "patent_status": {
      "enum": [
        "application_pending_none_granted"
      ]
    },
    "principles": {
      "items": {
        "additionalProperties": false,
        "else": {
          "properties": {
            "withheld": {
              "type": "null"
            }
          }
        },
        "if": {
          "properties": {
            "published_depth": {
              "const": "principle"
            }
          }
        },
        "properties": {
          "alignment": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "article": {
                  "minLength": 1,
                  "type": "string"
                },
                "checked_on": {
                  "$ref": "#/$defs/isoDate"
                },
                "instrument": {
                  "minLength": 1,
                  "type": "string"
                },
                "source_kind": {
                  "const": "primary"
                },
                "source_url": {
                  "pattern": "^https?://",
                  "type": "string"
                }
              },
              "required": [
                "instrument",
                "article",
                "source_kind",
                "source_url",
                "checked_on"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "alignment_statement": {
            "$ref": "#/$defs/localeMap"
          },
          "id": {
            "pattern": "^P-[1-8]$",
            "type": "string"
          },
          "prior_art": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/$defs/localeMap"
              }
            ]
          },
          "published_depth": {
            "enum": [
              "full",
              "principle"
            ]
          },
          "statement": {
            "$ref": "#/$defs/localeMap"
          },
          "title": {
            "$ref": "#/$defs/localeMap"
          },
          "withheld": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/$defs/localeMap"
              }
            ]
          }
        },
        "required": [
          "id",
          "title",
          "statement",
          "published_depth",
          "withheld",
          "prior_art",
          "alignment_statement",
          "alignment"
        ],
        "then": {
          "properties": {
            "withheld": {
              "$ref": "#/$defs/localeMap"
            }
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "public_projection_hash": {
      "pattern": "^[0-9a-f]{64}$",
      "type": "string"
    },
    "public_source_commit": {
      "pattern": "^[0-9a-f]{40}$",
      "type": "string"
    },
    "publication_date": {
      "$ref": "#/$defs/isoDate"
    },
    "publication_line": {
      "$ref": "#/$defs/localeMap"
    },
    "red_lines": {
      "items": {
        "additionalProperties": false,
        "properties": {
          "alignment": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "article": {
                  "minLength": 1,
                  "type": "string"
                },
                "checked_on": {
                  "$ref": "#/$defs/isoDate"
                },
                "instrument": {
                  "minLength": 1,
                  "type": "string"
                },
                "source_kind": {
                  "const": "primary"
                },
                "source_url": {
                  "pattern": "^https?://",
                  "type": "string"
                }
              },
              "required": [
                "instrument",
                "article",
                "source_kind",
                "source_url",
                "checked_on"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "id": {
            "type": "string"
          },
          "never": {
            "$ref": "#/$defs/localeMap"
          },
          "say": {
            "$ref": "#/$defs/localeMap"
          },
          "why": {
            "$ref": "#/$defs/localeMap"
          }
        },
        "required": [
          "id",
          "say",
          "never",
          "why",
          "alignment"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "schema_version": {
      "const": "1.0"
    }
  },
  "required": [
    "schema_version",
    "$schema",
    "name",
    "alternate_name",
    "framework_version",
    "edition_revision",
    "publication_date",
    "public_source_commit",
    "public_projection_hash",
    "licence_status",
    "licence_line",
    "patent_status",
    "patent_notice",
    "publication_line",
    "attribution",
    "principles",
    "candidates",
    "red_lines",
    "fences_public_subset",
    "conformance_public",
    "agent_charter"
  ],
  "type": "object"
}
