Skip to main content

detect_communities

Function detect_communities 

Source
pub async fn detect_communities(
    store: &GraphStore,
    provider: &AnyProvider,
    community_summary_max_prompt_bytes: usize,
    concurrency: usize,
    edge_chunk_size: usize,
) -> Result<usize, MemoryError>
Expand description

Run label propagation on the full entity graph, generate community summaries via LLM, and upsert results to SQLite.

Returns the number of communities detected (with >= 2 entities).

Unchanged communities (same entity membership and intra-community edges) are skipped — their existing summaries are preserved without LLM calls (incremental detection, #1262). LLM calls for changed communities are parallelized via a JoinSet bounded by a semaphore with concurrency permits (#1260).

§Panics

Does not panic in normal operation. The semaphore.acquire().await.expect(...) call is infallible because the semaphore is never closed during the lifetime of this function.

§Errors

Returns an error if SQLite queries or LLM calls fail.