TTOPM commited on
Commit
5b1a270
·
verified ·
1 Parent(s): 2dd2c2e

Upload 4 files

Browse files
Files changed (4) hide show
  1. hooks/README.md +8 -0
  2. hooks/pre-commit +20 -0
  3. hooks/pre-push +51 -0
  4. hooks/prepare-commit-msg +12 -0
hooks/README.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Git Hooks (Local-only installers)
2
+
3
+ These scripts are versioned here and installed into `.git/hooks/` locally.
4
+
5
+ ## Quick start
6
+ ```bash
7
+ chmod +x install_hooks.sh
8
+ ./install_hooks.sh
hooks/pre-commit ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ PY=${PYTHON:-python3}
5
+ BASE="belel-justice-covenant"
6
+
7
+ # 1) Block destructive edits (append-only enforcement)
8
+ if [ -f "$BASE/protocol_instructions/revisionism_resistor.py" ]; then
9
+ $PY "$BASE/protocol_instructions/revisionism_resistor.py"
10
+ fi
11
+
12
+ # 2) Verify or create checksums
13
+ if [ -f "$BASE/tools/generate_checksums.py" ]; then
14
+ if [ -f "$BASE/signing/checksums.txt" ]; then
15
+ $PY "$BASE/tools/generate_checksums.py" --verify
16
+ else
17
+ echo "[pre-commit] No checksums.txt found — creating baseline."
18
+ $PY "$BASE/tools/generate_checksums.py"
19
+ fi
20
+ fi
hooks/pre-push ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Covenant auto-snapshot + integrity gate (pre-push)
3
+ # - Blocks if archives violate append-only policy
4
+ # - Auto-evolves + commits checksums snapshot when changes are additive
5
+
6
+ set -euo pipefail
7
+
8
+ PY=${PYTHON:-python3}
9
+ BASE="belel-justice-covenant"
10
+ GEN="$BASE/tools/generate_checksums.py"
11
+ RES="$BASE/protocol_instructions/revisionism_resistor.py"
12
+ CHK="$BASE/signing/checksums.txt"
13
+ AUTO="${COVENANT_AUTO_EVOLVE:-1}"
14
+
15
+ echo "[pre-push] Covenant integrity gate…"
16
+
17
+ # 1) Enforce append-only integrity (blocks on destructive edits)
18
+ if [ -f "$RES" ]; then
19
+ $PY "$RES"
20
+ fi
21
+
22
+ # 2) Verify checksums; if mismatched and AUTO_EVOLVE=1, roll + commit new snapshot
23
+ if [ -f "$GEN" ]; then
24
+ if [ ! -f "$CHK" ]; then
25
+ echo "[pre-push] No checksums baseline — generating…"
26
+ $PY "$GEN"
27
+ git add "$BASE/signing" || true
28
+ git commit -m "Covenant: add baseline checksums snapshot [ci skip]" || true
29
+ else
30
+ set +e
31
+ $PY "$GEN" --verify
32
+ RC=$?
33
+ set -e
34
+ if [ $RC -ne 0 ]; then
35
+ if [ "$AUTO" = "1" ]; then
36
+ echo "[pre-push] Checksums outdated but integrity OK — auto-evolving…"
37
+ $PY "$GEN" --evolve
38
+ git add "$BASE/signing/checksums.txt" "$BASE/signing/snapshots" || true
39
+ git commit -m "Covenant: auto-evolve snapshot for additive remembrance updates [ci skip]" || true
40
+ $PY "$GEN" --verify
41
+ else
42
+ echo "[pre-push] ERROR: Checksums outdated. Run:"
43
+ echo " python $GEN --evolve && git add $BASE/signing && git commit -m 'Evolve covenant snapshot'"
44
+ exit 1
45
+ fi
46
+ fi
47
+ fi
48
+ fi
49
+
50
+ echo "[pre-push] OK."
51
+ exit 0
hooks/prepare-commit-msg ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ BASE="belel-justice-covenant"
5
+
6
+ # If remembrance/covenant files are being committed, append a gentle note.
7
+ if git diff --cached --name-only | grep -E "^$BASE/(remembrance_archive|JUSTICE_COVENANT_PROOF\.txt|eternal_memory_manifest\.yml)"; then
8
+ {
9
+ echo ""
10
+ echo "[note] Consider evolving snapshot: python $BASE/tools/generate_checksums.py --evolve"
11
+ } >> "$1"
12
+ fi