{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://iarpg.com/alliance-network.schema.json",
  "title": "IARPG Fictional Alliance Network",
  "description": "Validation schema for the browser-local fictional faction, relationship, influence, and mission-seed prototype.",
  "type": "object",
  "required": [
    "$schema",
    "id",
    "release",
    "version",
    "status",
    "updated_utc",
    "purpose",
    "research_basis",
    "fairness_rules",
    "safety_boundary",
    "domains",
    "relationship_types",
    "factions",
    "relationships",
    "alliance_lifecycle",
    "influence_continuum",
    "stress_tests",
    "mission_seeds",
    "counts"
  ],
  "properties": {
    "$schema": {
      "const": "https://iarpg.com/alliance-network.schema.json"
    },
    "id": {
      "const": "https://iarpg.com/alliance-network.json"
    },
    "release": {
      "const": "IARPG-OPS-2"
    },
    "version": {
      "const": "2.0.14-wip"
    },
    "status": {
      "type": "string",
      "minLength": 1
    },
    "updated_utc": {
      "type": "string",
      "format": "date-time"
    },
    "purpose": {
      "type": "string",
      "minLength": 1
    },
    "research_basis": {
      "type": "array",
      "minItems": 6,
      "items": {
        "type": "object",
        "required": [
          "title",
          "url"
        ],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "pattern": "^/docs/report/[a-z0-9-]+#reviewed-synthesis$"
          }
        },
        "additionalProperties": false
      }
    },
    "fairness_rules": {
      "type": "array",
      "minItems": 6,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "safety_boundary": {
      "type": "string",
      "minLength": 1
    },
    "domains": {
      "type": "array",
      "minItems": 8,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "description"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "relationship_types": {
      "type": "array",
      "minItems": 12,
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "definition"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "definition": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "factions": {
      "type": "array",
      "minItems": 12,
      "items": {
        "$ref": "#/$defs/faction"
      }
    },
    "relationships": {
      "type": "array",
      "minItems": 24,
      "items": {
        "$ref": "#/$defs/relationship"
      }
    },
    "alliance_lifecycle": {
      "type": "array",
      "minItems": 7,
      "items": {
        "$ref": "#/$defs/stage"
      }
    },
    "influence_continuum": {
      "type": "array",
      "minItems": 10,
      "items": {
        "type": "object",
        "required": [
          "level",
          "id",
          "label",
          "description"
        ],
        "properties": {
          "level": {
            "type": "integer",
            "minimum": 1
          },
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "stress_tests": {
      "type": "array",
      "minItems": 4,
      "items": {
        "type": "object",
        "required": [
          "id",
          "title",
          "trigger",
          "signals",
          "possible_outcomes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "trigger": {
            "type": "string",
            "minLength": 1
          },
          "signals": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "possible_outcomes": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "additionalProperties": false
      }
    },
    "mission_seeds": {
      "type": "array",
      "minItems": 12,
      "items": {
        "type": "object",
        "required": [
          "id",
          "title",
          "region",
          "domains",
          "factions",
          "brief",
          "objective",
          "uncertainty",
          "nonviolent_path",
          "safety_boundary"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "region": {
            "type": "string",
            "minLength": 1
          },
          "domains": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          "factions": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          "brief": {
            "type": "string",
            "minLength": 1
          },
          "objective": {
            "type": "string",
            "minLength": 1
          },
          "uncertainty": {
            "type": "string",
            "minLength": 1
          },
          "nonviolent_path": {
            "type": "string",
            "minLength": 1
          },
          "safety_boundary": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "counts": {
      "type": "object",
      "required": [
        "factions",
        "relationships",
        "relationship_types",
        "domains",
        "mission_seeds",
        "influence_levels"
      ],
      "properties": {
        "factions": {
          "type": "integer",
          "minimum": 1
        },
        "relationships": {
          "type": "integer",
          "minimum": 1
        },
        "relationship_types": {
          "type": "integer",
          "minimum": 1
        },
        "domains": {
          "type": "integer",
          "minimum": 1
        },
        "mission_seeds": {
          "type": "integer",
          "minimum": 1
        },
        "influence_levels": {
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "$defs": {
    "stage": {
      "type": "object",
      "required": [
        "id",
        "label",
        "description"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "bloc": {
      "type": "object",
      "required": [
        "name",
        "position"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "position": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "recruitment": {
      "type": "object",
      "required": [
        "access",
        "pathways",
        "vetting",
        "integration",
        "lone_actor_posture",
        "safeguards"
      ],
      "properties": {
        "access": {
          "type": "string",
          "minLength": 1
        },
        "pathways": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "vetting": {
          "type": "string",
          "minLength": 1
        },
        "integration": {
          "type": "string",
          "minLength": 1
        },
        "lone_actor_posture": {
          "type": "string",
          "minLength": 1
        },
        "safeguards": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "faction": {
      "type": "object",
      "required": [
        "id",
        "name",
        "short_name",
        "type",
        "region",
        "purpose",
        "public_position",
        "practical_interests",
        "internal_blocs",
        "decision_model",
        "strengths",
        "dependencies",
        "oversight",
        "community_views",
        "recruitment",
        "confidence",
        "x",
        "y"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "short_name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "minLength": 1
        },
        "region": {
          "type": "string",
          "minLength": 1
        },
        "purpose": {
          "type": "string",
          "minLength": 1
        },
        "public_position": {
          "type": "string",
          "minLength": 1
        },
        "practical_interests": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "internal_blocs": {
          "type": "array",
          "minItems": 2,
          "items": {
            "$ref": "#/$defs/bloc"
          }
        },
        "decision_model": {
          "type": "string",
          "minLength": 1
        },
        "strengths": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "dependencies": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "oversight": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "community_views": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "recruitment": {
          "$ref": "#/$defs/recruitment"
        },
        "confidence": {
          "enum": [
            "high",
            "medium",
            "low",
            "disputed"
          ]
        },
        "x": {
          "type": "number",
          "minimum": 0,
          "maximum": 1000
        },
        "y": {
          "type": "number",
          "minimum": 0,
          "maximum": 620
        }
      },
      "additionalProperties": false
    },
    "relationship": {
      "type": "object",
      "required": [
        "id",
        "source",
        "target",
        "type",
        "domains",
        "lifecycle_stage",
        "public_label",
        "practical_note",
        "frictions",
        "confidence",
        "evidence_signals"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "source": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "target": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "type": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "domains": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          }
        },
        "lifecycle_stage": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "public_label": {
          "type": "string",
          "minLength": 1
        },
        "practical_note": {
          "type": "string",
          "minLength": 1
        },
        "frictions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "confidence": {
          "enum": [
            "high",
            "medium",
            "low",
            "disputed"
          ]
        },
        "evidence_signals": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    }
  }
}
