Skip to main content

Module query

Module query 

Source
Expand description

Hybrid query — combines semantic search, graph expansion, and episode search.

Pipeline:

  1. Semantic phase: HNSW KNN with limit * 2 to gather candidates
  2. Graph phase: 1-hop expansion from the top 3 candidates
  3. Merge by entity ID — corroborating an existing candidate or adding a new one
  4. Episode search (optional) — separate KNN on episodes

§Scoring

Both channels score through [super::search::score_with_utility]:

score = w_semantic * similarity + w_hotness * hotness + w_utility * utility

The channel decides only where similarity comes from. A semantic candidate measures it against the query vector; a graph candidate propagates it — the parent’s similarity discounted by the edge’s effective (decayed) confidence:

similarity_graph = similarity_parent * effective_confidence

Hotness and utility are read off the neighbor itself, exactly as they are for a semantic hit. Confidence therefore still orders neighbors — a decayed edge ranks below a fresh one — without a graph candidate having to overcome a base every semantic candidate gets for free.

When an entity arrives on both channels the graph corroborates the query, and its measured relevance is raised — bounded, and proportional to how much the edge is believed:

similarity = min(1.0, similarity_semantic
                      * (1 + corroboration_boost * effective_confidence))

The measurement stays the base: a direct reading of this entity against this query outranks an estimate propagated from a neighbor, so corroboration adds to it rather than replacing it. Two clamps keep it from running away — the similarity ceiling of 1.0, and a boost default cut to the width of the similarity band it perturbs (see GraphScoringConfig::corroboration_boost). An entity reachable from several expanded parents is credited once, over its strongest path: the parents are the top hits of a single query and are not independent witnesses. Self-edges corroborate nothing and are skipped.

Functions§

pipeline_entities
Get all pipeline entities for a given stage, optionally filtered by status.
pipeline_flow
Trace the lineage of a pipeline entity through relationship chains.
pipeline_stats
Get pipeline stats: counts by (stage, status), stale entities.
query
Run a hybrid query: semantic search + graph expansion + optional episode search.