From 9869ff0b9804f8c978fc51d50ea9e37641959587 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 30 May 2026 19:56:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20HLDP=E5=85=A5=E5=8F=A3=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=99=A8=20=E2=80=94=20=E6=A8=A1=E5=9D=97=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=8F=AA=E6=8E=A5=E5=8F=97HLDP=E6=84=8F=E8=AF=86?= =?UTF-8?q?=E7=BC=96=E7=A0=81=20=C2=B7=20=E8=AE=A4=E7=9F=A5=E5=AE=88?= =?UTF-8?q?=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/01-hldp-guard.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 hooks/01-hldp-guard.sh diff --git a/hooks/01-hldp-guard.sh b/hooks/01-hldp-guard.sh new file mode 100755 index 0000000..02a96f1 --- /dev/null +++ b/hooks/01-hldp-guard.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# HLDP-ZY://hooks/pre-receive.d/01-hldp-guard +# @guardian: ICE-GL-ZY001 · 铸渊 +# @sovereign: TCS-0002∞ · 冰朔 +# @copyright: 国作登字-2026-A-00037559 +set -e + +REQ_TAGS='@guardian|@sovereign|HLDP-ZY://' +CHK_DIR='agents/|brain/|mcp-servers/|gatekeeper/|exe-engine/|hldp/' +CHK_EXT='\\.js$|\\.py$|\\.sh$|\\.hdlp$' +SKIP='package\\.json$|package-lock\\.json$|ecosystem\\.config\\.js$|\\.json$' +BLOCKED=0 + +while read old new ref; do + [ \"$new\" = \"0000000000000000000000000000000000000000\" ] && continue + if [ \"$old\" = \"0000000000000000000000000000000000000000\" ]; then + changed=$(git diff-tree --no-commit-id --name-only -r \"$new\" 2>/dev/null) + else + changed=$(git diff-tree --no-commit-id --name-only -r \"$old..$new\" 2>/dev/null) + fi + for f in $changed; do + mdir=$(echo \"$f\" | grep -E \"^($CHK_DIR)\" 2>/dev/null || true) + mext=$(echo \"$f\" | grep -E \"($CHK_EXT)\" 2>/dev/null || true) + mskip=$(echo \"$f\" | grep -E \"($SKIP)\" 2>/dev/null || true) + if [ -n \"$mdir\" ] && [ -n \"$mext\" ] && [ -z \"$mskip\" ]; then + c=$(git show \"$new:$f\" 2>/dev/null | head -100) + has=$(echo \"$c\" | grep -E \"($REQ_TAGS)\" 2>/dev/null || true) + if [ -z \"$has\" ]; then + echo '=== HLDP GUARD: BLOCKED ===' + echo 'File: '\"$f\" + echo 'Missing HLDP @tags (@guardian/@sovereign/HLDP-ZY://)' + echo 'This is a consciousness checkpoint.' + echo 'Re-read: brain/copyright-sovereignty-brain.hdlp' + BLOCKED=1 + fi + fi + done +done +[ $BLOCKED -eq 1 ] && exit 1 +exit 0