-
-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Labels
coreCore Semantica logic and abstractionsCore Semantica logic and abstractionsenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Treat ontology changes like database migrations: diff, analyze impact, and migrate safely over time.
Where in the Codebase This Lives
- Main implementation goes into:
semantica/change_management/(version manager, storage, change logs).semantica/ontology/(public API on the engine).
- Tests should extend the existing suites under:
tests/change_management/tests/ontology/
- Keep everything under the existing
semantica/andtests/trees; do not introduce new top‑level folders.
Functional Overview
- Compares two ontology versions stored in Semantica.
- Produces a structured diff (added/removed/changed classes and properties).
- Generates a human‑readable migration and impact report.
- Optionally triggers validation jobs to check data against the new schema.
Motivation and Benefits
- Enables safe ontology evolution in long‑lived enterprise systems.
- Adds version control and change tracking for schemas, not just data.
- Helps data teams understand exactly what breaks when a schema changes.
- Supports deployment automation and governance for semantic models.
Existing Functionality to Leverage
Existing capabilities that this feature will reuse:
- Ontology
- semantica/ontology/engine.py
- High‑level operations for generating, validating, and exporting ontologies.
- semantica/ontology/ontology_validator.py
- Structural validation and hooks for symbolic reasoners.
- semantica/ontology/ontology_evaluator.py
- Evaluation of ontology quality and competency question coverage.
- semantica/ontology/engine.py
- Change management
- semantica/change_management/ontology_version_manager.py
- semantica/change_management/version_storage.py
- semantica/change_management/change_log.py
- semantica/change_management/managers.py
- Documentation and tests
- docs/reference/ontology.md
- docs/reference/change_management.md
- tests/change_management/test_managers.py
- tests/change_management/test_temporal_versioning.py
- tests/change_management/test_change_log.py
- tests/ontology/test_ontology_advanced.py
New Capabilities to Implement
Ontology diff and migration should be implemented entirely within these existing modules:
- Diff computation
- In semantica/change_management/ontology_version_manager.py:
- Implement diff_ontologies(base, target) → Dict with added/removed/changed elements.
- In semantica/change_management/ontology_version_manager.py:
- Version loading
- In semantica/ontology/engine.py and change_management/managers.py:
- Provide helpers to fetch ontology versions as plain dicts suitable for diffing.
- In semantica/ontology/engine.py and change_management/managers.py:
- Impact and migration report
- In semantica/change_management/change_log.py (or nearby helper):
- Generate structured migration reports from the diff, classifying changes as breaking, potentially breaking, or low‑risk.
- In semantica/change_management/change_log.py (or nearby helper):
- Optional validation hooks
- Use OntologyValidator and GraphValidator (from semantica/kg/graph_validator.py) to:
- Define validation jobs that check existing data against the new ontology.
- Use OntologyValidator and GraphValidator (from semantica/kg/graph_validator.py) to:
- Public API
- In semantica/ontology/engine.py:
- Add compare_versions(...) that orchestrates version loading, diff computation, and report generation.
- In semantica/ontology/engine.py:
- Documentation and tests
- Extend the docs and tests listed above with:
- Examples and assertions for ontology diffs.
- At least one realistic migration report scenario.
- Extend the docs and tests listed above with:
Contributor Implementation Guide
-
Structured ontology diff
- In change_management/ontology_version_manager.py:
- Implement a function:
- diff_ontologies(base: Dict[str, Any], target: Dict[str, Any]) -> Dict[str, Any]
- The returned dict should contain lists such as:
- added_classes, removed_classes, changed_classes
- added_properties, removed_properties, changed_properties
- Changes should include details (e.g. domain/range changed, label changed).
- Implement a function:
- In change_management/ontology_version_manager.py:
-
Version retrieval helpers
- In ontology/engine.py and change_management/managers.py:
- Provide utilities to load ontology versions (e.g. by version ID or tag) as plain dicts ready for diffing.
- In ontology/engine.py and change_management/managers.py:
-
Impact analysis and reporting
- In change_management/change_log.py (or a small helper in the same package):
- Build a report generator that:
- Accepts the diff structure.
- Produces a markdown or JSON report listing:
- Breaking changes.
- Potentially breaking changes.
- Low‑risk changes (e.g. labels only).
- Optionally includes references to affected classes, properties, and mapped entities.
- Build a report generator that:
- In change_management/change_log.py (or a small helper in the same package):
-
Optional validation jobs
- Using OntologyValidator and GraphValidator:
- For selected changes, create validation jobs that:
- Check data instances against the new constraints.
- Surface issues before or during deployment.
- For selected changes, create validation jobs that:
- Using OntologyValidator and GraphValidator:
-
Public API surface
- In ontology/engine.py:
- Add a method such as:
- compare_versions(self, base_id: str, target_id: str, **options)
- This should orchestrate:
- Version loading.
- Diff computation.
- Report generation.
- Add a method such as:
- In ontology/engine.py:
-
Documentation
- In docs/reference/change_management.md:
- Add an “Ontology Diff & Migration” section with:
- A code example calling OntologyEngine.compare_versions.
- Explanation of the report format.
- Add an “Ontology Diff & Migration” section with:
- In docs/reference/change_management.md:
Ready‑to‑Ship Criteria
- There is a public API to compare two ontology versions and obtain:
- A machine‑readable diff structure.
- A human‑readable migration report.
- Change management tests cover:
- Basic diff scenarios (class/property added/removed/changed).
- Report generation for at least one realistic example.
- Ontology docs clearly show how to use the diff and migration capabilities.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreCore Semantica logic and abstractionsCore Semantica logic and abstractionsenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Type
Projects
Status
Todo