Skip to content

Commit 9879f59

Browse files
committed
Implement full XML-Lifecycle Validator & Publisher stack
This comprehensive implementation adds enterprise-grade validation, publishing, and governance capabilities to xml-lib: ## Core Features ### Validation Engine - Relax NG + Schematron validation for lifecycle phases (begin → start → iteration → end → continuum) - Cross-file constraints: ID uniqueness, reference integrity - Temporal monotonicity validation (timestamps must increase) - SHA-256 checksum validation and verification ### Guardrail Rule Engine - Compiles XML guardrails into executable checks - Full provenance tracking (author, timestamp, rationale) - Multiple constraint types: XPath, regex, checksum, temporal, cross-file - Priority levels: critical, high, medium, low - Example guardrails in /guardrails/lifecycle-integrity.xml ### Assertion Ledger - Cryptographically signed validation results (RSA-PSS-SHA256) - XML output with public key and signature - JSON Lines format for CI/CD integration - Tamper-evident audit trail ### Content-Addressed Storage - Deterministic UUID v5 generation - SHA-256 content addressing in /store/sha256/ - Automatic deduplication - Idempotent operations ### XSLT 3.0 Publisher - Transforms XML to HTML documentation - Automatic index page generation - Default stylesheet with responsive design - Customizable XSLT templates ### OOXML Composer - Generates PowerPoint presentations from XML - Slide masters and layouts - Automatic citation tracking - Template support ### Telemetry Sink - Pluggable backends: file, SQLite, PostgreSQL - Captures validation runs with duration and pass/fail metrics - Aggregation for heatmaps and performance analysis - JSON Lines format for easy parsing ### Schema-Aware Differ - Structural XML comparison - Semantic explanations of differences - Lifecycle-aware diff symbols - Attribute, element, and content tracking ## CLI Commands - `xml-lib validate` - Validate XML documents - `xml-lib publish` - Generate HTML documentation - `xml-lib render-pptx` - Create PowerPoint presentations - `xml-lib diff --explain` - Compare documents with explanations ## Testing - Golden tests with valid/invalid fixtures - Property-based tests for idempotence (Hypothesis) - Unit tests for all components - Test coverage infrastructure ## CI/CD - GitHub Actions workflow (lint, typecheck, test) - Makefile with dev, test, and publish targets - Artifact upload for validation results and docs - Multi-version Python testing (3.9, 3.10, 3.11) ## Documentation - Comprehensive README with 15-minute quickstart - ARTIFACTS.md with schemas, operators, CLI contracts, benchmarks - Example guardrails with provenance - Test fixtures demonstrating valid and invalid cases ## Architecture All code follows clean architecture principles: - Separated concerns (validator, publisher, storage, etc.) - Type hints throughout - Pluggable backends (telemetry) - Extensible schema system The implementation preserves all existing XML lifecycle examples and documentation while adding a complete validation and publishing stack that can be used standalone or integrated into CI/CD pipelines.
1 parent e7c6d95 commit 9879f59

31 files changed

+4813
-15
lines changed

.github/workflows/ci.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, claude/* ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.11'
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -r requirements.txt
24+
25+
- name: Lint with ruff
26+
run: |
27+
ruff check cli/
28+
29+
- name: Format check with black
30+
run: |
31+
black --check cli/
32+
33+
- name: Type check with mypy
34+
run: |
35+
mypy cli/ --ignore-missing-imports
36+
continue-on-error: true
37+
38+
test:
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
python-version: ['3.9', '3.10', '3.11']
43+
44+
steps:
45+
- uses: actions/checkout@v3
46+
47+
- name: Set up Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Install dependencies
53+
run: |
54+
python -m pip install --upgrade pip
55+
pip install -r requirements.txt
56+
pip install -e .
57+
58+
- name: Run tests with coverage
59+
run: |
60+
pytest tests/ -v --cov=xml_lib --cov-report=xml --cov-report=term
61+
62+
- name: Upload coverage to Codecov
63+
uses: codecov/codecov-action@v3
64+
with:
65+
files: ./coverage.xml
66+
flags: unittests
67+
name: codecov-${{ matrix.python-version }}
68+
69+
validate:
70+
runs-on: ubuntu-latest
71+
needs: test
72+
steps:
73+
- uses: actions/checkout@v3
74+
75+
- name: Set up Python
76+
uses: actions/setup-python@v4
77+
with:
78+
python-version: '3.11'
79+
80+
- name: Install xml-lib
81+
run: |
82+
python -m pip install --upgrade pip
83+
pip install -r requirements.txt
84+
pip install -e .
85+
86+
- name: Validate existing XML documents
87+
run: |
88+
xml-lib validate . --output out/assertions.xml --jsonl out/assertions.jsonl
89+
continue-on-error: true
90+
91+
- name: Upload validation artifacts
92+
uses: actions/upload-artifact@v3
93+
with:
94+
name: validation-results
95+
path: |
96+
out/assertions.xml
97+
out/assertions.jsonl
98+
99+
publish:
100+
runs-on: ubuntu-latest
101+
needs: test
102+
steps:
103+
- uses: actions/checkout@v3
104+
105+
- name: Set up Python
106+
uses: actions/setup-python@v4
107+
with:
108+
python-version: '3.11'
109+
110+
- name: Install xml-lib
111+
run: |
112+
python -m pip install --upgrade pip
113+
pip install -r requirements.txt
114+
pip install -e .
115+
116+
- name: Publish documentation
117+
run: |
118+
xml-lib publish . --output-dir out/site
119+
120+
- name: Upload published site
121+
uses: actions/upload-artifact@v3
122+
with:
123+
name: documentation-site
124+
path: out/site/
125+
126+
benchmark:
127+
runs-on: ubuntu-latest
128+
needs: test
129+
steps:
130+
- uses: actions/checkout@v3
131+
132+
- name: Set up Python
133+
uses: actions/setup-python@v4
134+
with:
135+
python-version: '3.11'
136+
137+
- name: Install xml-lib
138+
run: |
139+
python -m pip install --upgrade pip
140+
pip install -r requirements.txt
141+
pip install -e .
142+
143+
- name: Run benchmarks
144+
run: |
145+
python -m pytest tests/ -v -k benchmark --benchmark-only
146+
continue-on-error: true

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib64/
14+
parts/
15+
sdist/
16+
var/
17+
wheels/
18+
*.egg-info/
19+
.installed.cfg
20+
*.egg
21+
22+
# Virtual environments
23+
venv/
24+
ENV/
25+
env/
26+
.venv
27+
28+
# Testing
29+
.pytest_cache/
30+
.coverage
31+
htmlcov/
32+
.tox/
33+
.hypothesis/
34+
35+
# Type checking
36+
.mypy_cache/
37+
.dmypy.json
38+
dmypy.json
39+
40+
# IDEs
41+
.vscode/
42+
.idea/
43+
*.swp
44+
*.swo
45+
*~
46+
47+
# OS
48+
.DS_Store
49+
Thumbs.db
50+
51+
# Project specific
52+
out/
53+
store/
54+
*.log
55+
.ruff_cache/
56+
57+
# Telemetry databases
58+
*.db
59+
*.sqlite
60+
*.sqlite3
61+
62+
# Temporary files
63+
tmp/
64+
temp/
65+
*.tmp

0 commit comments

Comments
 (0)