Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

fix(github): strip wrapped search qualifiers from topics (#952) (#970)

Som Samantray3181c957c1ef
diff --git a/changelog.d/952.fixed.md b/changelog.d/952.fixed.md
new file mode 100644
index 00000000..227bb0f9
--- /dev/null
+++ b/changelog.d/952.fixed.md
@@ -0,0 +1 @@
+GitHub search qualifiers wrapped in parentheses, quotes, or brackets (`(created:>2025-03-20)`, `"created:>2025-03-20"`) are now stripped from topics before the query is built, matching the plain-qualifier behavior. Previously a wrapped `created:` survived into the search, collided with the adapter's own `created:>{from_date}` window (GitHub honors the first), and the source silently reported zero results. Leftover empty wrapper pairs are removed too, so a wrapped qualifier-only topic still degrades to the no-search error instead of emitting stray characters.
diff --git a/docs/residual-review-findings/fix-github-qualifier-wrapper-strip.md b/docs/residual-review-findings/fix-github-qualifier-wrapper-strip.md
new file mode 100644
index 00000000..8b2f4fe1
--- /dev/null
+++ b/docs/residual-review-findings/fix-github-qualifier-wrapper-strip.md
@@ -0,0 +1,14 @@
+# Residual Review Findings
+
+Source: LFG pipeline review of the #952 fix (branch `fix/github-qualifier-wrapper-strip`, commits a2b7785, 59f8937, 58b8bd5). Review run `20260809-160411-d2ac968f` (ce-code-review, roster: correctness, project-standards, testing, adversarial).
+
+## Filed
+
+- **P3 — skills/last30days/scripts/lib/github.py:201 — Stray wrapper residue from unbalanced wrapper collapse.** Mixed/nested wrapper shapes that strip a qualifier but leave a lone opener/closer (e.g. `(created:>2025-03-20` → `(`, cross-type nesting `(("created:>2025-03-20"))` → residue) survive into the query. Cosmetic only — the qualifier itself never leaks, so the #949 collision class stays dead. Suggested fix (a final lone-wrapper-char pass) was not applied because blindly removing all `)`/`]` could mangle legitimate topic text with unbalanced parens. Filed as https://github.com/mvanhorn/last30days-skill/issues/969.
+
+## Applied (not residual)
+
+- P1 — missing-closer / space-in-quote wrapper shapes leaking the raw qualifier into the query (regression vs first commit) — fixed in 58b8bd5 (boundary accepts wrapper openers).
+- P2 — wrapped qualifiers with comma/semicolon glue (e.g. `(created:>2025-03-20,robotics)`) surviving the strip — fixed in 58b8bd5; glued terms preserved, qualifier stripped.
+- Adversarial residual risk notes (empty-pair removal on whole topic, lenient mismatched-pair handling, fixpoint termination) — reviewed, no action required.
+- Testing gaps (deeper nesting, mixed wrapper content, empty-pair-stays branch) — covered by structural guarantees; P1/P2 shapes now have regression tests.
diff --git a/skills/last30days/scripts/lib/github.py b/skills/last30days/scripts/lib/github.py
index 944c0501..2d7d5964 100644
--- a/skills/last30days/scripts/lib/github.py
+++ b/skills/last30days/scripts/lib/github.py
@@ -173,6 +173,13 @@ def _compute_relevance(
# honours the FIRST and silently ignores ours. The API then returns
# out-of-window items that `parse_github_response`'s date filter drops
# wholesale — a source that fetches results and reports zero (issue #949).
+# Qualifiers may also arrive fully wrapped in one pair of parens/brackets/
+# quotes ("(created:>2025-03-20)", '"stars:>1000"'), which an LLM planner
+# plausibly emits; _WRAPPED_QUALIFIER_RE consumes the whole wrapper pair with
+# the qualifier so no stray `()`/`""` residue reaches the query (issue #952).
+# The plain regex's boundary also accepts wrapper openers so a qualifier with
+# a missing closer ("(created:>2025-03-20") is still stripped rather than
+# leaking into the query; only the stray opener survives, harmlessly.
QUALIFIER_KEYS = frozenset({
"archived", "assignee", "author", "base", "closed", "comments", "commenter",
"created", "fork", "forks", "head", "in", "interactions", "involves", "is",
@@ -182,11 +189,27 @@ QUALIFIER_KEYS = frozenset({
"topic", "topics", "type", "updated", "user",
})
+_QUALIFIER_KEYS_ALT = "|".join(sorted(QUALIFIER_KEYS))
+
_QUALIFIER_RE = re.compile(
- r"(?:(?<=[\s,;])|^)(?:" + "|".join(sorted(QUALIFIER_KEYS)) + r"):(?:[<>]=?)?(?:\"[^\"]*\"|[^\s,;()\[\]]+)[,;]?",
+ r"(?:(?<=[\s,;(\[\"'])|^)(?:" + _QUALIFIER_KEYS_ALT + r"):(?:[<>]=?)?(?:\"[^\"]*\"|[^\s,;()\[\]]+)[,;]?",
+ re.IGNORECASE,
+)
+
+# A qualifier fully wrapped in a single pair of parens/brackets/quotes. The
+# wrapper pair is consumed with the qualifier, so stripping leaves no residue.
+# An unbalanced quote (e.g. `label:"bug`) is not a wrapper shape and is left
+# to _QUALIFIER_RE, which strips the qualifier as before.
+_WRAPPED_QUALIFIER_RE = re.compile(
+ r"[\(\[\"'](?:" + _QUALIFIER_KEYS_ALT + r"):(?:[<>]=?)?(?:\"[^\"]*\"|[^\s,;()\[\]]+)[\)\]\"']",
re.IGNORECASE,
)
+# Empty wrapper pairs left behind when a nested wrapper collapses (e.g. the
+# `()` from "((created:>2025-03-20))"). Removed to fixpoint; a pair enclosing
+# real text stays.
+_EMPTY_WRAPPER_RE = re.compile(r"\(\s*\)|\[\s*\]|\"\s*\"|'\s*'")
+
def strip_search_qualifiers(text: str) -> str:
"""Strip GitHub search qualifiers from a topic, leaving plain-language text.
@@ -195,7 +218,14 @@ def strip_search_qualifiers(text: str) -> str:
but qualifiers; callers must handle that rather than searching on an empty
term, which would match the entire site.
"""
- return " ".join(_QUALIFIER_RE.sub(" ", text).split())
+ stripped = _WRAPPED_QUALIFIER_RE.sub(" ", text)
+ stripped = _QUALIFIER_RE.sub(" ", stripped)
+ while True:
+ cleaned = _EMPTY_WRAPPER_RE.sub("", stripped)
+ if cleaned == stripped:
+ break
+ stripped = cleaned
+ return " ".join(stripped.split())
def search_github(
diff --git a/tests/test_github.py b/tests/test_github.py
index 7ca2c597..dcc57db7 100644
--- a/tests/test_github.py
+++ b/tests/test_github.py
@@ -522,6 +522,78 @@ class TestStripSearchQualifiers(unittest.TestCase):
"langchain",
)
+ def test_paren_wrapped_qualifier_stripped(self):
+ # Wrapper shapes bypassed the strip until the boundary accepted them
+ # (issue #952); a surviving created: would collide with the adapter's
+ # own window and silently zero out the source (issue #949 class).
+ self.assertEqual(
+ github.strip_search_qualifiers("(created:>2025-03-20)"),
+ "",
+ )
+
+ def test_double_quote_wrapped_qualifier_stripped(self):
+ self.assertEqual(
+ github.strip_search_qualifiers('"created:>2025-03-20"'),
+ "",
+ )
+
+ def test_single_quote_wrapped_qualifier_stripped(self):
+ self.assertEqual(
+ github.strip_search_qualifiers("'is:issue'"),
+ "",
+ )
+
+ def test_bracket_wrapped_qualifier_stripped(self):
+ self.assertEqual(
+ github.strip_search_qualifiers("[stars:>1000]"),
+ "",
+ )
+
+ def test_wrapped_qualifier_among_words_leaves_no_empty_pair(self):
+ self.assertEqual(
+ github.strip_search_qualifiers("ai (created:>2025-03-20) model"),
+ "ai model",
+ )
+
+ def test_quoted_value_and_wrapped_qualifier_both_stripped(self):
+ self.assertEqual(
+ github.strip_search_qualifiers('label:"bug fix" (created:>2025-03-20)'),
+ "",
+ )
+
+ def test_wrapped_and_plain_duplicate_qualifiers_both_stripped(self):
+ self.assertEqual(
+ github.strip_search_qualifiers("(created:>2025-03-20) created:>2026-01-01"),
+ "",
+ )
+
+ def test_nested_wrapper_collapses_to_fixpoint(self):
+ self.assertEqual(
+ github.strip_search_qualifiers("((created:>2025-03-20))"),
+ "",
+ )
+
+ def test_missing_closer_qualifier_still_stripped(self):
+ # An opener without its closer ("(created:>2025-03-20") must not leak
+ # the qualifier into the query: only the stray opener survives, and the
+ # collision class (#949) stays dead.
+ result = github.strip_search_qualifiers("(created:>2025-03-20")
+ self.assertNotIn("created:", result)
+
+ def test_quote_wrapped_with_space_inside_does_not_leak_qualifier(self):
+ # '"created:>2025-03-20 abc"' has a space in the quoted value, so it is
+ # not a single wrapper pair; the qualifier itself must still not reach
+ # the query.
+ result = github.strip_search_qualifiers('"created:>2025-03-20 abc"')
+ self.assertNotIn("created:", result)
+
+ def test_wrapped_qualifier_with_glued_term_preserves_term(self):
+ # Mirrors the plain glued-term case: "(created:>2025-03-20,robotics)"
+ # must strip the qualifier and keep the term, with no created: leak.
+ result = github.strip_search_qualifiers("(created:>2025-03-20,robotics)")
+ self.assertIn("robotics", result)
+ self.assertNotIn("created:", result)
+
def test_case_insensitive_qualifier_only_topic(self):
self.assertEqual(github.strip_search_qualifiers("Stars:>1000"), "")
@@ -731,6 +803,33 @@ class TestSearchGithubQualifiers(unittest.TestCase):
self.assertIn("ai", q)
self.assertEqual(q.count("created:"), 1)
+ @patch.object(github, "_resolve_token", return_value="test-token")
+ def test_paren_wrapped_qualifier_builds_single_created_query(self, mock_token):
+ # Wrapped qualifier (issue #952) must not survive into the query to
+ # collide with the adapter's own created: window (issue #949 class).
+ captured = {}
+ with patch.object(github, "_fetch_json", side_effect=self._capturing_fetch(captured)):
+ github.search_github(
+ "open source ai (created:>2025-03-20)", "2026-07-01", "2026-07-31",
+ )
+ q = self._query(captured["url"])
+ self.assertEqual(q, "open source ai created:>2026-07-01")
+ self.assertEqual(q.count("created:"), 1)
+
+ @patch.object(github, "_resolve_token", return_value="test-token")
+ def test_quote_wrapped_qualifier_only_topic_errors_without_network(self, mock_token):
+ # A quote-wrapped qualifier-only topic strips to nothing, so the
+ # adapter must report the empty-topic error instead of querying an
+ # empty term (issue #952; mirrors the plain qualifier-only case).
+ with patch.object(github, "_fetch_json") as mock_fetch:
+ result = github.search_github(
+ '"created:>2025-03-20"', "2026-07-01", "2026-07-31",
+ )
+ mock_fetch.assert_not_called()
+ self.assertEqual(result["items"], [])
+ self.assertIn("error", result)
+ self.assertIn("qualifier", result["error"].lower())
+
if __name__ == "__main__":
unittest.main()