phase 9.1-9.2: add commit-msg hook + consolidate tool docs

Adds the commit-msg hook promised in HOOKS.md since Round 5.
The hook auto-prepends the current Red Bear development phase
(e.g. 'phase 8.4:') to commit messages. The phase is detected
from the most recent 'phase X.Y:' commit in the git log.

Hook behavior:
  - Normal commit    → prepended: 'phase 8.4: my message'
  - Already has prefix → skipped
  - Revert message   → skipped
  - Empty/comment    → skipped

Install: cp local/scripts/commit-msg .git/hooks/commit-msg && chmod +x

Updates HOOKS.md with:
  - commit-msg hook documentation (install, behavior)
  - Full tool inventory table (10 tools across 9+ rounds)
    listing each tool's type, purpose, and modes/flags
This commit is contained in:
2026-07-12 12:20:29 +03:00
parent 3cbdad57e1
commit 87f3f908bf
2 changed files with 62 additions and 2 deletions
+29 -2
View File
@@ -74,5 +74,32 @@ in `local/scripts/` so operators can opt in by copying it to
## Audit
This directory was created in Phase 4.5 (Round 5). The current
hook inventory is just the 1 file above. Future hooks should be
added here as they are created.
hook inventory is:
| Hook | File | Function |
|------|------|----------|
| pre-push | `local/scripts/pre-push-checks.sh` | Runs 7 pre-flight checks before push |
| commit-msg | `local/scripts/commit-msg` | Auto-prepends `phase X.Y:` to commit messages |
| (server-side) | (gitea admin only) | Pre-receive — defense in depth; not yet implemented |
## Full Tool Inventory (Round 10)
The build system has grown organically across 9+ rounds. Here is
the complete tool inventory for reference.
| Tool | Type | Purpose | Modes |
|------|------|---------|-------|
| `patch-status.sh` | shell | Top-level consolidated report | `--brief`, `--json` |
| `sync-versions.sh` | shell | Cat 0+1+2 version sync | `--check`, `--no-regen`, `--regen-only` |
| `verify-patch-content.sh` | shell↦py | Orphan patch detection | `--strict`, `--report action\|detail`, `--selftest` |
| `verify-fork-versions.sh` | shell | Cat 2 fork supremacy check | diverged mode; `REDBEAR_STRICT_DIVERGED_CHECK=1` |
| `verify-collision-detection.py` | python | Config [[files]] vs installs/files collision | `--strict`, `--selftest` (8 cases) |
| `pre-push-checks.sh` | shell | 7-check pre-push safety net | `--soft` for warn-only |
| `push-fork-branches.sh` | shell | Operator-reviewed fork push | `--execute` for actual push (default=print-only) |
| `unblock-base-push.sh` | shell | Base fork deadlock resolver | `path-a`, `path-b`, `path-c` for 3 operator paths |
| `commit-msg` | shell | Auto-phase-prefix hook | opt-in; install to `.git/hooks/commit-msg` |
| `build-preflight.sh` | shell | Build-time validation | Called by `build-redbear.sh` |
All scripts are under `local/scripts/` and are designed to be
operator-friendly. Hooks are strictly opt-in per AGENTS.md
"absolutely NEVER DELETE, NEVER IGNORE" rule.
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# commit-msg — Optional commit-msg hook for Red Bear OS.
# Auto-prepends the current development phase to commit messages.
# Usage:
# cp local/scripts/commit-msg .git/hooks/commit-msg
# chmod +x .git/hooks/commit-msg
# The hook is OPT-IN. See local/docs/HOOKS.md.
set -euo pipefail
COMMIT_MSG_FILE="$1"
PHASE=""
# Detect current phase from the most recent "phase X.Y:" commit in log
detect_phase() {
PHASE=$(git log --oneline -50 2>/dev/null | grep -oP 'phase \d+\.\d+' | head -1)
[ -n "$PHASE" ] || PHASE="phase"
}
detect_phase
FIRST_LINE=$(head -1 "$COMMIT_MSG_FILE" 2>/dev/null)
# Already has phase prefix or is Revert — skip
echo "$FIRST_LINE" | grep -qE '^(phase [0-9]+\.[0-9]+):' && exit 0
echo "$FIRST_LINE" | grep -qE '^Revert ' && exit 0
# Empty or comment — skip
[ -z "$FIRST_LINE" ] && exit 0
echo "$FIRST_LINE" | grep -q '^#' && exit 0
# Prepend phase
sed -i "1s/^/${PHASE}: /" "$COMMIT_MSG_FILE"
exit 0