{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:coding-task-v1",
  "title": "AWOOOI Coding 任務事件 (v1)",
  "description": "Code Review 後交給 Codex 或其他 coding worker 的標準任務契約。初期只允許 patch-only / suggest-only。",
  "type": "object",
  "required": [
    "schema_version",
    "source",
    "repo",
    "branch",
    "base_sha",
    "head_sha",
    "risk",
    "summary",
    "allowed_actions",
    "blocked_actions",
    "required_reviewers"
  ],
  "properties": {
    "schema_version": {
      "const": "coding_task_v1"
    },
    "source": {
      "type": "string",
      "enum": [
        "github_code_review",
        "gitea_code_review",
        "codex_security",
        "manual_review"
      ]
    },
    "repo": {
      "type": "string",
      "minLength": 1
    },
    "branch": {
      "type": "string",
      "minLength": 1
    },
    "base_sha": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{7,40}$"
    },
    "head_sha": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{7,40}$"
    },
    "risk": {
      "type": "string",
      "enum": ["LOW", "MEDIUM", "HIGH", "CRITICAL"]
    },
    "summary": {
      "type": "string",
      "minLength": 1
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "severity", "file", "reason", "recommended_action"],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "severity": {
            "type": "string",
            "enum": ["LOW", "MEDIUM", "HIGH", "CRITICAL"]
          },
          "file": {
            "type": "string",
            "minLength": 1
          },
          "reason": {
            "type": "string",
            "minLength": 1
          },
          "recommended_action": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "allowed_actions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "enum": [
          "create_patch",
          "add_tests",
          "open_draft_pr"
        ]
      },
      "uniqueItems": true
    },
    "blocked_actions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "enum": [
          "auto_merge",
          "production_deploy",
          "force_push",
          "secret_rotation",
          "network_policy_change"
        ]
      },
      "uniqueItems": true
    },
    "required_reviewers": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "critic",
          "vuln-verifier",
          "migration-engineer",
          "security-commander",
          "human-owner"
        ]
      },
      "uniqueItems": true
    },
    "evidence_refs": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": false
}
