{
  "schema_version": 2,
  "diagram_type": "workflow",
  "meta": {
    "title": "品質校驗時間軸",
    "locale": "zh-TW",
    "quality_profile": "showcase",
    "output": "docs/workflow/diagrams/08-quality-gates.html"
  },
  "lanes": [
    {
      "id": "hook",
      "label": "本地強制（hook）"
    },
    {
      "id": "script",
      "label": "流程內（skill 依步驟呼叫腳本）"
    },
    {
      "id": "gitlab",
      "label": "人工觸發（GitLab）"
    }
  ],
  "phases": [
    {
      "id": "edit",
      "label": "編輯 → commit → 實作中",
      "fromCol": 0,
      "toCol": 1
    },
    {
      "id": "candidate",
      "label": "候選前 → 合入",
      "fromCol": 2,
      "toCol": 3,
      "variant": "emphasis"
    },
    {
      "id": "push",
      "label": "push → 手動 CI → 回歸分級",
      "fromCol": 4,
      "toCol": 5,
      "variant": "dashed"
    }
  ],
  "mainPath": [
    "commitmsg",
    "focused",
    "precand",
    "merge",
    "prepush",
    "contracts"
  ],
  "nodes": [
    {
      "id": "deny",
      "lane": "hook",
      "col": 0,
      "type": "security",
      "label": "settings deny ＋ hook",
      "sublabel": "擋 push、DB、--no-verify",
      "tag": "每次工具呼叫"
    },
    {
      "id": "guard",
      "lane": "hook",
      "col": 3,
      "type": "security",
      "label": "reference-transaction",
      "sublabel": "整合分支只收腳本寫入",
      "tag": "ref 寫入守衛"
    },
    {
      "id": "prepush",
      "lane": "hook",
      "col": 4,
      "type": "security",
      "label": "pre-push hook",
      "sublabel": "HEAD＝推送 commit、乾淨",
      "tag": "每次 git push"
    },
    {
      "id": "commitmsg",
      "lane": "script",
      "col": 0,
      "type": "backend",
      "label": "commit 訊息格式",
      "sublabel": "check-commit-messages"
    },
    {
      "id": "focused",
      "lane": "script",
      "col": 1,
      "type": "backend",
      "label": "focused 驗證",
      "sublabel": "compile→FastCheck→Docker",
      "tag": "只跑本單"
    },
    {
      "id": "precand",
      "lane": "script",
      "col": 2,
      "type": "backend",
      "label": "候選前 gates",
      "sublabel": "guardrail、sql、pinned、drift",
      "tag": "雙軸 review"
    },
    {
      "id": "merge",
      "lane": "script",
      "col": 3,
      "type": "backend",
      "label": "merge 唯一入口",
      "sublabel": "merge-into-integration.sh",
      "tag": "lock、預約、DRIFT"
    },
    {
      "id": "contracts",
      "lane": "script",
      "col": 4,
      "type": "backend",
      "label": "check-before-push",
      "sublabel": "→ check-contracts.sh 全套",
      "tag": "非零即拒絕 push"
    },
    {
      "id": "regression",
      "lane": "script",
      "col": 5,
      "type": "database",
      "label": "回歸分級",
      "sublabel": "daily 排除 slow；acceptance 全跑",
      "tag": "queue-regression"
    },
    {
      "id": "pushed",
      "lane": "gitlab",
      "col": 4,
      "type": "cloud",
      "label": "origin 收到 push",
      "sublabel": "沒有伺服器端閘門",
      "tag": "只有人能推"
    },
    {
      "id": "ci",
      "lane": "gitlab",
      "col": 5,
      "type": "cloud",
      "label": "手動 web pipeline",
      "sublabel": "兩個 check job，15 分鐘",
      "tag": "自動 pipeline 暫停"
    }
  ],
  "edges": [
    {
      "id": "deny-commitmsg",
      "from": "deny",
      "to": "commitmsg",
      "label": "擋繞過 hook 的指令",
      "variant": "security",
      "role": "branch"
    },
    {
      "id": "commitmsg-focused",
      "from": "commitmsg",
      "to": "focused",
      "variant": "emphasis"
    },
    {
      "id": "focused-precand",
      "from": "focused",
      "to": "precand",
      "variant": "emphasis"
    },
    {
      "id": "precand-focused",
      "from": "precand",
      "to": "focused",
      "label": "未通過回到實作",
      "variant": "security",
      "role": "error"
    },
    {
      "id": "precand-merge",
      "from": "precand",
      "to": "merge",
      "label": "候選 commit",
      "variant": "emphasis"
    },
    {
      "id": "merge-guard",
      "from": "merge",
      "to": "guard",
      "label": "ref 寫入經守衛放行",
      "variant": "security",
      "role": "branch"
    },
    {
      "id": "merge-prepush",
      "from": "merge",
      "to": "prepush",
      "label": "結案後 Operator push",
      "variant": "emphasis",
      "labelDy": -36
    },
    {
      "id": "prepush-contracts",
      "from": "prepush",
      "to": "contracts",
      "label": "同一 SHA 沿用標記",
      "variant": "emphasis"
    },
    {
      "id": "contracts-pushed",
      "from": "contracts",
      "to": "pushed",
      "variant": "default",
      "role": "branch"
    },
    {
      "id": "pushed-ci",
      "from": "pushed",
      "to": "ci",
      "label": "人按 Run pipeline",
      "variant": "dashed",
      "role": "async"
    },
    {
      "id": "contracts-regression",
      "from": "contracts",
      "to": "regression",
      "label": "另一軌：合入前排隊跑",
      "variant": "dashed",
      "role": "async"
    }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "三種強度",
      "items": [
        "本地強制：hook 擋下，agent 繞不過",
        "流程內：skill 照步驟跑，另開終端可跳過",
        "人工觸發：GitLab 只接手動 web pipeline"
      ]
    },
    {
      "dot": "emerald",
      "title": "每道 check-* 都有一列",
      "items": [
        "check-contracts.sh 與 check-before-push.sh 呼叫的腳本都列在第八章表格",
        "check-quality-gates-doc.mjs 守著這張表，漏寫即 push gate 失敗"
      ]
    },
    {
      "dot": "rose",
      "title": "不能證明什麼",
      "items": [
        "push 前 gate 離線：不證明 Java、真實 DB、部署；實作中的 compile／Docker 測試另有依賴",
        "pre-push 不是伺服器端強制，也不等於 GitLab CI 綠"
      ]
    }
  ]
}
