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

Merged
sirius merged 1 commit from wt/t_39f51764 into master 2026-11-14 02:57:46 +00:00
Owner

Follow-up to #53 (merged, summarizer amd64-2c41737d42dd, SUMMARY_MIN_SCORE=60).
Two paths still let low-value items reach the brief. Measured on a forced interval
(14 articles, 4 map batches, score distribution 45, 30, 15, 15, 12, 12, 10, 8, 5, 5, 5, 5, 5, 3):

  1. get_recent_news() only filtered timestamp > NOW() - window, so the 12
    future-dated wiseye.org event listings (Nov 17 / Nov 20 while now() = Nov 14)
    were re-fetched, re-graded by the LLM and re-billed every 15 minutes for a week.
  2. select_graded() returned ordered[:fallback_top] with no floor, so a 15/100
    event listing ("UW-Madison Elections Research Center to host 2026 midterm election
    symposium") entered the operator brief and ticker as low.

Change

  • get_recent_news() window is now (now - window, now] (AND timestamp <= NOW()).
    The content IS NOT NULL AND length(content) > 100 filter and ORDER BY timestamp DESC
    are untouched. NULL timestamps never matched the lower bound and still do not.
  • New SUMMARY_FALLBACK_MIN_SCORE (env, default 40, clamped 0-100) read through
    _env_int/selection_config(), returned as the 4th value. select_graded() gains a
    fallback_min_score parameter (default 0 = previous behaviour): the fallback set is
    [b for b in ordered if b["score"] >= fallback_min_score][:fallback_top]; if empty it
    returns ([], False) and the reduce phase gets empty DATA (existing empty-brief path).
    The WARNING now reads ... fallback to top %d with score >= %d (max score %d).
  • .env.example + docs/news.md document the knob and the closed window.

No change to the map prompt, rubric, parse_map_scores, article_scores, the other three
knobs, the scraper or app/main.py. No new LLM call. No row deletions.

Verification

$ pytest -q                          # repo root
347 passed, 18 skipped in 3.74s

$ cd news/summerizer && pytest tests -q
78 passed in 0.10s                  # was 60 before this branch

Live check against a real postgres:16 scratch DB (fresh -2min, future +3d/+6d,
past -20min, NULL timestamp, short content):

now() = 2026-11-14 02:56:37.702862+00:00
OLD query (master) -> ['future-6d', 'future-3d', 'fresh-2min']
NEW query (patched) -> ['fresh-2min']

Replay of the observed run as a unit test (45, 30, 15, min_score=60, fallback_top=3,
fallback_min_score=40) selects [45] only - the symposium listing is gone from DATA.

Merge policy: operator merges, rebuilds the summarizer image, pins it in
sirius/homek8s, sets SUMMARY_FALLBACK_MIN_SCORE in the ConfigMap and re-runs a forced
interval. This PR is not merged by the worker.

Follow-up to #53 (merged, summarizer `amd64-2c41737d42dd`, `SUMMARY_MIN_SCORE=60`). Two paths still let low-value items reach the brief. Measured on a forced interval (14 articles, 4 map batches, score distribution `45, 30, 15, 15, 12, 12, 10, 8, 5, 5, 5, 5, 5, 3`): 1. `get_recent_news()` only filtered `timestamp > NOW() - window`, so the 12 future-dated `wiseye.org` event listings (Nov 17 / Nov 20 while `now()` = Nov 14) were re-fetched, re-graded by the LLM and re-billed every 15 minutes for a week. 2. `select_graded()` returned `ordered[:fallback_top]` with no floor, so a 15/100 event listing ("UW-Madison Elections Research Center to host 2026 midterm election symposium") entered the operator brief and ticker as `low`. ## Change - `get_recent_news()` window is now `(now - window, now]` (`AND timestamp <= NOW()`). The `content IS NOT NULL AND length(content) > 100` filter and `ORDER BY timestamp DESC` are untouched. NULL timestamps never matched the lower bound and still do not. - New `SUMMARY_FALLBACK_MIN_SCORE` (env, default **40**, clamped 0-100) read through `_env_int`/`selection_config()`, returned as the 4th value. `select_graded()` gains a `fallback_min_score` parameter (default `0` = previous behaviour): the fallback set is `[b for b in ordered if b["score"] >= fallback_min_score][:fallback_top]`; if empty it returns `([], False)` and the reduce phase gets empty DATA (existing empty-brief path). The WARNING now reads `... fallback to top %d with score >= %d (max score %d)`. - `.env.example` + `docs/news.md` document the knob and the closed window. No change to the map prompt, rubric, `parse_map_scores`, `article_scores`, the other three knobs, the scraper or `app/main.py`. No new LLM call. No row deletions. ## Verification ``` $ pytest -q # repo root 347 passed, 18 skipped in 3.74s $ cd news/summerizer && pytest tests -q 78 passed in 0.10s # was 60 before this branch ``` Live check against a real `postgres:16` scratch DB (fresh -2min, future +3d/+6d, past -20min, NULL timestamp, short content): ``` now() = 2026-11-14 02:56:37.702862+00:00 OLD query (master) -> ['future-6d', 'future-3d', 'fresh-2min'] NEW query (patched) -> ['fresh-2min'] ``` Replay of the observed run as a unit test (`45, 30, 15`, `min_score=60`, `fallback_top=3`, `fallback_min_score=40`) selects `[45]` only - the symposium listing is gone from DATA. Merge policy: operator merges, rebuilds the summarizer image, pins it in `sirius/homek8s`, sets `SUMMARY_FALLBACK_MIN_SCORE` in the ConfigMap and re-runs a forced interval. This PR is not merged by the worker.
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.
sirius merged commit fa745ee3f7 into master 2026-11-14 02:57:46 +00:00
sirius deleted branch wt/t_39f51764 2026-11-14 02:57:46 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/osint-dashboard!54
No description provided.