{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "business_plan.schema.json",
  "title": "Business Plan twin (PIL-BZ)",
  "description": "Mandated by AI Project Governance Standard v4.0, REQ-BUS-001..REQ-BUS-010. Every governed project carries this twin plus its generated BUSINESS_PLAN_A3.html before /SE-NEW-PROJECT can ratify. The twelve checks C-BP1..C-BP12 are implemented in build_business_plan.py --check.",
  "type": "object",
  "required": [
    "meta", "purpose", "target_market", "value_proposition", "cba",
    "running_costs", "marketing_strategy", "revenue_model",
    "areas_of_concern", "efficiency_audit", "value_validation", "footer"
  ],
  "properties": {
    "meta": {
      "description": "C-BP1 — project metadata.",
      "type": "object",
      "required": ["project_name", "owner", "date", "status", "class", "version", "standard"],
      "properties": {
        "project_name": {"type": "string", "minLength": 3},
        "owner": {"type": "string", "minLength": 2},
        "date": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
        "status": {"type": "string", "enum": ["DRAFT", "BUILT, UNVERIFIED", "VERIFIED", "RATIFIED"]},
        "class": {"type": "string", "enum": ["MICRO", "STANDARD", "MAJOR"]},
        "version": {"type": "string"},
        "standard": {"type": "string"}
      }
    },
    "purpose": {
      "description": "C-BP2 — purpose and problem statement.",
      "type": "object",
      "required": ["statement", "problem", "current_state", "desired_state", "gap"],
      "properties": {
        "statement": {"type": "string", "minLength": 40},
        "problem": {"type": "string", "minLength": 40},
        "current_state": {"type": "string", "minLength": 20},
        "desired_state": {"type": "string", "minLength": 20},
        "gap": {"type": "string", "minLength": 20}
      }
    },
    "target_market": {
      "description": "C-BP3 — market segments, each with a size and a need. Minimum two segments.",
      "type": "array",
      "minItems": 2,
      "items": {
        "type": "object",
        "required": ["segment", "size", "size_source", "need", "why_us"],
        "properties": {
          "segment": {"type": "string"},
          "size": {"type": "string"},
          "size_source": {"type": "string", "description": "SRC-### or ASM-###"},
          "need": {"type": "string"},
          "why_us": {"type": "string"}
        }
      }
    },
    "value_proposition": {
      "description": "C-BP4 — benefits each with a MEASURABLE metric, beneficiaries, realisation timeline.",
      "type": "object",
      "required": ["statement", "benefits", "beneficiaries", "realisation_timeline"],
      "properties": {
        "statement": {"type": "string", "minLength": 40},
        "benefits": {
          "type": "array", "minItems": 3,
          "items": {
            "type": "object",
            "required": ["benefit", "metric", "baseline", "target", "measured_by"],
            "properties": {
              "benefit": {"type": "string"},
              "metric": {"type": "string"},
              "baseline": {"type": "string"},
              "target": {"type": "string"},
              "measured_by": {"type": "string"}
            }
          }
        },
        "beneficiaries": {"type": "array", "minItems": 1, "items": {"type": "string"}},
        "realisation_timeline": {"type": "string"}
      }
    },
    "cba": {
      "description": "C-BP5 — lifecycle cost-benefit. All eight fields required (REQ-BUS-002).",
      "type": "object",
      "required": ["lifecycle_years", "development_costs", "running_costs_total",
                   "maintenance_costs", "opportunity_costs", "quantitative_benefits",
                   "qualitative_benefits", "roi_pct", "break_even"],
      "properties": {
        "lifecycle_years": {"type": "number", "minimum": 1},
        "development_costs": {"type": "number"},
        "running_costs_total": {"type": "number"},
        "maintenance_costs": {"type": "number"},
        "opportunity_costs": {"type": "number"},
        "quantitative_benefits": {"type": "number"},
        "qualitative_benefits": {"type": "array", "minItems": 1, "items": {"type": "string"}},
        "roi_pct": {"type": "number"},
        "break_even": {"type": "string"},
        "basis": {"type": "string"}
      }
    },
    "running_costs": {
      "description": "C-BP6 — at least five categories, each with an annual projection per lifecycle year.",
      "type": "array",
      "minItems": 5,
      "items": {
        "type": "object",
        "required": ["category", "annual", "source"],
        "properties": {
          "category": {"type": "string"},
          "annual": {"type": "array", "minItems": 1, "items": {"type": "number"}},
          "source": {"type": "string"}
        }
      }
    },
    "marketing_strategy": {
      "description": "C-BP7 — all five fields required (REQ-BUS-005).",
      "type": "object",
      "required": ["target_audience", "go_to_market", "pricing", "positioning", "channels"],
      "properties": {
        "target_audience": {"type": "string", "minLength": 20},
        "go_to_market": {"type": "string", "minLength": 20},
        "pricing": {"type": "string", "minLength": 20},
        "positioning": {"type": "string", "minLength": 20},
        "channels": {"type": "array", "minItems": 2, "items": {"type": "string"}}
      }
    },
    "revenue_model": {
      "description": "C-BP8 — at least one use case, each with a projection and its assumptions.",
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["use_case", "unit", "unit_revenue", "year_projection", "assumptions"],
        "properties": {
          "use_case": {"type": "string"},
          "unit": {"type": "string"},
          "unit_revenue": {"type": "number"},
          "year_projection": {"type": "array", "minItems": 1, "items": {"type": "number"}},
          "assumptions": {"type": "array", "minItems": 1, "items": {"type": "string"}}
        }
      }
    },
    "areas_of_concern": {
      "description": "C-BP9 — at least three risks, each with likelihood, impact, mitigation and an early warning indicator.",
      "type": "array",
      "minItems": 3,
      "items": {
        "type": "object",
        "required": ["concern", "likelihood", "impact", "mitigation", "early_warning"],
        "properties": {
          "concern": {"type": "string"},
          "likelihood": {"type": "string", "enum": ["Rare", "Unlikely", "Possible", "Likely", "Almost certain"]},
          "impact": {"type": "string", "enum": ["Negligible", "Minor", "Moderate", "Major", "Severe"]},
          "mitigation": {"type": "string"},
          "early_warning": {"type": "string"},
          "register_id": {"type": "string"}
        }
      }
    },
    "efficiency_audit": {
      "description": "C-BP10 — SP07. Alternatives researched, build-vs-buy decided, recommendation justified (REQ-BUS-008).",
      "type": "object",
      "required": ["alternatives", "build_vs_buy", "recommendation", "date"],
      "properties": {
        "alternatives": {
          "type": "array", "minItems": 2,
          "items": {
            "type": "object",
            "required": ["option", "cost", "time", "risk", "verdict"],
            "properties": {
              "option": {"type": "string"}, "cost": {"type": "string"},
              "time": {"type": "string"}, "risk": {"type": "string"},
              "verdict": {"type": "string"}
            }
          }
        },
        "build_vs_buy": {"type": "string", "minLength": 20},
        "recommendation": {"type": "string", "minLength": 20},
        "date": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"}
      }
    },
    "value_validation": {
      "description": "C-BP11 — verdict, justification, conditions (REQ-BUS-010).",
      "type": "object",
      "required": ["verdict", "justification", "conditions"],
      "properties": {
        "verdict": {"type": "string", "enum": ["PROCEED", "PROCEED WITH CONDITIONS", "DO NOT PROCEED", "DECISION OWED BY OWNER"]},
        "justification": {"type": "string", "minLength": 40},
        "conditions": {"type": "array", "items": {"type": "string"}},
        "what_would_change_this": {"type": "array", "items": {"type": "string"}}
      }
    },
    "footer": {
      "description": "C-BP12 — provenance.",
      "type": "object",
      "required": ["generated_from", "generator_version", "produced_by", "verified_by"],
      "properties": {
        "generated_from": {"type": "string"},
        "generator_version": {"type": "string"},
        "produced_by": {"type": "string"},
        "verified_by": {"type": "string"}
      }
    }
  }
}
