Heuristic:666ghj BettaFish Keyword Fallback Chain
| Knowledge Sources | |
|---|---|
| Domains | Crawling, Optimization |
| Last Updated | 2026-10-08 21:30 GMT |
Overview
Distribute crawl keywords across platforms with a multi-level fallback chain: active keywords → stored keywords → LLM-generated keywords → topic defaults.
Description
The KeywordManager in MindSpider distributes crawl keywords to platform crawlers. When no active keywords are configured, it falls back through a chain: (1) active keywords from database, (2) all stored keywords, (3) LLM-generated keywords from topic extraction, (4) hardcoded topic defaults. This ensures the crawling pipeline always has keywords to work with, even when the database is empty or LLM APIs are unavailable.
Usage
Use this heuristic when designing systems that require guaranteed input data even when upstream sources fail. Apply when a keyword/config source may be empty, expired, or unreachable.
The Insight (Rule of Thumb)
- Action: Implement a multi-level fallback chain for keyword retrieval: `get_all_keywords()` tries active → stored → generated → default.
- Value: Each level returns a non-empty list, guaranteeing the crawler always has work.
- Trade-off: Lower fallback levels may be less relevant/current, but guarantee availability.
- Compatibility: Works with any keyword/config distribution system.
Reasoning
Crawling pipelines are inherently fragile — databases may be empty on first run, LLM APIs may be rate-limited, and topic extraction may fail. A fallback chain ensures the pipeline continues operating at reduced capacity rather than failing entirely. The active keywords are the most recently curated, stored keywords are the historical set, LLM-generated keywords provide fresh extraction, and defaults guarantee a baseline.
Code Evidence
KeywordManager implementation from `MindSpider/DeepSentimentCrawling/keyword_manager.py` (class overview):
class KeywordManager:
def get_all_keywords(self):
"""Get keywords with fallback chain:
1. Active keywords from database
2. All stored keywords from database
3. LLM-generated keywords from topic extraction
4. Hardcoded topic defaults
"""
# Level 1: Active keywords
active = self._get_active_keywords()
if active:
return active
# Level 2: All stored keywords
stored = self._get_stored_keywords()
if stored:
return stored
# Level 3: LLM-generated
generated = self._generate_keywords()
if generated:
return generated
# Level 4: Defaults
return self._get_default_keywords()