[schemas] Knowledge graph tables and extraction trigger#5
[schemas] Knowledge graph tables and extraction trigger#5alanshurafa wants to merge 5 commits intomainfrom
Conversation
Add entities, edges, thought_entities, entity_extraction_queue, and consolidation_log tables for automatic entity and relationship extraction from thoughts. Install auto-queue trigger that enqueues thoughts on insert or content change with fingerprint-based dedup guards. Part of the OB1 alpha milestone. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 087c43f333
ℹ️ 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 TABLE IF NOT EXISTS public.thought_entities ( | ||
| thought_id BIGINT NOT NULL REFERENCES public.thoughts(id) ON DELETE CASCADE, |
There was a problem hiding this comment.
Use UUID thought_id to match thoughts.id
The new schema defines thought_id as BIGINT, but the documented base Open Brain schema creates thoughts.id as UUID (docs/01-getting-started.md, lines 67-74). In Postgres, this makes the FK invalid (BIGINT cannot reference UUID), so applying this migration will fail when creating thought_entities (and similarly entity_extraction_queue), and the trigger path that inserts NEW.id into the queue will also be type-incompatible. This blocks installation for standard deployments that followed the setup guide.
Useful? React with 👍 / 👎.
Add blank lines around headings (MD022), fenced code blocks (MD031), and between adjacent blockquotes (MD028). Fix broken link fragment (MD051) and remove extra blank line (MD012). No content changes. These errors were blocking CI on all open PRs since the lint check runs repo-wide. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Base OB1 thoughts.id is UUID (gen_random_uuid()), not BIGINT. Fixed thought_entities.thought_id, entity_extraction_queue.thought_id, consolidation_log.survivor_id, and consolidation_log.loser_id. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
entities,edges,thought_entities,entity_extraction_queue,consolidation_logthoughtsthat enqueues new/updated thoughts for entity extractionWhat's included
entitiesedgesthought_entitiesentity_extraction_queueconsolidation_logqueue_entity_extraction()trg_queue_entity_extractionthoughtstableDesign decisions
CREATE TABLE IF NOT EXISTS,CREATE OR REPLACE FUNCTION, andDROP TRIGGER IF EXISTSpatterns — safe to run multiple timesmetadata.generated_by IS NOT NULL) and no-op updates where content fingerprint hasn't changedON CONFLICT (thought_id) DO UPDATEonly resets whensource_fingerprint IS DISTINCT FROMthe stored value, preventing churn from metadata-only writesDependencies
thoughtstable columnscontent_fingerprintcolumn onthoughts(from Step 2.6 of getting-started guide)Test plan
schema.sqlinto Supabase SQL Editor and run — no errorsqueue_entity_extractionfunction in Database > Functionstrg_queue_entity_extractiontrigger onthoughtstableentity_extraction_queue🤖 Generated with Claude Code