{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://iarpg.com/campaign-turn.schema.json",
  "title": "IARPG Deterministic Campaign Turn Export",
  "description": "A compact browser-local record of one fictional alliance campaign response.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "record_type",
    "release",
    "version",
    "campaign_id",
    "baseline_version",
    "turn",
    "scenario_event",
    "response",
    "evidence_events",
    "consultation_questions",
    "consultation_decision",
    "relationship_changes",
    "internal_bloc_responses",
    "affected_community_consequences",
    "correction_path",
    "mission_brief_ids",
    "reason_codes",
    "reversible",
    "truth_boundary",
    "safety_boundary",
    "generated_by"
  ],
  "properties": {
    "$schema": {
      "const": "https://iarpg.com/campaign-turn.schema.json"
    },
    "record_type": {
      "const": "campaign-turn"
    },
    "release": {
      "const": "IARPG-OPS-2"
    },
    "version": {
      "const": "1.0.0"
    },
    "campaign_id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "baseline_version": {
      "const": "2.0.15-wip"
    },
    "turn": {
      "type": "integer",
      "minimum": 1
    },
    "scenario_event": {
      "$ref": "#/$defs/scenarioEventSummary"
    },
    "response": {
      "$ref": "#/$defs/responseSummary"
    },
    "evidence_events": {
      "type": "array",
      "minItems": 2,
      "items": {
        "$ref": "#/$defs/evidenceEvent"
      }
    },
    "consultation_questions": {
      "type": "array",
      "minItems": 2,
      "items": {
        "type": "string",
        "minLength": 10
      }
    },
    "consultation_decision": {
      "$ref": "#/$defs/consultationDecision"
    },
    "relationship_changes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/relationshipChange"
      }
    },
    "internal_bloc_responses": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/internalBlocResponse"
      }
    },
    "affected_community_consequences": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/communityConsequence"
      }
    },
    "correction_path": {
      "$ref": "#/$defs/correctionPath"
    },
    "mission_brief_ids": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/id"
      }
    },
    "reason_codes": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[A-Z][A-Z0-9_]+$"
      }
    },
    "reversible": {
      "const": true
    },
    "truth_boundary": {
      "type": "string",
      "minLength": 40
    },
    "safety_boundary": {
      "type": "string",
      "minLength": 40
    },
    "generated_by": {
      "const": "IARPG browser-local deterministic campaign console"
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "scenarioEventSummary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "category",
        "trigger",
        "design_question"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "title": {
          "type": "string",
          "minLength": 3
        },
        "category": {
          "$ref": "#/$defs/id"
        },
        "trigger": {
          "type": "string",
          "minLength": 20
        },
        "design_question": {
          "type": "string",
          "minLength": 20
        }
      }
    },
    "responseSummary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "label",
        "summary"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "label": {
          "type": "string",
          "minLength": 5
        },
        "summary": {
          "type": "string",
          "minLength": 20
        }
      }
    },
    "evidenceEvent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "kind",
        "summary",
        "source_class",
        "confidence",
        "contestability"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "kind": {
          "$ref": "#/$defs/id"
        },
        "summary": {
          "type": "string",
          "minLength": 15
        },
        "source_class": {
          "$ref": "#/$defs/id"
        },
        "confidence": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "contestability": {
          "type": "string",
          "minLength": 15
        }
      }
    },
    "consultationDecision": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "participants",
        "decision_rule",
        "decision",
        "recording_rule",
        "dissent"
      ],
      "properties": {
        "participants": {
          "type": "array",
          "minItems": 2,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/id"
          }
        },
        "decision_rule": {
          "type": "string",
          "minLength": 5
        },
        "decision": {
          "type": "string",
          "minLength": 20
        },
        "recording_rule": {
          "type": "string",
          "minLength": 20
        },
        "dissent": {
          "type": "string",
          "minLength": 10
        }
      }
    },
    "domainPosture": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "domain",
        "cooperation"
      ],
      "properties": {
        "domain": {
          "$ref": "#/$defs/id"
        },
        "cooperation": {
          "enum": [
            "minimal",
            "bounded",
            "formal",
            "integrated",
            "contested",
            "suspended"
          ]
        }
      }
    },
    "relationshipState": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "relationship_id",
        "version",
        "lifecycle_stage",
        "domain_postures",
        "burden_distribution",
        "source_dependency",
        "target_dependency",
        "consultation_state",
        "evidence_confidence",
        "community_impact",
        "reason_code",
        "explanation",
        "evidence_event_ids",
        "reversible"
      ],
      "properties": {
        "relationship_id": {
          "$ref": "#/$defs/id"
        },
        "version": {
          "type": "integer",
          "minimum": 1
        },
        "effective_turn": {
          "type": "integer",
          "minimum": 0
        },
        "lifecycle_stage": {
          "$ref": "#/$defs/id"
        },
        "domain_postures": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/domainPosture"
          }
        },
        "burden_distribution": {
          "enum": [
            "balanced",
            "source-heavy",
            "target-heavy",
            "contested"
          ]
        },
        "source_dependency": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "target_dependency": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "consultation_state": {
          "enum": [
            "unavailable",
            "available",
            "routine",
            "active",
            "suspended"
          ]
        },
        "evidence_confidence": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "community_impact": {
          "enum": [
            "beneficial",
            "mixed",
            "strained",
            "harmful"
          ]
        },
        "reason_code": {
          "type": "string",
          "pattern": "^[A-Z][A-Z0-9_]+$"
        },
        "explanation": {
          "type": "string",
          "minLength": 15
        },
        "evidence_event_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          }
        },
        "reversible": {
          "const": true
        },
        "supersedes": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "reversal": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "eligible",
        "trigger",
        "restores"
      ],
      "properties": {
        "eligible": {
          "const": true
        },
        "trigger": {
          "type": "string",
          "minLength": 15
        },
        "restores": {
          "const": "previous-version"
        }
      }
    },
    "relationshipChange": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "relationship_id",
        "relationship_label",
        "relationship_type",
        "domain",
        "from_version",
        "to_version",
        "before",
        "after",
        "reason_code",
        "domain_posture_updates",
        "explanation",
        "reversal"
      ],
      "properties": {
        "relationship_id": {
          "$ref": "#/$defs/id"
        },
        "relationship_label": {
          "type": "string",
          "minLength": 3
        },
        "relationship_type": {
          "$ref": "#/$defs/id"
        },
        "domain": {
          "$ref": "#/$defs/id"
        },
        "from_version": {
          "type": "integer",
          "minimum": 1
        },
        "to_version": {
          "type": "integer",
          "minimum": 2
        },
        "before": {
          "$ref": "#/$defs/relationshipState"
        },
        "after": {
          "$ref": "#/$defs/relationshipState"
        },
        "reason_code": {
          "type": "string",
          "pattern": "^[A-Z][A-Z0-9_]+$"
        },
        "domain_posture_updates": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/domainPosture"
          }
        },
        "explanation": {
          "type": "string",
          "minLength": 15
        },
        "reversal": {
          "$ref": "#/$defs/reversal"
        }
      }
    },
    "internalBlocResponse": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "faction_id",
        "bloc_name",
        "stance",
        "rationale"
      ],
      "properties": {
        "faction_id": {
          "$ref": "#/$defs/id"
        },
        "bloc_name": {
          "type": "string",
          "minLength": 3
        },
        "stance": {
          "enum": [
            "support",
            "oppose",
            "support with conditions",
            "support with limits",
            "support with regret"
          ]
        },
        "rationale": {
          "type": "string",
          "minLength": 10
        }
      }
    },
    "communityConsequence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "community",
        "likely_effect",
        "safeguard",
        "severity"
      ],
      "properties": {
        "community": {
          "type": "string",
          "minLength": 3
        },
        "likely_effect": {
          "type": "string",
          "minLength": 15
        },
        "safeguard": {
          "type": "string",
          "minLength": 15
        },
        "severity": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        }
      }
    },
    "correctionPath": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "trigger",
        "action"
      ],
      "properties": {
        "trigger": {
          "type": "string",
          "minLength": 15
        },
        "action": {
          "type": "string",
          "minLength": 15
        }
      }
    }
  }
}
