Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:666ghj BettaFish Keyword Fallback Chain

From Leeroopedia
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()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment