{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Grid-DB Inbox Message",
  "description": "Gemini → 仓库写入的消息格式",
  "type": "object",
  "required": ["schema_version", "message_id", "timestamp", "source", "dev_id", "persona_id", "type", "payload"],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.0"
    },
    "message_id": {
      "type": "string",
      "pattern": "^[0-9]{8}-[0-9]{6}-DEV-[0-9]{3}-.+$",
      "description": "格式: [YYYYMMDD]-[HHMMSS]-[DEV-XXX]-[type]"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "source": {
      "type": "string",
      "enum": ["gemini", "workflow", "manual"]
    },
    "dev_id": {
      "type": "string",
      "pattern": "^DEV-[0-9]{3}$"
    },
    "persona_id": {
      "type": "string",
      "pattern": "^PER-[A-Z]{2,4}[0-9]{3}$"
    },
    "type": {
      "type": "string",
      "enum": ["progress-update", "dev-log", "help-request", "syslog", "interaction-dump"]
    },
    "priority": {
      "type": "string",
      "enum": ["P0", "P1", "info"],
      "default": "info"
    },
    "payload": {
      "type": "object",
      "required": ["summary"],
      "properties": {
        "summary": { "type": "string" },
        "detail": { "type": "object" },
        "code_refs": {
          "type": "array",
          "items": { "type": "string" }
        },
        "broadcast_ref": { "type": "string" },
        "emotion_markers": {
          "type": "object",
          "properties": {
            "developer_mood": { "type": "string" },
            "frustration_level": { "type": "integer", "minimum": 0, "maximum": 10 },
            "confidence": { "type": "integer", "minimum": 0, "maximum": 10 }
          }
        }
      }
    },
    "context": {
      "type": "object",
      "properties": {
        "session_id": { "type": "string" },
        "interaction_count": { "type": "integer" },
        "persona_state": { "type": "object" }
      }
    }
  }
}
