{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "event_tl_issue_responses.schema.json",
  "title": "Tech Lead Issue Responses Event Schema",
  "description": "Schema for tl_issue_responses event stored in bazinga-db. Records developer/SSE responses to TL issues.",
  "type": "object",
  "additionalProperties": false,
  "required": ["group_id", "iteration", "from_agent", "issue_responses", "blocking_summary"],
  "$comment": "session_id and event_type are NOT required in payload - injected by save-event CLI",
  "properties": {
    "session_id": {
      "type": "string",
      "pattern": "^bazinga_",
      "description": "Session identifier. Note: When using save-event CLI, session_id is passed as first arg and stored in DB record - NOT required in JSON payload."
    },
    "group_id": {
      "type": "string",
      "description": "Task group identifier"
    },
    "iteration": {
      "type": "integer",
      "minimum": 1,
      "description": "Review iteration number for deduplication"
    },
    "event_type": {
      "const": "tl_issue_responses",
      "description": "Event type identifier"
    },
    "from_agent": {
      "enum": ["developer", "senior_software_engineer"],
      "description": "Which agent responded to TL issues (Developer or SSE after escalation)"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "issue_responses": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["issue_id", "action"],
        "properties": {
          "issue_id": {
            "type": "string",
            "pattern": "^TL-[A-Za-z0-9_-]+-[0-9]+-[0-9]+$",
            "description": "Reference to original TL issue ID"
          },
          "action": {
            "enum": ["FIXED", "REJECTED", "DEFERRED"],
            "description": "Developer's response action"
          },
          "details": {
            "type": "string",
            "description": "Implementation details or fix description"
          },
          "reason": {
            "type": "string",
            "description": "Rejection/deferral reason (required for REJECTED/DEFERRED)"
          },
          "commit": {
            "type": "string",
            "description": "Commit hash for FIXED actions"
          },
          "rejection_accepted": {
            "type": "boolean",
            "description": "DEPRECATED: Use tl_verdicts events instead. This field is ignored in progress calculations. The tl_verdicts event is the single source of truth for TL decisions.",
            "deprecated": true
          },
          "location": {
            "type": "string",
            "description": "File:line location (for cross-iteration matching)"
          },
          "title": {
            "type": "string",
            "description": "Issue title (for cross-iteration matching)"
          }
        }
      }
    },
    "blocking_summary": {
      "type": "object",
      "required": ["total_blocking", "fixed", "rejected_with_reason", "unaddressed"],
      "properties": {
        "total_blocking": {
          "type": "integer",
          "minimum": 0,
          "description": "Total blocking issues from TL"
        },
        "fixed": {
          "type": "integer",
          "minimum": 0,
          "description": "Blocking issues addressed with fixes"
        },
        "rejected_with_reason": {
          "type": "integer",
          "minimum": 0,
          "description": "Blocking issues rejected with justification"
        },
        "unaddressed": {
          "type": "integer",
          "minimum": 0,
          "description": "Blocking issues not addressed (SHOULD be 0)"
        }
      }
    }
  },
  "x-dedup-key": {
    "description": "Deduplication key to prevent duplicate events",
    "fields": ["session_id", "group_id", "iteration", "event_type"]
  }
}
