-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (71 loc) · 3.04 KB
/
Copy pathsection-integrity.yml
File metadata and controls
83 lines (71 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Section Marker Integrity Audit
on:
push:
branches: [ main ]
paths:
- 'bash4llm'
- 'bin/bash4llm'
- '.github/workflows/section-integrity.yml'
pull_request:
branches: [ main ]
paths:
- 'bash4llm'
- 'bin/bash4llm'
- '.github/workflows/section-integrity.yml'
workflow_dispatch:
jobs:
audit-sections:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify Macro-Sections and Full Tag Symmetry
run: |
bash -c '
set -euo pipefail
echo "Locating bash4llm executable..."
# Dynamic Path Detection
B4L_BIN="./bash4llm"
if [ ! -f "$B4L_BIN" ]; then
B4L_BIN=$(find . -maxdepth 2 -name "bash4llm" -type f | head -n 1 || true)
fi
if [ -z "$B4L_BIN" ] || [ ! -f "$B4L_BIN" ]; then
echo "❌ ERROR: Executable file '\''bash4llm'\'' not found in repository!"
ls -la
exit 1
fi
echo "Found executable at: $B4L_BIN"
chmod +x "$B4L_BIN"
# 1. Verify Macro-Sections (BEGIN / END) match
macro_begin=$(grep -cE "^# SECTION: [A-Z0-9_]+ - BEGIN" "$B4L_BIN" || true)
macro_end=$(grep -cE "^# SECTION: [A-Z0-9_]+ - END" "$B4L_BIN" || true)
if [ "$macro_begin" -ne "$macro_end" ] || [ "$macro_begin" -eq 0 ]; then
echo "❌ ERROR: Macro-Section mismatch! BEGIN count: $macro_begin, END count: $macro_end"
exit 1
fi
# 2. Extract full line tags including trailing anchors --->N-- safely under pipefail
open_tags=$(grep -oE "#--[0-9]+<---\[ SECTION: [A-Z0-9_]+ \]--->[0-9]+--" "$B4L_BIN" | sort || true)
close_tags=$(grep -oE "#--[0-9]+<---\[ /SECTION: [A-Z0-9_]+ \]--->[0-9]+--" "$B4L_BIN" | sed "s#/SECTION:#SECTION:#" | sort || true)
if [ -z "$open_tags" ]; then
echo "❌ ERROR: No section tags found in $B4L_BIN!"
exit 1
fi
if [ "$open_tags" != "$close_tags" ]; then
echo "❌ ERROR: Mismatch between opening and closing Section tags or trailing anchors!"
diff -u <(echo "$open_tags") <(echo "$close_tags") || true
exit 1
fi
# 3. Check for Duplicate Section Tags
duplicates=$(echo "$open_tags" | sort | uniq -d || true)
if [ -n "$duplicates" ]; then
echo "❌ ERROR: Duplicate section tags detected:"
echo "$duplicates"
exit 1
fi
# 4. Enforce Flat Architecture (Strictly NO Subsections $N.X)
if grep -qE "#--[0-9]+\.[0-9]+" "$B4L_BIN"; then
echo "❌ ERROR: Subsections ($N.X) detected! Architectural violation of Flat Policy."
grep -nE "#--[0-9]+\.[0-9]+" "$B4L_BIN"
exit 1
fi
echo "✅ Section Marker Architecture on $B4L_BIN is 100% Valid and Symmetrical!"
'