{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://oto.dtp/schemas/pie/pie_manifest.schema.json",
  "title": "PIE · manifest de dépendances (pie_manifest.json)",
  "description": "Sortie déterministe du Project Identity Engine (Annexe 12 · V10.1). Décrit le graphe de dépendances faisabilité(SSOT)→livrables downstream. Zéro invention (#6) : contenus transcrits de la directive PIE ; codes projets ancrés à CLAUDE.md §Projets.",
  "type": "object",
  "required": ["engine", "annexe", "version_workflow", "ssot", "source_spec", "master_data_groups", "downstream_registry", "sync_rules", "workflow", "brands", "storage_layout"],
  "additionalProperties": false,
  "properties": {
    "engine": { "type": "string", "minLength": 1 },
    "annexe": { "type": "integer" },
    "version_workflow": { "type": "string", "minLength": 1 },
    "ssot": { "type": "string", "minLength": 1 },
    "source_spec": { "type": "string", "minLength": 1 },
    "master_data_groups": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["cle", "libelle", "champs"],
        "additionalProperties": false,
        "properties": {
          "cle": { "type": "string", "minLength": 1 },
          "libelle": { "type": "string", "minLength": 1 },
          "champs": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } }
        }
      }
    },
    "downstream_registry": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["cle", "libelle", "module", "statut"],
        "additionalProperties": false,
        "properties": {
          "cle": { "type": "string", "minLength": 1 },
          "libelle": { "type": "string", "minLength": 1 },
          "module": { "type": ["string", "null"] },
          "statut": { "type": "string", "enum": ["gated", "a_construire"] }
        }
      }
    },
    "sync_rules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["trigger", "trigger_group", "downstream"],
        "additionalProperties": false,
        "properties": {
          "trigger": { "type": "string", "minLength": 1 },
          "trigger_group": { "type": "string", "minLength": 1 },
          "downstream": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } }
        }
      }
    },
    "workflow": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["etape", "libelle"],
        "additionalProperties": false,
        "properties": {
          "etape": { "type": "integer", "minimum": 1 },
          "libelle": { "type": "string", "minLength": 1 }
        }
      }
    },
    "brands": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["code", "marque", "localisation"],
        "additionalProperties": false,
        "properties": {
          "code": { "type": "string", "pattern": "^P0[1-9]$" },
          "marque": { "type": "string", "minLength": 1 },
          "localisation": { "type": "string", "minLength": 1 }
        }
      }
    },
    "storage_layout": {
      "type": "object",
      "required": ["racine", "artefacts"],
      "additionalProperties": false,
      "properties": {
        "racine": { "type": "string", "minLength": 1 },
        "artefacts": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["chemin", "role"],
            "additionalProperties": false,
            "properties": {
              "chemin": { "type": "string", "minLength": 1 },
              "role": { "type": "string", "minLength": 1 }
            }
          }
        }
      }
    }
  }
}
