Skip to content

fix(cache): bound in-memory caches, stop caching empty stories, use priority prefetch #79

Done

Description

@mlgitdev

Description

  1. NewsService.story() (app/news.py:229-236) caches empty {"html": "", "source_url": ""} responses permanently, so a single transient network failure leaves that story blank until restart.
  2. BamSECService.get_filings() (app/bamsec.py:82-94) caches HTTP 5xx/429 error responses for the full 120s TTL.
  3. AlpacaNews._stories, NewsService._cache, NewsService._stories, BamSECService._cache, NewsPrefetcher._fetched, and TapeWorker._tg_last_alert grow without bound over long sessions.
  4. NewsPrefetcher (app/screener.py:75-81) uses a FIFO queue.Queue, so priority=True calls for newly alerted symbols sit behind the entire background backlog (0.25s per ticker).

References: app/news.py:112-113, 210-211, 229-236, app/bamsec.py:50, 82-94, app/screener.py:75-81

Steps to Reproduce

  1. Trigger a transient failure when fetching a story via NewsService.story(id) and retry -> empty result stays cached forever.
  2. Enqueue A, B, then URGENT (priority=True) in NewsPrefetcher -> dequeues in FIFO order ['A', 'B', 'URGENT'].

Expected Behavior

Skip caching empty/failed stories and 5xx/429 BamSEC errors, enforce bounded LRU/max-size eviction on caches, and use queue.PriorityQueue in NewsPrefetcher so urgent new-symbol news fetches jump ahead of background prefetches.

Operating System & Version

  • OS: Windows 11 x64 / macOS arm64 / Linux x86_64
  • Version: v2.12.0
  • Display / Scale: Verified via live Chrome CDP (1600x960) & local unit/backend suite

Logs & Additional Context

Backend reproduction confirmed perm_empty_story_cache=True, bamsec_caches_503=True, and prefetch_order=['A', 'B', 'URGENT'].

Activity

  1. self-assigned this
    on Dec 2, 2026
  2. added
    bug
    on Dec 2, 2026
  3. mlgitdev commented on Dec 2, 2026

    @mlgitdev
    OwnerAuthor

    🚀 Resolution In Progress

    A fix for this issue has been implemented and submitted in Pull Request #82 (v2.12.1).

    • Branch: fix/audit-remediation-67
    • PR URL: fix(core): resolve 15 verified audit issues across UI, API, concurrency, audio, and packaging (v2.12.1) #82
    • Summary of Changes: Stopped permanently caching empty stories (app/news.py) and transient BamSEC 5xx/429 responses (app/bamsec.py), bounded caches with LRU OrderedDict, and upgraded NewsPrefetcher (app/screener.py) to queue.PriorityQueue. Verified via unit tests.
    • Verification: compileall clean, 84/84 unit tests passing (including tests/test_audit_fixes.py), and live Chrome CDP verification passed.

    This issue will automatically close upon PR #82 review and merge into main.

  4. github-actions commented on Dec 2, 2026

    @github-actions

    ✅ Issue Validation Passed

    • Conventional Commit title syntax (fix(cache))
    • Verified issue type: BUG
    • Required template sections present and filled out

    This issue is well-structured and ready for work according to the Issue-First Protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions