← Back to Pull requests

Pick the accounts that fund the retirement plan #5930

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 29, 2026 06:15 UTC
Author

Part of #5567

Fork pre-flight: jaysbeekay/sure#1031 (same branch, same commits)

Stacked on #5755

Problem

A retirement plan can already be funded from accounts the user picks (RetirementPlan::FundingAccount, #5610): linked accounts replace the default set of cash, investment and crypto accounts. The settings never offered a way to pick them, so the default set was the only one anyone could use. @dgilperez raised this on #5567.

Resulting behaviour

The settings modal gets a "Fund the plan from" list: every cash, investment and crypto account the user counts in their finances (RetirementPlan#eligible_funding_accounts), with the linked ones ticked. With none ticked, the plan uses all of them, as it does today.

  • A save replaces the links in the same transaction as the settings and the first seeding, so a refused save links nothing.

  • The form always sends the list, with a blank first entry, so unticking the last account still reaches the server and returns the plan to the default set. A save that does not send the list (an older form) leaves the links alone.

  • Only accounts the plan can draw on are linked. Any other id, such as a property or another family's account, is dropped.

  • A refused save re-renders with the accounts that were ticked, not the saved ones.
  • No model change: this uses the funding model #5610 already has.

    Size: 46 non-test lines (controller 30, form 14, locale 2).

    Validation

  • Full suite bin/rails test at this head 7110d042f: 18749 runs, 1 failure, 8 errors. The failure is AccountsControllerTest "credit card overview shows the credit label when a credit outlives the due date", which depends on today's date and fails the same way at #5610's old head 158640ad4; the 8 errors are ReleaseNotesWorkflowTest, which needs node, missing from the test image.

  • Targeted: test/controllers/retirement_plans/funding_accounts_test.rb (listing with ticks, linking, replacing, none ticked, a list not sent, ineligible ids, a refused save, a refused save keeping the ticks) and a system test that ticks an account, saves, then unticks it and saves.

  • bin/rubocop and erb_lint: clean.

  • Mutations, each caught by a failing assertion: the link step skipped; the old links not removed; the eligibility filter dropped; a save without the list clearing the links; the saved links not ticked; ineligible accounts listed; the blank entry dropped (caught by the system test); the submitted ticks ignored on a refused save.
  • Blast radius

    RetirementPlansController#update and the settings form. #save_settings gains one step inside its existing transaction. The funding total, projection, simulation and Monte Carlo already read the links.

    Migration notes

    No migration.

    Screenshots

    The bottom of the settings modal. Before:

    | | Desktop | Phone |
    | --- | --- | --- |
    | Light | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/before/funding-light-desktop.png) | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/before/funding-light-phone.png) |
    | Dark | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/before/funding-dark-desktop.png) | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/before/funding-dark-phone.png) |

    After, with one account ticked:

    | | Desktop | Phone |
    | --- | --- | --- |
    | Light | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/after/funding-light-desktop.png) | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/after/funding-light-phone.png) |
    | Dark | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/after/funding-dark-desktop.png) | ![](https://raw.githubusercontent.com/jaysbeekay/sure/8c34e7a997e89089eba32477005dd572cd9dd723/after/funding-dark-phone.png) |

    <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Adds a way to pick which accounts fund a retirement plan. The settings modal now lists every eligible cash, investment, and crypto account with the linked ones ticked; ticking none uses all of them as before.

  • A save replaces the funding links in the same transaction as the settings, so a failed save links nothing.

  • Unticking all accounts sends an empty list (with a blank entry) and returns to the default set.

  • Only accounts the plan can draw on are linked; other ids are dropped.

  • A refused save re-renders with the submitted ticks, not the saved ones.

  • A save of a saved plan locks its row before writing, so two saves at once replace rather than merge the funding links.

  • Asset balances are converted before the lock is taken, so a provider call for a missing exchange rate never runs under it.
  • <sup>Written for commit 160439a69c5bc71f0cf1ddcd3a62232b14b0abb8. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/we-promise/sure/pull/5930?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/we-promise/sure/5930?returnTo=https%3A%2F%2Fgithub.com%2Fwe-promise%2Fsure%2Fpull%2F5930&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Retirement-plan settings now let you choose which eligible accounts fund the plan. Clearing the selection restores the default set of cash, investment, and crypto accounts.
    Your selected accounts remain checked when settings are redisplayed, including after a save is refused.
    Bug Fixes
    * Account selections are saved only for eligible accounts, and existing selections are preserved when the account list isn’t submitted.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: jaysbeekay Review duration: 9149m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #5930"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%