-
Notifications
You must be signed in to change notification settings - Fork 0
323 lines (272 loc) · 10.6 KB
/
python-ci.yml
File metadata and controls
323 lines (272 loc) · 10.6 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
name: Oraculus-DI-Auditor CI
on:
push:
branches:
- main
- master
- copilot/initiate-full-ingestion
- ingestion-clean
pull_request:
branches:
- main
- master
- copilot/initiate-full-ingestion
- ingestion-clean
permissions:
contents: write
pull-requests: write
jobs:
self_healing_ci:
name: Self-Healing CI Pipeline
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .[dev]
- name: Run Pre-Commit (with auto-fix enabled)
id: fmt
run: |
pre-commit run --all-files || true
- name: Detect Formatting Changes
id: diff
run: |
git diff --exit-code || echo "needs_fix=true" >> $GITHUB_OUTPUT
- name: Auto-Commit Formatting Fixes
if: steps.diff.outputs.needs_fix == 'true'
run: |
git config --global user.name "oraculus-ci"
git config --global user.email "ci@oraculus.local"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" = "HEAD" ]; then
echo "Skipping auto-push: detached HEAD (likely PR SHA)."
else
git add .
git commit -m "auto-fix: formatting corrections (Black/Ruff/Pre-Commit)" || echo "No changes to commit."
git push origin "$CURRENT_BRANCH"
fi
- name: Run Tests
env:
PYTHONPATH: ${{ github.workspace }}/src
run: |
pytest --maxfail=1 --disable-warnings -q
- name: Report to Oraculus-DI-Auditor Mesh
run: |
echo "::notice::Sending CI metadata to Oraculus auditor mesh..."
echo '{
"ci_event": "${{ github.event_name }}",
"branch": "${{ github.ref }}",
"commit": "${{ github.sha }}",
"status": "passed",
"auto_fix": "${{ steps.diff.outputs.needs_fix }}"
}' > ci_report.json
transparency_release:
name: Transparency Release Package
runs-on: ubuntu-latest
needs: self_healing_ci
continue-on-error: true
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .[dev]
pip install matplotlib
- name: Generate Transparency Package
env:
PYTHONPATH: ${{ github.workspace }}/src:${{ github.workspace }}
run: |
python scripts/generate_transparency_package.py
python scripts/generate_timeline.py
- name: Verify Hash Manifests
run: |
cd transparency_release
echo "Verifying hash manifests..."
# Check that hash manifest exists and has content
if [ -f "HASH_MANIFEST_FULL_SHA256.txt" ]; then
echo "Hash manifest exists with $(grep -v '^#' HASH_MANIFEST_FULL_SHA256.txt | wc -l) entries"
else
echo "ERROR: Hash manifest not found"
exit 1
fi
- name: Upload Transparency Artifacts
uses: actions/upload-artifact@v4
with:
name: transparency-release-package
path: |
transparency_release/
retention-days: 90
jim-analysis:
name: JIM Legal Analysis
runs-on: ubuntu-latest
needs: self_healing_ci
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .[dev]
- name: Validate Case Law JSON
run: |
echo "Validating SCOTUS_INDEX.json..."
python -c "
import json
from pathlib import Path
index_path = Path('legal/cases/SCOTUS_INDEX.json')
with open(index_path) as f:
data = json.load(f)
assert 'version' in data
assert 'cases' in data
assert len(data['cases']) > 0
print(f'✓ Valid: {len(data[\"cases\"])} cases loaded')
"
- name: Validate Legal Lexicon
run: |
echo "Validating legal lexicon files..."
python -c "
from scripts.jim.jim_semantic_loader import JIMSemanticLoader
# Load all lexicon sources
loader = JIMSemanticLoader()
result = loader.load_lexicon_sources()
assert result['success'], f'Failed to load lexicon: {result}'
print(f'✓ Loaded {result[\"sources_loaded\"]} dictionary sources')
print(f' - Black\\'s Law: {result[\"blacks_terms\"]} terms')
print(f' - Bouvier\\'s 1856: {result[\"bouvier_terms\"]} terms')
print(f' - Webster Legal: {result[\"webster_terms\"]} terms')
print(f' - Oxford synonyms: {result[\"oxford_mappings\"]} mappings')
print(f' - Latin maxims: {result[\"latin_terms\"]} terms')
# Validate schema
validation = loader.validate_lexicon_schema()
assert validation['valid'], f'Schema validation failed: {validation[\"errors\"]}'
print(f'✓ Schema validation passed')
# Test semantic processing
merged = loader.merge_definitions()
synonym_graph = loader.build_synonym_graph()
antonym_graph = loader.build_antonym_graph()
doctrine_map = loader.infer_doctrines()
print(f'✓ Semantic processing complete:')
print(f' - Merged terms: {len(merged)}')
print(f' - Synonym relationships: {sum(len(s) for s in synonym_graph.values()) // 2}')
print(f' - Antonym relationships: {sum(len(a) for a in antonym_graph.values()) // 2}')
print(f' - Doctrines mapped: {len(doctrine_map)}')
"
- name: Run JIM Tests
env:
PYTHONPATH: ${{ github.workspace }}/src:${{ github.workspace }}
run: |
pytest tests/jim/ -v --tb=short
- name: Run Lexicon Tests
env:
PYTHONPATH: ${{ github.workspace }}/src:${{ github.workspace }}
run: |
pytest tests/lexicon/ -v --tb=short
- name: Run Harmonization Tests
env:
PYTHONPATH: ${{ github.workspace }}/src:${{ github.workspace }}
run: |
pytest tests/harmonization/ -v --tb=short
- name: Validate Semantic Harmonization
run: |
echo "Validating semantic harmonization artifacts..."
python -c "
from scripts.jim.semantic_harmonizer import SemanticHarmonizer
# Initialize harmonizer
harmonizer = SemanticHarmonizer()
load_result = harmonizer.load_lexicon_sources()
assert load_result['success'], 'Failed to load lexicon sources'
# Build harmonization matrix
matrix = harmonizer.build_harmonization_matrix()
print(f'✓ Matrix built: {len(matrix)} terms')
# Detect conflicts
conflicts = harmonizer.detect_semantic_conflicts()
print(f'✓ Conflicts detected: {len(conflicts)}')
# Compute divergence index
divergence = harmonizer.compute_meaning_divergence_index()
print(f'✓ Divergence index computed: {len(divergence)} terms')
# Check canonically stable terms
stable_terms = [t for t, d in divergence.items() if d['divergence_score'] <= 0.05]
print(f'✓ Canonically stable terms: {len(stable_terms)} (≤0.05 divergence)')
# Generate artifacts
artifacts = harmonizer.generate_artifacts()
assert artifacts['success'], 'Failed to generate artifacts'
print(f'✓ Artifacts generated: {artifacts[\"total_terms\"]} terms')
print(f' - Matrix: {artifacts[\"matrix_path\"]}')
print(f' - Divergence: {artifacts[\"divergence_path\"]}')
"
- name: Validate Doctrine Alignment
run: |
echo "Validating doctrine map..."
python -c "
import json
from pathlib import Path
doctrine_path = Path('scripts/jim/jim_doctrine_map.json')
with open(doctrine_path) as f:
data = json.load(f)
assert 'doctrines' in data
assert 'interpretive_frameworks' in data
print(f'✓ Valid: {len(data[\"doctrines\"])} doctrines')
"
- name: Run Sample JIM Analysis
env:
PYTHONPATH: ${{ github.workspace }}/src:${{ github.workspace }}
run: |
python -c "
from scripts.jim.jim_core import JIMCore
# Initialize JIM
jim = JIMCore()
result = jim.initialize()
assert result['success'], 'JIM initialization failed'
# Run sample analysis
sample_anomalies = [
{'id': 'ci_test_1', 'type': 'metadata_break', 'source': 'ace'},
{'id': 'ci_test_2', 'type': 'surveillance_program', 'source': 'caim'}
]
analysis = jim.run_full_analysis(sample_anomalies)
assert analysis['success'], 'JIM analysis failed'
print('✓ JIM analysis completed successfully')
print(f\" - Analyzed: {analysis['analysis']['total_anomalies_analyzed']} anomalies\")
print(f\" - High priority: {analysis['analysis']['risk_summary']['high_priority_count']}\")
"
- name: Upload JIM Artifacts
uses: actions/upload-artifact@v4
with:
name: jim-analysis-artifacts
path: |
analysis/jim/
retention-days: 30
- name: Upload Harmonization Artifacts
uses: actions/upload-artifact@v4
with:
name: semantic-harmonization-artifacts
path: |
artifacts/SEMANTIC_HARMONIZATION_MATRIX.json
artifacts/MEANING_DIVERGENCE_INDEX.json
retention-days: 30