From 8e136cd4dd7e6f237da9d4db30c11c7d6997a8bc Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 23:04:42 +0000 Subject: [PATCH] Remove unused `defaultdict` import and dead code in `scout.py` Co-authored-by: wjohns989 <56205870+wjohns989@users.noreply.github.com> --- muninn/retrieval/scout.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/muninn/retrieval/scout.py b/muninn/retrieval/scout.py index 389305e..b8683a7 100644 --- a/muninn/retrieval/scout.py +++ b/muninn/retrieval/scout.py @@ -6,14 +6,12 @@ """ import logging -import asyncio import time -from typing import List, Optional, Dict, Any, Tuple -from collections import defaultdict +from typing import List, Optional -from muninn.core.types import SearchResult, MemoryRecord -from muninn.retrieval.hybrid import HybridRetriever from muninn.core.feature_flags import get_flags +from muninn.core.types import SearchResult +from muninn.retrieval.hybrid import HybridRetriever logger = logging.getLogger("Muninn.Scout") @@ -40,7 +38,7 @@ async def hunt( """ t0 = time.time() flags = get_flags() - + # 1. Initial Hybrid Search (Broad) initial_results = await self.retriever.search( query=query, @@ -51,7 +49,7 @@ async def hunt( explain=True, rerank=True ) - + # Track effective scope for the final rerank pass. If the fallback # fires we must propagate the widened (None) scope into the final # search, otherwise discovered candidates from the fallback are @@ -78,7 +76,7 @@ async def hunt( # Find all entities mentioned in initial results seed_ids = [r.memory.id for r in initial_results] discovery_ids = set(seed_ids) - + related_entities = set() for r in initial_results: meta = r.memory.metadata or {} @@ -102,7 +100,7 @@ async def hunt( # Follow PRECEDES/CAUSES edges from initial seeds if flags.is_enabled("memory_chains") and seed_ids: chain_results = self.retriever.graph.find_chain_related_memories( - seed_ids, + seed_ids, limit=limit ) for mid, _score in chain_results: @@ -114,10 +112,6 @@ async def hunt( if not all_ids: return initial_results - # Fetch full records from metadata - records = self.retriever.metadata.get_by_ids(all_ids) - record_map = {r.id: r for r in records} - # Final scoring (Hybrid + Discovery Bonus) # We re-score the union using the retriever's logic final_results = await self.retriever.search( @@ -134,5 +128,5 @@ async def hunt( # (This would ideally use an LLM, but we'll build the trace here) elapsed = time.time() - t0 logger.info("Scout: Hunt completed in %.3fs. Found %d candidates.", elapsed, len(all_ids)) - - return final_results \ No newline at end of file + + return final_results