Files
Leo 7b83465acf feat: SDD 生命週期鐵律——單一活性 SDD+pending-changes 緩衝+雙層硬約束(issue #6)+ bump 1.15.0
leo 2026-07-17 拍板:任何時刻每 repo 只有一份現行 SDD(status: active)。

- 新增 3-specs/SDD-LIFECYCLE.md:frontmatter 狀態標記(active|draft|paused|closed + superseded_by)+五條鐵律(單一活性/禁 CC 自建 SDD/規格變更走 pending-changes.md 等 confirm/開新 SDD 先逐條搬舊任務才准寫 code/session 開始回報三數字)
- 新增 3-specs/pending-changes.md:規格變更緩衝區骨架(待裁決/已裁決留底)
- TEMPLATE-sdd/design.md 掛 frontmatter(status: draft),移除舊「> 狀態」blockquote
- sdd-guard.sh 升級:active>1 不論寫什麼檔一律 exit 2;寫 code 檔需恰好 1 份 active;老 repo 無 frontmatter 退回舊行為(統計排除 archive/ 與 TEMPLATE)
- 新增 template/scripts/sdd-active-check.sh:獨立檢查,pre-commit/CI 可掛,>1 exit 1
- /sdd-check 加生命週期段(五鐵律摘要+三數字回報格式);template/CLAUDE.md 鐵律指向 SDD-LIFECYCLE.md
- install.sh/update.sh 鋪齊新檔(issue #13 教訓:update 不補新檔=結構斷層)
- 三情境 pipe-test 真跑通過:兩份 active 擋(2)/一份放行(0)/零 frontmatter 退舊行為(0)
- 版號:遠端已被 issue #5(vault 萃取)佔走 1.14.0,本案改記 1.15.0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 16:53:18 +08:00

50 lines
1.8 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# sdd-active-check.sh — 單一活性 SDD 獨立硬約束(SDD 生命週期鐵律,issue #6
# 規則全文:system-dev/docs/3-specs/SDD-LIFECYCLE.md
#
# 用法:bash sdd-active-check.sh [specs目錄]
# 參數 1(可選)=specs 目錄,預設 system-dev/docs/3-specs
#
# 行為:統計 status: active 的 design.mddesign.md 前 10 行有 ^status: active
# 排除 archive/ 與 TEMPLATE)——
# >1 份 → stderr 列出清單,exit 1(違反單一活性)
# ≤1 份 → exit 0
#
# pre-commit 掛法(.git/hooks/pre-commit,記得 chmod +x):
# #!/bin/sh
# bash system-dev/scripts/sdd-active-check.sh || exit 1
# CI 也是同一行,違反即紅。
#
# 誠實限制:與 sdd-guard.sh 同精神——只做語法層機械檢查,繞道可行但留痕可審,
# 不聲稱不可繞過。價值是「不變量被違反時一定有機器出聲」。
set -euo pipefail
SPECS_DIR="${1:-system-dev/docs/3-specs}"
# 沒有 specs 目錄(沒裝 SDD 模組)→ 無事可查,放行
[ -d "$SPECS_DIR" ] || exit 0
ACTIVE_COUNT=0
ACTIVE_LIST=""
while IFS= read -r f; do
[ -n "$f" ] || continue
if head -10 "$f" 2>/dev/null | grep -q '^status:[[:space:]]*active'; then
ACTIVE_COUNT=$((ACTIVE_COUNT + 1))
ACTIVE_LIST="${ACTIVE_LIST}${f}
"
fi
done < <(find "$SPECS_DIR" -name 'design.md' -not -path '*TEMPLATE*' -not -path '*/archive/*' 2>/dev/null)
if [ "$ACTIVE_COUNT" -gt 1 ]; then
cat >&2 <<EOF
🚫 SDD 單一活性鐵律違反:${SPECS_DIR}/ 下有 ${ACTIVE_COUNT} 份 status: active 的 SDD(任何時刻最多一份):
${ACTIVE_LIST}
請收斂到一份:其餘改 status: paused / closedclosed 且被取代者填 superseded_by 並移入 archive/)。
規則見 system-dev/docs/3-specs/SDD-LIFECYCLE.md。
EOF
exit 1
fi
exit 0