What Is Change Management & Versioning?

Knowledge graphs change constantly. TemporalVersionManager gives your graph a verifiable history by capturing complete state snapshots at specific points in time. It allows you to take named snapshots before consequential changes, generate detailed diffs between any two states, roll back to previous versions with a single call, and verify SHA-256 checksums before publishing data downstream.

Storage Behavior

Pass storage_path, e.g. TemporalVersionManager(storage_path="versions.db"), to persist snapshots to a SQLite database on disk. Omit storage_path and it defaults to an in-memory store that vanishes when your script finishes.

Why Use Change Management?

Change Management acts as your safety net and audit trail. Use it to:
  • Safeguard Ingestion: Take a snapshot before a large batch ingestion so you can instantly roll back if the data is corrupted.
  • Audit Trails: Maintain a verifiable log of when a change occurred, who authorized it, and exactly what nodes/edges were modified.
  • Release Gating: Compare staging and production graphs and verify checksums before signing off on a release.

Which Tool Do I Need?

Semantica offers multiple tracking features. It is critical to choose the right one:
  • Change Management (this guide): Use for whole-graph snapshots, state diffs, and full rollbacks.
  • Provenance: Use for granular source and lineage tracking. It answers “Which specific document did this node come from?”
  • Agent Memory: Use for conversational and context state. It answers “What decisions did the AI agent make during this session?”

When To Use / When Not To Use

  • When to Use: You have critical checkpoints (like daily feeds, partner merges, or regulatory submissions) where you need to freeze the entire state of the graph and potentially revert it.
  • When NOT to Use: You have a massive, multi-million node graph and want to track every minor edit. Because TemporalVersionManager snapshots the entire graph dictionary, snapshotting huge graphs too frequently will cause severe storage bloat. Use Provenance for granular tracking instead.
TemporalVersionManager integrates directly with AgentContext.flush_checkpoint() — agent checkpoints and manual snapshots share the same storage format, allowing diffs across both automated and manual workflows.

Typical Workflow

A standard change management cycle follows this progression:
  1. Snapshot: Capture the baseline graph state.
  2. Modify: Run your ingestion, mutations, or analysis.
  3. Compare: Generate a diff to see what changed.
  4. Verify: Check the SHA-256 hash to ensure data integrity.
  5. Tag: Apply a human-readable tag (e.g., approved).
  6. Rollback: Revert the graph state if the modifications were incorrect.

Universal Example: Employee Profile Update

Let’s look at a universally understood example: tracking an employee’s department transfer.
Now let’s explore these capabilities in more depth using domain-specific scenarios.

Creating Snapshots

Take a snapshot before any consequential change: an ingestion sweep, a partner feed merge, or an automated enrichment run.
After running the ingestion, snapshot again to mark the post-change state:

Comparing Two Snapshots

compare_versions returns a precise diff — nodes and edges added, removed, or modified — between any two named snapshots.
You can also pass snapshot dicts directly instead of labels:

Verifying Integrity

Before publishing a snapshot to a downstream system — SIEM, partner feed, regulatory submission — verify the SHA-256 checksum to confirm nothing was modified after the snapshot was written.

Rolling Back

Pass the target label and require_confirmation=False (an explicit safety gate) to restore the graph to any prior snapshot.
restore_snapshot raises ProcessingError if require_confirmation is not explicitly False, preventing accidental rollbacks from automated scripts.

Building an Audit Changelog

List all snapshots in chronological order and diff each one against its predecessor to produce a human-readable change log.
Sample output:

Tagging Milestones

Attach a named tag to any snapshot to mark review gates, approved states, or regulatory submissions.

Node History

Attach TemporalVersionManager to a live ContextGraph to automatically record every individual mutation — every add_node, add_edge, and update call — not just snapshot-level diffs.

AgentContext Integration

Pass the version manager at AgentContext construction. Agent checkpoints and manual snapshots share the same storage, giving you one unified history.

Common Pitfalls

  • Snapshotting huge graphs too frequently: TemporalVersionManager snapshots the entire graph structure. Doing this on every minor edit for a massive graph will cause severe storage bloat. Use it for milestone gating, not event sourcing.
  • Forgetting attach_to_graph before mutation tracking: If you want to use get_node_history(), you must call vm.attach_to_graph(graph) before any mutations happen. Otherwise, the events will not be captured.
  • Confusing provenance with versioning: Do not use version snapshots to answer “Where did this specific node’s data come from?”. That is the role of the Provenance module. Versioning tracks the state of the entire graph at a point in time.
  • Forgetting rollback confirmation requirements: Calling restore_snapshot in automated scripts will raise a ProcessingError and crash your pipeline unless you explicitly pass require_confirmation=False.
  • Storage growth from excessive snapshots: Over time, SQLite databases can grow large if you never prune old snapshots or if you snapshot unnecessarily.

Domain Examples

Daily NVD and ISAC feed ingestion with pre/post snapshots, a SOC change bulletin, and an integrity gate before publishing to the SIEM.
  • Context GraphsContextGraph.to_dict() feeds create_snapshot()
  • Ontology Management — pair ontology versioning with graph versioning for a complete schema + data audit trail
  • SHACL Validation — validate graph data at each version gate before snapshotting
  • Provenance — combine change management with W3C PROV-O lineage for a full audit trail
  • VisualizationTemporalVisualizer.visualize_snapshot_comparison() and visualize_metrics_evolution() render version diffs as interactive charts