{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://oto-enterprise-os-dtp/qa/audit_5d.schema.json",
  "title": "Rapport d'audit 5D de conformité genere depuis audit_spec.json + les hand-off out/ des livrables",
  "description": "Contrat de sortie du generateur audit_5d_gen.py. Valide par le validateur maison Publiciste (zero pip) dans le job CI qa-audit-5d-tests.",
  "type": "object",
  "additionalProperties": false,
  "required": ["audit", "version", "reference_cadre", "dimensions", "controls", "open_items", "totals", "verdict", "notes"],
  "properties": {
    "audit": { "type": "string", "const": "OTO QA · Audit 5D Conformité" },
    "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+$" },
    "reference_cadre": { "type": "string", "minLength": 1 },
    "dimensions": {
      "type": "array",
      "minItems": 5,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "titre", "reference", "controls_total", "pass", "fail", "a_confirmer", "statut"],
        "properties": {
          "id": { "type": "string", "pattern": "^D[1-9]$" },
          "titre": { "type": "string", "minLength": 1 },
          "reference": { "type": "string", "minLength": 1 },
          "controls_total": { "type": "integer", "minimum": 1 },
          "pass": { "type": "integer", "minimum": 0 },
          "fail": { "type": "integer", "minimum": 0 },
          "a_confirmer": { "type": "integer", "minimum": 0 },
          "statut": { "type": "string", "enum": ["PASS", "FAIL", "PASS_WITH_OPEN_ITEMS"] }
        }
      }
    },
    "controls": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "dimension", "titre", "reference", "statut", "detail", "owner"],
        "properties": {
          "id": { "type": "string", "pattern": "^D[1-9]\\.[0-9]+$" },
          "dimension": { "type": "string", "pattern": "^D[1-9]$" },
          "titre": { "type": "string", "minLength": 1 },
          "reference": { "type": "string", "minLength": 1 },
          "statut": { "type": "string", "enum": ["PASS", "FAIL", "A_CONFIRMER"] },
          "detail": { "type": "string", "minLength": 1 },
          "owner": { "type": ["string", "null"] }
        }
      }
    },
    "open_items": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["control", "dimension", "detail", "owner"],
        "properties": {
          "control": { "type": "string", "pattern": "^D[1-9]\\.[0-9]+$" },
          "dimension": { "type": "string", "pattern": "^D[1-9]$" },
          "detail": { "type": "string", "minLength": 1 },
          "owner": { "type": "string", "minLength": 1 }
        }
      }
    },
    "totals": {
      "type": "object",
      "additionalProperties": false,
      "required": ["controls", "pass", "fail", "a_confirmer"],
      "properties": {
        "controls": { "type": "integer", "minimum": 1 },
        "pass": { "type": "integer", "minimum": 0 },
        "fail": { "type": "integer", "minimum": 0 },
        "a_confirmer": { "type": "integer", "minimum": 0 }
      }
    },
    "verdict": { "type": "string", "enum": ["PASS", "FAIL", "PASS_WITH_OPEN_ITEMS"] },
    "notes": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 }
    }
  }
}
