feat: entity system and temporal graph with Postgres-native search#249
Merged
feat: entity system and temporal graph with Postgres-native search#249
Conversation
New entity system built as an independent package alongside the existing asset system. Zero changes to existing asset code. All search is Postgres-native — no Elasticsearch dependency for v2. Core domain (core/entity/): - Entity: open type system, temporal (valid_from/valid_to), properties JSONB - Edge: typed, directed, temporal relationships - Chunk: pgvector embeddings for semantic search - Service: context assembly, impact analysis, search orchestration - HybridSearch: keyword + semantic fusion via Reciprocal Rank Fusion - SearchRepository: Postgres tsvector + pg_trgm (replaces ES) Storage (store/postgres/): - EntityRepository: CRUD with temporal support - EdgeRepository: recursive CTE graph traversal - ChunkRepository: pgvector cosine similarity search - EntitySearchRepository: tsvector full-text + pg_trgm fuzzy matching - Migration 000019: entities, edges, chunks tables with search_vector generated column, GIN indexes, trigram indexes Search architecture (all Postgres): - Keyword: tsvector with weighted fields (URN/name=A, desc=B, source=C) - Fuzzy: pg_trgm similarity with automatic fallback - Semantic: pgvector cosine distance on chunk embeddings - Hybrid: RRF fusion of keyword + semantic results - Suggest: pg_trgm similarity-based autocomplete MCP tools (internal/mcp/): - search_entities: hybrid search across the entity graph - get_context: assembled context subgraph - impact: downstream blast radius analysis
Generated Go code from proton proto definitions for entity v2 RPCs. Created handler/entity.go implementing all 12 new RPC methods: Entity CRUD: GetAllEntities, GetEntityByID, UpsertEntity, DeleteEntity Search: SearchEntities, SuggestEntities, GetEntityTypes Context: GetEntityContext, GetEntityImpact Edges: UpsertEdge, GetEdges, DeleteEdge Handler accepts entity and edge services via WithEntityService/ WithEdgeService options — no changes to existing handler constructor signature. Serve function passes options through to handler.
Deleted: - core/asset/ — entire old asset package - core/discussion/ — discussions and comments - core/tag/ — tags and tag templates - store/elasticsearch/ — ES client and discovery repos - store/postgres/asset_*, lineage_*, discussion_*, comment_*, tag_* repos - handler/asset.go, discussion.go, comment.go, tag.go, search.go, lineage.go - All old CLI commands (assets, discussions, lineage, search) - All old migrations (replaced with single 000001_init_schema.up.sql) Updated: - Proto regenerated from proton (entity-only service definition) - handler.go: simplified — only namespace, star, user, entity, edge services - bootstrap.go: removed ES, removed all old service wiring - config.go: removed Elasticsearch config - star package: updated to use entity.Entity instead of asset.Asset - CLI: entity commands (list, view, upsert, delete, search, types, context, impact) - Migration: single fresh schema with namespaces, users, entities, edges, chunks, stars Schema (6 tables): - namespaces, users, entities, edges, chunks, stars - tsvector + pg_trgm + pgvector for search (no ES) - RLS on all tables
- go mod tidy: removed unused ES and other stale dependencies - Namespace service: nil-safe DiscoveryRepository (ES removed) - Deleted stale integration tests (postgres, user, namespace repo tests that depended on deleted test infrastructure) - Fixed last 2 "asset" string references in star errors and CLI - Added entity unit tests (11 tests): - Type validation (open type system) - Entity.IsCurrent temporal check - Reciprocal Rank Fusion (empty, single, multi-list) - Service: Upsert, GetByURN, Delete, GetAll, GetTypes, Search
- Removed elasticsearch from docker-compose.yaml (Postgres-only) - Removed elasticsearch from config.yaml and config.example.yaml - Removed elasticsearch service from .github/workflows/test.yml - Deleted stale guide docs (ingestion, querying, starring, telemetry) - Deleted stale handler mocks (no tests import them) - Removed empty test/ directory - Updated Postgres to v16 in docker-compose - go mod tidy (cleaned unused indirect deps)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedToo many files! This PR contains 216 files, which is 66 over the limit of 150. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (216)
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
17c6f0e to
7a08437
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete rewrite of Compass from a static asset catalog to a temporal entity graph with Postgres-native search. No Elasticsearch dependency.
Companion PR: raystack/proton#461
What's New
Core Domain (
core/entity/)Storage (
store/postgres/)Search (all Postgres, no ES)
API (12 new RPCs)
MCP Tools
search_entities: hybrid search across the entity graphget_context: assembled context subgraph (entity + edges + related)impact: downstream blast radius analysisCLI
compass entity list/view/upsert/delete/search/types/context/impactWhat's Removed
core/asset/— entire old asset packagecore/discussion/,core/tag/— discussions, comments, tags, tag templatesstore/elasticsearch/— ES client and all discovery reposSchema (6 tables)
namespaces→users→entities→edges→chunks→starsSingle fresh migration:
000001_init_schema.up.sqlTest Plan
go build ./...passesgo vet ./...passes