Description
I noticed an inconsistency in how fact invalidation and expiration are handled when adding new episodes that contain updated information about an existing entity relationship.
The invalidation works as expected in one scenario, but does not happen in a similar scenario involving project assignment.
Scenario 1 — Working as Expected
1st Episode
Episode content:
Kiran lives in Whitefield.
Graphiti creates the following relationship:
Kiran ──LIVES_IN──> Whitefield
Fact:
Kiran lives in Whitefield
The fact initially contains only the valid_at attribute.
2nd Episode
Episode content:
Kiran moved from Whitefield to Electronic City.
Graphiti correctly invalidates the previous fact.
The previous relationship:
Kiran ──LIVES_IN──> Whitefield
is updated with invalid_at and expired_at information.
Graphiti then creates the following new relationships:
Relationship 1
Kiran ──LIVED_IN──> Whitefield
Fact:
Kiran lived in Whitefield.
This fact contains the valid_at attribute.
Relationship 2
Kiran ──LIVES_IN──> Electronic City
Fact:
Kiran moved from Whitefield to Electronic City.
This fact also contains the valid_at attribute.
Result
This behavior is correct because the previous LIVES_IN fact is invalidated when the new information indicates that Kiran no longer lives in Whitefield.
Scenario 2 — Not Working as Expected
1st Episode
Episode content:
Kiran is assigned to the Payments Project.
Graphiti creates the following relationship:
Kiran ──ASSIGNED──> Payments Project
Fact:
Kiran is assigned to the Payments Project.
The fact initially contains only the valid_at attribute.
2nd Episode
Episode content:
Kiran has been released from the Payments Project and assigned to the AI Copilot Project.
Graphiti creates the following relationships:
Relationship 1
Kiran ──RELEASED──> Payments Project
Fact:
Kiran was released from the Payments Project.
This fact contains invalid_at and expired_at attributes.
However, the original ASSIGNED relationship:
Kiran ──ASSIGNED──> Payments Project
is not invalidated.
The original fact:
Kiran is assigned to the Payments Project.
still remains valid, even though the new episode explicitly states that Kiran has been released from that project.
Relationship 2
Kiran ──ASSIGNED──> AI Copilot Project
Fact:
Kiran is assigned to the AI Copilot Project.
This fact contains the valid_at attribute.
Expected Behavior
When the second episode states:
Kiran has been released from the Payments Project
I would expect the existing fact:
Kiran ──ASSIGNED──> Payments Project
to be invalidated/expired, similar to the behavior observed in Scenario 1.
The expected state would be approximately:
Kiran ──ASSIGNED──> Payments Project
↓
INVALIDATED
Kiran ──RELEASED──> Payments Project
Kiran ──ASSIGNED──> AI Copilot Project
Actual Behavior
The RELEASED relationship is created and receives invalid_at / expired_at information, but the original ASSIGNED relationship remains valid.
Kiran ──ASSIGNED──> Payments Project ← Still valid
Kiran ──RELEASED──> Payments Project ← Created
Kiran ──ASSIGNED──> AI Copilot Project ← Created
Question
Could you please clarify whether this is the expected behavior or a potential issue with fact invalidation?
Specifically, should a fact such as:
Kiran is assigned to the Payments Project
automatically be invalidated when a subsequent episode states:
Kiran has been released from the Payments Project
similar to how the LIVES_IN fact is invalidated in Scenario 1?
Description
I noticed an inconsistency in how fact invalidation and expiration are handled when adding new episodes that contain updated information about an existing entity relationship.
The invalidation works as expected in one scenario, but does not happen in a similar scenario involving project assignment.
Scenario 1 — Working as Expected
1st Episode
Episode content:
Kiran lives in Whitefield.
Graphiti creates the following relationship:
Kiran ──LIVES_IN──> Whitefield
Fact:
Kiran lives in Whitefield
The fact initially contains only the valid_at attribute.
2nd Episode
Episode content:
Kiran moved from Whitefield to Electronic City.
Graphiti correctly invalidates the previous fact.
The previous relationship:
Kiran ──LIVES_IN──> Whitefield
is updated with invalid_at and expired_at information.
Graphiti then creates the following new relationships:
Relationship 1
Kiran ──LIVED_IN──> Whitefield
Fact:
Kiran lived in Whitefield.
This fact contains the valid_at attribute.
Relationship 2
Kiran ──LIVES_IN──> Electronic City
Fact:
Kiran moved from Whitefield to Electronic City.
This fact also contains the valid_at attribute.
Result
This behavior is correct because the previous LIVES_IN fact is invalidated when the new information indicates that Kiran no longer lives in Whitefield.
Scenario 2 — Not Working as Expected
1st Episode
Episode content:
Kiran is assigned to the Payments Project.
Graphiti creates the following relationship:
Kiran ──ASSIGNED──> Payments Project
Fact:
Kiran is assigned to the Payments Project.
The fact initially contains only the valid_at attribute.
2nd Episode
Episode content:
Kiran has been released from the Payments Project and assigned to the AI Copilot Project.
Graphiti creates the following relationships:
Relationship 1
Kiran ──RELEASED──> Payments Project
Fact:
Kiran was released from the Payments Project.
This fact contains invalid_at and expired_at attributes.
However, the original ASSIGNED relationship:
Kiran ──ASSIGNED──> Payments Project
is not invalidated.
The original fact:
Kiran is assigned to the Payments Project.
still remains valid, even though the new episode explicitly states that Kiran has been released from that project.
Relationship 2
Kiran ──ASSIGNED──> AI Copilot Project
Fact:
Kiran is assigned to the AI Copilot Project.
This fact contains the valid_at attribute.
Expected Behavior
When the second episode states:
Kiran has been released from the Payments Project
I would expect the existing fact:
Kiran ──ASSIGNED──> Payments Project
to be invalidated/expired, similar to the behavior observed in Scenario 1.
The expected state would be approximately:
Kiran ──ASSIGNED──> Payments Project
↓
INVALIDATED
Kiran ──RELEASED──> Payments Project
Kiran ──ASSIGNED──> AI Copilot Project
Actual Behavior
The RELEASED relationship is created and receives invalid_at / expired_at information, but the original ASSIGNED relationship remains valid.
Kiran ──ASSIGNED──> Payments Project ← Still valid
Kiran ──RELEASED──> Payments Project ← Created
Kiran ──ASSIGNED──> AI Copilot Project ← Created
Question
Could you please clarify whether this is the expected behavior or a potential issue with fact invalidation?
Specifically, should a fact such as:
Kiran is assigned to the Payments Project
automatically be invalidated when a subsequent episode states:
Kiran has been released from the Payments Project
similar to how the LIVES_IN fact is invalidated in Scenario 1?