Skip to content

[Feature]: Community Subgraph - Hierarchical Graph Aggregation #90

@zircote

Description

@zircote

Problem Statement

Subcog current knowledge graph is flat - entities and relationships exist at a single level. Zep Graphiti engine implements a three-tier hierarchical structure that enables:

  • Community-level insights
  • Aggregated relationship patterns
  • Scalable graph queries
  • Topic clustering

This hierarchy is: Episodes -> Entities -> Communities

Proposed Solution

Implement a community subgraph tier:

Graph Hierarchy:

  1. Episode Subgraph: Individual memories/events
  2. Entity Subgraph: Extracted entities and relationships (current)
  3. Community Subgraph: Aggregated clusters of related entities

Community Features:

  • Automatic clustering of related entities
  • Community summarization
  • Inter-community relationships
  • Hierarchical navigation

Benefits:

  • "Zoom out" to see big picture
  • Faster queries via community-level filtering
  • Emergent topic discovery
  • Scalable to large graphs

Proposed API:

pub struct Community {
    id: CommunityId,
    name: String,
    summary: String,
    members: Vec<EntityId>,
    parent: Option<CommunityId>,
}

MCP tools:

subcog_communities:
  action: detect  # Run community detection algorithm
  algorithm: louvain
  min_size: 3

subcog_community_get:
  community_id: "comm_123"
  include: ["members", "relationships", "summary"]

subcog_graph:
  operation: visualize
  level: community  # Show community-level view
  depth: 2

Enhanced recall with community context:

subcog_recall:
  query: "database decisions"
  community_boost: true  # Boost results from same community

Alternatives Considered

  • Flat graph only (current) - does not scale
  • Manual tagging for grouping - tedious
  • External graph analytics - lose integration

Additional Context

Breaking Change: No
Priority: Nice to have
Contribution: Yes, with guidance

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions