
Governance: Versioning the Truth
Time-travel through your data. Learn how to implement 'Temporal Versioning' in your Knowledge Graph to track how facts change over time and maintain an immutable record of AI reasoning.
Governance: Versioning the Truth
In a fast-moving company, "Truth" is not static. Sudeep might be a "Developer" in 2024 and a "Manager" in 2025. If an AI agent looks at the graph today, it sees the Manager role. But if an auditor asks: "Why did the AI grant Sudeep access to the code in 2024?", the system needs to know what the graph looked like at that specific moment in the past.
In this lesson, we will look at Graph Governance. We will learn how to implement Temporal Versions using the valid_from and valid_to properties. We will explore the "Audit Snapshot" pattern and learn how to build an immutable record of "The Truth as it was known then."
1. The "Snapshotting" Problem
If you overwrite a property (e.g., p.role = 'Manager'), the old data is gone forever. This is a disaster for governance.
Professional Graph RAG systems use Non-Destructive Updates.
The Pattern: Instead of changing a property on a node, we create a new Relationship with a timestamp.
(Sudeep)-[:HAS_ROLE {from: 2024, to: 2025}]->(Developer)(Sudeep)-[:HAS_ROLE {from: 2025, to: null}]->(Manager)
2. Querying the "Past Truth"
When the AI agent performs a retrieval, it must specify the Reference Time.
MATCH (p:Person {name: 'Sudeep'})-[r:HAS_ROLE]->(role)
WHERE r.from <= $as_of_date AND (r.to IS NULL OR r.to > $as_of_date)
This allows the AI to "Time-Travel." It can answer: "According to our records in March 2024, Sudeep was authorized to access the server."
3. The "Immutable Reasoning" Log
For high-stakes decisions (e.g., loan approvals), you must store the Reference Graph.
- User asks a question.
- System retrieves a subgraph of facts.
- Governance Step: The system saves a "Static Copy" of these facts (the IDs and their properties at that moment).
- If the decision is challenged 6 months later, the system can recreate the exact context the AI saw.
graph LR
Sudeep ---|HAS_ROLE {Active: False}| Dev
Sudeep ---|HAS_ROLE {Active: True}| Man
style Man fill:#34A853,color:#fff
style Dev fill:#9e9e9e,color:#fff
note[The graph stores the history of the relationship]
4. Implementation: Updating a Fact with Versioning
// 1. Close the old fact
MATCH (p:Person {id: '123'})-[r:HAS_STATUS {to: null}]->(s)
SET r.to = datetime()
// 2. Create the new fact
WITH p
CREATE (p)-[:HAS_STATUS {from: datetime(), to: null}]->(:Status {name: 'Deactivated'})
5. Summary and Exercises
Governance ensures that your graph is not just a "Database," but a "Ledger of Knowledge."
- Temporal Versioning preserves the history of facts.
- Reference Times allow for "As-is" auditing and reasoning.
- Immutability protects the system against malicious or accidental data overwrites.
- Auditable Paths are the only way to prove why an AI made a decision in the past.
Exercises
- Version Design: You are tracking a "Home Address." If a person moves, do you delete the old address node? How do you link the person to both their "Old" and "New" address while clearly marking which is current?
- The "Time-Travel" Query: Write a Cypher snippet that finds "All employees who worked on Project X in the month of January 2025."
- Visualization: Draw a timeline with 3 nodes. Show how relationships can "Turn on" and "Turn off" over time.
In the next lesson, we will look at the global standard: Compliance Frameworks (GDPR/HIPAA in Graph).