{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://venuemind.dev/schemas/planning-effect.schema.json",
  "title": "VenueMind Planning Effect",
  "oneOf": [
    {
      "type": "object",
      "required": [
        "operation",
        "targetBriefId",
        "targetRequirementId",
        "before",
        "after",
        "requirement",
        "affectedConstraintIds",
        "evidenceFamilies",
        "source"
      ],
      "properties": {
        "operation": {
          "const": "set_attendance_target"
        },
        "targetBriefId": {
          "type": "string",
          "minLength": 1
        },
        "targetRequirementId": {
          "type": "string",
          "minLength": 1
        },
        "requirement": {
          "type": "object",
          "required": [
            "id",
            "category",
            "label",
            "priority",
            "owner",
            "status",
            "measurable",
            "constraintIds",
            "evidenceRefs"
          ],
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1
            },
            "category": {
              "enum": [
                "accessibility",
                "seating",
                "production",
                "catering",
                "staffing",
                "security",
                "emergency",
                "circulation"
              ]
            },
            "label": {
              "type": "string",
              "minLength": 1
            },
            "priority": {
              "enum": [
                "critical",
                "high",
                "medium",
                "low"
              ]
            },
            "owner": {
              "type": [
                "string",
                "null"
              ]
            },
            "status": {
              "enum": [
                "open",
                "confirmed",
                "satisfied",
                "waived"
              ]
            },
            "measurable": {
              "type": "boolean"
            },
            "constraintIds": {
              "type": "array",
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "evidenceRefs": {
              "type": "array",
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "additionalProperties": false
        },
        "source": {
          "type": "object",
          "required": [
            "adapterId",
            "sourceSystem",
            "entityType",
            "externalId",
            "sourceVersion",
            "checksum",
            "synchronizedAt"
          ],
          "properties": {
            "adapterId": {
              "type": "string",
              "minLength": 1
            },
            "sourceSystem": {
              "type": "string",
              "minLength": 1
            },
            "entityType": {
              "type": "string",
              "minLength": 1
            },
            "externalId": {
              "type": "string",
              "minLength": 1
            },
            "sourceVersion": {
              "type": "string",
              "minLength": 1
            },
            "checksum": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "synchronizedAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$"
            }
          },
          "additionalProperties": false
        },
        "before": {
          "type": "integer",
          "minimum": 0
        },
        "after": {
          "type": "integer",
          "minimum": 0
        },
        "affectedConstraintIds": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "evidenceFamilies": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "prefixItems": [
            {
              "const": "capacity"
            },
            {
              "const": "flow"
            }
          ],
          "items": false
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "operation",
        "targetBriefId",
        "targetRequirementId",
        "before",
        "after",
        "requirement",
        "affectedConstraintIds",
        "evidenceFamilies",
        "source"
      ],
      "properties": {
        "operation": {
          "const": "set_event_schedule"
        },
        "targetBriefId": {
          "type": "string",
          "minLength": 1
        },
        "targetRequirementId": {
          "type": "string",
          "minLength": 1
        },
        "requirement": {
          "type": "object",
          "required": [
            "id",
            "category",
            "label",
            "priority",
            "owner",
            "status",
            "measurable",
            "constraintIds",
            "evidenceRefs"
          ],
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1
            },
            "category": {
              "enum": [
                "accessibility",
                "seating",
                "production",
                "catering",
                "staffing",
                "security",
                "emergency",
                "circulation"
              ]
            },
            "label": {
              "type": "string",
              "minLength": 1
            },
            "priority": {
              "enum": [
                "critical",
                "high",
                "medium",
                "low"
              ]
            },
            "owner": {
              "type": [
                "string",
                "null"
              ]
            },
            "status": {
              "enum": [
                "open",
                "confirmed",
                "satisfied",
                "waived"
              ]
            },
            "measurable": {
              "type": "boolean"
            },
            "constraintIds": {
              "type": "array",
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "evidenceRefs": {
              "type": "array",
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "additionalProperties": false
        },
        "source": {
          "type": "object",
          "required": [
            "adapterId",
            "sourceSystem",
            "entityType",
            "externalId",
            "sourceVersion",
            "checksum",
            "synchronizedAt"
          ],
          "properties": {
            "adapterId": {
              "type": "string",
              "minLength": 1
            },
            "sourceSystem": {
              "type": "string",
              "minLength": 1
            },
            "entityType": {
              "type": "string",
              "minLength": 1
            },
            "externalId": {
              "type": "string",
              "minLength": 1
            },
            "sourceVersion": {
              "type": "string",
              "minLength": 1
            },
            "checksum": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "synchronizedAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$"
            }
          },
          "additionalProperties": false
        },
        "before": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "object",
              "required": [
                "startAt",
                "endAt",
                "timezone"
              ],
              "properties": {
                "startAt": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?(?:Z|(?!-00:00)[+-]\\d{2}:\\d{2})$"
                },
                "endAt": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?(?:Z|(?!-00:00)[+-]\\d{2}:\\d{2})$"
                },
                "timezone": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "after": {
          "type": "object",
          "required": [
            "startAt",
            "endAt",
            "timezone"
          ],
          "properties": {
            "startAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?(?:Z|(?!-00:00)[+-]\\d{2}:\\d{2})$"
            },
            "endAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?(?:Z|(?!-00:00)[+-]\\d{2}:\\d{2})$"
            },
            "timezone": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": false
        },
        "affectedConstraintIds": {
          "type": "array",
          "maxItems": 0
        },
        "evidenceFamilies": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1,
          "prefixItems": [
            {
              "const": "operations"
            }
          ],
          "items": false
        }
      },
      "additionalProperties": false
    }
  ]
}
