{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://oto.dtp/schemas/faisabilite/bancable.schema.json",
  "title": "Manifeste du dossier financier bancable trilingue",
  "description": "Vue machine-lisible du dossier bancable FR/EN/ES d'un projet. Toute valeur numérique absente est null (jamais 0-inventé · CLAUDE.md #6). Les figures calculées portent leur formule (traçabilité). Sous-ensemble draft-07 supporté par le validateur maison Publiciste (zéro pip).",
  "type": "object",
  "required": ["projet", "template_version", "langues", "synthetique", "publiable", "figures_sourcees", "figures_calculees", "typologies_count", "champs_manquants", "fichiers"],
  "additionalProperties": false,
  "properties": {
    "projet": { "type": "string", "pattern": "^P0[1-9]$" },
    "template_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "langues": {
      "type": "array",
      "minItems": 3,
      "maxItems": 3,
      "uniqueItems": true,
      "items": { "type": "string", "enum": ["fr", "en", "es"] }
    },
    "synthetique": { "type": "boolean" },
    "publiable": { "type": "boolean" },
    "generated_at": { "type": "string", "format": "date-time" },
    "figures_sourcees": {
      "type": "object",
      "required": ["cout_construction_usd", "revenu_brut_usd", "marge_pct", "taux_conversion"],
      "additionalProperties": false,
      "properties": {
        "cout_construction_usd": { "type": ["number", "null"] },
        "revenu_brut_usd": { "type": ["number", "null"] },
        "marge_pct": { "type": ["number", "null"] },
        "taux_conversion": {
          "type": "object",
          "required": ["taux", "date", "source"],
          "additionalProperties": false,
          "properties": {
            "taux": { "type": ["number", "null"] },
            "date": { "type": ["string", "null"] },
            "source": { "type": ["string", "null"] }
          }
        }
      }
    },
    "figures_calculees": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "items": {
        "type": "object",
        "required": ["cle", "libelle", "formule", "valeur", "unite"],
        "additionalProperties": false,
        "properties": {
          "cle": { "type": "string", "enum": ["total_unites", "valeur_catalogue_usd", "valeur_catalogue_dop", "point_equilibre_unites"] },
          "libelle": { "type": "string", "minLength": 1 },
          "formule": { "type": "string", "minLength": 1 },
          "valeur": { "type": ["number", "null"] },
          "unite": { "type": "string" }
        }
      }
    },
    "typologies_count": { "type": "integer", "minimum": 0 },
    "champs_manquants": {
      "type": "array",
      "items": { "type": "string" }
    },
    "fichiers": {
      "type": "array",
      "minItems": 3,
      "maxItems": 3,
      "items": { "type": "string", "pattern": "^50_financier_bancable/(fr|en|es)\\.md$" }
    }
  }
}
