{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://altheia.local/schemas/altheia-profile-multisector-2.5.schema.json",
  "title": "ALTHEIA Canonical Synthetic Profile Multisector 2.5",
  "description": "Contrato canónico con Sector Pack y Brand Pack versionados, huella operativa de marca y vista bancaria 2.0 preservada.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "profile_uuid",
    "generation_id",
    "profile_id",
    "synthetic",
    "country",
    "language",
    "created_at",
    "updated_at",
    "sector_context",
    "brand_context",
    "brand_relationship",
    "sector_data",
    "migration_metadata",
    "base_data",
    "dimensions",
    "dimension_evidence",
    "archetyping",
    "context_memory",
    "generation_metadata",
    "field_provenance",
    "quality_check",
    "governance"
  ],
  "properties": {
    "schema_version": {
      "const": "altheia_profile_2.5"
    },
    "profile_uuid": {
      "type": "string",
      "format": "uuid"
    },
    "generation_id": {
      "$ref": "#/$defs/nonEmptyString"
    },
    "profile_id": {
      "type": "string",
      "pattern": "^SP-[0-9]{8}$"
    },
    "synthetic": {
      "const": true
    },
    "country": {
      "type": "string",
      "pattern": "^[A-Z]{2}$"
    },
    "language": {
      "type": "string",
      "pattern": "^[a-z]{2,3}(?:-[A-Z]{2})?$"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "sector_context": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sector_id", "sector_name", "sector_pack_id", "sector_pack_version", "sector_pack_schema", "core_contract", "dimension_semantics_hash"],
      "properties": {
        "sector_id": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"},
        "sector_name": {"$ref": "#/$defs/nonEmptyString"},
        "sector_pack_id": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*@[0-9]+\\.[0-9]+\\.[0-9]+$"},
        "sector_pack_version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
        "sector_pack_schema": {"const": "altheia_sector_pack_1.0"},
        "core_contract": {"const": "altheia_profile_core_2.5"},
        "dimension_semantics_hash": {"type": "string", "pattern": "^fnv1a-[a-f0-9]{8}$"}
      }
    },
    "brand_context": {
      "type": "object",
      "additionalProperties": false,
      "required": ["brand_id", "brand_name", "client_id", "client_name", "brand_pack_id", "brand_pack_version", "brand_pack_schema", "brand_pack_hash", "sector_pack_id", "dimension_semantics_hash"],
      "properties": {
        "brand_id": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"},
        "brand_name": {"$ref": "#/$defs/nonEmptyString"},
        "client_id": {"type": ["string", "null"]},
        "client_name": {"type": ["string", "null"]},
        "brand_pack_id": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*/[a-z0-9]+(?:-[a-z0-9]+)*@[0-9]+\\.[0-9]+\\.[0-9]+$"},
        "brand_pack_version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
        "brand_pack_schema": {"const": "altheia_brand_pack_1.0"},
        "brand_pack_hash": {"type": "string", "pattern": "^fnv1a-[a-f0-9]{8}$"},
        "sector_pack_id": {"type": "string"},
        "dimension_semantics_hash": {"type": "string", "pattern": "^fnv1a-[a-f0-9]{8}$"}
      }
    },
    "brand_relationship": {
      "type": "object",
      "additionalProperties": false,
      "required": ["target_brand", "status", "role", "relationship_types", "tenure_years", "intensity", "other_providers", "source_status"],
      "properties": {
        "target_brand": {"$ref": "#/$defs/nonEmptyString"},
        "status": {"enum": ["customer", "non_customer", "prospect", "former_customer"]},
        "role": {"enum": ["primary", "secondary", "shared", "unknown"]},
        "relationship_types": {"type": "array", "items": {"$ref": "#/$defs/nonEmptyString"}, "uniqueItems": true},
        "tenure_years": {"type": "number", "minimum": 0},
        "intensity": {"enum": ["none", "active", "primary", "unknown"]},
        "other_providers": {"type": "array", "items": {"$ref": "#/$defs/nonEmptyString"}, "uniqueItems": true},
        "source_status": {"$ref": "#/$defs/nonEmptyString"}
      }
    },
    "sector_data": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sector_id", "offer_catalog_version", "owned_offers", "lifecycle_stage", "channels", "decision_contexts", "legacy_data_paths"],
      "properties": {
        "sector_id": {"type": "string"},
        "offer_catalog_version": {"type": ["string", "null"]},
        "owned_offers": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
        "lifecycle_stage": {"type": "string"},
        "channels": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
        "decision_contexts": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
        "legacy_data_paths": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
        "profile_contract": {"type": "string"},
        "profile_fields": {
          "type": "object",
          "additionalProperties": {
            "type": ["string", "number", "boolean", "array", "null"],
            "items": {"type": ["string", "number", "boolean"]}
          }
        }
      }
    },
    "migration_metadata": {
      "type": "object",
      "additionalProperties": false,
      "required": ["adapter_version", "source_schema_version", "migration_type", "migrated_at", "legacy_view_preserved"],
      "properties": {
        "adapter_version": {"const": "altheia_multisector_runtime_2.5"},
        "source_schema_version": {"enum": ["altheia_profile_2.0", "altheia_profile_2.4"]},
        "migration_type": {"enum": ["generated_as_2.5", "altheia_profile_2.0_to_2.5", "altheia_profile_2.4_to_2.5"]},
        "migrated_at": {"type": "string", "format": "date-time"},
        "legacy_view_preserved": {"const": true}
      }
    },
    "base_data": {
      "$ref": "#/$defs/baseData"
    },
    "dimensions": {
      "$ref": "#/$defs/dimensions"
    },
    "dimension_evidence": {
      "$ref": "#/$defs/dimensionEvidence"
    },
    "archetyping": {
      "$ref": "#/$defs/archetyping"
    },
    "context_memory": {
      "$ref": "#/$defs/contextMemory"
    },
    "generation_metadata": {
      "$ref": "#/$defs/generationMetadata"
    },
    "field_provenance": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/provenanceRecord"
      }
    },
    "quality_check": {
      "$ref": "#/$defs/qualityCheck"
    },
    "governance": {
      "$ref": "#/$defs/governance"
    },
    "extensions": {
      "type": "object",
      "description": "Extensiones namespaced. No sustituyen campos canónicos.",
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9_]*\\.[a-z][a-z0-9_.-]*$"
      },
      "properties": {
        "altheia.voice_style": {
          "type": "object",
          "description": "Capa editorial independiente. Modula únicamente la forma de redactar verbatims, nunca su contenido ni la evidencia conductual.",
          "additionalProperties": false,
          "required": ["schema_version", "formality", "source"],
          "properties": {
            "schema_version": {
              "const": "altheia_voice_style_1.0"
            },
            "formality": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10,
              "description": "1 = máxima coloquialidad; 10 = máxima formalidad. Solo afecta a la redacción de answer."
            },
            "source": {
              "type": "string",
              "enum": ["generated", "manual", "imported", "defaulted"]
            }
          }
        }
      },
      "additionalProperties": true
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "base_data": {
            "properties": {
              "banking_relationship": {
                "properties": {
                  "brand_customer": {
                    "const": false
                  }
                },
                "required": ["brand_customer"]
              }
            },
            "required": ["banking_relationship"]
          }
        },
        "required": ["base_data"]
      },
      "then": {
        "properties": {
          "base_data": {
            "properties": {
              "banking_relationship": {
                "properties": {
                  "years_as_customer": {
                    "const": 0
                  },
                  "main_bank": {
                    "const": false
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "base_data": {
            "properties": {
              "banking_relationship": {
                "properties": {
                  "relationship_status": {
                    "const": "customer"
                  }
                },
                "required": ["relationship_status"]
              }
            },
            "required": ["banking_relationship"]
          }
        },
        "required": ["base_data"]
      },
      "then": {
        "properties": {
          "base_data": {
            "properties": {
              "banking_relationship": {
                "properties": {
                  "brand_customer": {
                    "const": true
                  }
                }
              }
            }
          }
        }
      },
      "else": {
        "properties": {
          "base_data": {
            "properties": {
              "banking_relationship": {
                "properties": {
                  "brand_customer": {
                    "const": false
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "base_data": {
            "properties": {
              "banking_relationship": {
                "properties": {
                  "relationship_status": {
                    "const": "unbanked"
                  }
                },
                "required": ["relationship_status"]
              }
            },
            "required": ["banking_relationship"]
          }
        },
        "required": ["base_data"]
      },
      "then": {
        "properties": {
          "base_data": {
            "properties": {
              "banking_relationship": {
                "properties": {
                  "primary_bank_name": {
                    "type": "null"
                  },
                  "years_with_primary_bank": {
                    "const": 0
                  },
                  "uses_multiple_banks": {
                    "const": false
                  },
                  "other_banks": {
                    "maxItems": 0
                  }
                }
              },
              "financial_products": {
                "properties": {
                  "current_account": { "const": false },
                  "savings_account": { "const": false },
                  "credit_card": { "const": false },
                  "mortgage": { "const": false },
                  "personal_loan": { "const": false },
                  "deposit_account": { "const": false },
                  "pension_plan": { "const": false },
                  "insurance": { "maxItems": 0 },
                  "investment_products": { "maxItems": 0 },
                  "other_products": { "maxItems": 0 }
                }
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "nonEmptyString": {
      "type": "string",
      "minLength": 1,
      "pattern": ".*\\S.*"
    },
    "nullableNonEmptyString": {
      "oneOf": [
        {
          "$ref": "#/$defs/nonEmptyString"
        },
        {
          "type": "null"
        }
      ]
    },
    "score1to10": {
      "type": "integer",
      "minimum": 1,
      "maximum": 10
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "frequency": {
      "type": "string",
      "enum": [
        "never",
        "less_than_monthly",
        "monthly",
        "weekly",
        "several_times_week",
        "daily"
      ]
    },
    "lowMediumHigh": {
      "type": "string",
      "enum": ["low", "medium", "high"]
    },
    "stringArray": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/nonEmptyString"
      }
    },
    "insuranceProduct": {
      "type": "string",
      "enum": [
        "home",
        "auto",
        "life",
        "health",
        "dental",
        "travel",
        "accident",
        "disability",
        "income_protection",
        "unemployment_protection",
        "loan_payment_protection",
        "mortgage_payment_protection",
        "funeral",
        "pet",
        "mobile_device",
        "cyber",
        "legal_protection",
        "personal_liability",
        "rental_default",
        "long_term_care",
        "savings_life",
        "unit_linked",
        "business",
        "professional_liability"
      ]
    },
    "investmentProduct": {
      "type": "string",
      "enum": [
        "individual_stocks",
        "etfs",
        "index_funds",
        "active_mutual_funds",
        "money_market_funds",
        "mixed_funds",
        "target_date_funds",
        "government_bonds",
        "corporate_bonds",
        "high_yield_bonds",
        "green_bonds",
        "treasury_bills",
        "reits",
        "real_estate_funds",
        "commodities",
        "precious_metals",
        "structured_products",
        "certificates",
        "options",
        "futures",
        "warrants",
        "forex",
        "managed_portfolio",
        "robo_advisor_portfolio",
        "discretionary_portfolio",
        "private_equity",
        "venture_capital",
        "crowdfunding",
        "p2p_lending",
        "cryptoassets"
      ]
    },
    "otherFinancialProduct": {
      "type": "string",
      "enum": [
        "debit_card",
        "prepaid_card",
        "charge_card",
        "payroll_account",
        "youth_account",
        "joint_account",
        "business_account",
        "foreign_currency_account",
        "overdraft",
        "credit_line",
        "revolving_credit",
        "auto_loan",
        "student_loan",
        "business_loan",
        "leasing",
        "factoring",
        "payment_wallet",
        "buy_now_pay_later",
        "remittance_service",
        "international_transfer_service",
        "safe_deposit_box",
        "brokerage_account",
        "custody_account",
        "financial_advisory",
        "wealth_management",
        "private_banking",
        "merchant_services",
        "payment_terminal"
      ]
    },
    "insuranceProductArray": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/insuranceProduct"
      }
    },
    "investmentProductArray": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/investmentProduct"
      }
    },
    "otherFinancialProductArray": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/otherFinancialProduct"
      }
    },
    "baseData": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "demographic",
        "personal_situation",
        "professional_situation",
        "financial_situation",
        "financial_products",
        "banking_relationship",
        "digital_behavior",
        "observable_financial_behavior"
      ],
      "properties": {
        "demographic": {
          "$ref": "#/$defs/demographic"
        },
        "personal_situation": {
          "$ref": "#/$defs/personalSituation"
        },
        "professional_situation": {
          "$ref": "#/$defs/professionalSituation"
        },
        "financial_situation": {
          "$ref": "#/$defs/financialSituation"
        },
        "financial_products": {
          "$ref": "#/$defs/financialProducts"
        },
        "banking_relationship": {
          "$ref": "#/$defs/bankingRelationship"
        },
        "digital_behavior": {
          "$ref": "#/$defs/digitalBehavior"
        },
        "observable_financial_behavior": {
          "$ref": "#/$defs/observableFinancialBehavior"
        }
      }
    },
    "demographic": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "age",
        "gender",
        "province",
        "city_size",
        "nationality",
        "education_level"
      ],
      "properties": {
        "age": {
          "type": "integer",
          "minimum": 18,
          "maximum": 100
        },
        "gender": {
          "type": "string",
          "enum": [
            "female",
            "male",
            "non_binary",
            "self_described",
            "not_specified"
          ]
        },
        "province": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "city_size": {
          "type": "string",
          "enum": ["rural", "small", "medium", "large", "metropolitan"]
        },
        "nationality": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "education_level": {
          "type": "string",
          "enum": [
            "no_formal_education",
            "primary",
            "secondary",
            "vocational",
            "bachelor",
            "master",
            "doctorate",
            "other",
            "not_specified"
          ]
        }
      }
    },
    "personalSituation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "marital_status",
        "children",
        "dependents",
        "household_size",
        "housing_status",
        "life_stage"
      ],
      "properties": {
        "marital_status": {
          "type": "string",
          "enum": [
            "single",
            "partnered",
            "married",
            "separated",
            "divorced",
            "widowed",
            "not_specified"
          ]
        },
        "children": {
          "type": "integer",
          "minimum": 0,
          "maximum": 20
        },
        "dependents": {
          "type": "integer",
          "minimum": 0,
          "maximum": 20
        },
        "household_size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 25
        },
        "housing_status": {
          "type": "string",
          "enum": [
            "owner_without_mortgage",
            "owner_with_mortgage",
            "renting",
            "living_with_family",
            "social_housing",
            "other"
          ]
        },
        "life_stage": {
          "type": "string",
          "enum": [
            "first_salary_or_early_career",
            "professional_growth",
            "family_building",
            "midlife_consolidation",
            "pre_retirement",
            "retirement",
            "life_transition"
          ]
        }
      }
    },
    "professionalSituation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "employment_status",
        "employment_type",
        "occupation",
        "industry",
        "seniority",
        "annual_income",
        "income_currency",
        "income_stability"
      ],
      "properties": {
        "employment_status": {
          "type": "string",
          "enum": [
            "employed",
            "self_employed",
            "unemployed",
            "student",
            "retired",
            "homemaker",
            "unable_to_work",
            "other"
          ]
        },
        "employment_type": {
          "oneOf": [
            {
              "type": "string",
              "enum": [
                "permanent",
                "temporary",
                "freelance",
                "entrepreneur",
                "civil_servant",
                "seasonal",
                "part_time",
                "other"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "occupation": {
          "$ref": "#/$defs/nullableNonEmptyString"
        },
        "industry": {
          "$ref": "#/$defs/nullableNonEmptyString"
        },
        "seniority": {
          "oneOf": [
            {
              "type": "string",
              "enum": ["junior", "mid", "senior", "executive"]
            },
            {
              "type": "null"
            }
          ]
        },
        "annual_income": {
          "type": "number",
          "minimum": 0
        },
        "income_currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "income_stability": {
          "$ref": "#/$defs/score1to10"
        }
      }
    },
    "financialSituation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "monthly_net_income",
        "monthly_expenses",
        "monthly_savings",
        "estimated_liquid_savings",
        "estimated_investment_assets",
        "estimated_total_financial_assets",
        "estimated_total_debt",
        "debt_level",
        "wealth_level",
        "liquidity",
        "financial_complexity",
        "wealth_band"
      ],
      "properties": {
        "monthly_net_income": {
          "type": "number",
          "minimum": 0
        },
        "monthly_expenses": {
          "type": "number",
          "minimum": 0
        },
        "monthly_savings": {
          "type": "number",
          "minimum": 0
        },
        "estimated_liquid_savings": {
          "type": "number",
          "minimum": 0
        },
        "estimated_investment_assets": {
          "type": "number",
          "minimum": 0
        },
        "estimated_total_financial_assets": {
          "type": "number",
          "minimum": 0
        },
        "estimated_total_debt": {
          "type": "number",
          "minimum": 0
        },
        "debt_level": {
          "$ref": "#/$defs/score1to10"
        },
        "wealth_level": {
          "$ref": "#/$defs/score1to10"
        },
        "liquidity": {
          "$ref": "#/$defs/score1to10"
        },
        "financial_complexity": {
          "$ref": "#/$defs/score1to10"
        },
        "wealth_band": {
          "type": "string",
          "enum": ["vulnerable", "emerging", "medium", "affluent", "high"]
        }
      }
    },
    "financialProducts": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "catalog_version",
        "current_account",
        "savings_account",
        "credit_card",
        "mortgage",
        "personal_loan",
        "deposit_account",
        "pension_plan",
        "insurance",
        "investment_products",
        "other_products"
      ],
      "properties": {
        "catalog_version": { "const": "altheia_financial_products_2.0" },
        "current_account": { "type": "boolean" },
        "savings_account": { "type": "boolean" },
        "credit_card": { "type": "boolean" },
        "mortgage": { "type": "boolean" },
        "personal_loan": { "type": "boolean" },
        "deposit_account": { "type": "boolean" },
        "pension_plan": { "type": "boolean" },
        "insurance": { "$ref": "#/$defs/insuranceProductArray" },
        "investment_products": { "$ref": "#/$defs/investmentProductArray" },
        "other_products": { "$ref": "#/$defs/otherFinancialProductArray" }
      }
    },
    "bankingRelationship": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "target_brand",
        "relationship_status",
        "brand_customer",
        "years_as_customer",
        "main_bank",
        "primary_bank_name",
        "years_with_primary_bank",
        "uses_multiple_banks",
        "other_banks"
      ],
      "properties": {
        "target_brand": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "relationship_status": {
          "type": "string",
          "enum": ["customer", "former_customer", "prospect", "unbanked"]
        },
        "brand_customer": {
          "type": "boolean"
        },
        "years_as_customer": {
          "type": "integer",
          "minimum": 0,
          "maximum": 82
        },
        "main_bank": {
          "type": "boolean"
        },
        "primary_bank_name": {
          "$ref": "#/$defs/nullableNonEmptyString"
        },
        "years_with_primary_bank": {
          "type": "integer",
          "minimum": 0,
          "maximum": 82
        },
        "uses_multiple_banks": {
          "type": "boolean"
        },
        "other_banks": {
          "$ref": "#/$defs/stringArray"
        }
      },
      "not": {
        "required": ["ing_customer"]
      }
    },
    "digitalBehavior": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mobile_app_usage",
        "web_usage",
        "preferred_channel",
        "digital_skills",
        "self_service_preference",
        "ai_usage",
        "online_purchase_frequency",
        "biometric_auth_comfort"
      ],
      "properties": {
        "mobile_app_usage": {
          "$ref": "#/$defs/frequency"
        },
        "web_usage": {
          "$ref": "#/$defs/frequency"
        },
        "preferred_channel": {
          "type": "string",
          "enum": [
            "mobile_app",
            "web",
            "branch",
            "phone",
            "chat",
            "video_call",
            "advisor",
            "mixed"
          ]
        },
        "digital_skills": {
          "$ref": "#/$defs/score1to10"
        },
        "self_service_preference": {
          "$ref": "#/$defs/score1to10"
        },
        "ai_usage": {
          "$ref": "#/$defs/score1to10"
        },
        "online_purchase_frequency": {
          "$ref": "#/$defs/frequency"
        },
        "biometric_auth_comfort": {
          "$ref": "#/$defs/score1to10"
        }
      }
    },
    "observableFinancialBehavior": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "reviews_investments_monthly",
        "compares_prices_before_buying",
        "reads_financial_content",
        "contacts_support_frequency",
        "switches_provider_frequency",
        "budgeting_frequency",
        "saves_regularly",
        "missed_payment_frequency",
        "comparison_intensity",
        "decision_time_preference"
      ],
      "properties": {
        "reviews_investments_monthly": { "type": "boolean" },
        "compares_prices_before_buying": { "type": "boolean" },
        "reads_financial_content": { "type": "boolean" },
        "contacts_support_frequency": { "$ref": "#/$defs/lowMediumHigh" },
        "switches_provider_frequency": { "$ref": "#/$defs/lowMediumHigh" },
        "budgeting_frequency": { "$ref": "#/$defs/frequency" },
        "saves_regularly": { "type": "boolean" },
        "missed_payment_frequency": {
          "type": "string",
          "enum": ["never", "rare", "occasional", "frequent"]
        },
        "comparison_intensity": { "$ref": "#/$defs/score1to10" },
        "decision_time_preference": {
          "type": "string",
          "enum": ["fast", "balanced", "deliberate"]
        }
      }
    },
    "dimensions": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "D01", "D02", "D03", "D04", "D05", "D06", "D07", "D08", "D09",
        "D10", "D11", "D12", "D13", "D14", "D15", "D16", "D17", "D18", "D19",
        "D20", "D21", "D22", "D23", "D24", "D25", "D26", "D27", "D28", "D29",
        "D30", "D31", "D32", "D33", "D34", "D35", "D36", "D37", "D38", "D39",
        "D40", "D41", "D42", "D43", "D44", "D45"
      ],
      "properties": {
        "D01": { "$ref": "#/$defs/score1to10", "description": "Alfabetización financiera" },
        "D02": { "$ref": "#/$defs/score1to10", "description": "Alfabetización digital" },
        "D03": { "$ref": "#/$defs/score1to10", "description": "Autonomía digital" },
        "D04": { "$ref": "#/$defs/score1to10", "description": "Capacidad de planificación" },
        "D05": { "$ref": "#/$defs/score1to10", "description": "Capacidad de aprendizaje" },
        "D06": { "$ref": "#/$defs/score1to10", "description": "Orientación al ahorro" },
        "D07": { "$ref": "#/$defs/score1to10", "description": "Orientación al crecimiento patrimonial" },
        "D08": { "$ref": "#/$defs/score1to10", "description": "Necesidad de seguridad" },
        "D09": { "$ref": "#/$defs/score1to10", "description": "Necesidad de control" },
        "D10": { "$ref": "#/$defs/score1to10", "description": "Necesidad de simplicidad" },
        "D11": { "$ref": "#/$defs/score1to10", "description": "Tolerancia al riesgo" },
        "D12": { "$ref": "#/$defs/score1to10", "description": "Ansiedad financiera" },
        "D13": { "$ref": "#/$defs/score1to10", "description": "Sensibilidad al precio" },
        "D14": { "$ref": "#/$defs/score1to10", "description": "Confianza en instituciones financieras" },
        "D15": { "$ref": "#/$defs/score1to10", "description": "Necesidad de asesoramiento" },
        "D16": { "$ref": "#/$defs/score1to10", "description": "Profundidad de investigación" },
        "D17": { "$ref": "#/$defs/score1to10", "description": "Impulsividad" },
        "D18": { "$ref": "#/$defs/score1to10", "description": "Apertura a la innovación" },
        "D19": { "$ref": "#/$defs/score1to10", "description": "Influenciabilidad" },
        "D20": { "$ref": "#/$defs/score1to10", "description": "Lealtad" },
        "D21": { "$ref": "#/$defs/score1to10", "description": "Confianza en la marca focal" },
        "D22": { "$ref": "#/$defs/score1to10", "description": "Afinidad con la marca focal" },
        "D23": { "$ref": "#/$defs/score1to10", "description": "Tolerancia a la fricción" },
        "D24": { "$ref": "#/$defs/score1to10", "description": "Preferencia de autoservicio" },
        "D25": { "$ref": "#/$defs/score1to10", "description": "Propensión a recomendar la marca focal" },
        "D26": { "$ref": "#/$defs/score1to10", "description": "Estabilidad vital" },
        "D27": { "$ref": "#/$defs/score1to10", "description": "Presión económica percibida" },
        "D28": { "$ref": "#/$defs/score1to10", "description": "Horizonte temporal" },
        "D29": { "$ref": "#/$defs/score1to10", "description": "Tolerancia a la incertidumbre" },
        "D30": { "$ref": "#/$defs/score1to10", "description": "Sobrecarga informativa" },
        "D31": { "$ref": "#/$defs/score1to10", "description": "Pensamiento analítico" },
        "D32": { "$ref": "#/$defs/score1to10", "description": "Influencia familiar" },
        "D33": { "$ref": "#/$defs/score1to10", "description": "Sensibilidad social" },
        "D34": { "$ref": "#/$defs/score1to10", "description": "Confianza en IA" },
        "D35": { "$ref": "#/$defs/score1to10", "description": "Disposición al cambio" },
        "D36": { "$ref": "#/$defs/score1to10", "description": "Aversión a la pérdida" },
        "D37": { "$ref": "#/$defs/score1to10", "description": "Sesgo del presente" },
        "D38": { "$ref": "#/$defs/score1to10", "description": "Sesgo de statu quo" },
        "D39": { "$ref": "#/$defs/score1to10", "description": "Exceso de confianza" },
        "D40": { "$ref": "#/$defs/score1to10", "description": "Susceptibilidad al anclaje" },
        "D41": { "$ref": "#/$defs/score1to10", "description": "Parálisis por exceso de opciones" },
        "D42": { "$ref": "#/$defs/score1to10", "description": "Susceptibilidad a la prueba social" },
        "D43": { "$ref": "#/$defs/score1to10", "description": "Contabilidad mental" },
        "D44": { "$ref": "#/$defs/score1to10", "description": "Efecto default" },
        "D45": { "$ref": "#/$defs/score1to10", "description": "Efecto dotación" }
      }
    },
    "dimensionEvidenceItem": {
      "type": "object",
      "additionalProperties": false,
      "required": ["method", "confidence", "evidence", "rules_version", "generated_at"],
      "properties": {
        "method": {
          "type": "string",
          "enum": ["rule_based", "model_generated", "calibrated", "imported", "hybrid"]
        },
        "confidence": {
          "$ref": "#/$defs/confidence"
        },
        "evidence": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/nonEmptyString"
          }
        },
        "rules_version": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "generated_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "dimensionEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["scale", "coverage_count", "items"],
      "properties": {
        "scale": {
          "const": "1-10"
        },
        "coverage_count": {
          "const": 45
        },
        "items": {
          "type": "object",
          "minProperties": 45,
          "maxProperties": 45,
          "propertyNames": {
            "pattern": "^D(?:0[1-9]|[1-3][0-9]|4[0-5])$"
          },
          "patternProperties": {
            "^D(?:0[1-9]|[1-3][0-9]|4[0-5])$": {
              "$ref": "#/$defs/dimensionEvidenceItem"
            }
          },
          "additionalProperties": false
        }
      }
    },
    "archetypeAssignment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "domain",
        "subdomain",
        "confidence",
        "evidence",
        "counterevidence",
        "assignment_type"
      ],
      "properties": {
        "id": { "$ref": "#/$defs/nonEmptyString" },
        "name": { "$ref": "#/$defs/nonEmptyString" },
        "domain": { "$ref": "#/$defs/nonEmptyString" },
        "subdomain": { "$ref": "#/$defs/nonEmptyString" },
        "confidence": { "$ref": "#/$defs/confidence" },
        "evidence": {
          "type": "array",
          "minItems": 2,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/nonEmptyString" }
        },
        "counterevidence": {
          "type": "array",
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/nonEmptyString" }
        },
        "assignment_type": {
          "type": "string",
          "enum": ["primary", "secondary"]
        }
      }
    },
    "archetyping": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "taxonomy_version",
        "classifier_version",
        "classified_at",
        "assignments"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": ["not_classified", "classified", "review"]
        },
        "taxonomy_version": {
          "$ref": "#/$defs/nullableNonEmptyString"
        },
        "classifier_version": {
          "$ref": "#/$defs/nullableNonEmptyString"
        },
        "classified_at": {
          "oneOf": [
            { "type": "string", "format": "date-time" },
            { "type": "null" }
          ]
        },
        "assignments": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/archetypeAssignment"
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "status": { "const": "classified" }
            },
            "required": ["status"]
          },
          "then": {
            "properties": {
              "taxonomy_version": { "$ref": "#/$defs/nonEmptyString" },
              "classifier_version": { "$ref": "#/$defs/nonEmptyString" },
              "classified_at": { "type": "string", "format": "date-time" },
              "assignments": { "minItems": 1 }
            }
          }
        },
        {
          "if": {
            "properties": {
              "status": { "const": "not_classified" }
            },
            "required": ["status"]
          },
          "then": {
            "properties": {
              "taxonomy_version": { "type": "null" },
              "classifier_version": { "type": "null" },
              "classified_at": { "type": "null" },
              "assignments": { "maxItems": 0 }
            }
          }
        }
      ]
    },
    "goal": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "priority", "status", "started_at", "target_date", "evidence"],
      "properties": {
        "id": { "$ref": "#/$defs/nonEmptyString" },
        "type": { "$ref": "#/$defs/nonEmptyString" },
        "priority": { "type": "string", "enum": ["low", "medium", "high"] },
        "status": { "type": "string", "enum": ["active", "paused", "achieved", "abandoned"] },
        "started_at": { "type": "string", "format": "date" },
        "target_date": {
          "oneOf": [
            { "type": "string", "format": "date" },
            { "type": "null" }
          ]
        },
        "evidence": { "$ref": "#/$defs/stringArray" }
      }
    },
    "contextEvent": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "occurred_at", "impact", "status", "evidence"],
      "properties": {
        "id": { "$ref": "#/$defs/nonEmptyString" },
        "type": { "$ref": "#/$defs/nonEmptyString" },
        "occurred_at": { "type": "string", "format": "date" },
        "impact": { "type": "string", "enum": ["low", "medium", "high"] },
        "status": { "type": "string", "enum": ["active", "resolved", "inactive"] },
        "evidence": { "$ref": "#/$defs/stringArray" }
      }
    },
    "researchRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "study_id", "interaction_type", "occurred_at", "result_reference"],
      "properties": {
        "id": { "$ref": "#/$defs/nonEmptyString" },
        "study_id": { "$ref": "#/$defs/nonEmptyString" },
        "interaction_type": {
          "type": "string",
          "enum": ["synthetic_interview", "survey", "ux_test", "concept_test", "other"]
        },
        "occurred_at": { "type": "string", "format": "date-time" },
        "result_reference": { "$ref": "#/$defs/nonEmptyString" }
      }
    },
    "contextMemory": {
      "type": "object",
      "additionalProperties": false,
      "required": ["active_goals", "life_events", "financial_events", "research_history"],
      "properties": {
        "active_goals": {
          "type": "array",
          "items": { "$ref": "#/$defs/goal" }
        },
        "life_events": {
          "type": "array",
          "items": { "$ref": "#/$defs/contextEvent" }
        },
        "financial_events": {
          "type": "array",
          "items": { "$ref": "#/$defs/contextEvent" }
        },
        "research_history": {
          "type": "array",
          "items": { "$ref": "#/$defs/researchRecord" }
        }
      }
    },
    "generationMetadata": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "generator_version",
        "schema_version",
        "seed",
        "generation_mode",
        "cohort_id",
        "cohort_label",
        "profile_sequence_in_generation",
        "source_package",
        "generated_at"
        ,"sector_pack_id"
        ,"sector_pack_version"
        ,"dimension_semantics_hash"
        ,"brand_pack_id"
        ,"brand_pack_version"
        ,"brand_pack_hash"
        ,"target_brand"
      ],
      "properties": {
        "generator_version": { "$ref": "#/$defs/nonEmptyString" },
        "schema_version": { "const": "altheia_profile_2.5" },
        "seed": {
          "oneOf": [
            { "type": "integer" },
            { "$ref": "#/$defs/nonEmptyString" }
          ]
        },
        "generation_mode": {
          "type": "string",
          "enum": ["balanced", "natural", "quota", "imported", "custom"]
        },
        "cohort_id": { "$ref": "#/$defs/nonEmptyString" },
        "cohort_label": { "$ref": "#/$defs/nonEmptyString" },
        "profile_sequence_in_generation": {
          "type": "integer",
          "minimum": 1
        },
        "source_package": { "$ref": "#/$defs/nonEmptyString" },
        "generated_at": { "type": "string", "format": "date-time" },
        "sector_pack_id": { "$ref": "#/$defs/nonEmptyString" },
        "sector_pack_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
        "dimension_semantics_hash": { "type": "string", "pattern": "^fnv1a-[a-f0-9]{8}$" },
        "brand_pack_id": { "$ref": "#/$defs/nonEmptyString" },
        "brand_pack_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
        "brand_pack_hash": { "type": "string", "pattern": "^fnv1a-[a-f0-9]{8}$" },
        "target_brand": { "$ref": "#/$defs/nonEmptyString" }
      }
    },
    "provenanceRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": ["field_path", "source_type", "source_reference", "confidence", "created_at"],
      "properties": {
        "field_path": {
          "type": "string",
          "pattern": "^/(?:[^/~]|~0|~1)+(?:/(?:[^/~]|~0|~1)+)*$"
        },
        "source_type": {
          "type": "string",
          "enum": ["generated", "rule_derived", "model_derived", "imported", "manual_override"]
        },
        "source_reference": { "$ref": "#/$defs/nonEmptyString" },
        "confidence": { "$ref": "#/$defs/confidence" },
        "created_at": { "type": "string", "format": "date-time" }
      }
    },
    "qualityIssue": {
      "type": "object",
      "additionalProperties": false,
      "required": ["code", "field_path", "message", "severity"],
      "properties": {
        "code": { "$ref": "#/$defs/nonEmptyString" },
        "field_path": {
          "type": "string",
          "pattern": "^/(?:[^/~]|~0|~1)+(?:/(?:[^/~]|~0|~1)+)*$"
        },
        "message": { "$ref": "#/$defs/nonEmptyString" },
        "severity": { "type": "string", "enum": ["warning", "error"] }
      }
    },
    "qualityCheck": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "validator_version",
        "validated_at",
        "completeness_score",
        "dimension_coverage",
        "errors",
        "warnings"
      ],
      "properties": {
        "status": { "type": "string", "enum": ["passed", "warning", "failed"] },
        "validator_version": { "$ref": "#/$defs/nonEmptyString" },
        "validated_at": { "type": "string", "format": "date-time" },
        "completeness_score": { "$ref": "#/$defs/confidence" },
        "dimension_coverage": { "type": "integer", "minimum": 0, "maximum": 45 },
        "errors": {
          "type": "array",
          "items": { "$ref": "#/$defs/qualityIssue" }
        },
        "warnings": {
          "type": "array",
          "items": { "$ref": "#/$defs/qualityIssue" }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": { "status": { "const": "passed" } },
            "required": ["status"]
          },
          "then": {
            "properties": {
              "completeness_score": { "const": 1 },
              "dimension_coverage": { "const": 45 },
              "errors": { "maxItems": 0 }
            }
          }
        }
      ]
    },
    "governance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "contains_real_personal_data",
        "synthetic_disclosure",
        "intended_uses",
        "prohibited_uses",
        "risk_tier",
        "review_status"
      ],
      "properties": {
        "contains_real_personal_data": { "const": false },
        "synthetic_disclosure": { "const": true },
        "intended_uses": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/nonEmptyString" }
        },
        "prohibited_uses": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/nonEmptyString" }
        },
        "risk_tier": { "type": "string", "enum": ["low", "medium", "high"] },
        "review_status": { "type": "string", "enum": ["approved", "review_required", "blocked"] }
      }
    }
  }
}
