#!/usr/bin/env bash # Constitution enforcement: no amendment, no functional change. # # If a commit touches src/ (game behavior), it must also touch spec/ or # DESIGN.md (the amendment). Process-only commits (AGENT.md, tools/, # DEVLOG.md, README.md, knowledge/) are exempt. # # This is the local fast-feedback layer. The Tangled pipeline is the # server-side enforcement that can't be bypassed. set -euo pipefail # Get staged files (added, modified, renamed, copied — not deleted) changed=$(git diff --cached --name-only --diff-filter=ACMR HEAD) if [ -z "$changed" ]; then exit 0 fi # Check if any src/ file is in the changeset touches_src=0 echo "$changed" | grep -q "^src/" && touches_src=1 if [ "$touches_src" -eq 0 ]; then # No functional changes — commit is fine exit 0 fi # src/ is touched: require spec/ or DESIGN.md in the same commit touches_spec=0 echo "$changed" | grep -qE "^spec/|^DESIGN\.md" && touches_spec=1 if [ "$touches_spec" -eq 0 ]; then echo "" echo "CONSTITUTION VIOLATION" echo " This commit touches src/ (functional change) but does not touch" echo " spec/ or DESIGN.md (the amendment)." echo "" echo " AGENT.md: 'No amendment, no functional change.'" echo " Either add a spec/DESIGN.md change to this commit, or restructure" echo " so functional changes and their amendment ship together." echo "" echo " If this is a false positive (e.g. generated code, test-only change)," echo " bypass with: git commit --no-verify" echo "" exit 1 fi exit 0