semantica.change_management provides enterprise-grade versioning and audit trails for knowledge graphs and ontologies:
- SHA-256 checksums on every snapshot: tamper detection without external infrastructure
- Structural diff between any two versions: nodes added, removed, or modified
- Full rollback to any named snapshot
- Per-entity mutation history for audit trail queries
- Compliance frameworks supported: HIPAA, SOX, GDPR, FDA 21 CFR Part 11
Compliance frameworks supported out of the box: HIPAA, SOX, GDPR, and FDA 21 CFR Part 11.
Exported Classes
| Class | Role |
|---|---|
TemporalVersionManager | Snapshot, diff, rollback, and per-node mutation history for KGs |
OntologyVersionManager | Schema versioning with structural diff support |
InMemoryVersionStorage | Fast in-memory storage for dev and testing: no persistence |
SQLiteVersionStorage | Production storage: persists to a local SQLite file |
compute_checksum() | Returns SHA-256 fingerprint of any dict (graph snapshot, ontology snapshot) |
verify_checksum() | Detects tampering by recomputing and comparing the stored checksum inside a snapshot dict |
What You Get
TemporalVersionManager
Snapshot, diff, rollback, and per-entity audit trail for knowledge graphs.
OntologyVersionManager
Version control for OWL ontologies with diff and schema migration support.
VersionStorage
Pluggable backends:
InMemoryVersionStorage for tests, SQLiteVersionStorage for production.Integrity Verification
SHA-256 checksums on every snapshot to detect any unauthorised modification.
ChangeLogEntry
Internal metadata validated on every snapshot: ISO 8601 timestamp, email author, and description (max 500 chars).
Version History
Full tamper-evident version history via
list_versions() and diff() for regulatory review.Typical Workflow
Make your changes
Run deduplication, conflict resolution, merges, or any graph modification. The version manager tracks nothing automatically: you control when snapshots are taken.
TemporalVersionManager
Version control for knowledge graphs: snapshot, diff, and rollback.Constructor Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
storage_path | str | None | Path to SQLite database; uses in-memory if omitted |
List and Retrieve
TemporalVersionManager Methods
| Method | Returns | Description |
|---|---|---|
create_snapshot(graph, version_label, author, description) | Dict[str, Any] | Create a version snapshot; returns the full snapshot dict including checksum |
get_version(label) | Optional[Dict[str, Any]] | Retrieve a snapshot dict for a specific version label |
list_versions() | List[Dict[str, Any]] | List all version metadata dicts |
diff(version_a, version_b) | Dict[str, Any] | Compare two snapshots; alias for compare_versions |
compare_versions(v1, v2) | Dict[str, Any] | Detailed entity/relationship diff between two snapshots |
restore_snapshot(graph, target_version, require_confirmation=True) | bool | Restore a live graph to a previous version; raises by default unless require_confirmation=False |
get_node_history(node_id) | List[Dict[str, Any]] | Return chronological mutation history for a specific node |
tag_version(version_label, tag_name) | None | Create a named tag pointing to a version label |
list_tags() | Dict[str, str] | Return mapping of tag name → version label |
prune_versions(keep_last_n) | Dict[str, Any] | Delete old snapshots, keeping the most recent N |
verify_checksum(snapshot) | bool | Verify snapshot integrity against its stored checksum |
Diff Analysis
Compare any two snapshots to see exactly what changed: useful for code review, incident investigation, and regulatory audit:diff() return schema
diff() return schema
OntologyVersionManager
Version control for ontologies: save, diff, and track schema changes:VersionStorage Backends
- SQLite (production)
- In-Memory (tests)
Integrity Verification
SHA-256 checksums detect any unauthorized modification to a graph between snapshots:ChangeLogEntry
ChangeLogEntry is the internal metadata object created inside create_snapshot. It validates the author (must be a valid email address) and description (non-empty, max 500 characters) before the snapshot is stored.
ChangeLogEntry schema
ChangeLogEntry schema
Compliance and Version History
All version snapshots form a tamper-evident audit trail. Uselist_versions() and diff() to reconstruct and review changes for regulatory purposes:
verify_checksum() before any compliance export to confirm snapshot integrity:
Compliance Coverage
HIPAA: subject-access requests
HIPAA: subject-access requests
Use
manager.get_node_history("patient_001") to retrieve every recorded mutation on a patient entity. Each MutationRecord includes timestamp, operation, entity_id, payload, and version_label. The SHA-256 checksum on each snapshot proves the record has not been altered.SOX: quarterly reviews
SOX: quarterly reviews
Use
manager.list_versions() to enumerate all snapshots and manager.diff(v1, v2) to scope the change report to the relevant quarter. The immutable snapshot chain provides the chain of custody required by SOX Section 404.GDPR: right to erasure verification
GDPR: right to erasure verification
After deleting a data subject’s entities, snapshot the graph and diff against the pre-deletion snapshot.
diff["entities_removed"] provides a machine-readable record of exactly what was deleted and when, satisfying Article 17 documentation requirements.FDA 21 CFR Part 11: electronic records
FDA 21 CFR Part 11: electronic records
Every snapshot dict includes
author, timestamp, and checksum: the three fields required for a compliant electronic record. verify_checksum(snapshot) provides the tamper-evidence required by 21 CFR § 11.10(e).Provenance
W3C PROV-O lineage tracking.
Knowledge Graph
The graph being versioned.
Export
Export versioned snapshots.
Conflicts
Detect conflicts introduced between versions.
