{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/sutro-planet/story-orbit/creator-packs/0.2/pack.schema.json",
  "title": "StoryOrbit Creator Pack 0.2",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "protocol_version": {
      "const": "0.2"
    },
    "manifest": {
      "$ref": "#/$defs/manifest"
    },
    "publication": {
      "$ref": "#/$defs/publication"
    },
    "experience": {
      "$ref": "#/$defs/experience"
    },
    "instructions": {
      "$ref": "#/$defs/instructions"
    },
    "generation": {
      "$ref": "#/$defs/generation"
    },
    "style": {
      "$ref": "#/$defs/style"
    },
    "default_entry_id": {
      "$ref": "#/$defs/id"
    },
    "entries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entry"
      },
      "minItems": 1,
      "maxItems": 256
    },
    "canon": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/fact"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "actors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/actor"
      },
      "minItems": 1,
      "maxItems": 4096
    },
    "scenes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/visualEntity"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "props": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/visualEntity"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "predicates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/predicate"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "arcs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/arc"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "event_cards": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/event"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "stats": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/stat"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "lorebook": {
      "$ref": "#/$defs/lorebook"
    },
    "visual_anchors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/visualAnchor"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "assets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/asset"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "endings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ending"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "collection": {
      "$ref": "#/$defs/collection"
    },
    "runtime": {
      "$ref": "#/$defs/runtime"
    },
    "open_questions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/question"
      },
      "minItems": 0,
      "maxItems": 4096
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9]*(?:\\.[a-z0-9-]+)+$"
      },
      "additionalProperties": true
    }
  },
  "required": [
    "protocol_version",
    "manifest",
    "publication",
    "experience",
    "instructions",
    "generation",
    "style",
    "default_entry_id",
    "entries",
    "canon",
    "actors",
    "scenes",
    "props",
    "predicates",
    "arcs",
    "event_cards",
    "stats",
    "lorebook",
    "visual_anchors",
    "assets",
    "endings",
    "collection",
    "open_questions",
    "extensions"
  ],
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
    },
    "sourceRef": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "document_id": {
          "$ref": "#/$defs/id"
        },
        "locator": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        }
      },
      "required": [
        "document_id",
        "locator"
      ]
    },
    "origin": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "basis": {
          "enum": [
            "source_explicit",
            "source_inference",
            "creator_design",
            "synthetic_example"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/sourceRef"
          },
          "minItems": 0,
          "maxItems": 4096
        },
        "review": {
          "enum": [
            "proposed",
            "accepted",
            "example_only"
          ]
        }
      },
      "required": [
        "basis",
        "source_refs",
        "review"
      ]
    },
    "scope": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/id"
      },
      "minItems": 0,
      "maxItems": 4096,
      "uniqueItems": true
    },
    "condition": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "literal": {
              "type": "boolean"
            }
          },
          "required": [
            "literal"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "all": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/condition"
              },
              "minItems": 1,
              "maxItems": 32
            }
          },
          "required": [
            "all"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "any": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/condition"
              },
              "minItems": 1,
              "maxItems": 32
            }
          },
          "required": [
            "any"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "not": {
              "$ref": "#/$defs/condition"
            }
          },
          "required": [
            "not"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "stat_id": {
              "$ref": "#/$defs/id"
            },
            "op": {
              "enum": [
                "eq",
                "ne",
                "lt",
                "lte",
                "gt",
                "gte"
              ]
            },
            "value": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "stat_id",
            "op",
            "value"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "fact_id": {
              "$ref": "#/$defs/id"
            },
            "holder": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "known": {
              "type": "boolean"
            }
          },
          "required": [
            "fact_id",
            "holder",
            "known"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "event_id": {
              "$ref": "#/$defs/id"
            },
            "occurred": {
              "type": "boolean"
            }
          },
          "required": [
            "event_id",
            "occurred"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "predicate_id": {
              "$ref": "#/$defs/id"
            }
          },
          "required": [
            "predicate_id"
          ]
        }
      ]
    },
    "predicate": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "evidence_policy": {
          "enum": [
            "on_page"
          ]
        },
        "origin": {
          "$ref": "#/$defs/origin"
        }
      },
      "required": [
        "id",
        "entry_ids",
        "prompt",
        "evidence_policy",
        "origin"
      ]
    },
    "document": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "revision_or_digest": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "locator_scheme": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        }
      },
      "required": [
        "id",
        "title",
        "revision_or_digest",
        "locator_scheme"
      ]
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "kind": {
          "enum": [
            "novel",
            "original",
            "synthetic_example"
          ]
        },
        "documents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/document"
          },
          "minItems": 0,
          "maxItems": 4096
        },
        "adaptation_mode": {
          "enum": [
            "continue_after_anchor",
            "adapt_arc",
            "original"
          ]
        },
        "future_treatment": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        }
      },
      "required": [
        "kind",
        "documents",
        "adaptation_mode",
        "future_treatment"
      ]
    },
    "manifest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "pack_id": {
          "$ref": "#/$defs/id"
        },
        "revision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "status": {
          "enum": [
            "draft",
            "ready",
            "example"
          ]
        },
        "language": {
          "type": "string",
          "minLength": 1,
          "maxLength": 35
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "required_capabilities": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "minItems": 1,
          "maxItems": 128,
          "uniqueItems": true
        }
      },
      "required": [
        "pack_id",
        "revision",
        "status",
        "language",
        "title",
        "source",
        "required_capabilities"
      ]
    },
    "publication": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "tagline": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 10000
        },
        "cover_asset_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/id"
            },
            {
              "type": "null"
            }
          ]
        },
        "genres": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "target_audience": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "age_rating": {
          "enum": [
            "general",
            "adult"
          ]
        },
        "content_warnings": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 0,
          "maxItems": 4096
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 0,
          "maxItems": 4096
        },
        "visibility": {
          "enum": [
            "public",
            "unlisted",
            "private"
          ]
        },
        "comments_enabled": {
          "type": "boolean"
        },
        "creator_credit": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "rights": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "basis": {
              "enum": [
                "original",
                "licensed",
                "public_domain",
                "unknown"
              ]
            },
            "statement": {
              "type": "string",
              "minLength": 1,
              "maxLength": 20000
            }
          },
          "required": [
            "basis",
            "statement"
          ]
        }
      },
      "required": [
        "tagline",
        "description",
        "cover_asset_id",
        "genres",
        "target_audience",
        "age_rating",
        "content_warnings",
        "tags",
        "visibility",
        "comments_enabled",
        "creator_credit",
        "rights"
      ]
    },
    "experience": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "interaction_mode": {
          "const": "roleplay",
          "description": "The player acts as the entry participant. Reading/observer mode is not supported."
        },
        "progression": {
          "enum": [
            "bounded_arc",
            "open_ended"
          ]
        },
        "reader_controls": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "boundaries": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "rewards": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "premise": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        }
      },
      "required": [
        "interaction_mode",
        "progression",
        "reader_controls",
        "boundaries",
        "rewards",
        "premise"
      ]
    },
    "example": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "user": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "assistant": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        }
      },
      "required": [
        "id",
        "user",
        "assistant"
      ]
    },
    "instructions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "template": {
          "enum": [
            "default",
            "custom"
          ]
        },
        "story_details": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100000
        },
        "custom_prompt": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 100000
            },
            {
              "type": "null"
            }
          ]
        },
        "examples": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/example"
          },
          "minItems": 0,
          "maxItems": 64
        }
      },
      "required": [
        "template",
        "story_details",
        "custom_prompt",
        "examples"
      ]
    },
    "generation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "target_output_tokens": {
          "type": "integer",
          "minimum": 1,
          "maximum": 32768,
          "description": "Soft target for prose length. The host owns output caps and may accept a naturally longer or shorter passage, including endings."
        },
        "max_paragraphs": {
          "type": "integer",
          "minimum": 1,
          "default": 60,
          "description": "Maximum paragraphs per generated continuation, including endings. Omit for the platform default of 60; set a positive integer to override it. Counts both JSON paragraph items and paragraphs separated by blank lines. Independent host character and provider output-token limits still apply."
        }
      },
      "required": [
        "target_output_tokens"
      ]
    },
    "style": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "pov": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "voice": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "dialogue_notes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 0,
          "maxItems": 4096
        },
        "positive_example": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "avoid": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 0,
          "maxItems": 4096
        }
      },
      "required": [
        "pov",
        "voice",
        "dialogue_notes",
        "positive_example",
        "avoid"
      ]
    },
    "belief": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "statement": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "confidence": {
          "enum": [
            "possible",
            "likely",
            "certain"
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        }
      },
      "required": [
        "statement",
        "confidence",
        "evidence_refs"
      ]
    },
    "actor": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "allOf": [
            {
              "$ref": "#/$defs/id"
            },
            {
              "not": {
                "enum": [
                  "world",
                  "reader"
                ]
              }
            }
          ]
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "public_intro": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "appearance": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "goal": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "stakes": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "methods": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "limits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "origin": {
          "$ref": "#/$defs/origin"
        },
        "visual_anchor_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 64,
          "uniqueItems": true
        }
      },
      "required": [
        "id",
        "entry_ids",
        "name",
        "public_intro",
        "appearance",
        "goal",
        "stakes",
        "methods",
        "limits",
        "origin",
        "visual_anchor_ids"
      ]
    },
    "actorSetup": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "actor_id": {
          "$ref": "#/$defs/id"
        },
        "goal": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "known_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "beliefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/belief"
          },
          "minItems": 0,
          "maxItems": 4096
        },
        "relationship_notes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 0,
          "maxItems": 4096
        }
      },
      "required": [
        "actor_id",
        "goal",
        "known_fact_ids",
        "beliefs",
        "relationship_notes"
      ]
    },
    "suggestions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "enum": [
            "disabled",
            "semantic_match"
          ]
        },
        "count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 3,
          "description": "Maximum displayed suggestions (0 when disabled; 1–3 for semantic_match). The candidate pool may contain more items."
        },
        "items": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 0,
          "maxItems": 4096,
          "description": "Authored candidate actions. Jev selects relevant, currently available next steps; fewer than count may qualify. Never display the full pool as fixed suggestions."
        }
      },
      "required": [
        "mode",
        "count",
        "items"
      ],
      "description": "Optional reader directions selected from the active entry’s authored candidate pool. Selection never generates new text."
    },
    "persona": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "role": {
          "const": "participant"
        },
        "actor_id": {
          "$ref": "#/$defs/id",
          "description": "The player character; must belong to actor_ids and present_actor_ids for this entry."
        },
        "display_name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "customization": {
          "enum": [
            "none",
            "cosmetic",
            "within_boundaries"
          ]
        },
        "boundaries": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 0,
          "maxItems": 4096
        }
      },
      "required": [
        "role",
        "actor_id",
        "display_name",
        "description",
        "customization",
        "boundaries"
      ]
    },
    "entry": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "anchor": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        },
        "opening_text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100000
        },
        "opening_scene": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100000
        },
        "play_guide": {
          "type": "string",
          "minLength": 0,
          "maxLength": 20000
        },
        "suggestions": {
          "$ref": "#/$defs/suggestions"
        },
        "persona": {
          "$ref": "#/$defs/persona"
        },
        "location": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        },
        "story_time": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        },
        "actor_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 1,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "present_actor_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 1,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "actor_setup": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/actorSetup"
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "established_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "reader_known_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "arc_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/id"
            },
            {
              "type": "null"
            }
          ]
        },
        "opening_scene_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/id"
            },
            {
              "type": "null"
            }
          ]
        },
        "present_prop_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        }
      },
      "required": [
        "id",
        "name",
        "anchor",
        "opening_text",
        "opening_scene",
        "play_guide",
        "suggestions",
        "persona",
        "location",
        "story_time",
        "actor_ids",
        "present_actor_ids",
        "actor_setup",
        "established_fact_ids",
        "reader_known_fact_ids",
        "arc_id",
        "opening_scene_id",
        "present_prop_ids"
      ]
    },
    "fact": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "statement": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "kind": {
          "enum": [
            "past_event",
            "identity",
            "world_rule",
            "initial_state"
          ]
        },
        "origin": {
          "$ref": "#/$defs/origin"
        },
        "disclosure": {
          "enum": [
            "public",
            "gated"
          ]
        },
        "reveal_condition": {
          "$ref": "#/$defs/condition"
        }
      },
      "required": [
        "id",
        "entry_ids",
        "statement",
        "kind",
        "origin",
        "disclosure",
        "reveal_condition"
      ]
    },
    "promise": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "question": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "satisfied_when": {
          "$ref": "#/$defs/condition"
        },
        "target_scene": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10000
        },
        "overdue_action": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        }
      },
      "required": [
        "id",
        "question",
        "satisfied_when",
        "target_scene",
        "overdue_action"
      ]
    },
    "arc": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "question": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "promises": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/promise"
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "completion_condition": {
          "$ref": "#/$defs/condition"
        },
        "outcome_space": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "pacing": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "target_scene_count": {
              "type": "array",
              "items": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000
              },
              "minItems": 2,
              "maxItems": 2
            },
            "max_continuations_per_scene": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            "max_run_continuations": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000
            },
            "repetition_limits": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 20000
              },
              "minItems": 0,
              "maxItems": 4096
            },
            "recovery_rule": {
              "type": "string",
              "minLength": 1,
              "maxLength": 20000
            }
          },
          "required": [
            "target_scene_count",
            "max_continuations_per_scene",
            "max_run_continuations",
            "repetition_limits",
            "recovery_rule"
          ]
        }
      },
      "required": [
        "id",
        "entry_ids",
        "question",
        "promises",
        "completion_condition",
        "outcome_space",
        "pacing"
      ]
    },
    "event": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "purpose": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "actor_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 1,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "requires_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "requires_event_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "eligible_when": {
          "$ref": "#/$defs/condition"
        },
        "blocked_when": {
          "$ref": "#/$defs/condition"
        },
        "action": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "possible_outcomes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "reveal_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "advances_promise_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "repeat_policy": {
          "enum": [
            "once",
            "repeat_if_state_changed"
          ]
        },
        "repeat_change_condition": {
          "anyOf": [
            {
              "$ref": "#/$defs/condition"
            },
            {
              "type": "null"
            }
          ]
        },
        "origin": {
          "$ref": "#/$defs/origin"
        }
      },
      "required": [
        "id",
        "entry_ids",
        "label",
        "purpose",
        "actor_ids",
        "requires_fact_ids",
        "requires_event_ids",
        "eligible_when",
        "blocked_when",
        "action",
        "possible_outcomes",
        "reveal_fact_ids",
        "advances_promise_ids",
        "repeat_policy",
        "repeat_change_condition",
        "origin"
      ]
    },
    "statInitial": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "entry_id": {
          "$ref": "#/$defs/id"
        },
        "value": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "entry_id",
        "value"
      ]
    },
    "statRule": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "when": {
          "$ref": "#/$defs/condition"
        },
        "min_delta": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "max_delta": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        }
      },
      "required": [
        "id",
        "when",
        "min_delta",
        "max_delta",
        "reason"
      ]
    },
    "statLevel": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "min": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "max": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        }
      },
      "required": [
        "id",
        "name",
        "min",
        "max",
        "prompt"
      ]
    },
    "stat": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "icon": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "color": {
          "type": "string",
          "pattern": "^#[0-9A-Fa-f]{6}$"
        },
        "unit": {
          "type": "string",
          "minLength": 0,
          "maxLength": 40
        },
        "min": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "max": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "initial": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/statInitial"
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "visibility": {
          "enum": [
            "reader",
            "internal"
          ]
        },
        "overflow": {
          "enum": [
            "clamp",
            "reject"
          ]
        },
        "update_rules": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/statRule"
          },
          "minItems": 0,
          "maxItems": 4096
        },
        "levels": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/statLevel"
          },
          "minItems": 0,
          "maxItems": 4096
        }
      },
      "required": [
        "id",
        "entry_ids",
        "name",
        "description",
        "icon",
        "color",
        "unit",
        "min",
        "max",
        "initial",
        "visibility",
        "overflow",
        "update_rules",
        "levels"
      ]
    },
    "loreEntry": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "body": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100000
        },
        "keywords": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "match": {
          "enum": [
            "any",
            "all"
          ]
        },
        "case_sensitive": {
          "type": "boolean"
        },
        "priority": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "when": {
          "$ref": "#/$defs/condition"
        },
        "discloses_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "origin": {
          "$ref": "#/$defs/origin"
        }
      },
      "required": [
        "id",
        "entry_ids",
        "name",
        "body",
        "keywords",
        "match",
        "case_sensitive",
        "priority",
        "when",
        "discloses_fact_ids",
        "origin"
      ]
    },
    "lorebook": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "scan_messages": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000
        },
        "max_active_entries": {
          "type": "integer",
          "minimum": 1,
          "maximum": 256
        },
        "token_budget": {
          "type": "integer",
          "minimum": 1,
          "maximum": 131072
        },
        "recursion": {
          "enum": [
            "disabled"
          ]
        },
        "entries": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/loreEntry"
          },
          "minItems": 0,
          "maxItems": 4096
        }
      },
      "required": [
        "scan_messages",
        "max_active_entries",
        "token_budget",
        "recursion",
        "entries"
      ]
    },
    "assetReference": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "asset_id": {
          "$ref": "#/$defs/id"
        },
        "role": {
          "enum": [
            "identity",
            "style",
            "composition",
            "pose",
            "background",
            "mask",
            "first_frame",
            "last_frame"
          ]
        },
        "instruction": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 20000
            },
            {
              "type": "null"
            }
          ]
        },
        "strength": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "asset_id",
        "role",
        "instruction",
        "strength"
      ]
    },
    "visualPrompts": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100000
        },
        "negative_prompt": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 100000
            },
            {
              "type": "null"
            }
          ]
        },
        "system_prompt": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 100000
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "prompt",
        "negative_prompt",
        "system_prompt"
      ]
    },
    "visualSampling": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "seed": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "steps": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000
            },
            {
              "type": "null"
            }
          ]
        },
        "guidance_scale": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "maximum": 1000
            },
            {
              "type": "null"
            }
          ]
        },
        "sampler": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            {
              "type": "null"
            }
          ]
        },
        "scheduler": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            {
              "type": "null"
            }
          ]
        },
        "temperature": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "maximum": 2
            },
            {
              "type": "null"
            }
          ]
        },
        "top_p": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 1
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "seed",
        "steps",
        "guidance_scale",
        "sampler",
        "scheduler",
        "temperature",
        "top_p"
      ]
    },
    "visualOutput": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mime_type": {
          "enum": [
            "image/jpeg",
            "image/png",
            "image/webp",
            "image/gif",
            "video/mp4"
          ]
        },
        "width": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 32768
            },
            {
              "type": "null"
            }
          ]
        },
        "height": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 32768
            },
            {
              "type": "null"
            }
          ]
        },
        "aspect_ratio": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,4}:[1-9][0-9]{0,4}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "duration_ms": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 3600000
            },
            {
              "type": "null"
            }
          ]
        },
        "fps": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 240
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "mime_type",
        "width",
        "height",
        "aspect_ratio",
        "duration_ms",
        "fps"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "width": {
                "type": "null"
              }
            }
          },
          "then": {
            "properties": {
              "height": {
                "type": "null"
              }
            }
          },
          "else": {
            "properties": {
              "height": {
                "type": "integer"
              }
            }
          }
        }
      ]
    },
    "visualGenerationConfig": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "task": {
          "enum": [
            "text_to_image",
            "image_to_image",
            "text_to_video",
            "image_to_video",
            "video_to_video"
          ]
        },
        "provider": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_.-]{0,99}$"
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "model_version": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            {
              "type": "null"
            }
          ]
        },
        "prompts": {
          "$ref": "#/$defs/visualPrompts"
        },
        "sampling": {
          "$ref": "#/$defs/visualSampling"
        },
        "output": {
          "$ref": "#/$defs/visualOutput"
        },
        "provider_parameters": {
          "type": "object",
          "maxProperties": 64,
          "propertyNames": {
            "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,99}$"
          },
          "additionalProperties": true
        }
      },
      "required": [
        "task",
        "provider",
        "model",
        "model_version",
        "prompts",
        "sampling",
        "output",
        "provider_parameters"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "task": {
                "enum": [
                  "text_to_image",
                  "image_to_image"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "output": {
                "properties": {
                  "mime_type": {
                    "enum": [
                      "image/jpeg",
                      "image/png",
                      "image/webp",
                      "image/gif"
                    ]
                  },
                  "duration_ms": {
                    "type": "null"
                  },
                  "fps": {
                    "type": "null"
                  }
                }
              }
            }
          },
          "else": {
            "properties": {
              "output": {
                "properties": {
                  "mime_type": {
                    "const": "video/mp4"
                  }
                }
              }
            }
          }
        }
      ]
    },
    "assetGenerationInput": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "asset_id": {
          "$ref": "#/$defs/id"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "role": {
          "enum": [
            "identity",
            "style",
            "composition",
            "pose",
            "background",
            "mask",
            "first_frame",
            "last_frame"
          ]
        },
        "instruction": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 20000
            },
            {
              "type": "null"
            }
          ]
        },
        "strength": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "anchor_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/id"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "asset_id",
        "sha256",
        "role",
        "instruction",
        "strength",
        "anchor_id"
      ]
    },
    "assetGenerationRecord": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "config": {
          "$ref": "#/$defs/visualGenerationConfig"
        },
        "input_assets": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/assetGenerationInput"
          },
          "maxItems": 64
        },
        "provider_revised_prompt": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 100000
            },
            {
              "type": "null"
            }
          ]
        },
        "output_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "config",
        "input_assets",
        "provider_revised_prompt",
        "output_sha256"
      ]
    },
    "asset": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "kind": {
          "enum": [
            "image",
            "audio",
            "video"
          ]
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "alt_text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "uri": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^asset://[A-Za-z0-9][A-Za-z0-9/_.-]{0,511}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "sha256": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "mime_type": {
          "enum": [
            "image/jpeg",
            "image/png",
            "image/webp",
            "image/gif",
            "audio/mpeg",
            "audio/wav",
            "video/mp4"
          ]
        },
        "byte_size": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 1073741824
            },
            {
              "type": "null"
            }
          ]
        },
        "reference_only": {
          "type": "boolean"
        },
        "depicts_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "depicts_event_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "valid_when": {
          "$ref": "#/$defs/condition"
        },
        "origin": {
          "$ref": "#/$defs/origin"
        },
        "source_url": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri",
              "pattern": "^https://[^\\s/?#@]+(?:[/?#][^\\s]*)?$",
              "maxLength": 2048
            },
            {
              "type": "null"
            }
          ]
        },
        "references": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/assetReference"
          },
          "maxItems": 64
        },
        "generation": {
          "anyOf": [
            {
              "$ref": "#/$defs/visualGenerationConfig"
            },
            {
              "type": "null"
            }
          ]
        },
        "generation_record": {
          "anyOf": [
            {
              "$ref": "#/$defs/assetGenerationRecord"
            },
            {
              "type": "null"
            }
          ]
        },
        "anchor_references": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/anchorReference"
          },
          "minItems": 0,
          "maxItems": 64
        }
      },
      "required": [
        "id",
        "entry_ids",
        "kind",
        "description",
        "alt_text",
        "uri",
        "sha256",
        "mime_type",
        "byte_size",
        "reference_only",
        "depicts_fact_ids",
        "depicts_event_ids",
        "valid_when",
        "origin",
        "source_url",
        "references",
        "generation",
        "generation_record",
        "anchor_references"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "generation_record": {
                "type": "object"
              }
            }
          },
          "then": {
            "properties": {
              "uri": {
                "type": "string"
              },
              "sha256": {
                "type": "string"
              },
              "byte_size": {
                "type": "integer"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "generation": {
                "type": "object"
              },
              "uri": {
                "type": "string"
              }
            }
          },
          "then": {
            "properties": {
              "generation_record": {
                "type": "object"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "audio"
              }
            }
          },
          "then": {
            "properties": {
              "generation": {
                "type": "null"
              },
              "generation_record": {
                "type": "null"
              },
              "references": {
                "maxItems": 0
              },
              "anchor_references": {
                "maxItems": 0
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "image"
              }
            }
          },
          "then": {
            "properties": {
              "generation": {
                "properties": {
                  "task": {
                    "enum": [
                      "text_to_image",
                      "image_to_image"
                    ]
                  }
                }
              },
              "generation_record": {
                "properties": {
                  "config": {
                    "properties": {
                      "task": {
                        "enum": [
                          "text_to_image",
                          "image_to_image"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "video"
              }
            }
          },
          "then": {
            "properties": {
              "generation": {
                "properties": {
                  "task": {
                    "enum": [
                      "text_to_video",
                      "image_to_video",
                      "video_to_video"
                    ]
                  }
                }
              },
              "generation_record": {
                "properties": {
                  "config": {
                    "properties": {
                      "task": {
                        "enum": [
                          "text_to_video",
                          "image_to_video",
                          "video_to_video"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    "ending": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "arc_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/id"
            },
            {
              "type": "null"
            }
          ]
        },
        "priority": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "min_turns": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100000
        },
        "check_every_turns": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100000
        },
        "condition": {
          "$ref": "#/$defs/condition"
        },
        "evaluation_prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "epilogue": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "mode": {
              "enum": [
                "fixed",
                "adapt"
              ]
            },
            "text": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100000
            }
          },
          "required": [
            "mode",
            "text"
          ]
        },
        "hint": {
          "type": "string",
          "minLength": 0,
          "maxLength": 1000
        },
        "card_asset_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/id"
            },
            {
              "type": "null"
            }
          ]
        },
        "rarity": {
          "enum": [
            "N",
            "R",
            "SR",
            "SSR"
          ]
        },
        "completion": {
          "enum": [
            "terminal",
            "milestone"
          ]
        },
        "collectible": {
          "type": "boolean"
        },
        "repeatable": {
          "type": "boolean"
        }
      },
      "required": [
        "id",
        "entry_ids",
        "name",
        "arc_id",
        "priority",
        "min_turns",
        "check_every_turns",
        "condition",
        "evaluation_prompt",
        "epilogue",
        "hint",
        "card_asset_id",
        "rarity",
        "completion",
        "collectible",
        "repeatable"
      ]
    },
    "collection": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "rarity_policy": {
          "enum": [
            "unrestricted",
            "ooc_2026"
          ]
        },
        "leaderboard": {
          "enum": [
            "disabled",
            "first_completion"
          ]
        },
        "rank_limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        }
      },
      "required": [
        "rarity_policy",
        "leaderboard",
        "rank_limit"
      ]
    },
    "memory": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "editable_long_term": {
          "type": "boolean"
        },
        "relationships": {
          "type": "boolean"
        },
        "goals": {
          "type": "boolean"
        },
        "temporary_to_long_term": {
          "type": "boolean"
        }
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "memory": {
          "$ref": "#/$defs/memory"
        }
      }
    },
    "question": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "question": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "blocks_play": {
          "type": "boolean"
        },
        "related_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        }
      },
      "required": [
        "id",
        "question",
        "blocks_play",
        "related_ids"
      ]
    },
    "visualEntity": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "visual_anchor_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 64,
          "uniqueItems": true
        },
        "origin": {
          "$ref": "#/$defs/origin"
        }
      },
      "required": [
        "id",
        "entry_ids",
        "name",
        "description",
        "visual_anchor_ids",
        "origin"
      ]
    },
    "visualAnchorImage": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "asset_id": {
          "$ref": "#/$defs/id"
        },
        "view": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        }
      },
      "required": [
        "asset_id",
        "view"
      ]
    },
    "visualAnchor": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "entry_ids": {
          "$ref": "#/$defs/scope"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "kind": {
          "enum": [
            "character",
            "environment",
            "object"
          ]
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20000
        },
        "invariants": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "minItems": 1,
          "maxItems": 64,
          "uniqueItems": true
        },
        "references": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/visualAnchorImage"
          },
          "minItems": 1,
          "maxItems": 64
        },
        "depicts_fact_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "depicts_event_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 0,
          "maxItems": 4096,
          "uniqueItems": true
        },
        "valid_when": {
          "$ref": "#/$defs/condition"
        },
        "origin": {
          "$ref": "#/$defs/origin"
        }
      },
      "required": [
        "id",
        "entry_ids",
        "name",
        "kind",
        "description",
        "invariants",
        "references",
        "depicts_fact_ids",
        "depicts_event_ids",
        "valid_when",
        "origin"
      ]
    },
    "anchorReference": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "anchor_id": {
          "$ref": "#/$defs/id"
        },
        "reference_asset_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 1,
          "maxItems": 64,
          "uniqueItems": true
        },
        "role": {
          "enum": [
            "identity",
            "style",
            "composition",
            "pose",
            "background",
            "mask",
            "first_frame",
            "last_frame"
          ]
        },
        "instruction": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 20000
            },
            {
              "type": "null"
            }
          ]
        },
        "strength": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "anchor_id",
        "reference_asset_ids",
        "role",
        "instruction",
        "strength"
      ]
    }
  }
}
