{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bibleome.org/schemas/oia-v1.schema.json",
  "title": "Bibleome Inductive Study (OIA) Payload v1",
  "description": "Vendor-neutral schema for bottom-up Observation / Interpretation / Application (OIA) study notes with mandatory {b, c, v} scriptural grounding and multi-tradition non-dogmatic tensions.",
  "type": "object",
  "required": [
    "meta",
    "observations",
    "theses",
    "tensions",
    "glossary",
    "segments",
    "applications"
  ],
  "properties": {
    "meta": {
      "type": "object",
      "required": ["title", "principle"],
      "properties": {
        "title": { "type": "string", "minLength": 1 },
        "principle": { "type": "string", "minLength": 1 },
        "principle_type": { "type": "string" },
        "sensitive": { "type": "integer", "enum": [0, 1] }
      }
    },
    "observations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["point", "support"],
        "properties": {
          "kind": { "type": "string" },
          "point": { "type": "string", "minLength": 1 },
          "support": {
            "type": "array",
            "minItems": 1,
            "items": { "$ref": "#/$defs/bcv" }
          }
        }
      }
    },
    "theses": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["claim", "support"],
        "properties": {
          "claim": { "type": "string", "minLength": 1 },
          "support": {
            "type": "array",
            "minItems": 1,
            "items": { "$ref": "#/$defs/bcv" }
          }
        }
      }
    },
    "tensions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["issue", "positions"],
        "properties": {
          "issue": { "type": "string", "minLength": 1 },
          "positions": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "object",
              "required": ["reading", "support"],
              "properties": {
                "tradition": { "type": "string" },
                "reading": { "type": "string", "minLength": 1 },
                "support": {
                  "type": "array",
                  "items": { "$ref": "#/$defs/bcv" }
                }
              }
            }
          }
        }
      }
    },
    "glossary": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["strong", "orig"],
        "properties": {
          "strong": { "type": "string", "pattern": "^[HG][0-9]+$" },
          "orig": { "type": "string", "minLength": 1 },
          "gloss": { "type": "string" },
          "zh": { "type": "string", "description": "Legacy alias for gloss" }
        },
        "anyOf": [
          { "required": ["gloss"] },
          { "required": ["zh"] }
        ]
      }
    },
    "segments": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["v_start", "v_end", "title"],
        "properties": {
          "v_start": { "type": "integer", "minimum": 1 },
          "v_end": { "type": "integer", "minimum": 1 },
          "level": { "type": "integer" },
          "basis": { "type": "string" },
          "title": { "type": "string" },
          "why": { "type": "string" }
        }
      }
    },
    "applications": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["question", "support"],
        "properties": {
          "for_whom": { "type": "string" },
          "question": { "type": "string", "minLength": 1 },
          "support": {
            "type": "array",
            "minItems": 1,
            "items": { "$ref": "#/$defs/bcv" }
          }
        }
      }
    },
    "answers": { "type": "array" },
    "layer_notes": { "type": "object" },
    "allusion_notes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["ref", "note"],
        "properties": {
          "ref": { "$ref": "#/$defs/bcv" },
          "note": { "type": "string" }
        }
      }
    }
  },
  "$defs": {
    "bcv": {
      "type": "object",
      "required": ["b", "c", "v"],
      "properties": {
        "b": { "type": "integer", "minimum": 1, "maximum": 66 },
        "c": { "type": "integer", "minimum": 1, "maximum": 150 },
        "v": { "type": "integer", "minimum": 1, "maximum": 176 }
      }
    }
  }
}
