{
  "schema_version": 2,
  "diagram_type": "workflow",
  "meta": {
    "title": "SQL Issue 變體",
    "locale": "zh-TW",
    "quality_profile": "standard",
    "output": "docs/workflow/diagrams/07-sql-issue.html"
  },
  "lanes": [
    { "id": "operator", "label": "Operator（人）" },
    { "id": "claude", "label": "Claude Code" },
    { "id": "gitlab", "label": "GitLab" },
    { "id": "local", "label": "本機 Docker" }
  ],
  "mainPath": ["discover", "declare", "exec", "readback", "closesql", "unblock"],
  "nodes": [
    { "id": "discover", "lane": "claude", "col": 0, "type": "backend", "label": "SQL-first 評估", "sublabel": "開工、範圍變更、交付前各一次" },
    { "id": "declare", "lane": "claude", "col": 1, "type": "backend", "label": "sql-issue.mjs", "sublabel": "建 SQL Issue 並宣告 prerequisite" },
    { "id": "readback", "lane": "claude", "col": 3, "type": "backend", "label": "讀回結果", "sublabel": "verify 只跑固定唯讀查詢" },
    { "id": "closesql", "lane": "claude", "col": 4, "type": "backend", "label": "close-sql-issue.mjs", "sublabel": "close-issue 會拒絕 SQL Issue" },
    { "id": "unblock", "lane": "claude", "col": 5, "type": "backend", "label": "feature Issue 解除 Blocked by", "sublabel": "再走 /issue-run" },
    { "id": "sqlissue", "lane": "gitlab", "col": 1, "type": "cloud", "label": "SQL Issue", "sublabel": "feature Issue body：Blocked by #sql" },
    { "id": "closed", "lane": "gitlab", "col": 4, "type": "cloud", "label": "SQL Issue 已關閉", "sublabel": "prerequisite 滿足" },
    { "id": "exec", "lane": "operator", "col": 2, "type": "external", "label": "人執行 SQL", "sublabel": "共用 DB 只能手動", "tag": "SQL 以檔案交付" },
    { "id": "localdb", "lane": "local", "col": 2, "type": "database", "label": "本機 MySQL", "sublabel": "可拋棄，可自由試跑" }
  ],
  "edges": [
    { "id": "s1", "from": "discover", "to": "declare", "label": "需要目標 SQL", "variant": "emphasis" },
    { "id": "s2", "from": "declare", "to": "sqlissue", "label": "建立", "variant": "default", "role": "branch" },
    { "id": "s3", "from": "declare", "to": "exec", "label": "交付 SQL 檔", "variant": "security" },
    { "id": "s4", "from": "declare", "to": "localdb", "label": "先在本機試跑", "variant": "dashed", "role": "branch" },
    { "id": "s5", "from": "exec", "to": "readback", "label": "貼回執行結果", "variant": "emphasis" },
    { "id": "s6", "from": "readback", "to": "closesql", "variant": "emphasis" },
    { "id": "s7", "from": "closesql", "to": "closed", "label": "關閉", "variant": "default", "role": "branch" },
    { "id": "s8", "from": "closesql", "to": "unblock", "variant": "emphasis" }
  ],
  "cards": [
    { "dot": "cyan", "title": "邊界", "items": ["agent 不連共用資料庫、不執行目標 SQL；只有本機可拋棄的 Docker MySQL 可以隨意跑", "沒有 SQL 時在 feature Issue body 記 SQL prerequisite：無 與理由"] },
    { "dot": "rose", "title": "常見坑", "items": ["手動 SQL 以檔案交付，貼到終端會被 CRLF 換行弄壞；COMMENT 用 HEX 檢查", "SQL Issue 不能用 close-issue.mjs 結案"] }
  ]
}
