{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://oto-enterprise-os-dtp/qa/acceptance.schema.json",
  "title": "Matrice d'acceptation / traçabilité MVP (roadmap → livrable → preuve)",
  "description": "Contrat de sortie de acceptance_gen.py. Validé par le validateur maison Publiciste (zéro pip) dans le job CI qa-acceptance-tests. Mappe chaque promesse roadmap (livrables de sprint + métriques succès MVP) vers sa preuve gated (module CI) ou un hors-périmètre sourcé. Aucun chiffre métier fabriqué : les nombres des énoncés sont des citations verbatim de la roadmap.",
  "type": "object",
  "additionalProperties": false,
  "required": ["matrix", "manifest", "verdict"],
  "properties": {
    "matrix": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/definitions/row" }
    },
    "verdict": { "type": "boolean" },
    "manifest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "generated_from",
        "reference_cadre",
        "roadmap_ref",
        "cible_portage",
        "self_module",
        "counts",
        "coverage",
        "roadmap"
      ],
      "properties": {
        "generated_from": { "type": "string", "minLength": 1 },
        "reference_cadre": { "type": "string", "minLength": 1 },
        "roadmap_ref": { "type": "string", "minLength": 1 },
        "cible_portage": { "type": "string", "minLength": 1 },
        "self_module": { "type": "string", "const": "qa/acceptance" },
        "counts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "sprint_deliverables",
            "mvp_metrics",
            "deliverables_total",
            "in_repo",
            "out_of_scope_full",
            "gated_modules",
            "cited_modules",
            "out_of_scope_items"
          ],
          "properties": {
            "sprint_deliverables": { "type": "integer", "minimum": 1 },
            "mvp_metrics": { "type": "integer", "minimum": 1 },
            "deliverables_total": { "type": "integer", "minimum": 1 },
            "in_repo": { "type": "integer", "minimum": 0 },
            "out_of_scope_full": { "type": "integer", "minimum": 0 },
            "gated_modules": { "type": "integer", "minimum": 1 },
            "cited_modules": { "type": "integer", "minimum": 0 },
            "out_of_scope_items": { "type": "integer", "minimum": 0 }
          }
        },
        "coverage": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "ci_modules_count",
            "cited_modules_count",
            "bijective",
            "missing_in_matrix",
            "phantom_evidence",
            "partition_ok",
            "sprint_partition",
            "unknown_sprint",
            "missing_artifacts",
            "self_module_excluded"
          ],
          "properties": {
            "ci_modules_count": { "type": "integer", "minimum": 0 },
            "cited_modules_count": { "type": "integer", "minimum": 0 },
            "bijective": { "type": "boolean" },
            "missing_in_matrix": { "type": "array", "items": { "type": "string" } },
            "phantom_evidence": { "type": "array", "items": { "type": "string" } },
            "partition_ok": { "type": "boolean" },
            "sprint_partition": {
              "type": "array",
              "items": { "$ref": "#/definitions/partition" }
            },
            "unknown_sprint": { "type": "array", "items": { "type": "string" } },
            "missing_artifacts": { "type": "array", "items": { "type": "string" } },
            "self_module_excluded": { "type": "string", "const": "qa/acceptance" }
          }
        },
        "roadmap": {
          "type": "object",
          "additionalProperties": false,
          "required": ["sprint_ids", "metric_ids"],
          "properties": {
            "sprint_ids": { "type": "array", "items": { "type": "string" } },
            "metric_ids": { "type": "array", "items": { "type": "string" } }
          }
        }
      }
    }
  },
  "definitions": {
    "row": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "kind",
        "sprint",
        "roadmap_line",
        "statement",
        "status",
        "modules",
        "artifacts",
        "out_of_scope",
        "n_modules",
        "all_modules_gated",
        "all_artifacts_exist",
        "has_evidence"
      ],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "kind": { "type": "string", "enum": ["sprint_deliverable", "mvp_metric"] },
        "sprint": { "type": ["string", "null"] },
        "roadmap_line": { "type": "integer", "minimum": 1 },
        "statement": { "type": "string", "minLength": 1 },
        "status": { "type": "string", "enum": ["in_repo", "out_of_scope"] },
        "modules": {
          "type": "array",
          "items": { "$ref": "#/definitions/evmodule" }
        },
        "artifacts": {
          "type": "array",
          "items": { "$ref": "#/definitions/evartifact" }
        },
        "out_of_scope": {
          "type": "array",
          "items": { "$ref": "#/definitions/oos" }
        },
        "n_modules": { "type": "integer", "minimum": 0 },
        "all_modules_gated": { "type": "boolean" },
        "all_artifacts_exist": { "type": "boolean" },
        "has_evidence": { "type": "boolean" }
      }
    },
    "evmodule": {
      "type": "object",
      "additionalProperties": false,
      "required": ["module", "ci_job", "gated"],
      "properties": {
        "module": { "type": "string", "minLength": 1 },
        "ci_job": { "type": ["string", "null"] },
        "gated": { "type": "boolean" }
      }
    },
    "evartifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "exists"],
      "properties": {
        "path": { "type": "string", "minLength": 1 },
        "exists": { "type": "boolean" }
      }
    },
    "oos": {
      "type": "object",
      "additionalProperties": false,
      "required": ["item", "source"],
      "properties": {
        "item": { "type": "string", "minLength": 1 },
        "source": { "type": "string", "minLength": 1 }
      }
    },
    "partition": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sprint", "expected", "cited", "missing", "extra", "exact"],
      "properties": {
        "sprint": { "type": "string", "minLength": 1 },
        "expected": { "type": "array", "items": { "type": "string" } },
        "cited": { "type": "array", "items": { "type": "string" } },
        "missing": { "type": "array", "items": { "type": "string" } },
        "extra": { "type": "array", "items": { "type": "string" } },
        "exact": { "type": "boolean" }
      }
    }
  }
}
