-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (124 loc) · 4.78 KB
/
Copy pathci.yml
File metadata and controls
132 lines (124 loc) · 4.78 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install pytest
- name: Drift alarm - no StopMachine class in primitives
run: |
if grep -rn "class StopMachine" primitives/; then
echo "DRIFT DETECTED: StopMachine class found in primitives/"
exit 1
fi
- name: Drift alarm - no Gate implementation in primitives
run: |
if grep -rn "class.*Gate" primitives/authority-gate-v0/ primitives/stop-machine-v0/; then
echo "DRIFT DETECTED: Gate class found in v0 folders"
exit 1
fi
- name: Drift alarm - no runtime imports from analysis/docs/artifacts/examples
run: |
echo "Checking runtime roots for forbidden imports..."
FOUND=0
for token in "import analysis" "from analysis" "import docs" "from docs" "import artifacts" "from artifacts" "import examples" "from examples"; do
if grep -rn "$token" stop_machine.py primitives/ --include="*.py" 2>/dev/null; then
echo "DRIFT DETECTED: forbidden token '$token' found in runtime code"
FOUND=1
fi
done
if [ "$FOUND" -eq 1 ]; then
exit 1
fi
echo "OK: no forbidden imports found."
- name: Run primitive tests
run: python -m pytest primitives -v
- name: Run root tests
run: python -m pytest test_stop_machine.py -v
- name: Run invariant tests
run: python -m pytest tests/ -v
geometry-analysis:
needs: [test]
if: always()
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Validate geometry JSONL artefacts
shell: bash
run: |
cat > /tmp/validate_geometry.py << 'PYEOF'
import json, glob, sys
files = sorted(glob.glob("artifacts/geometry/**/*.jsonl", recursive=True))
if not files:
print("No geometry artefacts found. Skipping validation.")
sys.exit(0)
REQUIRED_KEYS = {"schema_version", "primitive", "event", "exit", "violations", "input_hash", "result_hash"}
VALID_EXITS = {"ALLOW", "HOLD", "DENY", "SILENCE"}
file_count = len(files)
line_count = 0
parse_fail = 0
exits = {}
for path in files:
with open(path, "r", encoding="utf-8") as fh:
for lineno, raw in enumerate(fh, 1):
raw = raw.strip()
if not raw:
continue
line_count += 1
try:
obj = json.loads(raw)
except json.JSONDecodeError as e:
print(f"PARSE FAIL: {path}:{lineno}: {e}")
parse_fail += 1
continue
missing = REQUIRED_KEYS - set(obj.keys())
if missing:
print(f"MISSING KEYS: {path}:{lineno}: {missing}")
parse_fail += 1
continue
if obj.get("schema_version") != "0.1":
print(f"BAD SCHEMA: {path}:{lineno}: {obj.get('schema_version')}")
parse_fail += 1
ex = obj.get("exit", "")
if ex not in VALID_EXITS:
print(f"BAD EXIT: {path}:{lineno}: {ex}")
parse_fail += 1
exits[ex] = exits.get(ex, 0) + 1
print("")
print("=== Geometry JSONL Summary ===")
print(f"Files: {file_count}")
print(f"Lines: {line_count}")
print(f"Parse fails: {parse_fail}")
for ex in sorted(exits):
print(f" {ex}: {exits[ex]}")
if parse_fail:
print(f"WARNING: {parse_fail} validation issue(s) found.")
sys.exit(1)
print("All lines valid.")
PYEOF
python3 /tmp/validate_geometry.py
- name: Upload geometry artefacts
if: always()
uses: actions/upload-artifact@v4
with:
name: geometry-artifacts-${{ github.run_id }}
path: artifacts/geometry/**
if-no-files-found: warn