You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a Knowledge Graph feature that extracts citations, legal authorities, sections, agents, and their relationships from completed pipeline sessions, stores them in PostgreSQL, and renders an interactive force-directed graph in a new center-panel tab alongside Chat.
The Citation Chat answers "what does the memo say about X?" but cannot answer "how are these citations connected?" or "which authorities support the CFIUS analysis and where did they come from?" A knowledge graph fills this gap by making relationships, provenance, and cross-section dependencies visible and queryable.
Architecture Decisions (validated via Exa research, March 2026)
Decision
Choice
Rationale
Graph storage
PostgreSQL adjacency tables
Already running pgvector:pg16. LightRAG (29K stars) validates this pattern. Apache AGE as future upgrade path.
Extraction
Hybrid: rule-based 80% + LLM 20%
SAP Practical GraphRAG: dependency parsing achieves 94% of LLM quality. Our pipeline already produces structured citation-map.json.
Summary
Add a Knowledge Graph feature that extracts citations, legal authorities, sections, agents, and their relationships from completed pipeline sessions, stores them in PostgreSQL, and renders an interactive force-directed graph in a new center-panel tab alongside Chat.
Spec:
docs/pending-updates/knowledge-graph.mdMotivation
The Citation Chat answers "what does the memo say about X?" but cannot answer "how are these citations connected?" or "which authorities support the CFIUS analysis and where did they come from?" A knowledge graph fills this gap by making relationships, provenance, and cross-section dependencies visible and queryable.
Architecture Decisions (validated via Exa research, March 2026)
force-graphv1.51 (Canvas)Roadmap
Phase 1 — Schema & Extraction (Backend)
ensureKnowledgeGraphSchema()topostgres.js— 5 tables:kg_nodes,kg_edges,kg_evolution,kg_provenance,kg_messagesKNOWLEDGE_GRAPHfeature flag tofeatureFlags.jsknowledgeGraphExtractor.js— post-session extraction:consolidated-footnotes.md→ citation nodes + verification tagscitation-map.json→ CITES edges (section → citation)report_embeddingshookDBBridge.jsSessionEnd →setImmediate(buildSessionKnowledgeGraph)(fire-and-forget)claude-sdk-server.jsPhase 2 — API Endpoints
GET /api/db/sessions/:key/kg/graph— full graph in{nodes, links}formatGET /api/db/sessions/:key/kg/neighbors/:nodeId— 1-hop neighborsGET /api/db/sessions/:key/kg/evolution— graph construction timelineGET /api/db/sessions/:key/kg/provenance/:nodeId— extraction audit trailPhase 3 — Frontend Visualization
force-graphCDN toindex.htmlstyles.css: toolbar, canvas, detail panel, node type colors (reuse design tokens)app.js: state vars,enableGraph()/disableGraph(),renderForceGraph(), node click → neighbors + provenance, layout switching, confidence filteringPhase 4 — Graph-Aware Q&A (RRF Hybrid Retrieval)
knowledgeGraphRouter.js— SSE streaming endpointsearchSimilar()openKgStream(),handleKgEvent(), highlight relevant nodes on queryPhase 5 — Tests & Polish
canonical_key(same case across memos)Files
New (3):
knowledgeGraphExtractor.js,knowledgeGraphRouter.js,knowledge-graph.test.jsModified (8):
postgres.js,featureFlags.js,claude-sdk-server.js,hookDBBridge.js,dbFrontendRouter.js,index.html,styles.css,app.jsDocker: Zero changes — CDN-loaded lib, auto-created schema, no new npm deps.
Dependencies
HOOK_DB_PERSISTENCE=true+EMBEDDING_PERSISTENCE=true(both already in production)🤖 Generated with Claude Code