fix(summarizer): ignore future-dated rows; require a score floor for the fallback

Two leaks let low-value items reach the operator brief:

- get_recent_news() only bounded the window from below, so event
  listings dated days ahead (wiseye.org, +3d/+6d) were re-fetched,
  re-graded and re-billed every interval for a week. The window is now
  (now - N, now]; NULL timestamps stay excluded as before.
- select_graded() returned ordered[:fallback_top] with no floor, so a
  15/100 event listing entered the brief as 'low'. New
  SUMMARY_FALLBACK_MIN_SCORE (default 40, clamped 0-100) filters the
  fallback set; when nothing clears it the reduce phase gets empty DATA
  and writes the empty-brief response. The fallback WARNING now logs the
  floor.

Docs: .env.example and docs/news.md document the new knob and window.
This commit is contained in:
backend 2026-11-13 21:56:46 -05:00
commit 57c0444a69
7 changed files with 311 additions and 23 deletions

View file

@ -100,11 +100,13 @@ NOUS_BASE_URL=https://inference-api.nousresearch.com/v1
NEWS_BATCH_SIZE=50
# Map-phase grading: the map model scores each article 0-100, and only blocks
# with score >= SUMMARY_MIN_SCORE reach the reduce brief (best first).
# If nothing clears the bar, the top SUMMARY_FALLBACK_TOP blocks are used
# (0 = honour the threshold and pass an empty DATA section instead).
# If nothing clears the bar, up to SUMMARY_FALLBACK_TOP blocks scoring at least
# SUMMARY_FALLBACK_MIN_SCORE are used; if none do, the reduce phase gets an
# empty DATA section (SUMMARY_FALLBACK_TOP=0 does the same unconditionally).
SUMMARY_MIN_SCORE=60
SUMMARY_TOP_N=12
SUMMARY_FALLBACK_TOP=3
SUMMARY_FALLBACK_MIN_SCORE=40
SUMMARY_WINDOW_MINUTES=15
# Futures/markets coupling from the upstream pipeline is OFF by default
# (irrelevant to OSINT). Set INCLUDE_FUTURES=1 + install yfinance to enable.