Add cache & freshness transparency (v0.4.1-alpha) - #27
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
force_refreshsupport without breaking existing read-only behavior or APIs.Description
make_cache_metadata(...)inbackend/app/core/source_diagnostics.pyto return cache metadata and computefreshnessas one ofLIVE|FRESH|EXPIRING_SOON|STALE|UNKNOWNfollowing the specified rules.make_source_diagnostic(...)to optionally includecache_ttl_seconds,fetched_at,expires_at, andfreshnesswhile preserving existing fields and shape.RipeStatClient.get_with_diagnostics(...)inbackend/app/services/ripe_stat_client.pyto store and return minimal cache metadata (wrapped payload,fetched_at,ttl_seconds,cache_key) in a backwards-compatible way, to computecache_age_seconds/cache_ttl_seconds/freshness, and to acceptforce_refresh: bool(bypasses cache and recordsdetails.force_refresh). Demo mode now returnscached=false,freshness=LIVE,message='Demo data returned', anddetails.demo_mode=true.RIPESTAT_CACHE_TTL_SECONDSconfiguration (default900) via settings and add it to.env.exampleandbackend/app/config.py.frontend/src/types.ts) andReportView(frontend/src/components/ReportView.tsx) to display Freshness, Cache HIT/MISS, Age and TTL with color hints and aformatDurationhelper fors/m/hdisplay.Unknownfallbacks.backend/tests/test_source_diagnostics.py, newbackend/tests/test_ripe_stat_client.py, and added smoke assertions inbackend/tests/test_api_smoke.pyto ensurefreshnessis present in diagnostics.v0.4.1-alpha/0.4.1and update README/RELEASE_NOTES with a short Cache & Freshness section.Testing
cd backend && pytest -q, all tests passed (67 passed).cd frontend && npm run build, build completed successfully.make_cache_metadata(...)freshness rules and RipeStat client demo/cache diagnostics which passed as part of the test run.Codex Task