Skip to content

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

Address PR review feedback (#863)

Trevin Chowf323ec6e7aa7
diff --git a/skills/last30days/scripts/lib/pipeline.py b/skills/last30days/scripts/lib/pipeline.py
index ac81ccf5..9c933ad2 100644
--- a/skills/last30days/scripts/lib/pipeline.py
+++ b/skills/last30days/scripts/lib/pipeline.py
@@ -2411,7 +2411,9 @@ def run(
resolved_handles=resolved_handles,
)
ranked_public = rerank.prune_fallback_entity_misses(ranked_public, topic=topic)
- ranked_private = rerank.prune_fallback_entity_misses(ranked_private, topic=topic)
+ # Private corpus already cleared a body-aware retrieval floor; do not apply
+ # the public title/snippet visibility gate (filenames often omit the head
+ # token even when the document body matched).
ranked_candidates = sorted(
[*ranked_public, *ranked_private],
key=lambda candidate: (
diff --git a/skills/last30days/scripts/lib/rerank.py b/skills/last30days/scripts/lib/rerank.py
index eb2290a7..4fcd8f26 100644
--- a/skills/last30days/scripts/lib/rerank.py
+++ b/skills/last30days/scripts/lib/rerank.py
@@ -670,6 +670,13 @@ def _primary_entity(topic: str) -> str:
return stripped
+def _is_corpus_candidate(candidate: schema.Candidate) -> bool:
+ """True when the candidate carries private corpus evidence."""
+ if candidate.source == "corpus":
+ return True
+ return any(item.source == "corpus" for item in candidate.source_items)
+
+
def prune_fallback_entity_misses(
candidates: list[schema.Candidate],
*,
@@ -684,7 +691,9 @@ def prune_fallback_entity_misses(
relevance floor and it lacks a strong local-relevance signal from an
explicitly scoped retrieval path. Comments and transcripts are excluded
from this escape because incidental words there do not ground the candidate
- itself. Source items remain in the report's diagnostic source dump.
+ itself. Private corpus candidates always escape: retrieval already accepted
+ them on body text, and titles are often filenames that omit the head token.
+ Source items remain in the report's diagnostic source dump.
"""
if not topic:
return candidates
@@ -694,6 +703,9 @@ def prune_fallback_entity_misses(
if candidate.explanation != _FALLBACK_ENTITY_MISS_EXPLANATION:
kept.append(candidate)
continue
+ if _is_corpus_candidate(candidate):
+ kept.append(candidate)
+ continue
if candidate.local_relevance >= FALLBACK_ENTITY_MISS_CONFIDENCE_ESCAPE:
kept.append(candidate)
continue
diff --git a/tests/test_rerank_v3.py b/tests/test_rerank_v3.py
index 700529ec..4eea29b2 100644
--- a/tests/test_rerank_v3.py
+++ b/tests/test_rerank_v3.py
@@ -366,6 +366,16 @@ class FallbackVisibilityTests(unittest.TestCase):
explanation="fallback-local-score (entity-miss demotion)",
source="x",
)
+ # Corpus titles are often filenames; retrieval may have matched body text
+ # that never lands in title/snippet, so local_relevance can sit below the
+ # public escape floor without meaning the document is off-topic.
+ corpus_body_match = self._candidate(
+ title="meeting-notes.md",
+ snippet="Agenda and follow-ups from last week.",
+ local_relevance=0.22,
+ explanation="fallback-local-score (entity-miss demotion)",
+ source="corpus",
+ )
kept = rerank.prune_fallback_entity_misses(
[
@@ -375,6 +385,7 @@ class FallbackVisibilityTests(unittest.TestCase):
ordinary_fallback,
incidental_metadata,
generic_title,
+ corpus_body_match,
],
topic=self.topic,
)
@@ -385,7 +396,29 @@ class FallbackVisibilityTests(unittest.TestCase):
self.assertIn(adjacent, kept)
self.assertIn(scoped_project, kept)
self.assertIn(ordinary_fallback, kept)
+ self.assertIn(corpus_body_match, kept)
+
+ def test_keeps_fused_candidate_with_corpus_source_item(self):
+ fused = self._candidate(
+ title="weekly-summary.md",
+ snippet="No head token in the extracted window.",
+ local_relevance=0.18,
+ explanation="fallback-local-score (entity-miss demotion)",
+ source="web",
+ )
+ fused.source_items = [
+ schema.SourceItem(
+ item_id="c1",
+ source="corpus",
+ title="weekly-summary.md",
+ url="corpus://abc",
+ body="Notes on durable execution architecture for AI coding agents.",
+ )
+ ]
+
+ kept = rerank.prune_fallback_entity_misses([fused], topic=self.topic)
+ self.assertIn(fused, kept)
class ExpandedHaystackTests(unittest.TestCase):
"""Unit 3: Entity-grounding haystack covers transcript snippets,