Nudge to re-value manual assets that have gone stale (#129, 10.1)
Summary
Part of #129 (10.1). A manually valued property, vehicle, other asset or other liability can go years without a valuation and nothing says so. This adds Insight::Generators::StaleValuationGenerator: one low-priority insight per such account whose newest valuation is older than the family's threshold. Valuing the account clears the insight on the next run, and the card's action opens the existing valuation form in the modal.
Plan and decisions are in the #129 body (triage plan, 10.1).
Scope and dependencies
- Issue: #129 (10.1). Does not close it; 10.2 and 10.3 are separate drafts.
- Parent PR/branch, if stacked: none. Off
mainat c783118, withmainat b5d85e9 merged in (480901a). Independent of the 10.2 and 10.3 drafts. - Intentionally out of scope: provider-linked accounts; accounts tracked by transactions rather than valuations (a manual
OtherLiabilitypaid down by transactions will be nudged, a known limitation recorded in the plan); changing who sees an insight in the feed (family-level, likeIdleCashGenerator). - Merge order: this merges before #294, which also added a migration at version
20261001100000; #294's was renumbered to20261003190000.
What changed
StaleValuationGenerator, registered inGeneratorRegistry;stale_valuationadded toInsight::TYPES.- Last valued is the newest
Valuationentry date, floored ataccounts.created_at: opening anchors are back-dated, so an account added today would otherwise read as years stale. Exactly the threshold is not stale; one day over is. - Active accounts only (a draft's setup is unfinished; a disabled account is closed). Oldest first, ties by id, capped at 3.
- Dedup key
stale_valuation:<account_id>:<YYYY-MM>; metadata isaccount_idandlast_valued_ononly, so the balance drifting does not resurface a dismissed card. - The stored prose carries no day count: the body is written once and kept until the numbers change materially, so a stored count would be a day older every night. The key figure works the days out from
metadata["last_valued_on"]when the card renders. InsightsHelper: icon, key figure, sentiment, and an action whose link carriesframe: :modal, offered only to a user who can write the account (AccountAuthorizable::PERMISSION_LEVELS[:write], the table the valuation form's own check reads). A broadcast render has noCurrent.userand cannot tell a writer from a read-only member, so it fails closed: the card is broadcast without the action and gains it on the next full page load._insight_cardpassesframetoDS::Link; nil for every other type.- Migration
families.stale_valuation_days(integer, default 90, not null, check 1..3650),Familyvalidation, admin-only strong param, and a 1..3650 number input on the preferences page (admin with preview features only). - Locale:
insights.*and the preferences strings in en and de (other locales fall back to en).
Blast radius
Who else hits these lines: Insight::TYPES is read by Assistant::Function::GetInsights (its enum follows automatically) and Api::V1::InsightsController serialises the type as a plain string (no change). insight_action is called only from _insight_card. The preferences form posts family_attributes; stale_valuation_days is pushed into the permitted list only for admins, as moniker and default_account_sharing are.
Siblings grepped: every case insight_type branch in InsightsHelper was updated (icon, key figure, action, sentiment). idle_cash links to its account without a per-viewer check, the same exposure the stale-valuation action had before review; it is left as is here and is not part of this change. GenerateInsightsJob and every generator take "today" from Date.current in the process zone while the card's day count uses the viewer's zone, so the "N days" figure can be one day off near midnight for a family far from UTC. That is a property of the whole job, not of this generator, and is left alone.
Evidence checklist
- Each issue in this PR has its own acceptance criteria and no unrelated issue work is included.
- Contract rows touched by this change name existing tests (see Validation).
- Any gate test has an observed failing mutation transcript attached. Mutations below.
- Fixtures used as evidence assert internal consistency: each test sets the age it exercises rather than leaning on fixture defaults (fixture accounts are created now with no valuation entries, the one state that must produce nothing).
- Financial calculations use
BigDecimaland documented rounding points. None here; ages are integers and the balance is formatted byMoney#format. - De-identification: no personal data in the diff.
- Files changed, decisions, tests/runtime, risks and next unblocked issue documented below.
Validation
Written fail-first (14 generator tests errored on the missing class before the generator existed). Then each behaviour broken deliberately, one at a time, and the named test went red:
| Mutation | Test that failed |
|---|---|
< to <= on the cutoff | says nothing at exactly the threshold |
drop the created_at floor | new account with a back-dated opening value; old account with only a back-dated opening value |
drop .manual | ignores a property fed by a sync provider |
| drop the active filter | disabled; draft |
| drop the cap / the oldest-first sort | reports the oldest three; a fourth stale account is reported once one of the three is valued |
| balance into metadata | the balance is a fact, not metadata |
drop frame: :modal | action opens the valuation form in the modal |
| drop the write check on the action | action is withheld from a user who cannot write the account |
| show the action when there is no current user | action is withheld where there is no current user, as in a broadcast |
| put the day count back in the prose | the stored prose carries no day count that would age |
drop the Family validation | threshold range test |
drop :stale_valuation_days from the permit list | admin can set the threshold |
| unregister the generator | job-level test: stale value raises an insight that valuing the account expires |
| drop the admin gate on the preferences field | not offered to a non-admin |
Exit criterion end to end (through the real generators and GenerateInsightsJob): a property valued 91 days ago raises one insight; adding a valuation then re-running expires it.
Commands (Ruby 3.3.6 with the Gemfile's ruby line removed, local Postgres and Redis; see Risks):
bin/rails test(before the review commit): 11379 runs, 49248 assertions, 4 failures, 1 error, 33 skips. All 5 also fail on an untouchedmainin this environment: 3 inSettings::HostingsControllerTestand 1 inProvider::RegistryTestreadANTHROPIC_BASE_URL(set in this sandbox), andProvider::OpenaiTestexpects Ruby 3.4'sHash#inspect. After the review commit the affected files were rerun (insight models,InsightsHelper, insights and users and preferences controllers,GenerateInsightsJob,Family,I18nTest): 133 runs, 0 failures. After the broadcast and German-string commit (18e81fb):InsightsHelper, the insight models,GenerateInsightsJobandI18nTestrerun, 91 runs, 0 failures, 4 skips. The full suite was not rerun locally after either commit.bin/rubocopon the changed files: no offenses.erb_linton the changed ERB file: no errors.bin/brakeman --no-pager: no warnings.- CI on the head
480901a(main merged in, schema regenerated): 32 of 32 passed, includingci / test_unitandci / test_systemon Ruby 3.4.9.
Not run: DISABLE_PARALLELIZATION=true bin/rails test:system locally (no Selenium here; CI's run is green), npm run lint (no JavaScript changed). No screenshots: the UI was not opened in a browser, only rendered through controller tests. The generator's body was exercised only with ai_enabled: false, so the LLM-written path of BodyWriter for the new template is unverified.
The schema.rb diff over main is the column and its check constraint, regenerated against main's schema after the merge. The migration was not run against any shared database.
Risks, blockers, and follow-up
- Verified locally under Ruby 3.3.6, not the 3.4.9 in
.ruby-version(3.4.9's source host is blocked in this environment). CI ran 3.4.9 and passed. - The owner waived the issue gate for #129 on 2026-10-01. Checked against upstream
we-promise/sureAGENTS.md(the copy onmirror/upstream-main, identical to this branch's) before marking ready. The full Gatekeeper review and CodeRabbit run now that this is ready. - Known limitation: a manual
OtherLiabilitytracked by transactions will be nudged. - A dismissal lasts to the end of the month (month-scoped dedup key, as the other month-scoped generators); the card returns on the 1st if the account is still unvalued.
- Upstream: UI work held on fork
mainbehind the preview gate, so there is nowe-promise/surePR yet. - Next unblocked: 10.2 and 10.3 (separate drafts).
Summary by CodeRabbit
- New Features
- Receive reminders when manually valued properties, vehicles, and other assets or liabilities haven’t been updated within your chosen time period. Reminders show the balance and last valuation date, and eligible users can open the account’s valuation form directly.
- Admins with preview features enabled can set the reminder threshold in preferences, from 1 to 3,650 days. The default is 90 days.