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

@@ -112,3 +112,15 @@ Phase 3e4/28-29完成 app.py 7,386→6,590 行(-10.8%),但**僅完
- 模板僅存 `templates/` + `web/templates/vendor_stockout/`
- gunicorn `--preload` 啟用、cache 跨 worker 一致
- scheduler 7 處 except 全改、docker-compose mount 全清
## 2026-04-30 補充決策:模組化治理守門
Phase 3f 已陸續完成 DB metadata、路由註冊、cache、scheduler、模板與 orphan cleanup 的多個收斂項目,但 line-count 盤點仍顯示 15 個 Python 檔案超過 800 行。為避免後續功能開發再次把 route / service 寫成巨檔,本 ADR 補充以下守門規則:
1. `app.py` 只保留 Flask app bootstrap、Blueprint registration、啟動自檢、版本與全域設定不得新增 route 或商業邏輯。
2. `routes/` 必須保持 thin controller重複邏輯需抽到 `services/``utils/`
3. 超過 800 行的 Python 檔案列入 `docs/memory/code_modularization_inventory_20260430.md`只能做安全修補、bugfix、或往外抽模組新增功能應先拆分。
4. 新增 Python 檔案超過 600 行需提出拆分理由;超過 800 行需同步更新 inventory 與測試。
5. `tests/test_modularization_governance.py` 是守門測試:新巨檔沒有被盤點會失敗。
詳細操作規則以 `docs/guides/modularization_governance.md` 為準。