fix(cache): bust balance-sheet caches when exchange rates arrive #4288
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 298 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.341
Real PR Conversation Timeline
1 comments
"Review active on #4288"
general
weight: 0.35
jjmata
Fixes #4287
Related to #4200
Summary
After linking a foreign-currency account (e.g. IBKR USD while the family is EUR), the first paint often runs before any FX rate exists. Conversion falls back to 1:1, so the Investments group shows e.g.
€112,701next to the account’s correct$112,701.IncomeStatement#cache_freshness_keyalready includesExchangeRate.maximum(:updated_at). Balance-sheet paths that useFamily#build_cache_key(..., invalidate_on_data_updates: true)— including the 12h account sidebar fragment and net worth series — did not. Hard refresh keeps serving the stale 1:1 fragment until TTL or an unrelated account write.This is distinct from #4235 (currency change / account deletion) and #3983 (stop converting at 1 when no rate exists). If #4235 merges first, this branch should rebase and keep the FX-rate freshness term (and prefer
accounts_status_versionif both land).Changes
Family#build_cache_key: includecurrency; wheninvalidate_on_data_updates, also includeExchangeRate.maximum(:updated_at)&.to_iv3→v4Test plan
stable/e336a285): cleared cache after inserting USD→EUR rate; Investments group converted once fragment key could see FX freshnessbin/rails test test/models/family_test.rb test/models/balance_sheet/net_worth_series_builder_fx_cache_test.rbdocs/llm-guides/development.md(CI will also run)Screenshots
Before: Investments
€112,701.18beside account$112,701.18(1:1 labeled as family currency).After (cache busted): Investments shows a converted EUR total beside account
$112,701.18.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
Net-worth series and other cached family data now refresh when relevant exchange rates change, helping keep displayed values in the family’s currency up to date.
Cached family data now reflects changes to the family currency, so displayed values stay consistent with the selected currency.
Account sidebar tabs use a new cache version, refreshing previously cached content.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->