Local Validation¶
This project uses Python scripts to validate ontology JSON files, merge layers, and generate derived outputs. The validation scripts are intentionally lightweight and use only the Python standard library.
本项目使用 Python 脚本校验 ontology JSON、合并层级并生成衍生格式。核心校验脚本保持轻量,运行时只依赖 Python 标准库。
Prerequisites¶
- Python 3.12 or newer
- Git
- A shell terminal, such as PowerShell, Windows Terminal, bash, or zsh
Check your Python installation:
If both commands fail, install Python from python.org and enable "Add python.exe to PATH" during installation.
Create a Virtual Environment¶
Create the environment at the repository root:
If PowerShell blocks activation because script execution is disabled, you can either use the interpreter path directly:
Or relax the execution policy for the current user:
Run the Core Checks¶
Run these commands before opening a PR that changes ontology JSON or scripts:
python scripts/validate_governance.py
python scripts/validate_l3.py --all
python scripts/merge_layers.py l3-enterprise/acme-tech-solutions/acme_tech_solutions_ontology_v1.json
Expected result:
validate_governance.pyreports no failed L1 governance checks.validate_l3.py --allreports PASS for all L2/L3 ontology files.merge_layers.pywrites merged output for the Acme L3 sample.
Validate JSON Syntax¶
If you only need a quick JSON parse check:
Generate Derived Outputs¶
After changing L1/L2/L3 JSON, regenerate derived formats as needed:
python scripts/json_to_owl.py
python scripts/export_neo4j.py l1-core/universal_ontology_v1.json
python scripts/export_for_llm.py l1-core/universal_ontology_v1.json
python scripts/visualize_ontology.py
Do not manually edit generated .ttl, .cypher, exported LLM files, or merged output/ artifacts.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
python is not recognized |
Python is not installed or not on PATH | Install Python and enable PATH, or use py -3 on Windows |
failed to locate pyvenv.cfg |
The .venv directory is incomplete or copied from another machine |
Delete .venv and recreate it with python -m venv .venv |
PowerShell blocks Activate.ps1 |
Execution policy blocks local scripts | Run the .venv\Scripts\python.exe path directly, or set RemoteSigned for the current user |
validate_l3.py --all finds no files |
Running from the wrong directory | Run commands from the repository root |
| Private enterprise merge fails | private_enterprise/ is not present in public clones |
Validate public L3 samples unless you have the private files locally |
CI Parity¶
GitHub Actions runs the same validation workflow on ontology and script changes:
python scripts/validate_governance.py
python scripts/validate_l3.py --all
python scripts/merge_layers.py l3-enterprise/acme-tech-solutions/acme_tech_solutions_ontology_v1.json
Keeping local validation aligned with CI makes PR review faster and keeps the source JSON, generated outputs, and documentation from drifting apart.