docs(modularization): 建立模組化治理守門
All checks were successful
CD Pipeline / deploy (push) Successful in 1m36s

This commit is contained in:
OoO
2026-04-30 14:07:10 +08:00
parent db21e7e8e8
commit c2e38be43d
13 changed files with 176 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
> 本文件定義專案開發的核心準則與不可違反的規範
> **建立日期**: 2026-01-12
> **當前版本**: V10.20 (ElephantAlpha transient fallback 版)
> **當前版本**: V10.21 (模組化治理守門版)
> **最後更新**: 2026-04-30
---
@@ -178,6 +178,18 @@
---
## 第六之一章:模組化治理規範
### 第 21.1 條:模組分層與大檔治理(強制要求)
- ✅ **正確**:新功能必須先放入對應層級:`routes/` 只處理 HTTP/Blueprint glue`services/` 放商業邏輯與外部 API client`database/` 放 ORM/DB access`utils/` 放無狀態共用工具,`templates/` 放 UI。
- ✅ **正確**`app.py` 只保留 Flask 初始化、Blueprint 註冊、啟動自檢、版本與全域設定;禁止新增 route、長函式或商業邏輯。
- ✅ **正確**:現有超過 800 行的 Python 檔案視為拆分技術債,只能做 bugfix / 安全修補 / 搭橋式抽離;新增功能前應優先抽 shared service 或子模組。
- ✅ **正確**:新增或修改導致 Python 檔案超過 600 行時,必須先評估拆模組;超過 800 行必須更新 `docs/memory/code_modularization_inventory_20260430.md` 與對應測試,並寫出拆分計畫。
- ❌ **禁止**:把可共用邏輯藏在 route、template helper 或單一巨檔內,造成其他模組只能複製貼上。
- **依據**ADR-017、`docs/guides/modularization_governance.md`
---
## 第七章:程式碼品質規範
### 第 22 條:命名規範(強制要求)