Skip to content

feat(news): panel feed prefers raw items endpoint#107

Merged
Allan-Feng merged 2 commits into
mainfrom
feat/finsearch-items-feed
Jul 14, 2026
Merged

feat(news): panel feed prefers raw items endpoint#107
Allan-Feng merged 2 commits into
mainfrom
feat/finsearch-items-feed

Conversation

@FlyM1ss

@FlyM1ss FlyM1ss commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Phase B of the FinSearch news-signals integration (Phase A = #102). Upgrades the Home panel's feed (left column) to prefer FinSearch's new GET /api/news/items/ raw-items endpoint, falling back to the existing Phase-A representative-story feed on any failure — so the panel can never regress below Phase A.

What it does

  • get_latest_panel_payload now fetches /api/news/items/ first for the feed; on any failure (transport error, non-200, unparseable/non-dict body, empty, all-malformed) it falls back to the signals-derived representative feed. signals/status/overview/staleness still come from the signals artifact (unchanged).
  • Panel feed output shape is unchanged ({headline, source, url, published, ticker}); the AF wire now speaks news-story v1 (headline/url + schema_version). Frontend: heading → "Latest news", null-ticker meta-line fix.
  • New FINSEARCH_ITEMS_URL env (.env.example updated); fetch_items is fully fail-closed (never raises).

Tests: +9 offline cases in test_news_sentiment_adapter.py (mapping correctness, each fallback trigger, signals-down-skips-items-fetch, non-dict body). Adapter file 30/30.

Depends on: the FinSearch /api/news/items/ endpoint being deployed (separate PR in Agentic-FinSearch). Until then the feed transparently uses the Phase-A source.

Note on CI: the one failing test (test_agent_runs_metadata.py::test_engine_llm_run_metadata_snapshot) is pre-existing on main, unrelated to this PR — introduced by #104 (_llm_run_metadata reads self.prompt_adaptations, which the __new__-based test never sets). Tracked separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_018rCr1NSRDG8kpsYtHPndmM

FlyM1ss and others added 2 commits July 14, 2026 15:53
…esentative feed

Adds fetch_items/_feed_from_items against the new /api/news/items/ producer
endpoint and wires a fail-closed chain into get_latest_panel_payload: prefer
the richer multi-story items feed, fall back to the existing Phase-A
representative feed (extracted to _representative_feed) on any items
failure (404, transport error, unparseable body, missing 'items' list, or
all-items-malformed). Wire shape is unchanged. Also stubs the test
fixture's _http_get_items to a fast 404 by default so pre-Phase-B tests
don't silently hit the live network now that the panel payload path calls
fetch_items().
…ses)

body.get('items') would AttributeError on a valid-JSON but non-dict body
(e.g. a bare list from a misconfigured FINSEARCH_ITEMS_URL); the brief
required fetch_items to never raise. Guard body is a dict before .get so it
fails closed to None -> panel falls back to the representative feed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018rCr1NSRDG8kpsYtHPndmM
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentic-trading-lab Ready Ready Preview, Comment Jul 14, 2026 8:21am

@Allan-Feng
Allan-Feng merged commit e17f363 into main Jul 14, 2026
4 of 5 checks passed
@FlyM1ss

FlyM1ss commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-ups landed: (1) adapter + fixtures moved to the news-story v1 wire shape (headline/url, response-level schema_version) matching AF #359's updated projection — _feed_from_items is now a near-passthrough; (2) review finding #1 fixed (null-ticker meta line via filter(Boolean)); (3) heading renamed to Latest news (finding #2 resolved as intended-broad-feed — ?tickers= would be a no-op on the items view); (4) canonical contract doc added at docs/integrations/finsearch-news-items.md. Merge after AF #359; until then the items path 404s and falls back to Phase A.

FlyM1ss added a commit that referenced this pull request Jul 14, 2026
Review follow-ups on the headline/url fix. The rename itself was silent in
prod for hours because failing closed and failing visibly are different
properties, and this seam only had the first.

- get_latest_panel_payload: ERROR when a non-empty batch projects to zero
  usable entries. One bad story stays a per-item warning; wholesale drift is
  now loud. An empty batch is "no news", not drift.
- items-wire-fixture.json: the items wire shape was previously only inline
  dicts inside individual tests, so it drifted with the adapter and stayed
  green. Record it once (key set verified against prod), drive the happy path
  from it, and guard it against the retired title/link vocabulary. The fixture
  reconciles with the signals fixtures' source_items/diagnostics, so the pair
  also shows the Phase-B breadth claim (6 stories -> 2 signals).
- docs: status line said AF #359 was unmerged and named #107 as the consumer;
  AF is live and #107 shipped without the adapter half. Note that no consumer
  reads schema_version, record the known gap (mocked producer can't catch a
  rename), and add a postscript on why the rollout inverted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants