{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://labsly.com/schemas/persona-v1.json",
  "title": "LabslyPersona v1",
  "description": "Shared persona schema across the labsly portfolio. See PLANS/06_LABSLY_SUBSTRATE.md.",
  "type": "object",
  "required": ["version", "id", "name", "kind"],
  "properties": {
    "version": {
      "const": "labsly-persona-v1",
      "description": "Schema version literal"
    },
    "id": {
      "type": "string",
      "description": "Stable UUID or app-prefixed ID"
    },
    "kind": {
      "enum": ["character", "stakeholder", "audience_member", "test_user", "npc", "strategic_audience"]
    },
    "name": { "type": "string" },
    "role": {
      "type": "string",
      "description": "Job title, archetype, or relational role"
    },
    "demographics": {
      "type": "object",
      "properties": {
        "age": { "type": "integer", "minimum": 0 },
        "background": { "type": "string" },
        "context": {
          "type": "string",
          "description": "Where they operate, what world they live in"
        }
      },
      "additionalProperties": false
    },
    "psychology": {
      "type": "object",
      "properties": {
        "values": { "type": "array", "items": { "type": "string" } },
        "fears": { "type": "array", "items": { "type": "string" } },
        "desires": { "type": "array", "items": { "type": "string" } },
        "wounds": { "type": "array", "items": { "type": "string" } },
        "contradictions": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "behavioral": {
      "type": "object",
      "properties": {
        "communication_style": { "type": "string" },
        "decision_pattern": { "type": "string" },
        "tech_proficiency": {
          "enum": ["novice", "intermediate", "expert"]
        }
      },
      "additionalProperties": false
    },
    "relationships": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["target_id", "kind"],
        "properties": {
          "target_id": { "type": "string" },
          "kind": {
            "enum": [
              "mentor",
              "rival",
              "ally",
              "manipulator",
              "savior",
              "predator_prey",
              "equal",
              "subordinate",
              "superior"
            ]
          },
          "strength": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          }
        },
        "additionalProperties": false
      }
    },
    "epistemics": {
      "type": "object",
      "description": "Per-field provenance and confidence — the labsly differentiator. Tools should label outputs with these.",
      "properties": {
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "source": {
          "enum": ["stated", "inferred", "synthesized", "observed"]
        },
        "evidence": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Citations or evidence references"
        },
        "review_state": {
          "enum": ["draft", "suggested", "confirmed", "disputed"]
        }
      },
      "additionalProperties": false
    },
    "app_overlay": {
      "type": "object",
      "description": "App-specific extensions; opaque to other apps. Each labsly app may add its own fields here.",
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
