{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.local/schemas/parser_event.schema.json",
  "title": "ParserEvent",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "document_id",
    "parser_kind",
    "event_type",
    "event_direction",
    "event_date",
    "filing_time_bucket",
    "summary",
    "guidance",
    "signals",
    "risk_flags",
    "confidence"
  ],
  "properties": {
    "schema_version": { "type": "string" },
    "document_id": { "type": "string", "minLength": 1 },
    "parser_kind": {
      "type": "string",
      "enum": ["rule", "llm", "merged"]
    },
    "event_type": {
      "type": "string",
      "enum": [
        "earnings_release",
        "guidance_update",
        "material_contract",
        "regulatory_or_approval",
        "capital_markets_or_financing",
        "management_change",
        "litigation_or_investigation",
        "other_material_event",
        "unknown"
      ]
    },
    "event_direction": {
      "type": "string",
      "enum": ["bullish", "bearish", "mixed", "neutral", "unknown"]
    },
    "event_date": { "type": "string", "format": "date" },
    "filing_time_bucket": {
      "type": "string",
      "enum": ["pre_market", "regular_hours", "post_market", "unknown"]
    },
    "headline": { "type": "string" },
    "summary": { "type": "string", "minLength": 1 },
    "guidance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "scope", "notes"],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "raised",
            "inline_or_maintained",
            "lowered",
            "withdrawn",
            "not_provided",
            "unclear"
          ]
        },
        "scope": {
          "type": "string",
          "enum": ["quarterly", "annual", "both", "unknown"]
        },
        "notes": { "type": "string" }
      }
    },
    "signals": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "demand_strength",
        "pricing_power",
        "backlog_or_bookings",
        "customer_expansion",
        "margin_quality"
      ],
      "properties": {
        "demand_strength": { "type": "string", "enum": ["strong", "stable", "weakening", "unknown"] },
        "pricing_power": { "type": "string", "enum": ["present", "mixed", "absent", "unknown"] },
        "backlog_or_bookings": { "type": "string", "enum": ["present", "mixed", "absent", "unknown"] },
        "customer_expansion": { "type": "string", "enum": ["present", "mixed", "absent", "unknown"] },
        "margin_quality": { "type": "string", "enum": ["improving", "stable", "deteriorating", "unknown"] }
      }
    },
    "risk_flags": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "oneoff_item",
        "tax_benefit",
        "valuation_gain",
        "non_gaap_heavy",
        "financing_related",
        "legal_or_regulatory_overhang"
      ],
      "properties": {
        "oneoff_item": { "type": "boolean" },
        "tax_benefit": { "type": "boolean" },
        "valuation_gain": { "type": "boolean" },
        "non_gaap_heavy": { "type": "boolean" },
        "financing_related": { "type": "boolean" },
        "legal_or_regulatory_overhang": { "type": "boolean" }
      }
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["label", "text_span", "section_hint", "confidence"],
        "properties": {
          "label": { "type": "string" },
          "text_span": { "type": "string" },
          "section_hint": { "type": "string" },
          "confidence": { "type": "number", "minimum": 0, "maximum": 1 }
        }
      }
    },
    "confidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["overall", "event_type", "event_direction", "guidance", "risk_flags"],
      "properties": {
        "overall": { "type": "number", "minimum": 0, "maximum": 1 },
        "event_type": { "type": "number", "minimum": 0, "maximum": 1 },
        "event_direction": { "type": "number", "minimum": 0, "maximum": 1 },
        "guidance": { "type": "number", "minimum": 0, "maximum": 1 },
        "risk_flags": { "type": "number", "minimum": 0, "maximum": 1 }
      }
    },
    "warnings": {
      "type": "array",
      "items": { "type": "string" }
    }
  }
}
