From b4896634508233c5d7f2998c8ee578ff057b0281 Mon Sep 17 00:00:00 2001 From: Jeffrey Sperling Date: Fri, 13 Mar 2026 01:08:28 -0700 Subject: [PATCH] Loosen source tiering for usage queries Classify prompting and animation queries as how_to so the stack does not treat them as generic breaking news. Also keep X available for how_to and preserve YouTube/HN coverage for breaking-news and prediction queries. Validated with uv run python -m unittest tests.test_query_type and the five-query local comparison run used for PR #65 review. --- scripts/lib/query_type.py | 9 +++++---- tests/test_query_type.py | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/lib/query_type.py b/scripts/lib/query_type.py index 36d325d..bc48c85 100644 --- a/scripts/lib/query_type.py +++ b/scripts/lib/query_type.py @@ -16,7 +16,8 @@ _OPINION_PATTERNS = re.compile( r"\b(worth it|thoughts on|opinion|review|experience with|recommend|should i|pros and cons|good or bad)\b", re.I ) _HOWTO_PATTERNS = re.compile( - r"\b(how to|tutorial|step by step|setup|install|configure|deploy|migrate|implement|build a|create a)\b", re.I + r"\b(how to|tutorial|step by step|setup|install|configure|deploy|migrate|implement|build a|create a|prompting|prompts?|best practices|tips|examples|animation|animations)\b", + re.I, ) _COMPARISON_PATTERNS = re.compile( r"\b(vs\.?|versus|compared to|comparison|better than|difference between|switch from)\b", re.I @@ -62,10 +63,10 @@ SOURCE_TIERS = { "product": {"tier1": {"reddit", "x", "youtube"}, "tier2": {"web", "tiktok"}}, "concept": {"tier1": {"reddit", "hn", "web"}, "tier2": {"youtube", "x"}}, "opinion": {"tier1": {"reddit", "x"}, "tier2": {"youtube", "bluesky"}}, - "how_to": {"tier1": {"youtube", "reddit", "hn"}, "tier2": {"web"}}, + "how_to": {"tier1": {"youtube", "reddit", "hn"}, "tier2": {"web", "x"}}, "comparison": {"tier1": {"reddit", "hn", "youtube"}, "tier2": {"x", "web"}}, - "breaking_news": {"tier1": {"x", "reddit", "web"}, "tier2": {"hn", "bluesky"}}, - "prediction": {"tier1": {"polymarket", "x", "reddit"}, "tier2": {"web"}}, + "breaking_news": {"tier1": {"x", "reddit", "web"}, "tier2": {"hn", "bluesky", "youtube"}}, + "prediction": {"tier1": {"polymarket", "x", "reddit"}, "tier2": {"web", "hn", "youtube"}}, } # WebSearch penalty adjustment by query type. diff --git a/tests/test_query_type.py b/tests/test_query_type.py index c07f343..bd36410 100644 --- a/tests/test_query_type.py +++ b/tests/test_query_type.py @@ -35,6 +35,8 @@ class TestDetectQueryType(unittest.TestCase): self.assertEqual(detect_query_type("how to deploy on Vercel"), "how_to") self.assertEqual(detect_query_type("tutorial for building MCP servers"), "how_to") self.assertEqual(detect_query_type("step by step Kubernetes setup"), "how_to") + self.assertEqual(detect_query_type("nano banana pro prompting"), "how_to") + self.assertEqual(detect_query_type("remotion animations for Claude Code"), "how_to") def test_comparison_queries(self): self.assertEqual(detect_query_type("cursor vs windsurf"), "comparison") @@ -87,6 +89,9 @@ class TestIsSourceEnabled(unittest.TestCase): def test_tier2_sources_enabled(self): self.assertTrue(is_source_enabled("web", "product")) self.assertTrue(is_source_enabled("bluesky", "opinion")) + self.assertTrue(is_source_enabled("x", "how_to")) + self.assertTrue(is_source_enabled("youtube", "breaking_news")) + self.assertTrue(is_source_enabled("hn", "prediction")) def test_tier3_sources_disabled_by_default(self): self.assertFalse(is_source_enabled("instagram", "concept"))