Skip to content

Add cache & freshness transparency (v0.4.1-alpha) - #27

Merged
DeepZone merged 1 commit into
mainfrom
codex/add-cache-and-freshness-transparency
May 20, 2026
Merged

Add cache & freshness transparency (v0.4.1-alpha)#27
DeepZone merged 1 commit into
mainfrom
codex/add-cache-and-freshness-transparency

Conversation

@DeepZone

Copy link
Copy Markdown
Owner

Motivation

  • Improve observability of whether external data was served live or from cache and provide operators with cache age/TTL/freshness so preflight decisions can be assessed.
  • Support demo-mode semantics and prepare internal force_refresh support without breaking existing read-only behavior or APIs.

Description

  • Add make_cache_metadata(...) in backend/app/core/source_diagnostics.py to return cache metadata and compute freshness as one of LIVE|FRESH|EXPIRING_SOON|STALE|UNKNOWN following the specified rules.
  • Extend make_source_diagnostic(...) to optionally include cache_ttl_seconds, fetched_at, expires_at, and freshness while preserving existing fields and shape.
  • Enhance RipeStatClient.get_with_diagnostics(...) in backend/app/services/ripe_stat_client.py to store and return minimal cache metadata (wrapped payload, fetched_at, ttl_seconds, cache_key) in a backwards-compatible way, to compute cache_age_seconds/cache_ttl_seconds/freshness, and to accept force_refresh: bool (bypasses cache and records details.force_refresh). Demo mode now returns cached=false, freshness=LIVE, message='Demo data returned', and details.demo_mode=true.
  • Introduce RIPESTAT_CACHE_TTL_SECONDS configuration (default 900) via settings and add it to .env.example and backend/app/config.py.
  • Update frontend types (frontend/src/types.ts) and ReportView (frontend/src/components/ReportView.tsx) to display Freshness, Cache HIT/MISS, Age and TTL with color hints and a formatDuration helper for s/m/h display.
  • Extend Markdown and HTML report templates to include Freshness, Cache Age and TTL with Unknown fallbacks.
  • Add/adjust tests: extended backend/tests/test_source_diagnostics.py, new backend/tests/test_ripe_stat_client.py, and added smoke assertions in backend/tests/test_api_smoke.py to ensure freshness is present in diagnostics.
  • Bump user-facing and package versions to v0.4.1-alpha / 0.4.1 and update README/RELEASE_NOTES with a short Cache & Freshness section.

Testing

  • Ran backend test suite with cd backend && pytest -q, all tests passed (67 passed).
  • Built frontend with cd frontend && npm run build, build completed successfully.
  • Added automated tests verifying make_cache_metadata(...) freshness rules and RipeStat client demo/cache diagnostics which passed as part of the test run.

Codex Task

@DeepZone
DeepZone merged commit c57c338 into main May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant