{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://oto.dtp/schemas/faisabilite/version.schema.json",
  "title": "Faisabilité _META/version.json",
  "description": "Métadonnées de versioning d'une faisabilité canonique. Un fichier par projet dans data_room/PXX/_META/version.json.",
  "type": "object",
  "required": [
    "projet",
    "template_version",
    "generated_at",
    "score_4big",
    "statut_faisabilite",
    "volets_complets",
    "champs_manquants"
  ],
  "additionalProperties": false,
  "properties": {
    "projet": {
      "type": "string",
      "pattern": "^P0[1-9]$",
      "description": "Code projet canonique (P01..P09) · domaine ancré sur CLAUDE.md §Projets."
    },
    "template_version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
      "description": "Version SemVer du template canonique utilisé (ex: 1.0.0)."
    },
    "generated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Horodatage ISO-8601 UTC de génération."
    },
    "score_4big": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "Score qualité 4Big. Doit être >= 95 pour statut 'complete' publiable."
    },
    "statut_faisabilite": {
      "type": "string",
      "enum": ["complete", "en_developpement", "incomplete"],
      "description": "complete = publiable (score>=95, champs 🔴 remplis). Sinon Publiciste affiche 'En développement'."
    },
    "volets_complets": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["masterplan", "architecture", "paysage_experience", "ingenierie"]
      },
      "uniqueItems": true,
      "description": "Liste des 4 volets validés."
    },
    "champs_manquants": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Identifiants des champs 🔴 non renseignés (ex: '3.2.typo_1_prix_usd'). Vide si complete."
    },
    "archive_precedente": {
      "type": ["string", "null"],
      "description": "Chemin _ARCHIVES/PXX_v{N}_YYYYMMDD/ de la version remplacée (null si première génération)."
    }
  },
  "allOf": [
    {
      "if": { "properties": { "statut_faisabilite": { "const": "complete" } } },
      "then": {
        "properties": {
          "score_4big": { "minimum": 95 },
          "champs_manquants": { "maxItems": 0 },
          "volets_complets": { "minItems": 4 }
        }
      }
    }
  ]
}
