Graph memory: Postgres schema + repo helpers (#48)#64
Conversation
…gres graph memory schema","intent":"Implement issue 48 graph tables and repo helpers","impact":"Unblocks graph ingestion and correction work","breaking":false,"risk":"medium","refs":["gh:#48"]}
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 096459944c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| CREATE UNIQUE INDEX IF NOT EXISTS uq_graph_facts_active_entity_object | ||
| ON graph_facts (tenant_id, project_id, scope, subject_entity_id, predicate, object_entity_id) | ||
| WHERE valid_to IS NULL AND object_entity_id IS NOT NULL; |
There was a problem hiding this comment.
Enforce uniqueness for all active fact windows
The partial unique indexes only apply when valid_to IS NULL, so duplicate facts with the same (tenant, project, scope, subject, predicate, object) can still be inserted with bounded windows like valid_to > now. Those rows are considered active by fetch_active_facts_for_subject (valid_from <= now AND (valid_to IS NULL OR valid_to > now)), which violates the new one-active-fact invariant and can return conflicting active facts whenever finite validity ranges are used.
Useful? React with 👍 / 👎.
Implements Graph Memory Postgres v1 schema and invariants.
Verification:
Closes #48