{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Virtual actor generation package",
  "description": "A proposal for authored AI-performance conditioning. Exactly one required experience_chunk object is nested directly in each beat. Empty arrays mean no cue was supplied; null times mean no measured or prescribed time was supplied.",
  "type": "object",
  "properties": {
    "schema_version": {
      "const": "actor-state-generation/2.0.0"
    },
    "purpose": {
      "type": "string",
      "minLength": 1
    },
    "source_materials": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/source_material"
      }
    },
    "output_request": {
      "type": "object",
      "properties": {
        "modalities": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "audio",
              "video",
              "audiovisual",
              "keypoints",
              "avatar_controls"
            ]
          }
        },
        "note": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "modalities",
        "note"
      ],
      "additionalProperties": false
    },
    "characters": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/character"
      }
    }
  },
  "required": [
    "schema_version",
    "purpose",
    "source_materials",
    "output_request",
    "characters"
  ],
  "additionalProperties": false,
  "$defs": {
    "profile": {
      "type": "object",
      "properties": {
        "portrait": {
          "type": "string",
          "minLength": 1
        },
        "voice_consequence": {
          "type": "string",
          "minLength": 1
        },
        "countertendency": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "portrait",
        "voice_consequence",
        "countertendency"
      ],
      "additionalProperties": false
    },
    "timing": {
      "type": "object",
      "properties": {
        "start_s": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "end_s": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "direction": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "start_s",
        "end_s",
        "direction"
      ],
      "additionalProperties": false
    },
    "outer": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "text_anchor": {
          "type": [
            "string",
            "null"
          ]
        },
        "playable_action": {
          "type": "string",
          "minLength": 1
        },
        "displayed_affect": {
          "type": "string",
          "minLength": 1
        },
        "action_cues": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "silence_cue": {
          "type": [
            "string",
            "null"
          ]
        },
        "timing": {
          "$ref": "#/$defs/timing"
        },
        "vocal_cues": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "physical_cues": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "voice_targets": {
          "type": "object",
          "propertyNames": {
            "enum": [
              "TEMP",
              "CLRT",
              "TENS",
              "EMPH",
              "RESP",
              "VULN",
              "RANG",
              "WARM",
              "DFLU",
              "S_PLAY",
              "SMTH",
              "STNC"
            ]
          },
          "additionalProperties": {
            "type": "integer",
            "minimum": 0,
            "maximum": 6
          }
        }
      },
      "required": [
        "text",
        "text_anchor",
        "playable_action",
        "displayed_affect",
        "action_cues",
        "silence_cue",
        "timing",
        "vocal_cues",
        "physical_cues",
        "voice_targets"
      ],
      "additionalProperties": false,
      "anyOf": [
        {
          "properties": {
            "text": {
              "minLength": 1
            }
          }
        },
        {
          "properties": {
            "action_cues": {
              "minItems": 1
            }
          }
        },
        {
          "properties": {
            "silence_cue": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        {
          "properties": {
            "physical_cues": {
              "minItems": 1
            }
          }
        }
      ]
    },
    "carryover": {
      "type": "object",
      "properties": {
        "from_beat_id": {
          "type": "string",
          "minLength": 1
        },
        "state": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "from_beat_id",
        "state"
      ],
      "additionalProperties": false
    },
    "experience_chunk": {
      "type": "object",
      "properties": {
        "status": {
          "const": "authored_fiction"
        },
        "stimulus_and_effect": {
          "type": "string",
          "minLength": 1
        },
        "attention": {
          "type": "string",
          "minLength": 1
        },
        "sensations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "memories": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "associations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "thought_fragments": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "emotion": {
          "type": "string",
          "minLength": 1
        },
        "impulse_and_regulation": {
          "type": "string",
          "minLength": 1
        },
        "competing_impulse": {
          "type": [
            "string",
            "null"
          ]
        },
        "carryover": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/carryover"
            }
          ]
        }
      },
      "required": [
        "status",
        "stimulus_and_effect",
        "attention",
        "sensations",
        "memories",
        "associations",
        "thought_fragments",
        "emotion",
        "impulse_and_regulation",
        "competing_impulse",
        "carryover"
      ],
      "additionalProperties": false
    },
    "beat": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "order": {
          "type": "integer",
          "minimum": 1
        },
        "outer": {
          "$ref": "#/$defs/outer"
        },
        "experience_chunk": {
          "$ref": "#/$defs/experience_chunk"
        },
        "source_emotion_labels": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Raw inherited EmoNet candidate names relating to the whole source beat. They are unassigned provenance metadata, not public-display controls or inner-emotion ground truth. Explicitly assign a label to authored inner emotion or intended public display before using it as a generation control; outer.displayed_affect and experience_chunk.emotion remain separate."
        }
      },
      "required": [
        "id",
        "order",
        "outer",
        "experience_chunk",
        "source_emotion_labels"
      ],
      "additionalProperties": false
    },
    "scene": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "source_text": {
          "type": "string"
        },
        "setting": {
          "type": "string",
          "minLength": 1
        },
        "premise": {
          "type": "string",
          "minLength": 1
        },
        "interpreted_through_makeup": {
          "type": "string",
          "minLength": 1
        },
        "dramatic_obligations": {
          "type": "object",
          "properties": {
            "time_and_place": {
              "type": "string",
              "minLength": 1
            },
            "relationship": {
              "type": "string",
              "minLength": 1
            },
            "emotional": {
              "type": "string",
              "minLength": 1
            },
            "character": {
              "type": "string",
              "minLength": 1
            },
            "historic": {
              "type": "string",
              "minLength": 1
            },
            "thematic": {
              "type": "string",
              "minLength": 1
            },
            "subtextual": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "time_and_place",
            "relationship",
            "emotional",
            "character",
            "historic",
            "thematic",
            "subtextual"
          ],
          "additionalProperties": false
        },
        "extension_obligations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "partner_obligations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "beats": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/beat"
          }
        }
      },
      "required": [
        "id",
        "title",
        "source_text",
        "setting",
        "premise",
        "interpreted_through_makeup",
        "dramatic_obligations",
        "extension_obligations",
        "partner_obligations",
        "beats"
      ],
      "additionalProperties": false
    },
    "reference_media": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "media_type": {
          "enum": [
            "audio",
            "video",
            "audiovisual"
          ]
        },
        "locator": {
          "type": "string",
          "minLength": 1
        },
        "permission_basis": {
          "type": "string",
          "minLength": 1
        },
        "behavioral_mode": {
          "type": "string",
          "minLength": 1
        },
        "use_instruction": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "id",
        "media_type",
        "locator",
        "permission_basis",
        "behavioral_mode",
        "use_instruction"
      ],
      "additionalProperties": false
    },
    "character": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "source_material_id": {
          "type": "string",
          "minLength": 1
        },
        "character_makeup": {
          "type": "object",
          "properties": {
            "physical": {
              "$ref": "#/$defs/profile"
            },
            "emotional": {
              "$ref": "#/$defs/profile"
            },
            "intellectual": {
              "$ref": "#/$defs/profile"
            },
            "psychological": {
              "$ref": "#/$defs/profile"
            }
          },
          "required": [
            "physical",
            "emotional",
            "intellectual",
            "psychological"
          ],
          "additionalProperties": false
        },
        "reference_media": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/reference_media"
          }
        },
        "scenes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/scene"
          }
        }
      },
      "required": [
        "id",
        "name",
        "source_material_id",
        "character_makeup",
        "reference_media",
        "scenes"
      ],
      "additionalProperties": false
    },
    "source_material": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "enum": [
            "book",
            "script",
            "screenplay",
            "stage_play",
            "radio_play",
            "authored_scene",
            "other"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "locator": {
          "type": "string",
          "minLength": 1
        },
        "basis": {
          "enum": [
            "source_text",
            "authored_fiction",
            "director_supplied"
          ]
        },
        "note": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "id",
        "kind",
        "title",
        "locator",
        "basis",
        "note"
      ],
      "additionalProperties": false
    }
  }
}
